blob: 87225ab162ddc0069433a7a0cbbf956b53e8f707 [file] [log] [blame]
wdenk327f7a02001-11-28 17:49:55 +00001#ifndef I2O_H
2#define I2O_H
3/*********************************************************
4 *
5 * copyright @ Motorola, 1999
6 *********************************************************/
7
8#define I2O_REG_OFFSET 0x0004
9
10#define PCI_CFG_CLA 0x0B
11#define PCI_CFG_SCL 0x0A
12#define PCI_CFG_PIC 0x09
13
14#define I2O_IMR0 0x0050
15#define I2O_IMR1 0x0054
16#define I2O_OMR0 0x0058
17#define I2O_OMR1 0x005C
18
19#define I2O_ODBR 0x0060
20#define I2O_IDBR 0x0068
21
22#define I2O_OMISR 0x0030
23#define I2O_OMIMR 0x0034
24#define I2O_IMISR 0x0100
25#define I2O_IMIMR 0x0104
26
27/* accessable to PCI master but local processor */
28#define I2O_IFQPR 0x0040
29#define I2O_OFQPR 0x0044
30
31/* accessable to local processor */
32#define I2O_IFHPR 0x0120
33#define I2O_IFTPR 0x0128
34#define I2O_IPHPR 0x0130
35#define I2O_IPTPR 0x0138
36#define I2O_OFHPR 0x0140
37#define I2O_OFTPR 0x0148
38#define I2O_OPHPR 0x0150
39#define I2O_OPTPR 0x0158
40#define I2O_MUCR 0x0164
41#define I2O_QBAR 0x0170
42
43#define I2O_NUM_MSG 2
44
45typedef enum _i2o_status
46{
47 I2OSUCCESS = 0,
48 I2OINVALID,
49 I2OMSGINVALID,
50 I2ODBINVALID,
51 I2OQUEINVALID,
52 I2OQUEEMPTY,
53 I2OQUEFULL,
54 I2ONOEVENT,
55} I2OSTATUS;
56
57typedef enum _queue_size
58{
59 QSIZE_4K = 0x02,
60 QSIZE_8K = 0x04,
61 QSIZE_16K = 0x08,
62 QSIZE_32K = 0x10,
63 QSIZe_64K = 0x20,
64} QUEUE_SIZE;
65
66typedef enum _location
67{
68 LOCAL = 0, /* used by local processor to access its own on board device,
69 local processor's eumbbar is required */
70 REMOTE, /* used by PCI master to access the devices on its PCI device,
71 device's pcsrbar is required */
72} LOCATION;
73
74/* door bell */
75typedef enum _i2o_in_db
76{
77 IN_DB = 1,
78 MC, /* machine check */
79} I2O_IN_DB;
80
81/* I2O PCI configuration identification */
82typedef struct _i2o_iop
83{
84 unsigned int base_class : 8;
85 unsigned int sub_class : 8;
86 unsigned int prg_code : 8;
87} I2OIOP;
88
89/* I2O Outbound Message Interrupt Status Register */
90typedef struct _i2o_om_stat
91{
92 unsigned int rsvd0 : 26;
93 unsigned int opqi : 1;
94 unsigned int rsvd1 : 1;
95 unsigned int odi : 1;
96 unsigned int rsvd2 : 1;
97 unsigned int om1i : 1;
98 unsigned int om0i : 1;
99} I2OOMSTAT;
100
101/* I2O inbound Message Interrupt Status Register */
102typedef struct _i2o_im_stat
103{
104 unsigned int rsvd0 : 23;
105 unsigned int ofoi : 1;
106 unsigned int ipoi : 1;
107 unsigned int rsvd1 : 1;
108 unsigned int ipqi : 1;
109 unsigned int mci : 1;
110 unsigned int idi : 1;
111 unsigned int rsvd2 : 1;
112 unsigned int im1i : 1;
113 unsigned int im0i : 1;
114} I2OIMSTAT;
115
116/**
117 Enable the interrupt associated with in/out bound msg
118
119 Inbound message interrupt generated by PCI master and serviced by local processor
120 local processor needs to enable its inbound interrupts it wants to handle (LOCAL)
121
122 Outbound message interrupt generated by local processor and serviced by PCI master
123 PCI master needs to enable the devices' outbound interrupts it wants to handle (REMOTE)
124 **/
125extern I2OSTATUS I2OMsgEnable( LOCATION, /* REMOTE/LOCAL */
126 unsigned int base, /* pcsrbar/eumbbar */
127 unsigned char n ); /* b'1' - msg 0
128 * b'10'- msg 1
129 * b'11'- both
130 */
131
132/**
133 Disable the interrupt associated with in/out bound msg
134
135 local processor needs to disable its inbound interrupts it is not interested (LOCAL)
136
137 PCI master needs to disable outbound interrupts of devices it is not interested (REMOTE)
138 **/
139extern I2OSTATUS I2OMsgDisable( LOCATION, /* REMOTE/LOCAL */
140 unsigned int base, /* pcsrbar/eumbbar */
141 unsigned char n ); /* b'1' - msg 0
142 * b'10'- msg 1
143 * b'11'- both
144 */
145
146/**
147 Read the msg register either from local inbound msg 0/1,
148 or an outbound msg 0/1 of devices.
149
150 If it is not local, pcsrbar must be passed to the function.
151 Otherwise eumbbar is passed.
152
153 If it is remote, outbound msg of the device is read.
154 Otherwise local inbound msg is read.
155 **/
156extern I2OSTATUS I2OMsgGet ( LOCATION, /* REMOTE/LOCAL */
157 unsigned int base, /*pcsrbar/eumbbar */
158 unsigned int n, /* 0 or 1 */
159 unsigned int *msg );
160
161/**
162 Write to nth Msg register either on local outbound msg 0/1,
163 or aninbound msg 0/1 of devices
164
165 If it is not local, pcsrbar must be passed to the function.
166 Otherwise eumbbar is passed.
167
168 If it is remote, inbound msg on the device is written.
169 Otherwise local outbound msg is written.
170 **/
171extern I2OSTATUS I2OMsgPost( LOCATION, /* REMOTE/LOCAL */
172 unsigned int base, /*pcsrbar/eumbbar */
173 unsigned int n, /* 0 or 1 */
174 unsigned int msg );
175
176/**
177 Enable the In/Out DoorBell Interrupt
178
179 InDoorBell interrupt is generated by PCI master and serviced by local processor
180 local processor needs to enable its inbound doorbell interrupts it wants to handle
181
182 OutDoorbell interrupt is generated by local processor and serviced by PCI master
183 PCI master needs to enable outbound doorbell interrupts of the devices it wants to handle
184 **/
185extern I2OSTATUS I2ODBEnable( LOCATION, /* REMOTE/LOCAL */
186 unsigned int base, /* pcsrbar/eumbbar */
187 unsigned int in_db );/* when LOCAL, I2O_IN_DB, MC, I2O_IN_DB|MC */
188
189/**
190 Disable the In/Out DoorBell Interrupt
191
192 local processor needs to disable its inbound doorbell interrupts it is not interested
193
194 PCI master needs to disable outbound doorbell interrupts of devices it is not interested
195
196 **/
197extern I2OSTATUS I2ODBDisable( LOCATION, /* REMOTE/LOCAL */
198 unsigned int base, /* pcsrbar/eumbbar */
199 unsigned int in_db ); /* when LOCAL, I2O_IN_DB, MC, I2O_IN_DB|MC */
200
201/**
202 Read a local indoorbell register, or an outdoorbell of devices.
203 Reading a doorbell register, the register will be cleared.
204
205 If it is not local, pcsrbar must be passed to the function.
206 Otherwise eumbbar is passed.
207
208 If it is remote, outdoorbell register on the device is read.
209 Otherwise local in doorbell is read
210 **/
211extern unsigned int I2ODBGet( LOCATION, /* REMOTE/LOCAL */
212 unsigned int base); /* pcsrbar/eumbbar */
213
214/**
215 Write to a local outdoorbell register, or an indoorbell register of devices.
216
217 If it is not local, pcsrbar must be passed to the function.
218 Otherwise eumbbar is passed.
219
220 If it is remote, in doorbell register on the device is written.
221 Otherwise local out doorbell is written
222 **/
223extern void I2ODBPost( LOCATION, /* REMOTE/LOCAL */
224 unsigned int base, /* pcsrbar/eumbbar */
225 unsigned int msg ); /* in / out */
226
227/**
228 Read the outbound msg unit interrupt status of devices. Reading an interrupt status register,
229 the register will be cleared.
230
231 The outbound interrupt status is AND with the outbound
232 interrupt mask. The result is returned.
233
234 PCI master must pass the pcsrbar to the function.
235 **/
236extern I2OSTATUS I2OOutMsgStatGet( unsigned int pcsrbar, I2OOMSTAT * );
237
238/**
239 Read the inbound msg unit interrupt status. Reading an interrupt status register,
240 the register will be cleared.
241
242 The inbound interrupt status is AND with the inbound
243 interrupt mask. The result is returned.
244
245 Local process must pass its eumbbar to the function.
246**/
247extern I2OSTATUS I2OInMsgStatGet( unsigned int eumbbar, I2OIMSTAT * );
248
249/**
250 Configure the I2O FIFO, including QBAR, IFHPR/IFTPR,IPHPR/IPTPR,OFHPR/OFTPR, OPHPR/OPTPR,
251 MUCR.
252 **/
253extern I2OSTATUS I2OFIFOInit( unsigned int eumbbar,
254 QUEUE_SIZE,
255 unsigned int qba);/* queue base address that must be aligned at 1M */
256/**
257 Enable the circular queue
258 **/
259extern I2OSTATUS I2OFIFOEnable( unsigned int eumbbar );
260
261/**
262 Disable the circular queue
263 **/
264extern void I2OFIFODisable( unsigned int eumbbar );
265
266/**
267 Enable the circular queue interrupt
268 PCI master enables outbound FIFO interrupt of device
269 Device enables its inbound FIFO interrupt
270 **/
271extern void I2OFIFOIntEnable( LOCATION, unsigned int base );
272
273/**
274 Disable the circular queue interrupt
275 PCI master disables outbound FIFO interrupt of device
276 Device disables its inbound FIFO interrupt
277 **/
278extern void I2OFIFOIntDisable( LOCATION, unsigned int base );
279
280/**
281 Enable the circular queue overflow interrupt
282 **/
283extern void I2OFIFOOverflowIntEnable( unsigned int eumbbar );
284
285/**
286 Disable the circular queue overflow interrupt
287 **/
288extern void I2OFIFOOverflowIntDisable( unsigned int eumbbar );
289
290/**
291 Allocate a free msg frame from free FIFO.
292
293 PCI Master allocates a free msg frame through inbound queue port of device(IFQPR)
294 while local processor allocates a free msg frame from outbound free queue(OFTPR)
295
296 Unless both free queues are initialized, allocating a free MF will return 0xffffffff
297 **/
298extern I2OSTATUS I2OFIFOAlloc( LOCATION,
299 unsigned int base,
300 void **pMsg);
301/**
302 Free a used msg frame back to free queue
303 PCI Master frees a MFA through outbound queue port of device(OFQPR)
304 while local processor frees a MFA into its inbound free queue(IFHPR)
305
306 Used msg frame does not need to be recycled in the order they
307 read
308
309 This function has to be called by PCI master to initialize Inbound free queue
310 and by device to initialize Outbound free queue before I2OFIFOAlloc can be used.
311 **/
312extern I2OSTATUS I2OFIFOFree( LOCATION,
313 unsigned int base,
314 void *pMsg );
315
316/**
317 Post a msg into FIFO
318 PCI Master posts a msg through inbound queue port of device(IFQPR)
319 while local processor post a msg into its outbound post queue(OPHPR)
320
321 The total number of msg must be less than the max size of the queue
322 Otherwise queue overflow interrupt will assert.
323 **/
324extern I2OSTATUS I2OFIFOPost( LOCATION,
325 unsigned int base,
326 void *pMsg );
327
328/**
329 Read a msg from FIFO
330 PCI Master reads a msg through outbound queue port of device(OFQPR)
331 while local processor reads a msg from its inbound post queue(IPTPR)
332 **/
333extern I2OSTATUS I2OFIFOGet( LOCATION,
334 unsigned int base,
335 void **pMsg );
336
337/**
338 Get the I2O PCI configuration identification register
339 **/
340extern I2OSTATUS I2OPCIConfigGet( LOCATION,
341 unsigned int base,
342 I2OIOP *);
343
344#endif