1 | /* General part of a AMBA Plug & Play bus driver. |
---|
2 | * |
---|
3 | * COPYRIGHT (c) 2008. |
---|
4 | * Cobham Gaisler AB. |
---|
5 | * |
---|
6 | * This is the general part of the different AMBA Plug & Play |
---|
7 | * drivers. The drivers are wrappers around this driver, making |
---|
8 | * the code size smaller for systems with multiple AMBA Plug & |
---|
9 | * Play buses. |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.org/license/LICENSE. |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef __AMBAPP_BUS_H__ |
---|
17 | #define __AMBAPP_BUS_H__ |
---|
18 | |
---|
19 | #include <drvmgr/drvmgr.h> |
---|
20 | #include <ambapp.h> |
---|
21 | |
---|
22 | #ifdef __cplusplus |
---|
23 | extern "C" { |
---|
24 | #endif |
---|
25 | |
---|
26 | /* GRLIB AMBA Plug&Play Driver ID generation */ |
---|
27 | #define DRIVER_AMBAPP_ID(vendor, device) \ |
---|
28 | DRIVER_ID(DRVMGR_BUS_TYPE_AMBAPP, ((((vendor) & 0xff) << 16) | ((device) & 0xfff))) |
---|
29 | |
---|
30 | /*** Gaisler Hardware Device Driver IDs ***/ |
---|
31 | #define DRIVER_AMBAPP_GAISLER_AHBSTAT_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_AHBSTAT) |
---|
32 | #define DRIVER_AMBAPP_GAISLER_APBUART_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_APBUART) |
---|
33 | #define DRIVER_AMBAPP_GAISLER_B1553BRM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_B1553BRM) |
---|
34 | #define DRIVER_AMBAPP_GAISLER_B1553RT_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_B1553RT) |
---|
35 | #define DRIVER_AMBAPP_GAISLER_GPTIMER_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GPTIMER) |
---|
36 | #define DRIVER_AMBAPP_GAISLER_GR1553B_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GR1553B) |
---|
37 | #define DRIVER_AMBAPP_GAISLER_GRADCDAC_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRADCDAC) |
---|
38 | #define DRIVER_AMBAPP_GAISLER_GRAES_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRAESDMA) |
---|
39 | #define DRIVER_AMBAPP_GAISLER_GRCAN_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRCAN) |
---|
40 | #define DRIVER_AMBAPP_GAISLER_GRCTM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRCTM) |
---|
41 | #define DRIVER_AMBAPP_GAISLER_GRETH_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_ETHMAC) |
---|
42 | #define DRIVER_AMBAPP_GAISLER_GRGPIO_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GPIO) |
---|
43 | #define DRIVER_AMBAPP_GAISLER_GRPCI2_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRPCI2) |
---|
44 | #define DRIVER_AMBAPP_GAISLER_GRIOMMU_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRIOMMU) |
---|
45 | #define DRIVER_AMBAPP_GAISLER_GRPCI_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCIFBRG) |
---|
46 | #define DRIVER_AMBAPP_GAISLER_GRPWM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRPWM) |
---|
47 | #define DRIVER_AMBAPP_GAISLER_GRPWRX_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PW2APB) |
---|
48 | #define DRIVER_AMBAPP_GAISLER_GRSPW_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW) |
---|
49 | #define DRIVER_AMBAPP_GAISLER_GRSPW2_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW2) |
---|
50 | #define DRIVER_AMBAPP_GAISLER_GRTC_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRTC) |
---|
51 | #define DRIVER_AMBAPP_GAISLER_GRTM_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRTM) |
---|
52 | #define DRIVER_AMBAPP_GAISLER_I2CMST_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_I2CMST) |
---|
53 | #define DRIVER_AMBAPP_GAISLER_OCCAN_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_CANAHB) |
---|
54 | #define DRIVER_AMBAPP_GAISLER_PCIF_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCIF) |
---|
55 | #define DRIVER_AMBAPP_GAISLER_PCITRACE_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCITRACE) |
---|
56 | #define DRIVER_AMBAPP_GAISLER_SPICTRL_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPICTRL) |
---|
57 | #define DRIVER_AMBAPP_GAISLER_SPWCUC_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPWCUC) |
---|
58 | #define DRIVER_AMBAPP_GAISLER_SPW_ROUTER_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW_ROUTER) |
---|
59 | #define DRIVER_AMBAPP_GAISLER_L2CACHE_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_L2CACHE) |
---|
60 | #define DRIVER_AMBAPP_GAISLER_MEMSCRUB_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_MEMSCRUB) |
---|
61 | |
---|
62 | /*** ESA Hardware Device Driver IDs ***/ |
---|
63 | #define DRIVER_AMBAPP_ESA_MCTRL_ID DRIVER_AMBAPP_ID(VENDOR_ESA, ESA_MCTRL) |
---|
64 | #define DRIVER_AMBAPP_MCTRL_ID DRIVER_AMBAPP_ESA_MCTRL_ID |
---|
65 | |
---|
66 | struct amba_dev_id { |
---|
67 | unsigned short vendor; |
---|
68 | unsigned short device; |
---|
69 | /* Version ? */ |
---|
70 | }; |
---|
71 | |
---|
72 | struct amba_drv_info { |
---|
73 | struct drvmgr_drv general; /* General bus info */ |
---|
74 | /* AMBA specific bus information */ |
---|
75 | struct amba_dev_id *ids; /* Supported hardware */ |
---|
76 | }; |
---|
77 | |
---|
78 | struct amba_dev_info { |
---|
79 | struct amba_dev_id id; |
---|
80 | struct ambapp_core info; |
---|
81 | }; |
---|
82 | |
---|
83 | struct ambapp_ops { |
---|
84 | int (*int_register) |
---|
85 | (struct drvmgr_dev *dev, int index, const char *info, drvmgr_isr isr, void *arg); |
---|
86 | int (*int_unregister) |
---|
87 | (struct drvmgr_dev *dev, int index, drvmgr_isr isr, void *arg); |
---|
88 | int (*int_clear)(struct drvmgr_dev *dev, int index); |
---|
89 | int (*int_mask)(struct drvmgr_dev *dev, int index); |
---|
90 | int (*int_unmask)(struct drvmgr_dev *dev, int index); |
---|
91 | #ifdef RTEMS_SMP |
---|
92 | int (*int_set_affinity)(struct drvmgr_dev *dev, int index, |
---|
93 | Processor_mask cpus); |
---|
94 | #endif |
---|
95 | int (*get_params) |
---|
96 | (struct drvmgr_dev *, struct drvmgr_bus_params *); |
---|
97 | }; |
---|
98 | |
---|
99 | struct ambapp_config { |
---|
100 | struct ambapp_bus *abus; /* Prescanned AMBA PnP bus */ |
---|
101 | struct ambapp_ops *ops; /* AMBA bus operations */ |
---|
102 | struct drvmgr_map_entry *maps_up; /* Bus memory map up-stream towards CPU */ |
---|
103 | struct drvmgr_map_entry *maps_down; /* Bus memory map down-stream towards HW */ |
---|
104 | struct drvmgr_bus_res *resources; /* Driver Resources */ |
---|
105 | int bus_type; /* Set DRVMGR_BUS_TYPE_AMBAPP_DIST if distributed AMBA Bus */ |
---|
106 | struct drvmgr_func *funcs; /* Custom functions */ |
---|
107 | }; |
---|
108 | |
---|
109 | /*** Bus operations with READ/WRITE access operations *** |
---|
110 | * |
---|
111 | * The functions are implemented using the standard drvmgr RW interface |
---|
112 | */ |
---|
113 | #define AMBAPP_R8 DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_REG) |
---|
114 | #define AMBAPP_R16 DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_REG) |
---|
115 | #define AMBAPP_R32 DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_REG) |
---|
116 | #define AMBAPP_R64 DRVMGR_RWFUNC(RW_SIZE_8|RW_READ|RW_REG) |
---|
117 | #define AMBAPP_W8 DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_REG) |
---|
118 | #define AMBAPP_W16 DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_REG) |
---|
119 | #define AMBAPP_W32 DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_REG) |
---|
120 | #define AMBAPP_W64 DRVMGR_RWFUNC(RW_SIZE_8|RW_WRITE|RW_REG) |
---|
121 | #define AMBAPP_RMEM DRVMGR_RWFUNC(RW_SIZE_ANY|RW_READ|RW_MEM) |
---|
122 | #define AMBAPP_WMEM DRVMGR_RWFUNC(RW_SIZE_ANY|RW_WRITE|RW_MEM) |
---|
123 | #define AMBAPP_MEMSET DRVMGR_RWFUNC(RW_SIZE_ANY|RW_SET|RW_MEM) |
---|
124 | #define AMBAPP_RW_ARG DRVMGR_RWFUNC(RW_ARG) |
---|
125 | |
---|
126 | /* Register an ambapp bus on-top of a device */ |
---|
127 | extern int ambapp_bus_register( |
---|
128 | struct drvmgr_dev *dev, |
---|
129 | struct ambapp_config *config |
---|
130 | ); |
---|
131 | |
---|
132 | extern void ambapp_bus_freq_register( |
---|
133 | struct drvmgr_dev *dev, |
---|
134 | int amba_interface, |
---|
135 | unsigned int freq_hz); |
---|
136 | |
---|
137 | #ifdef __cplusplus |
---|
138 | } |
---|
139 | #endif |
---|
140 | |
---|
141 | #endif |
---|