i2o.h 10 KB

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