source: rtems/c/src/lib/libbsp/sparc/shared/include/ambapp.h @ 438b6eca

Last change on this file since 438b6eca was 438b6eca, checked in by Daniel Hellstrom <daniel@…>, on 04/05/12 at 15:23:21

LEON3: added IRQAMP support

  • Property mode set to 100644
File size: 8.6 KB
Line 
1/*
2 *  AMBA Plag & Play Bus Driver Macros for LEON2
3 *
4 *  Macros used for AMBA Plug & Play bus scanning
5 *
6 *  COPYRIGHT (c) 2007.
7 *  Gaisler Research
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#ifndef __AMBAPP_H__
17#define __AMBAPP_H__
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#define AMBA_CONF_AREA 0xff000
24#define AMBA_AHB_SLAVE_CONF_AREA (1 << 11)
25
26#define AMBA_AHB_CONF_WORDS 8
27#define AMBA_APB_CONF_WORDS 2
28#define AMBA_AHB_MASTERS 16
29#define AMBA_AHB_SLAVES 16
30#define AMBA_APB_SLAVES 16
31#define AMBA_APBUARTS 8
32
33/* Vendor codes */
34#define VENDOR_GAISLER   1
35#define VENDOR_PENDER    2
36#define VENDOR_ESA       4
37#define VENDOR_OPENCORES 8
38
39/* Gaisler Research device id's */
40#define GAISLER_LEON3     0x03
41#define GAISLER_LEON3DSU  0x04
42#define GAISLER_ETHAHB    0x05
43#define GAISLER_APBMST    0x06
44#define GAISLER_AHBUART   0x07
45#define GAISLER_SRCTRL    0x08
46#define GAISLER_SDCTRL    0x09
47#define GAISLER_APBUART   0x0C
48#define GAISLER_IRQMP     0x0D
49#define GAISLER_AHBRAM    0x0E
50#define GAISLER_GPTIMER   0x11
51#define GAISLER_PCITRG    0x12
52#define GAISLER_PCISBRG   0x13
53#define GAISLER_PCIFBRG   0x14
54#define GAISLER_PCITRACE  0x15
55#define GAISLER_DMACTRL   0x16
56#define GAISLER_OCCAN     0x19
57#define GAISLER_PIOPORT   0x1A
58#define GAISLER_ETHMAC    0x1D
59#define GAISLER_SPACEWIRE 0x1f
60#define GAISLER_AHB2AHB   0x20
61#define GAISLER_I2CMST    0x28
62#define GAISLER_GRSPW2    0x29
63#define GAISLER_GRCAN     0x34
64#define GAISLER_GRHCAN    0x3d
65#define GAISLER_GRFIFO    0x35
66#define GAISLER_GRADCDAC  0x36
67#define GAISLER_GRPULSE   0x37
68#define GAISLER_GRTIMER   0x38
69#define GAISLER_FTAHBRAM  0x50
70#define GAISLER_FTMCTRL   0x54
71#define GAISLER_BRM       0x72
72
73
74/* European Space Agency device id's */
75#define ESA_LEON2        0x2
76#define ESA_MCTRL        0xF
77#define ESA_SPW2         0x12
78
79/* Opencores device id's */
80#define OPENCORES_PCIBR  0x4
81#define OPENCORES_ETHMAC 0x5
82
83/*
84 *
85 * Macros for manipulating Configuration registers
86 *
87 */
88#define amba_get_confword(tab, index, word) (*((tab).addr[(index)]+(word)))
89
90#define amba_vendor(x) (((x) >> 24) & 0xff)
91
92#define amba_device(x) (((x) >> 12) & 0xfff)
93
94#define amba_ahb_get_membar(tab, index, nr) (*((tab).addr[(index)]+4+(nr)))
95
96#define amba_ahb_get_custom(tab, index, nr) (*((tab).addr[(index)]+1+(nr)))
97
98#define amba_apb_get_membar(tab, index) (*((tab).addr[(index)]+1))
99
100#define amba_membar_start(mbar) (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16))
101
102#define amba_iobar_start(base, iobar) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) )
103
104#define amba_irq(conf) ((conf) & 0x1f)
105
106#define amba_ver(conf) (((conf)>>5) & 0x1f)
107
108#define amba_membar_type(mbar) ((mbar) & 0xf)
109
110#define AMBA_TYPE_APBIO 0x1
111#define AMBA_TYPE_MEM   0x2
112#define AMBA_TYPE_AHBIO 0x3
113
114#define AMBA_TYPE_AHBIO_ADDR(addr,base_ioarea) ((unsigned int)(base_ioarea) | ((addr) >> 12))
115
116/*
117 *  Types and structure used for AMBA Plug & Play bus scanning
118 *
119 */
120typedef struct amba_device_table {
121  int devnr;                    /* numbrer of devices on AHB or APB bus */
122  unsigned int *addr[16];       /* addresses to the devices configuration tables */
123} amba_device_table;
124
125typedef struct {
126  int devnr;
127  unsigned int *addr[AMBA_APB_SLAVES];  /* addresses to the devices configuration tables */
128  unsigned int apbmst[AMBA_APB_SLAVES]; /* pointer to AHB slave (which is a APB master) */
129} amba_apb_dev;
130
131struct amba_mmap {
132  unsigned int cpu_adr;
133  unsigned int size;
134  unsigned int remote_amba_adr;
135};
136
137typedef struct _amba_confarea_type amba_confarea_type;
138
139struct _amba_confarea_type {
140  amba_confarea_type  *next;   /* next bus in chain */
141  int                 notroot; /* is root of a bus (mother AHB has 64 masters/slaves rest 16) */
142        unsigned int        ioarea;
143  struct amba_mmap    *mmaps;
144  amba_device_table   ahbmst;
145  amba_device_table   ahbslv;
146  amba_apb_dev        apbslv;
147};
148
149typedef struct {
150  unsigned int start, irq, bus_id;
151} amba_apb_device;
152
153typedef struct {
154  unsigned int start[4], irq, ver;
155} amba_ahb_device;
156
157/* Scans AMBA Plug&Play Information and convers that information
158 * to a more readable format in RAM.
159 *
160 * Will scan for - AHB Masters
161 *               - AHB Slaves
162 *               - APB Slaves (if a AHB/APB bridge is found)
163 *
164 * \param amba_conf AMBA P&P device info is placed here.
165 * \param ioarea address of AMBA Plug&Play information,
166 *             on LEON3 systems default is 0xfff00000
167 * \param mmaps Memory mmap specific to this amba bus,
168 *              if NULL no translation will be made (default).
169 *              A array of maps, ending with a entry with size=0.
170 */
171void amba_scan (amba_confarea_type * amba_conf, unsigned int ioarea,
172                struct amba_mmap *mmaps);
173
174/* Print AMBA Plug&Play info on terminal */
175void amba_print_conf (amba_confarea_type * amba_conf);
176
177
178
179
180/***** APB SLAVES *****/
181
182/* Return number of APB Slave devices which has given vendor and device */
183int amba_get_number_apbslv_devices (amba_confarea_type * amba_conf, int vendor,
184                                    int device);
185
186/* Get First APB Slave device of this vendor&device id */
187int amba_find_apbslv (amba_confarea_type * amba_conf, int vendor, int device,
188                      amba_apb_device * dev);
189
190/* Get APB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_apbslv() ) */
191int amba_find_next_apbslv (amba_confarea_type * amba_conf, int vendor,
192                           int device, amba_apb_device * dev, int index);
193
194/* Get first nr APB Slave devices, put them into dev (which is an array of nr length) */
195int amba_find_apbslvs (amba_confarea_type * amba_conf, int vendor, int device,
196                       amba_apb_device * devs, int maxno);
197
198
199
200/***** AHB SLAVES *****/
201
202/* Return number of AHB Slave devices which has given vendor and device */
203int amba_get_number_ahbslv_devices (amba_confarea_type * amba_conf, int vendor,
204                                    int device);
205
206/* Get First AHB Slave device of this vendor&device id */
207int amba_find_ahbslv (amba_confarea_type * amba_conf, int vendor, int device,
208                      amba_ahb_device * dev);
209
210/* Get AHB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbslv() ) */
211int amba_find_next_ahbslv (amba_confarea_type * amba_conf, int vendor,
212                           int device, amba_ahb_device * dev, int index);
213
214/* Get first nr AHB Slave devices, put them into dev (which is an array of nr length) */
215int amba_find_ahbslvs (amba_confarea_type * amba_conf, int vendor, int device,
216                       amba_ahb_device * devs, int maxno);
217
218
219
220/***** AHB MASTERS *****/
221
222/* Return number of AHB Master devices which has given vendor and device */
223int amba_get_number_ahbmst_devices (amba_confarea_type * amba_conf, int vendor,
224                                    int device);
225
226/* Get First AHB Master device of this vendor&device id */
227int amba_find_ahbmst (amba_confarea_type * amba_conf, int vendor, int device,
228                      amba_ahb_device * dev);
229
230/* Get AHB Master device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbmst() ) */
231int amba_find_next_ahbmst (amba_confarea_type * amba_conf, int vendor,
232                           int device, amba_ahb_device * dev, int index);
233
234/* Get first nr AHB Master devices, put them into dev (which is an array of nr length) */
235int amba_find_ahbmsts (amba_confarea_type * amba_conf, int vendor, int device,
236                       amba_ahb_device * devs, int maxno);
237
238
239/******** AMBA DEVICES *******/
240
241/* ESA MEMORY CONTROLLER */
242typedef struct {
243  unsigned int mcfg1;
244  unsigned int mcfg2;
245  unsigned int mcfg3;
246} ambapp_regmap_mctrl;
247
248/* APB UART */
249typedef struct {
250  volatile unsigned int data;
251  volatile unsigned int status;
252  volatile unsigned int ctrl;
253  volatile unsigned int scaler;
254} ambapp_apb_uart;
255
256typedef struct {
257  volatile unsigned int ilevel;
258  volatile unsigned int ipend;
259  volatile unsigned int iforce;
260  volatile unsigned int iclear;
261  volatile unsigned int mpstat;
262  volatile unsigned int notused01;
263  volatile unsigned int notused02;
264  volatile unsigned int notused03;
265  volatile unsigned int ampctrl;
266  volatile unsigned int icsel[2];
267  volatile unsigned int notused13;
268  volatile unsigned int notused20;
269  volatile unsigned int notused21;
270  volatile unsigned int notused22;
271  volatile unsigned int notused23;
272  volatile unsigned int mask[16];
273  volatile unsigned int force[16];
274  /* Extended IRQ registers */
275  volatile unsigned int intid[16];
276  /* 0x100, align to 4Kb boundary */
277  volatile unsigned int resv1[(0x1000-0x100)/4];
278} LEON3_IrqCtrl_Regs_Map;
279
280/*****************************/
281
282#ifdef __cplusplus
283}
284#endif
285
286#endif
Note: See TracBrowser for help on using the repository browser.