source: rtems/c/src/lib/libbsp/sparc/shared/include/ambapp.h @ 0743eae

4.104.114.95
Last change on this file since 0743eae was 0743eae, checked in by Joel Sherrill <joel.sherrill@…>, on 10/11/07 at 12:56:09

2007-10-11 Daniel Hellstrom <daniel@…>

  • Makefile.am, shared/can/occan.c, shared/include/ambapp.h: Add initial i2c and update OC-CAN support.
  • shared/i2c/i2cmst.c, shared/include/i2cmst.h: New files.
  • Property mode set to 100644
File size: 8.5 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_GRHCAN    0x34
64#define GAISLER_GRFIFO    0x35
65#define GAISLER_GRPULSE   0x37
66#define GAISLER_GRTIMER   0x38
67#define GAISLER_FTAHBRAM  0x50
68#define GAISLER_FTMCTRL   0x54
69#define GAISLER_BRM       0x72
70
71
72/* European Space Agency device id's */
73#define ESA_LEON2        0x2
74#define ESA_MCTRL        0xF
75#define ESA_SPW2         0x12
76
77/* Opencores device id's */
78#define OPENCORES_PCIBR  0x4
79#define OPENCORES_ETHMAC 0x5
80
81/*
82 *
83 * Macros for manipulating Configuration registers 
84 *
85 */
86#define amba_get_confword(tab, index, word) (*((tab).addr[(index)]+(word)))
87
88#define amba_vendor(x) (((x) >> 24) & 0xff)
89
90#define amba_device(x) (((x) >> 12) & 0xfff)
91
92#define amba_ahb_get_membar(tab, index, nr) (*((tab).addr[(index)]+4+(nr)))
93
94#define amba_ahb_get_custom(tab, index, nr) (*((tab).addr[(index)]+1+(nr)))
95
96#define amba_apb_get_membar(tab, index) (*((tab).addr[(index)]+1))
97
98#define amba_membar_start(mbar) (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16))
99
100#define amba_iobar_start(base, iobar) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) )
101
102#define amba_irq(conf) ((conf) & 0x1f)
103
104#define amba_ver(conf) (((conf)>>5) & 0x1f)
105
106#define amba_membar_type(mbar) ((mbar) & 0xf)
107
108#define AMBA_TYPE_APBIO 0x1
109#define AMBA_TYPE_MEM   0x2
110#define AMBA_TYPE_AHBIO 0x3
111
112#define AMBA_TYPE_AHBIO_ADDR(addr,base_ioarea) ((unsigned int)(base_ioarea) | ((addr) >> 12))
113
114/*
115 *  Types and structure used for AMBA Plug & Play bus scanning
116 *
117 */
118typedef struct amba_device_table {
119  int devnr;                    /* numbrer of devices on AHB or APB bus */
120  unsigned int *addr[16];       /* addresses to the devices configuration tables */
121} amba_device_table;
122
123typedef struct {
124  int devnr;
125  unsigned int *addr[AMBA_APB_SLAVES];  /* addresses to the devices configuration tables */
126  unsigned int apbmst[AMBA_APB_SLAVES]; /* pointer to AHB slave (which is a APB master) */
127} amba_apb_dev;
128
129struct amba_mmap {
130  unsigned int cpu_adr;
131  unsigned int size;
132  unsigned int remote_amba_adr;
133};
134
135typedef struct _amba_confarea_type amba_confarea_type;
136
137struct _amba_confarea_type {
138  amba_confarea_type  *next;   /* next bus in chain */
139  int                 notroot; /* is root of a bus (mother AHB has 64 masters/slaves rest 16) */
140        unsigned int        ioarea;
141  struct amba_mmap    *mmaps;
142  amba_device_table   ahbmst;
143  amba_device_table   ahbslv;
144  amba_apb_dev        apbslv;
145};
146
147typedef struct {
148  unsigned int start, irq, bus_id;
149} amba_apb_device;
150
151typedef struct {
152  unsigned int start[4], irq, ver;
153} amba_ahb_device;
154
155/* Scans AMBA Plug&Play Information and convers that information
156 * to a more readable format in RAM.
157 *
158 * Will scan for - AHB Masters
159 *               - AHB Slaves
160 *               - APB Slaves (if a AHB/APB bridge is found)
161 *
162 * \param amba_conf AMBA P&P device info is placed here.
163 * \param ioarea address of AMBA Plug&Play information,
164 *             on LEON3 systems default is 0xfff00000
165 * \param mmaps Memory mmap specific to this amba bus,
166 *              if NULL no translation will be made (default).
167 *              A array of maps, ending with a entry with size=0.
168 */
169void amba_scan (amba_confarea_type * amba_conf, unsigned int ioarea,
170                struct amba_mmap *mmaps);
171
172/* Print AMBA Plug&Play info on terminal */
173void amba_print_conf (amba_confarea_type * amba_conf);
174
175
176
177
178/***** APB SLAVES *****/
179
180/* Return number of APB Slave devices which has given vendor and device */
181int amba_get_number_apbslv_devices (amba_confarea_type * amba_conf, int vendor,
182                                    int device);
183
184/* Get First APB Slave device of this vendor&device id */
185int amba_find_apbslv (amba_confarea_type * amba_conf, int vendor, int device,
186                      amba_apb_device * dev);
187
188/* Get APB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_apbslv() ) */
189int amba_find_next_apbslv (amba_confarea_type * amba_conf, int vendor,
190                           int device, amba_apb_device * dev, int index);
191
192/* Get first nr APB Slave devices, put them into dev (which is an array of nr length) */
193int amba_find_apbslvs (amba_confarea_type * amba_conf, int vendor, int device,
194                       amba_apb_device * devs, int maxno);
195
196
197
198/***** AHB SLAVES *****/
199
200/* Return number of AHB Slave devices which has given vendor and device */
201int amba_get_number_ahbslv_devices (amba_confarea_type * amba_conf, int vendor,
202                                    int device);
203
204/* Get First AHB Slave device of this vendor&device id */
205int amba_find_ahbslv (amba_confarea_type * amba_conf, int vendor, int device,
206                      amba_ahb_device * dev);
207
208/* Get AHB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbslv() ) */
209int amba_find_next_ahbslv (amba_confarea_type * amba_conf, int vendor,
210                           int device, amba_ahb_device * dev, int index);
211
212/* Get first nr AHB Slave devices, put them into dev (which is an array of nr length) */
213int amba_find_ahbslvs (amba_confarea_type * amba_conf, int vendor, int device,
214                       amba_ahb_device * devs, int maxno);
215
216
217
218/***** AHB MASTERS *****/
219
220/* Return number of AHB Master devices which has given vendor and device */
221int amba_get_number_ahbmst_devices (amba_confarea_type * amba_conf, int vendor,
222                                    int device);
223
224/* Get First AHB Master device of this vendor&device id */
225int amba_find_ahbmst (amba_confarea_type * amba_conf, int vendor, int device,
226                      amba_ahb_device * dev);
227
228/* Get AHB Master device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbmst() ) */
229int amba_find_next_ahbmst (amba_confarea_type * amba_conf, int vendor,
230                           int device, amba_ahb_device * dev, int index);
231
232/* Get first nr AHB Master devices, put them into dev (which is an array of nr length) */
233int amba_find_ahbmsts (amba_confarea_type * amba_conf, int vendor, int device,
234                       amba_ahb_device * devs, int maxno);
235
236
237/******** AMBA DEVICES *******/
238
239/* ESA MEMORY CONTROLLER */
240typedef struct {
241  unsigned int mcfg1;
242  unsigned int mcfg2;
243  unsigned int mcfg3;
244} ambapp_regmap_mctrl;
245
246/* APB UART */
247typedef struct {
248  volatile unsigned int data;
249  volatile unsigned int status;
250  volatile unsigned int ctrl;
251  volatile unsigned int scaler;
252} ambapp_apb_uart;
253
254typedef struct {
255  volatile unsigned int ilevel;
256  volatile unsigned int ipend;
257  volatile unsigned int iforce;
258  volatile unsigned int iclear;
259  volatile unsigned int mpstat;
260  volatile unsigned int notused01;
261  volatile unsigned int notused02;
262  volatile unsigned int notused03;
263  volatile unsigned int notused10;
264  volatile unsigned int notused11;
265  volatile unsigned int notused12;
266  volatile unsigned int notused13;
267  volatile unsigned int notused20;
268  volatile unsigned int notused21;
269  volatile unsigned int notused22;
270  volatile unsigned int notused23;
271  volatile unsigned int mask[16];
272  volatile unsigned int force[16];
273} LEON3_IrqCtrl_Regs_Map;
274
275/*****************************/
276
277#ifdef __cplusplus
278}
279#endif
280
281#endif
Note: See TracBrowser for help on using the repository browser.