summaryrefslogtreecommitdiffstats
path: root/bsps/sparc/include/drvmgr
diff options
context:
space:
mode:
Diffstat (limited to 'bsps/sparc/include/drvmgr')
-rw-r--r--bsps/sparc/include/drvmgr/ambapp_bus.h142
-rw-r--r--bsps/sparc/include/drvmgr/ambapp_bus_grlib.h36
-rw-r--r--bsps/sparc/include/drvmgr/bspcommon.h28
-rw-r--r--bsps/sparc/include/drvmgr/leon2_amba_bus.h95
4 files changed, 301 insertions, 0 deletions
diff --git a/bsps/sparc/include/drvmgr/ambapp_bus.h b/bsps/sparc/include/drvmgr/ambapp_bus.h
new file mode 100644
index 0000000000..d034aae3a3
--- /dev/null
+++ b/bsps/sparc/include/drvmgr/ambapp_bus.h
@@ -0,0 +1,142 @@
+/* General part of a AMBA Plug & Play bus driver.
+ *
+ * COPYRIGHT (c) 2008.
+ * Cobham Gaisler AB.
+ *
+ * This is the general part of the different AMBA Plug & Play
+ * drivers. The drivers are wrappers around this driver, making
+ * the code size smaller for systems with multiple AMBA Plug &
+ * Play buses.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef __AMBAPP_BUS_H__
+#define __AMBAPP_BUS_H__
+
+#include <drvmgr/drvmgr.h>
+#include <ambapp.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* GRLIB AMBA Plug&Play Driver ID generation */
+#define DRIVER_AMBAPP_ID(vendor, device) \
+ DRIVER_ID(DRVMGR_BUS_TYPE_AMBAPP, ((((vendor) & 0xff) << 16) | ((device) & 0xfff)))
+
+/*** Gaisler Hardware Device Driver IDs ***/
+#define DRIVER_AMBAPP_GAISLER_AHBSTAT_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_AHBSTAT)
+#define DRIVER_AMBAPP_GAISLER_APBUART_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_APBUART)
+#define DRIVER_AMBAPP_GAISLER_B1553BRM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_B1553BRM)
+#define DRIVER_AMBAPP_GAISLER_B1553RT_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_B1553RT)
+#define DRIVER_AMBAPP_GAISLER_GPTIMER_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GPTIMER)
+#define DRIVER_AMBAPP_GAISLER_GR1553B_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GR1553B)
+#define DRIVER_AMBAPP_GAISLER_GRADCDAC_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRADCDAC)
+#define DRIVER_AMBAPP_GAISLER_GRAES_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRAESDMA)
+#define DRIVER_AMBAPP_GAISLER_GRCAN_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRCAN)
+#define DRIVER_AMBAPP_GAISLER_GRCTM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRCTM)
+#define DRIVER_AMBAPP_GAISLER_GRETH_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_ETHMAC)
+#define DRIVER_AMBAPP_GAISLER_GRGPIO_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GPIO)
+#define DRIVER_AMBAPP_GAISLER_GRPCI2_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRPCI2)
+#define DRIVER_AMBAPP_GAISLER_GRIOMMU_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRIOMMU)
+#define DRIVER_AMBAPP_GAISLER_GRPCI_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCIFBRG)
+#define DRIVER_AMBAPP_GAISLER_GRPWM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRPWM)
+#define DRIVER_AMBAPP_GAISLER_GRPWRX_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PW2APB)
+#define DRIVER_AMBAPP_GAISLER_GRSPW_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW)
+#define DRIVER_AMBAPP_GAISLER_GRSPW2_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW2)
+#define DRIVER_AMBAPP_GAISLER_GRTC_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRTC)
+#define DRIVER_AMBAPP_GAISLER_GRTM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRTM)
+#define DRIVER_AMBAPP_GAISLER_I2CMST_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_I2CMST)
+#define DRIVER_AMBAPP_GAISLER_OCCAN_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_CANAHB)
+#define DRIVER_AMBAPP_GAISLER_PCIF_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCIF)
+#define DRIVER_AMBAPP_GAISLER_PCITRACE_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCITRACE)
+#define DRIVER_AMBAPP_GAISLER_SPICTRL_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPICTRL)
+#define DRIVER_AMBAPP_GAISLER_SPWCUC_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPWCUC)
+#define DRIVER_AMBAPP_GAISLER_SPW_ROUTER_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW_ROUTER)
+#define DRIVER_AMBAPP_GAISLER_L2CACHE_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_L2CACHE)
+#define DRIVER_AMBAPP_GAISLER_MEMSCRUB_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_MEMSCRUB)
+#define DRIVER_AMBAPP_GAISLER_L4STAT_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_L4STAT)
+
+/*** ESA Hardware Device Driver IDs ***/
+#define DRIVER_AMBAPP_ESA_MCTRL_ID DRIVER_AMBAPP_ID(VENDOR_ESA, ESA_MCTRL)
+#define DRIVER_AMBAPP_MCTRL_ID DRIVER_AMBAPP_ESA_MCTRL_ID
+
+struct amba_dev_id {
+ unsigned short vendor;
+ unsigned short device;
+ /* Version ? */
+};
+
+struct amba_drv_info {
+ struct drvmgr_drv general; /* General bus info */
+ /* AMBA specific bus information */
+ struct amba_dev_id *ids; /* Supported hardware */
+};
+
+struct amba_dev_info {
+ struct amba_dev_id id;
+ struct ambapp_core info;
+};
+
+struct ambapp_ops {
+ int (*int_register)
+ (struct drvmgr_dev *dev, int index, const char *info, drvmgr_isr isr, void *arg);
+ int (*int_unregister)
+ (struct drvmgr_dev *dev, int index, drvmgr_isr isr, void *arg);
+ int (*int_clear)(struct drvmgr_dev *dev, int index);
+ int (*int_mask)(struct drvmgr_dev *dev, int index);
+ int (*int_unmask)(struct drvmgr_dev *dev, int index);
+#ifdef RTEMS_SMP
+ int (*int_set_affinity)(struct drvmgr_dev *dev, int index,
+ const Processor_mask *cpus);
+#endif
+ int (*get_params)
+ (struct drvmgr_dev *, struct drvmgr_bus_params *);
+};
+
+struct ambapp_config {
+ struct ambapp_bus *abus; /* Prescanned AMBA PnP bus */
+ struct ambapp_ops *ops; /* AMBA bus operations */
+ struct drvmgr_map_entry *maps_up; /* Bus memory map up-stream towards CPU */
+ struct drvmgr_map_entry *maps_down; /* Bus memory map down-stream towards HW */
+ struct drvmgr_bus_res *resources; /* Driver Resources */
+ int bus_type; /* Set DRVMGR_BUS_TYPE_AMBAPP_DIST if distributed AMBA Bus */
+ struct drvmgr_func *funcs; /* Custom functions */
+};
+
+/*** Bus operations with READ/WRITE access operations ***
+ *
+ * The functions are implemented using the standard drvmgr RW interface
+ */
+#define AMBAPP_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_REG)
+#define AMBAPP_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_REG)
+#define AMBAPP_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_REG)
+#define AMBAPP_R64 DRVMGR_RWFUNC(RW_SIZE_8|RW_READ|RW_REG)
+#define AMBAPP_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_REG)
+#define AMBAPP_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_REG)
+#define AMBAPP_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_REG)
+#define AMBAPP_W64 DRVMGR_RWFUNC(RW_SIZE_8|RW_WRITE|RW_REG)
+#define AMBAPP_RMEM DRVMGR_RWFUNC(RW_SIZE_ANY|RW_READ|RW_MEM)
+#define AMBAPP_WMEM DRVMGR_RWFUNC(RW_SIZE_ANY|RW_WRITE|RW_MEM)
+#define AMBAPP_MEMSET DRVMGR_RWFUNC(RW_SIZE_ANY|RW_SET|RW_MEM)
+#define AMBAPP_RW_ARG DRVMGR_RWFUNC(RW_ARG)
+
+/* Register an ambapp bus on-top of a device */
+extern int ambapp_bus_register(
+ struct drvmgr_dev *dev,
+ struct ambapp_config *config
+ );
+
+extern void ambapp_bus_freq_register(
+ struct drvmgr_dev *dev,
+ int amba_interface,
+ unsigned int freq_hz);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/bsps/sparc/include/drvmgr/ambapp_bus_grlib.h b/bsps/sparc/include/drvmgr/ambapp_bus_grlib.h
new file mode 100644
index 0000000000..2def4bc2b4
--- /dev/null
+++ b/bsps/sparc/include/drvmgr/ambapp_bus_grlib.h
@@ -0,0 +1,36 @@
+/* LEON3 GRLIB AMBA Plug & Play bus driver interface.
+ *
+ * COPYRIGHT (c) 2008.
+ * Cobham Gaisler AB.
+ *
+ * This is driver is a wrapper for the general AMBA Plug & Play bus
+ * driver. This is the root bus driver for GRLIB systems.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef __AMBAPP_BUS_GRLIB_H__
+#define __AMBAPP_BUS_GRLIB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct grlib_config {
+ struct ambapp_bus *abus;
+ struct drvmgr_bus_res *resources;
+};
+
+/* Register GRLIB AMBA PnP Bus as root bus at driver manager */
+extern int ambapp_grlib_root_register(struct grlib_config *config);
+
+/* Register bus driver to Driver Manager */
+void ambapp_grlib_register(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/bsps/sparc/include/drvmgr/bspcommon.h b/bsps/sparc/include/drvmgr/bspcommon.h
new file mode 100644
index 0000000000..d3470009f8
--- /dev/null
+++ b/bsps/sparc/include/drvmgr/bspcommon.h
@@ -0,0 +1,28 @@
+/* Common BSP/driver configuration routines.
+ *
+ * COPYRIGHT (c) 2015.
+ * Cobham Gaisler.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ *
+ */
+
+#ifndef __BSPCOMMON_H__
+#define __BSPCOMMON_H__
+
+#include <drvmgr/drvmgr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Count driver resource array length. Array must be terminated with a NULL */
+int get_resarray_count(struct drvmgr_bus_res **array);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/bsps/sparc/include/drvmgr/leon2_amba_bus.h b/bsps/sparc/include/drvmgr/leon2_amba_bus.h
new file mode 100644
index 0000000000..ebb3a08486
--- /dev/null
+++ b/bsps/sparc/include/drvmgr/leon2_amba_bus.h
@@ -0,0 +1,95 @@
+/* LEON2 Hardcoded bus driver interface.
+ *
+ * COPYRIGHT (c) 2008.
+ * Cobham Gaisler AB.
+ *
+ * Bus driver for a hardcoded setup. LEON2 systems have some
+ * cores always present, here called "Standard Cores". In
+ * addtion to the standard cores there are often extra cores
+ * that can be defined using the "Custom Cores" mechanism.
+ *
+ * A Core is described by assigning a base register and
+ * IRQ0..IRQ15 using the leon2_core structure.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef __LEON2_AMBA_BUS_H__
+#define __LEON2_AMBA_BUS_H__
+
+/*** Cores location and IRQs hardcoded ***/
+
+#include <drvmgr/drvmgr.h>
+#include <ambapp.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* LEON2 AMBA Driver ID generation */
+#define DRIVER_LEON2_AMBA(id) DRIVER_ID(DRVMGR_BUS_TYPE_LEON2_AMBA, id)
+
+/* LEON2 Cores (any unique 48-bit number will do) */
+#define LEON2_AMBA_NONE_ID 0
+#define LEON2_AMBA_TIMER_ID 1
+#define LEON2_AMBA_UART_ID 2
+#define LEON2_AMBA_GPIO_ID 3
+#define LEON2_AMBA_IRQCTRL_ID 4
+
+#define LEON2_AMBA_AT697PCI_ID 100
+#define LEON2_AMBA_AMBAPP_ID 0xfff0
+
+/* LEON2 driver IDs */
+#define DRIVER_LEON2_AMBA_TIMER DRIVER_LEON2_AMBA(LEON2_AMBA_TIMER_ID)
+#define DRIVER_LEON2_AMBA_UART DRIVER_LEON2_AMBA(LEON2_AMBA_UART_ID)
+#define DRIVER_LEON2_AMBA_AT697PCI DRIVER_LEON2_AMBA(LEON2_AMBA_AT697PCI_ID)
+#define DRIVER_LEON2_AMBA_AMBAPP DRIVER_LEON2_AMBA(LEON2_AMBA_AMBAPP_ID)
+
+struct leon2_amba_dev_id {
+ unsigned short core_id;
+};
+
+#define EMPTY_LEON2_CORE {{LEON2_AMBA_NONE_ID}, NULL, NULL}
+struct leon2_core {
+ struct leon2_amba_dev_id id; /* Core ID */
+ char *name; /* Name of Core */
+ struct drvmgr_key *keys; /* Core setup (location, IRQs) */
+};
+
+struct leon2_bus {
+ struct leon2_core *std_cores; /* The LEON2 standard cores */
+ struct leon2_core *custom_cores; /* Custom cores on the same bus */
+ struct drvmgr_map_entry *maps_up; /* Memory map ip-stream */
+ struct drvmgr_map_entry *maps_down; /* Memory map down-stream */
+};
+
+extern struct leon2_core leon2_std_cores[];
+
+/* Data structure drivers can access */
+struct leon2_amba_dev_info {
+ unsigned short core_id; /* Core ID */
+ unsigned int reg_base; /* Register base */
+ char irqs[16]; /* 16 irqs */
+};
+
+struct leon2_amba_drv_info {
+ struct drvmgr_drv general; /* General bus info */
+ /* AMBA specific bus information */
+ struct leon2_amba_dev_id *ids; /* Supported hardware */
+};
+
+/* Initialize LEON2 bus with a configuration
+ * bus_config - What cores, their location and irqs
+ * resources - Driver configuration for the cores specified bus_config
+ */
+int leon2_root_register(
+ struct leon2_bus *bus_config,
+ struct drvmgr_bus_res *resources);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif