summaryrefslogtreecommitdiffstats
path: root/sys/arm64
diff options
context:
space:
mode:
authorandrew <andrew@FreeBSD.org>2016-09-07 12:10:30 +0000
committerandrew <andrew@FreeBSD.org>2016-09-07 12:10:30 +0000
commitae964e954722098da41ab6de612259f229aab1b3 (patch)
tree994f293d98e21eb1cc50cc4ddb53d760ec095f91 /sys/arm64
parent7e6ed55ce50dc52739073af27c0018f1d84ec77d (diff)
downloadFreeBSD-src-ae964e954722098da41ab6de612259f229aab1b3.zip
FreeBSD-src-ae964e954722098da41ab6de612259f229aab1b3.tar.gz
MFC 302849, 302851, 302896 GICv3 improvements:
- Move internal data structures out of the common header file - Remove unused data structures and macros - Add us_print_child to the GICv3 driver Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/arm64')
-rw-r--r--sys/arm64/arm64/gic_v3.c7
-rw-r--r--sys/arm64/arm64/gic_v3_fdt.c16
-rw-r--r--sys/arm64/arm64/gic_v3_var.h111
-rw-r--r--sys/arm64/arm64/gicv3_its.c77
4 files changed, 101 insertions, 110 deletions
diff --git a/sys/arm64/arm64/gic_v3.c b/sys/arm64/arm64/gic_v3.c
index 1c25cc8..34aecce 100644
--- a/sys/arm64/arm64/gic_v3.c
+++ b/sys/arm64/arm64/gic_v3.c
@@ -134,6 +134,13 @@ enum gic_v3_xdist {
REDIST,
};
+struct gic_v3_irqsrc {
+ struct intr_irqsrc gi_isrc;
+ uint32_t gi_irq;
+ enum intr_polarity gi_pol;
+ enum intr_trigger gi_trig;
+};
+
/* Helper routines starting with gic_v3_ */
static int gic_v3_dist_init(struct gic_v3_softc *);
static int gic_v3_redist_alloc(struct gic_v3_softc *);
diff --git a/sys/arm64/arm64/gic_v3_fdt.c b/sys/arm64/arm64/gic_v3_fdt.c
index 107893b..c3f50f0 100644
--- a/sys/arm64/arm64/gic_v3_fdt.c
+++ b/sys/arm64/arm64/gic_v3_fdt.c
@@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
*/
static int gic_v3_fdt_probe(device_t);
static int gic_v3_fdt_attach(device_t);
+static int gic_v3_fdt_print_child(device_t, device_t);
static struct resource *gic_v3_ofw_bus_alloc_res(device_t, device_t, int, int *,
rman_res_t, rman_res_t, rman_res_t, u_int);
@@ -64,6 +65,7 @@ static device_method_t gic_v3_fdt_methods[] = {
DEVMETHOD(device_attach, gic_v3_fdt_attach),
/* Bus interface */
+ DEVMETHOD(bus_print_child, gic_v3_fdt_print_child),
DEVMETHOD(bus_alloc_resource, gic_v3_ofw_bus_alloc_res),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
@@ -183,6 +185,20 @@ struct gic_v3_ofw_devinfo {
struct resource_list di_rl;
};
+static int
+gic_v3_fdt_print_child(device_t bus, device_t child)
+{
+ struct gic_v3_ofw_devinfo *di = device_get_ivars(child);
+ struct resource_list *rl = &di->di_rl;
+ int retval = 0;
+
+ retval += bus_print_child_header(bus, child);
+ retval += resource_list_print_type(rl, "mem", SYS_RES_MEMORY, "%#jx");
+ retval += bus_print_child_footer(bus, child);
+
+ return (retval);
+}
+
static const struct ofw_bus_devinfo *
gic_v3_ofw_get_devinfo(device_t bus __unused, device_t child)
{
diff --git a/sys/arm64/arm64/gic_v3_var.h b/sys/arm64/arm64/gic_v3_var.h
index 4dcff77..496a1ba 100644
--- a/sys/arm64/arm64/gic_v3_var.h
+++ b/sys/arm64/arm64/gic_v3_var.h
@@ -36,12 +36,7 @@
DECLARE_CLASS(gic_v3_driver);
-struct gic_v3_irqsrc {
- struct intr_irqsrc gi_isrc;
- uint32_t gi_irq;
- enum intr_polarity gi_pol;
- enum intr_trigger gi_trig;
-};
+struct gic_v3_irqsrc;
struct redist_lpis {
vm_offset_t conf_base;
@@ -108,87 +103,6 @@ void gic_r_write_4(device_t, bus_size_t, uint32_t var);
void gic_r_write_8(device_t, bus_size_t, uint64_t var);
/*
- * ITS
- */
-
-/* LPI chunk owned by ITS device */
-struct lpi_chunk {
- u_int lpi_base;
- u_int lpi_free; /* First free LPI in set */
- u_int lpi_num; /* Total number of LPIs in chunk */
- u_int lpi_busy; /* Number of busy LPIs in chink */
-};
-
-/* ITS device */
-struct its_dev {
- TAILQ_ENTRY(its_dev) entry;
- /* PCI device */
- device_t pci_dev;
- /* Device ID (i.e. PCI device ID) */
- uint32_t devid;
- /* List of assigned LPIs */
- struct lpi_chunk lpis;
- /* Virtual address of ITT */
- vm_offset_t itt;
- size_t itt_size;
-};
-
-/*
- * ITS command descriptor.
- * Idea for command description passing taken from Linux.
- */
-struct its_cmd_desc {
- uint8_t cmd_type;
-
- union {
- struct {
- struct its_dev *its_dev;
- struct its_col *col;
- uint32_t id;
- } cmd_desc_movi;
-
- struct {
- struct its_col *col;
- } cmd_desc_sync;
-
- struct {
- struct its_col *col;
- uint8_t valid;
- } cmd_desc_mapc;
-
- struct {
- struct its_dev *its_dev;
- struct its_col *col;
- uint32_t pid;
- uint32_t id;
- } cmd_desc_mapvi;
-
- struct {
- struct its_dev *its_dev;
- struct its_col *col;
- uint32_t pid;
- } cmd_desc_mapi;
-
- struct {
- struct its_dev *its_dev;
- uint8_t valid;
- } cmd_desc_mapd;
-
- struct {
- struct its_dev *its_dev;
- struct its_col *col;
- uint32_t pid;
- } cmd_desc_inv;
-
- struct {
- struct its_col *col;
- } cmd_desc_invall;
- };
-};
-
-#define ITS_TARGET_NONE 0xFBADBEEF
-
-/*
* GIC Distributor accessors.
* Notice that only GIC sofc can be passed.
*/
@@ -221,27 +135,4 @@ struct its_cmd_desc {
reg, val); \
})
-#define PCI_DEVID_GENERIC(pci_dev) \
-({ \
- ((pci_get_domain(pci_dev) << PCI_RID_DOMAIN_SHIFT) | \
- (pci_get_bus(pci_dev) << PCI_RID_BUS_SHIFT) | \
- (pci_get_slot(pci_dev) << PCI_RID_SLOT_SHIFT) | \
- (pci_get_function(pci_dev) << PCI_RID_FUNC_SHIFT)); \
-})
-
-/*
- * Request number of maximum MSI-X vectors for this device.
- * Device can ask for less vectors than maximum supported but not more.
- */
-#define PCI_MSIX_NUM(pci_dev) \
-({ \
- struct pci_devinfo *dinfo; \
- pcicfgregs *cfg; \
- \
- dinfo = device_get_ivars(pci_dev); \
- cfg = &dinfo->cfg; \
- \
- cfg->msix.msix_msgnum; \
-})
-
#endif /* _GIC_V3_VAR_H_ */
diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c
index 741d0f1..401c3d7 100644
--- a/sys/arm64/arm64/gicv3_its.c
+++ b/sys/arm64/arm64/gicv3_its.c
@@ -123,6 +123,83 @@ MALLOC_DEFINE(M_GICV3_ITS, "GICv3 ITS",
#define CMD_VALID_SHIFT (63)
#define CMD_VALID_MASK (1UL << CMD_VALID_SHIFT)
+#define ITS_TARGET_NONE 0xFBADBEEF
+
+/* LPI chunk owned by ITS device */
+struct lpi_chunk {
+ u_int lpi_base;
+ u_int lpi_free; /* First free LPI in set */
+ u_int lpi_num; /* Total number of LPIs in chunk */
+ u_int lpi_busy; /* Number of busy LPIs in chink */
+};
+
+/* ITS device */
+struct its_dev {
+ TAILQ_ENTRY(its_dev) entry;
+ /* PCI device */
+ device_t pci_dev;
+ /* Device ID (i.e. PCI device ID) */
+ uint32_t devid;
+ /* List of assigned LPIs */
+ struct lpi_chunk lpis;
+ /* Virtual address of ITT */
+ vm_offset_t itt;
+ size_t itt_size;
+};
+
+/*
+ * ITS command descriptor.
+ * Idea for command description passing taken from Linux.
+ */
+struct its_cmd_desc {
+ uint8_t cmd_type;
+
+ union {
+ struct {
+ struct its_dev *its_dev;
+ struct its_col *col;
+ uint32_t id;
+ } cmd_desc_movi;
+
+ struct {
+ struct its_col *col;
+ } cmd_desc_sync;
+
+ struct {
+ struct its_col *col;
+ uint8_t valid;
+ } cmd_desc_mapc;
+
+ struct {
+ struct its_dev *its_dev;
+ struct its_col *col;
+ uint32_t pid;
+ uint32_t id;
+ } cmd_desc_mapvi;
+
+ struct {
+ struct its_dev *its_dev;
+ struct its_col *col;
+ uint32_t pid;
+ } cmd_desc_mapi;
+
+ struct {
+ struct its_dev *its_dev;
+ uint8_t valid;
+ } cmd_desc_mapd;
+
+ struct {
+ struct its_dev *its_dev;
+ struct its_col *col;
+ uint32_t pid;
+ } cmd_desc_inv;
+
+ struct {
+ struct its_col *col;
+ } cmd_desc_invall;
+ };
+};
+
/* ITS command. Each command is 32 bytes long */
struct its_cmd {
uint64_t cmd_dword[4]; /* ITS command double word */
OpenPOWER on IntegriCloud