hpc3.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * hpc3.h: Definitions for SGI HPC3 controller
  7. *
  8. * Copyright (C) 1996 David S. Miller
  9. * Copyright (C) 1998 Ralf Baechle
  10. */
  11. #ifndef _SGI_HPC3_H
  12. #define _SGI_HPC3_H
  13. #include <linux/types.h>
  14. #include <asm/page.h>
  15. /* An HPC DMA descriptor. */
  16. struct hpc_dma_desc {
  17. u32 pbuf; /* physical address of data buffer */
  18. u32 cntinfo; /* counter and info bits */
  19. #define HPCDMA_EOX 0x80000000 /* last desc in chain for tx */
  20. #define HPCDMA_EOR 0x80000000 /* last desc in chain for rx */
  21. #define HPCDMA_EOXP 0x40000000 /* end of packet for tx */
  22. #define HPCDMA_EORP 0x40000000 /* end of packet for rx */
  23. #define HPCDMA_XIE 0x20000000 /* irq generated when at end of this desc */
  24. #define HPCDMA_XIU 0x01000000 /* Tx buffer in use by CPU. */
  25. #define HPCDMA_EIPC 0x00ff0000 /* SEEQ ethernet special xternal bytecount */
  26. #define HPCDMA_ETXD 0x00008000 /* set to one by HPC when packet tx'd */
  27. #define HPCDMA_OWN 0x00004000 /* Denotes ring buffer ownership on rx */
  28. #define HPCDMA_BCNT 0x00003fff /* size in bytes of this dma buffer */
  29. u32 pnext; /* paddr of next hpc_dma_desc if any */
  30. };
  31. /* The set of regs for each HPC3 PBUS DMA channel. */
  32. struct hpc3_pbus_dmacregs {
  33. volatile u32 pbdma_bptr; /* pbus dma channel buffer ptr */
  34. volatile u32 pbdma_dptr; /* pbus dma channel desc ptr */
  35. u32 _unused0[0x1000/4 - 2]; /* padding */
  36. volatile u32 pbdma_ctrl; /* pbus dma channel control register has
  37. * completely different meaning for read
  38. * compared with write */
  39. /* read */
  40. #define HPC3_PDMACTRL_INT 0x00000001 /* interrupt (cleared after read) */
  41. #define HPC3_PDMACTRL_ISACT 0x00000002 /* channel active */
  42. /* write */
  43. #define HPC3_PDMACTRL_SEL 0x00000002 /* little endian transfer */
  44. #define HPC3_PDMACTRL_RCV 0x00000004 /* direction is receive */
  45. #define HPC3_PDMACTRL_FLSH 0x00000008 /* enable flush for receive DMA */
  46. #define HPC3_PDMACTRL_ACT 0x00000010 /* start dma transfer */
  47. #define HPC3_PDMACTRL_LD 0x00000020 /* load enable for ACT */
  48. #define HPC3_PDMACTRL_RT 0x00000040 /* Use realtime GIO bus servicing */
  49. #define HPC3_PDMACTRL_HW 0x0000ff00 /* DMA High-water mark */
  50. #define HPC3_PDMACTRL_FB 0x003f0000 /* Ptr to beginning of fifo */
  51. #define HPC3_PDMACTRL_FE 0x3f000000 /* Ptr to end of fifo */
  52. u32 _unused1[0x1000/4 - 1]; /* padding */
  53. };
  54. /* The HPC3 SCSI registers, this does not include external ones. */
  55. struct hpc3_scsiregs {
  56. volatile u32 cbptr; /* current dma buffer ptr, diagnostic use only */
  57. volatile u32 ndptr; /* next dma descriptor ptr */
  58. u32 _unused0[0x1000/4 - 2]; /* padding */
  59. volatile u32 bcd; /* byte count info */
  60. #define HPC3_SBCD_BCNTMSK 0x00003fff /* bytes to transfer from/to memory */
  61. #define HPC3_SBCD_XIE 0x00004000 /* Send IRQ when done with cur buf */
  62. #define HPC3_SBCD_EOX 0x00008000 /* Indicates this is last buf in chain */
  63. volatile u32 ctrl; /* control register */
  64. #define HPC3_SCTRL_IRQ 0x01 /* IRQ asserted, either dma done or parity */
  65. #define HPC3_SCTRL_ENDIAN 0x02 /* DMA endian mode, 0=big 1=little */
  66. #define HPC3_SCTRL_DIR 0x04 /* DMA direction, 1=dev2mem 0=mem2dev */
  67. #define HPC3_SCTRL_FLUSH 0x08 /* Tells HPC3 to flush scsi fifos */
  68. #define HPC3_SCTRL_ACTIVE 0x10 /* SCSI DMA channel is active */
  69. #define HPC3_SCTRL_AMASK 0x20 /* DMA active inhibits PIO */
  70. #define HPC3_SCTRL_CRESET 0x40 /* Resets dma channel and external controller */
  71. #define HPC3_SCTRL_PERR 0x80 /* Bad parity on HPC3 iface to scsi controller */
  72. volatile u32 gfptr; /* current GIO fifo ptr */
  73. volatile u32 dfptr; /* current device fifo ptr */
  74. volatile u32 dconfig; /* DMA configuration register */
  75. #define HPC3_SDCFG_HCLK 0x00001 /* Enable DMA half clock mode */
  76. #define HPC3_SDCFG_D1 0x00006 /* Cycles to spend in D1 state */
  77. #define HPC3_SDCFG_D2 0x00038 /* Cycles to spend in D2 state */
  78. #define HPC3_SDCFG_D3 0x001c0 /* Cycles to spend in D3 state */
  79. #define HPC3_SDCFG_HWAT 0x00e00 /* DMA high water mark */
  80. #define HPC3_SDCFG_HW 0x01000 /* Enable 16-bit halfword DMA accesses to scsi */
  81. #define HPC3_SDCFG_SWAP 0x02000 /* Byte swap all DMA accesses */
  82. #define HPC3_SDCFG_EPAR 0x04000 /* Enable parity checking for DMA */
  83. #define HPC3_SDCFG_POLL 0x08000 /* hd_dreq polarity control */
  84. #define HPC3_SDCFG_ERLY 0x30000 /* hd_dreq behavior control bits */
  85. volatile u32 pconfig; /* PIO configuration register */
  86. #define HPC3_SPCFG_P3 0x0003 /* Cycles to spend in P3 state */
  87. #define HPC3_SPCFG_P2W 0x001c /* Cycles to spend in P2 state for writes */
  88. #define HPC3_SPCFG_P2R 0x01e0 /* Cycles to spend in P2 state for reads */
  89. #define HPC3_SPCFG_P1 0x0e00 /* Cycles to spend in P1 state */
  90. #define HPC3_SPCFG_HW 0x1000 /* Enable 16-bit halfword PIO accesses to scsi */
  91. #define HPC3_SPCFG_SWAP 0x2000 /* Byte swap all PIO accesses */
  92. #define HPC3_SPCFG_EPAR 0x4000 /* Enable parity checking for PIO */
  93. #define HPC3_SPCFG_FUJI 0x8000 /* Fujitsu scsi controller mode for faster dma/pio */
  94. u32 _unused1[0x1000/4 - 6]; /* padding */
  95. };
  96. /* SEEQ ethernet HPC3 registers, only one seeq per HPC3. */
  97. struct hpc3_ethregs {
  98. /* Receiver registers. */
  99. volatile u32 rx_cbptr; /* current dma buffer ptr, diagnostic use only */
  100. volatile u32 rx_ndptr; /* next dma descriptor ptr */
  101. u32 _unused0[0x1000/4 - 2]; /* padding */
  102. volatile u32 rx_bcd; /* byte count info */
  103. #define HPC3_ERXBCD_BCNTMSK 0x00003fff /* bytes to be sent to memory */
  104. #define HPC3_ERXBCD_XIE 0x20000000 /* HPC3 interrupts cpu at end of this buf */
  105. #define HPC3_ERXBCD_EOX 0x80000000 /* flags this as end of descriptor chain */
  106. volatile u32 rx_ctrl; /* control register */
  107. #define HPC3_ERXCTRL_STAT50 0x0000003f /* Receive status reg bits of Seeq8003 */
  108. #define HPC3_ERXCTRL_STAT6 0x00000040 /* Rdonly irq status */
  109. #define HPC3_ERXCTRL_STAT7 0x00000080 /* Rdonlt old/new status bit from Seeq */
  110. #define HPC3_ERXCTRL_ENDIAN 0x00000100 /* Endian for dma channel, little=1 big=0 */
  111. #define HPC3_ERXCTRL_ACTIVE 0x00000200 /* Tells if DMA transfer is in progress */
  112. #define HPC3_ERXCTRL_AMASK 0x00000400 /* Tells if ACTIVE inhibits PIO's to hpc3 */
  113. #define HPC3_ERXCTRL_RBO 0x00000800 /* Receive buffer overflow if set to 1 */
  114. volatile u32 rx_gfptr; /* current GIO fifo ptr */
  115. volatile u32 rx_dfptr; /* current device fifo ptr */
  116. u32 _unused1; /* padding */
  117. volatile u32 reset; /* reset register */
  118. #define HPC3_ERST_CRESET 0x1 /* Reset dma channel and external controller */
  119. #define HPC3_ERST_CLRIRQ 0x2 /* Clear channel interrupt */
  120. #define HPC3_ERST_LBACK 0x4 /* Enable diagnostic loopback mode of Seeq8003 */
  121. volatile u32 dconfig; /* DMA configuration register */
  122. #define HPC3_EDCFG_D1 0x0000f /* Cycles to spend in D1 state for PIO */
  123. #define HPC3_EDCFG_D2 0x000f0 /* Cycles to spend in D2 state for PIO */
  124. #define HPC3_EDCFG_D3 0x00f00 /* Cycles to spend in D3 state for PIO */
  125. #define HPC3_EDCFG_WCTRL 0x01000 /* Enable writes of desc into ex ctrl port */
  126. #define HPC3_EDCFG_FRXDC 0x02000 /* Clear eop stat bits upon rxdc, hw seeq fix */
  127. #define HPC3_EDCFG_FEOP 0x04000 /* Bad packet marker timeout enable */
  128. #define HPC3_EDCFG_FIRQ 0x08000 /* Another bad packet timeout enable */
  129. #define HPC3_EDCFG_PTO 0x30000 /* Programmed timeout value for above two */
  130. volatile u32 pconfig; /* PIO configuration register */
  131. #define HPC3_EPCFG_P1 0x000f /* Cycles to spend in P1 state for PIO */
  132. #define HPC3_EPCFG_P2 0x00f0 /* Cycles to spend in P2 state for PIO */
  133. #define HPC3_EPCFG_P3 0x0f00 /* Cycles to spend in P3 state for PIO */
  134. #define HPC3_EPCFG_TST 0x1000 /* Diagnostic ram test feature bit */
  135. u32 _unused2[0x1000/4 - 8]; /* padding */
  136. /* Transmitter registers. */
  137. volatile u32 tx_cbptr; /* current dma buffer ptr, diagnostic use only */
  138. volatile u32 tx_ndptr; /* next dma descriptor ptr */
  139. u32 _unused3[0x1000/4 - 2]; /* padding */
  140. volatile u32 tx_bcd; /* byte count info */
  141. #define HPC3_ETXBCD_BCNTMSK 0x00003fff /* bytes to be read from memory */
  142. #define HPC3_ETXBCD_ESAMP 0x10000000 /* if set, too late to add descriptor */
  143. #define HPC3_ETXBCD_XIE 0x20000000 /* Interrupt cpu at end of cur desc */
  144. #define HPC3_ETXBCD_EOP 0x40000000 /* Last byte of cur buf is end of packet */
  145. #define HPC3_ETXBCD_EOX 0x80000000 /* This buf is the end of desc chain */
  146. volatile u32 tx_ctrl; /* control register */
  147. #define HPC3_ETXCTRL_STAT30 0x0000000f /* Rdonly copy of seeq tx stat reg */
  148. #define HPC3_ETXCTRL_STAT4 0x00000010 /* Indicate late collision occurred */
  149. #define HPC3_ETXCTRL_STAT75 0x000000e0 /* Rdonly irq status from seeq */
  150. #define HPC3_ETXCTRL_ENDIAN 0x00000100 /* DMA channel endian mode, 1=little 0=big */
  151. #define HPC3_ETXCTRL_ACTIVE 0x00000200 /* DMA tx channel is active */
  152. #define HPC3_ETXCTRL_AMASK 0x00000400 /* Indicates ACTIVE inhibits PIO's */
  153. volatile u32 tx_gfptr; /* current GIO fifo ptr */
  154. volatile u32 tx_dfptr; /* current device fifo ptr */
  155. u32 _unused4[0x1000/4 - 4]; /* padding */
  156. };
  157. struct hpc3_regs {
  158. /* First regs for the PBUS 8 dma channels. */
  159. struct hpc3_pbus_dmacregs pbdma[8];
  160. /* Now the HPC scsi registers, we get two scsi reg sets. */
  161. struct hpc3_scsiregs scsi_chan0, scsi_chan1;
  162. /* The SEEQ hpc3 ethernet dma/control registers. */
  163. struct hpc3_ethregs ethregs;
  164. /* Here are where the hpc3 fifo's can be directly accessed
  165. * via PIO accesses. Under normal operation we never stick
  166. * our grubby paws in here so it's just padding. */
  167. u32 _unused0[0x18000/4];
  168. /* HPC3 irq status regs. Due to a peculiar bug you need to
  169. * look at two different register addresses to get at all of
  170. * the status bits. The first reg can only reliably report
  171. * bits 4:0 of the status, and the second reg can only
  172. * reliably report bits 9:5 of the hpc3 irq status. I told
  173. * you it was a peculiar bug. ;-)
  174. */
  175. volatile u32 istat0; /* Irq status, only bits <4:0> reliable. */
  176. #define HPC3_ISTAT_PBIMASK 0x0ff /* irq bits for pbus devs 0 --> 7 */
  177. #define HPC3_ISTAT_SC0MASK 0x100 /* irq bit for scsi channel 0 */
  178. #define HPC3_ISTAT_SC1MASK 0x200 /* irq bit for scsi channel 1 */
  179. volatile u32 gio_misc; /* GIO misc control bits. */
  180. #define HPC3_GIOMISC_ERTIME 0x1 /* Enable external timer real time. */
  181. #define HPC3_GIOMISC_DENDIAN 0x2 /* dma descriptor endian, 1=lit 0=big */
  182. u32 eeprom; /* EEPROM data reg. */
  183. #define HPC3_EEPROM_EPROT 0x01 /* Protect register enable */
  184. #define HPC3_EEPROM_CSEL 0x02 /* Chip select */
  185. #define HPC3_EEPROM_ECLK 0x04 /* EEPROM clock */
  186. #define HPC3_EEPROM_DATO 0x08 /* Data out */
  187. #define HPC3_EEPROM_DATI 0x10 /* Data in */
  188. volatile u32 istat1; /* Irq status, only bits <9:5> reliable. */
  189. volatile u32 bestat; /* Bus error interrupt status reg. */
  190. #define HPC3_BESTAT_BLMASK 0x000ff /* Bus lane where bad parity occurred */
  191. #define HPC3_BESTAT_CTYPE 0x00100 /* Bus cycle type, 0=PIO 1=DMA */
  192. #define HPC3_BESTAT_PIDSHIFT 9
  193. #define HPC3_BESTAT_PIDMASK 0x3f700 /* DMA channel parity identifier */
  194. u32 _unused1[0x14000/4 - 5]; /* padding */
  195. /* Now direct PIO per-HPC3 peripheral access to external regs. */
  196. volatile u32 scsi0_ext[256]; /* SCSI channel 0 external regs */
  197. u32 _unused2[0x7c00/4];
  198. volatile u32 scsi1_ext[256]; /* SCSI channel 1 external regs */
  199. u32 _unused3[0x7c00/4];
  200. volatile u32 eth_ext[320]; /* Ethernet external registers */
  201. u32 _unused4[0x3b00/4];
  202. /* Per-peripheral device external registers and DMA/PIO control. */
  203. volatile u32 pbus_extregs[16][256];
  204. volatile u32 pbus_dmacfg[8][128];
  205. /* Cycles to spend in D3 for reads */
  206. #define HPC3_DMACFG_D3R_MASK 0x00000001
  207. #define HPC3_DMACFG_D3R_SHIFT 0
  208. /* Cycles to spend in D4 for reads */
  209. #define HPC3_DMACFG_D4R_MASK 0x0000001e
  210. #define HPC3_DMACFG_D4R_SHIFT 1
  211. /* Cycles to spend in D5 for reads */
  212. #define HPC3_DMACFG_D5R_MASK 0x000001e0
  213. #define HPC3_DMACFG_D5R_SHIFT 5
  214. /* Cycles to spend in D3 for writes */
  215. #define HPC3_DMACFG_D3W_MASK 0x00000200
  216. #define HPC3_DMACFG_D3W_SHIFT 9
  217. /* Cycles to spend in D4 for writes */
  218. #define HPC3_DMACFG_D4W_MASK 0x00003c00
  219. #define HPC3_DMACFG_D4W_SHIFT 10
  220. /* Cycles to spend in D5 for writes */
  221. #define HPC3_DMACFG_D5W_MASK 0x0003c000
  222. #define HPC3_DMACFG_D5W_SHIFT 14
  223. /* Enable 16-bit DMA access mode */
  224. #define HPC3_DMACFG_DS16 0x00040000
  225. /* Places halfwords on high 16 bits of bus */
  226. #define HPC3_DMACFG_EVENHI 0x00080000
  227. /* Make this device real time */
  228. #define HPC3_DMACFG_RTIME 0x00200000
  229. /* 5 bit burst count for DMA device */
  230. #define HPC3_DMACFG_BURST_MASK 0x07c00000
  231. #define HPC3_DMACFG_BURST_SHIFT 22
  232. /* Use live pbus_dreq unsynchronized signal */
  233. #define HPC3_DMACFG_DRQLIVE 0x08000000
  234. volatile u32 pbus_piocfg[16][64];
  235. /* Cycles to spend in P2 state for reads */
  236. #define HPC3_PIOCFG_P2R_MASK 0x00001
  237. #define HPC3_PIOCFG_P2R_SHIFT 0
  238. /* Cycles to spend in P3 state for reads */
  239. #define HPC3_PIOCFG_P3R_MASK 0x0001e
  240. #define HPC3_PIOCFG_P3R_SHIFT 1
  241. /* Cycles to spend in P4 state for reads */
  242. #define HPC3_PIOCFG_P4R_MASK 0x001e0
  243. #define HPC3_PIOCFG_P4R_SHIFT 5
  244. /* Cycles to spend in P2 state for writes */
  245. #define HPC3_PIOCFG_P2W_MASK 0x00200
  246. #define HPC3_PIOCFG_P2W_SHIFT 9
  247. /* Cycles to spend in P3 state for writes */
  248. #define HPC3_PIOCFG_P3W_MASK 0x03c00
  249. #define HPC3_PIOCFG_P3W_SHIFT 10
  250. /* Cycles to spend in P4 state for writes */
  251. #define HPC3_PIOCFG_P4W_MASK 0x3c000
  252. #define HPC3_PIOCFG_P4W_SHIFT 14
  253. /* Enable 16-bit PIO accesses */
  254. #define HPC3_PIOCFG_DS16 0x40000
  255. /* Place even address bits in bits <15:8> */
  256. #define HPC3_PIOCFG_EVENHI 0x80000
  257. /* PBUS PROM control regs. */
  258. volatile u32 pbus_promwe; /* PROM write enable register */
  259. #define HPC3_PROM_WENAB 0x1 /* Enable writes to the PROM */
  260. u32 _unused5[0x0800/4 - 1];
  261. volatile u32 pbus_promswap; /* Chip select swap reg */
  262. #define HPC3_PROM_SWAP 0x1 /* invert GIO addr bit to select prom0 or prom1 */
  263. u32 _unused6[0x0800/4 - 1];
  264. volatile u32 pbus_gout; /* PROM general purpose output reg */
  265. #define HPC3_PROM_STAT 0x1 /* General purpose status bit in gout */
  266. u32 _unused7[0x1000/4 - 1];
  267. volatile u32 rtcregs[14]; /* Dallas clock registers */
  268. u32 _unused8[50];
  269. volatile u32 bbram[8192-50-14]; /* Battery backed ram */
  270. };
  271. /*
  272. * It is possible to have two HPC3's within the address space on
  273. * one machine, though only having one is more likely on an Indy.
  274. */
  275. extern struct hpc3_regs *hpc3c0, *hpc3c1;
  276. #define HPC3_CHIP0_BASE 0x1fb80000 /* physical */
  277. #define HPC3_CHIP1_BASE 0x1fb00000 /* physical */
  278. extern void sgihpc_init(void);
  279. #endif /* _SGI_HPC3_H */