io.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*
  2. * Definitions for IO devices. Used only in C.
  3. */
  4. enum
  5. {
  6. /* hardware counter frequency */
  7. ClockFreq= 3686400,
  8. };
  9. /*
  10. * IRQ's defined by SA1100
  11. */
  12. enum
  13. {
  14. IRQgpio0= 0,
  15. IRQgpio1= 1,
  16. IRQgpio2= 2,
  17. IRQgpio3= 3,
  18. IRQgpio4= 4,
  19. IRQgpio5= 5,
  20. IRQgpio6= 6,
  21. IRQgpio7= 7,
  22. IRQgpio8= 8,
  23. IRQgpio9= 9,
  24. IRQgpio10= 10,
  25. IRQgpiohi= 11,
  26. IRQlcd= 12,
  27. IRQudc= 13,
  28. IRQuart1b= 15,
  29. IRQuart2= 16,
  30. IRQuart3= 17,
  31. IRQmcp= 18,
  32. IRQssp= 19,
  33. IRQdma0= 20,
  34. IRQdma1= 21,
  35. IRQdma2= 22,
  36. IRQdma3= 23,
  37. IRQdma4= 24,
  38. IRQdma5= 25,
  39. IRQtimer0= 26,
  40. IRQtimer1= 27,
  41. IRQtimer2= 28,
  42. IRQtimer3= 29,
  43. IRQsecond= 30,
  44. IRQrtc= 31,
  45. };
  46. /*
  47. * GPIO lines (signal names from compaq document). _i indicates input
  48. * and _o output.
  49. */
  50. enum
  51. {
  52. GPIO_PWR_ON_i= 1<<0, /* power button */
  53. GPIO_UP_IRQ_i= 1<<1, /* microcontroller interrupts */
  54. GPIO_LDD8_o= 1<<2, /* LCD data 8-15 */
  55. GPIO_LDD9_o= 1<<3,
  56. GPIO_LDD10_o= 1<<4,
  57. GPIO_LDD11_o= 1<<5,
  58. GPIO_LDD12_o= 1<<6,
  59. GPIO_LDD13_o= 1<<7,
  60. GPIO_LDD14_o= 1<<8,
  61. GPIO_LDD15_o= 1<<9,
  62. GPIO_CARD_IND1_i= 1<<10, /* card inserted in PCMCIA socket 1 */
  63. GPIO_CARD_IRQ1_i= 1<<11, /* PCMCIA socket 1 interrupt */
  64. GPIO_CLK_SET0_o= 1<<12, /* clock selects for audio codec */
  65. GPIO_CLK_SET1_o= 1<<13,
  66. GPIO_L3_SDA_io= 1<<14, /* UDA1341 interface */
  67. GPIO_L3_MODE_o= 1<<15,
  68. GPIO_L3_SCLK_o= 1<<16,
  69. GPIO_CARD_IND0_i= 1<<17, /* card inserted in PCMCIA socket 0 */
  70. GPIO_KEY_ACT_i= 1<<18, /* hot key from cradle */
  71. GPIO_SYS_CLK_i= 1<<19, /* clock from codec */
  72. GPIO_BAT_FAULT_i= 1<<20, /* battery fault */
  73. GPIO_CARD_IRQ0_i= 1<<21, /* PCMCIA socket 0 interrupt */
  74. GPIO_LOCK_i= 1<<22, /* expansion pack lock/unlock */
  75. GPIO_COM_DCD_i= 1<<23, /* DCD from UART3 */
  76. GPIO_OPT_IRQ_i= 1<<24, /* expansion pack IRQ */
  77. GPIO_COM_CTS_i= 1<<25, /* CTS from UART3 */
  78. GPIO_COM_RTS_o= 1<<26, /* RTS to UART3 */
  79. GPIO_OPT_IND_i= 1<<27, /* expansion pack inserted */
  80. /* Peripheral Unit GPIO pin assignments: alternate functions */
  81. GPIO_SSP_TXD_o= 1<<10, /* SSP Transmit Data */
  82. GPIO_SSP_RXD_i= 1<<11, /* SSP Receive Data */
  83. GPIO_SSP_SCLK_o= 1<<12, /* SSP Sample CLocK */
  84. GPIO_SSP_SFRM_o= 1<<13, /* SSP Sample FRaMe */
  85. /* ser. port 1: */
  86. GPIO_UART_TXD_o= 1<<14, /* UART Transmit Data */
  87. GPIO_UART_RXD_i= 1<<15, /* UART Receive Data */
  88. GPIO_SDLC_SCLK_io= 1<<16, /* SDLC Sample CLocK (I/O) */
  89. GPIO_SDLC_AAF_o= 1<<17, /* SDLC Abort After Frame */
  90. GPIO_UART_SCLK1_i= 1<<18, /* UART Sample CLocK 1 */
  91. /* ser. port 4: */
  92. GPIO_SSP_CLK_i= 1<<19, /* SSP external CLocK */
  93. /* ser. port 3: */
  94. GPIO_UART_SCLK3_i= 1<<20, /* UART Sample CLocK 3 */
  95. /* ser. port 4: */
  96. GPIO_MCP_CLK_i= 1<<21, /* MCP CLocK */
  97. /* test controller: */
  98. GPIO_TIC_ACK_o= 1<<21, /* TIC ACKnowledge */
  99. GPIO_MBGNT_o= 1<<21, /* Memory Bus GraNT */
  100. GPIO_TREQA_i= 1<<22, /* TIC REQuest A */
  101. GPIO_MBREQ_i= 1<<22, /* Memory Bus REQuest */
  102. GPIO_TREQB_i= 1<<23, /* TIC REQuest B */
  103. GPIO_1Hz_o= 1<<25, /* 1 Hz clock */
  104. GPIO_RCLK_o= 1<<26, /* internal (R) CLocK (O, fcpu/2) */
  105. GPIO_32_768kHz_o= 1<<27, /* 32.768 kHz clock (O, RTC) */
  106. };
  107. /*
  108. * types of interrupts
  109. */
  110. enum
  111. {
  112. GPIOrising,
  113. GPIOfalling,
  114. GPIOboth,
  115. IRQ,
  116. };
  117. /* hardware registers */
  118. typedef struct Uartregs Uartregs;
  119. struct Uartregs
  120. {
  121. ulong ctl[4];
  122. ulong dummya;
  123. ulong data;
  124. ulong dummyb;
  125. ulong status[2];
  126. };
  127. extern Uartregs *uart3regs;
  128. extern Uartregs *uart1regs;
  129. /* general purpose I/O lines control registers */
  130. typedef struct GPIOregs GPIOregs;
  131. struct GPIOregs
  132. {
  133. ulong level; /* 1 == high */
  134. ulong direction; /* 1 == output */
  135. ulong set; /* a 1 sets the bit, 0 leaves it alone */
  136. ulong clear; /* a 1 clears the bit, 0 leaves it alone */
  137. ulong rising; /* rising edge detect enable */
  138. ulong falling; /* falling edge detect enable */
  139. ulong edgestatus; /* writing a 1 bit clears */
  140. ulong altfunc; /* turn on alternate function for any set bits */
  141. };
  142. extern GPIOregs *gpioregs;
  143. /* extra general purpose I/O bits, output only */
  144. enum
  145. {
  146. EGPIO_prog_flash= 1<<0,
  147. EGPIO_pcmcia_reset= 1<<1,
  148. EGPIO_exppack_reset= 1<<2,
  149. EGPIO_codec_reset= 1<<3,
  150. EGPIO_exp_nvram_power= 1<<4,
  151. EGPIO_exp_full_power= 1<<5,
  152. EGPIO_lcd_3v= 1<<6,
  153. EGPIO_rs232_power= 1<<7,
  154. EGPIO_lcd_ic_power= 1<<8,
  155. EGPIO_ir_power= 1<<9,
  156. EGPIO_audio_power= 1<<10,
  157. EGPIO_audio_ic_power= 1<<11,
  158. EGPIO_audio_mute= 1<<12,
  159. EGPIO_fir= 1<<13, /* not set is sir */
  160. EGPIO_lcd_5v= 1<<14,
  161. EGPIO_lcd_9v= 1<<15,
  162. };
  163. extern ulong *egpioreg;
  164. /* Peripheral pin controller registers */
  165. typedef struct PPCregs PPCregs;
  166. struct PPCregs {
  167. ulong direction;
  168. ulong state;
  169. ulong assignment;
  170. ulong sleepdir;
  171. ulong flags;
  172. };
  173. extern PPCregs *ppcregs;
  174. /* Synchronous Serial Port controller registers */
  175. typedef struct SSPregs SSPregs;
  176. struct SSPregs {
  177. ulong control0;
  178. ulong control1;
  179. ulong dummy0;
  180. ulong data;
  181. ulong dummy1;
  182. ulong status;
  183. };
  184. extern SSPregs *sspregs;
  185. /* Multimedia Communications Port controller registers */
  186. typedef struct MCPregs MCPregs;
  187. struct MCPregs {
  188. ulong control0;
  189. ulong reserved0;
  190. ulong data0;
  191. ulong data1;
  192. ulong data2;
  193. ulong reserved1;
  194. ulong status;
  195. ulong reserved[11];
  196. ulong control1;
  197. };
  198. extern MCPregs *mcpregs;
  199. /*
  200. * memory configuration
  201. */
  202. enum
  203. {
  204. /* bit shifts for pcmcia access time counters */
  205. MECR_io0= 0,
  206. MECR_attr0= 5,
  207. MECR_mem0= 10,
  208. MECR_fast0= 11,
  209. MECR_io1= MECR_io0+16,
  210. MECR_attr1= MECR_attr0+16,
  211. MECR_mem1= MECR_mem0+16,
  212. MECR_fast1= MECR_fast0+16,
  213. REFR_kapd= 29,
  214. REFR_eapd= 28,
  215. REFR_k1db2= 22,
  216. REFR_slfrsh= 31,
  217. };
  218. typedef struct MemConfRegs MemConfRegs;
  219. struct MemConfRegs
  220. {
  221. ulong mdcnfg; /* 0x00 dram */
  222. ulong mdcas00; /* 0x04 dram banks 0/1 */
  223. ulong mdcas01; /* 0x08 */
  224. ulong mdcas02; /* 0x0c */
  225. ulong msc0; /* 0x10 static */
  226. ulong msc1; /* 0x14 */
  227. ulong mecr; /* 0x18 pcmcia */
  228. ulong mdrefr; /* 0x1c dram refresh */
  229. ulong mdcas20; /* 0x20 dram banks 2/3 */
  230. ulong mdcas21; /* 0x24 */
  231. ulong mdcas22; /* 0x28 */
  232. ulong msc2; /* 0x2c static */
  233. ulong smcnfg; /* 0x30 SMROM config */
  234. };
  235. extern MemConfRegs *memconfregs;
  236. /*
  237. * power management
  238. */
  239. /* Power management ops */
  240. typedef struct PowerRegs PowerRegs;
  241. struct PowerRegs
  242. {
  243. ulong pmcr; /* 0x0 Power manager control register */
  244. ulong pssr; /* 0x4 Power manager sleep status register */
  245. ulong pspr; /* 0x8 Power manager scratch pad register */
  246. ulong pwer; /* 0xc Power manager wakeup enable register */
  247. ulong pcfr; /* 0x10 Power manager general configuration register */
  248. ulong ppcr; /* 0x14 Power manager PPL configuration register */
  249. ulong pgsr; /* 0x18 Power manager GPIO sleep state register */
  250. ulong posr; /* 0x1c Power manager oscillator status register */
  251. };
  252. extern PowerRegs *powerregs;
  253. /*
  254. * reset controller
  255. */
  256. enum
  257. {
  258. RCSR_hwr = 0x00000001, /* hw reset */
  259. RCSR_swr = 0x00000002, /* sw reset */
  260. RCSR_wdr = 0x00000004, /* watch dog */
  261. RCSR_smr = 0x00000008, /* sleep mode reset */
  262. };
  263. typedef struct ResetRegs ResetRegs;
  264. struct ResetRegs
  265. {
  266. ulong rsrr; /* reset controller software reset register */
  267. ulong rcsr; /* reset controller status register */
  268. };
  269. extern ResetRegs *resetregs;
  270. typedef struct OSTimerRegs OSTimerRegs;
  271. struct OSTimerRegs
  272. {
  273. ulong osmr[4]; /* match registers */
  274. ulong oscr; /* counter register */
  275. ulong ossr; /* status register */
  276. ulong ower; /* watchdog enable register */
  277. ulong oier; /* timer interrupt enable register */
  278. };
  279. extern OSTimerRegs* timerregs;
  280. typedef struct Intrregs Intrregs;
  281. struct Intrregs
  282. {
  283. ulong icip; /* pending IRQs */
  284. ulong icmr; /* IRQ mask */
  285. ulong iclr; /* IRQ if bit == 0, FRIQ if 1 */
  286. ulong iccr; /* control register */
  287. ulong icfp; /* pending FIQs */
  288. ulong dummy1[3];
  289. ulong icpr; /* pending interrupts */
  290. };
  291. extern Intrregs *intrregs;
  292. typedef struct Gpclkregs Gpclkregs;
  293. struct Gpclkregs
  294. {
  295. ulong r0;
  296. ulong r1;
  297. ulong dummya;
  298. ulong r2;
  299. ulong r3;
  300. };
  301. extern Gpclkregs *gpclkregs;
  302. /*
  303. * Dont use this on bitsy drivers.
  304. * This is for compat with code compiled
  305. * from the ../pc directory
  306. */
  307. typedef struct Pcidev Pcidev;
  308. typedef struct ISAConf ISAConf;
  309. struct Pcidev { int dummy; };
  310. struct ISAConf{ int port; int irq; };
  311. int pcmspecial(char*, ISAConf*);