i2o.h 10 KB

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