sa1111.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. /*
  2. * arch/arm/include/asm/hardware/sa1111.h
  3. *
  4. * Copyright (C) 2000 John G Dorsey <john+@cs.cmu.edu>
  5. *
  6. * This file contains definitions for the SA-1111 Companion Chip.
  7. * (Structure and naming borrowed from SA-1101.h, by Peter Danielsson.)
  8. *
  9. * Macro that calculates real address for registers in the SA-1111
  10. */
  11. #ifndef _ASM_ARCH_SA1111
  12. #define _ASM_ARCH_SA1111
  13. #include <mach/bitfield.h>
  14. /*
  15. * The SA1111 is always located at virtual 0xf4000000, and is always
  16. * "native" endian.
  17. */
  18. #define SA1111_VBASE 0xf4000000
  19. /* Don't use these! */
  20. #define SA1111_p2v( x ) ((x) - SA1111_BASE + SA1111_VBASE)
  21. #define SA1111_v2p( x ) ((x) - SA1111_VBASE + SA1111_BASE)
  22. #ifndef __ASSEMBLY__
  23. #define _SA1111(x) ((x) + sa1111->resource.start)
  24. #endif
  25. #define sa1111_writel(val,addr) __raw_writel(val, addr)
  26. #define sa1111_readl(addr) __raw_readl(addr)
  27. /*
  28. * 26 bits of the SA-1110 address bus are available to the SA-1111.
  29. * Use these when feeding target addresses to the DMA engines.
  30. */
  31. #define SA1111_ADDR_WIDTH (26)
  32. #define SA1111_ADDR_MASK ((1<<SA1111_ADDR_WIDTH)-1)
  33. #define SA1111_DMA_ADDR(x) ((x)&SA1111_ADDR_MASK)
  34. /*
  35. * Don't ask the (SAC) DMA engines to move less than this amount.
  36. */
  37. #define SA1111_SAC_DMA_MIN_XFER (0x800)
  38. /*
  39. * System Bus Interface (SBI)
  40. *
  41. * Registers
  42. * SKCR Control Register
  43. * SMCR Shared Memory Controller Register
  44. * SKID ID Register
  45. */
  46. #define SA1111_SKCR 0x0000
  47. #define SA1111_SMCR 0x0004
  48. #define SA1111_SKID 0x0008
  49. #define SKCR_PLL_BYPASS (1<<0)
  50. #define SKCR_RCLKEN (1<<1)
  51. #define SKCR_SLEEP (1<<2)
  52. #define SKCR_DOZE (1<<3)
  53. #define SKCR_VCO_OFF (1<<4)
  54. #define SKCR_SCANTSTEN (1<<5)
  55. #define SKCR_CLKTSTEN (1<<6)
  56. #define SKCR_RDYEN (1<<7)
  57. #define SKCR_SELAC (1<<8)
  58. #define SKCR_OPPC (1<<9)
  59. #define SKCR_PLLTSTEN (1<<10)
  60. #define SKCR_USBIOTSTEN (1<<11)
  61. /*
  62. * Don't believe the specs! Take them, throw them outside. Leave them
  63. * there for a week. Spit on them. Walk on them. Stamp on them.
  64. * Pour gasoline over them and finally burn them. Now think about coding.
  65. * - The October 1999 errata (278260-007) says its bit 13, 1 to enable.
  66. * - The Feb 2001 errata (278260-010) says that the previous errata
  67. * (278260-009) is wrong, and its bit actually 12, fixed in spec
  68. * 278242-003.
  69. * - The SA1111 manual (278242) says bit 12, but 0 to enable.
  70. * - Reality is bit 13, 1 to enable.
  71. * -- rmk
  72. */
  73. #define SKCR_OE_EN (1<<13)
  74. #define SMCR_DTIM (1<<0)
  75. #define SMCR_MBGE (1<<1)
  76. #define SMCR_DRAC_0 (1<<2)
  77. #define SMCR_DRAC_1 (1<<3)
  78. #define SMCR_DRAC_2 (1<<4)
  79. #define SMCR_DRAC Fld(3, 2)
  80. #define SMCR_CLAT (1<<5)
  81. #define SKID_SIREV_MASK (0x000000f0)
  82. #define SKID_MTREV_MASK (0x0000000f)
  83. #define SKID_ID_MASK (0xffffff00)
  84. #define SKID_SA1111_ID (0x690cc200)
  85. /*
  86. * System Controller
  87. *
  88. * Registers
  89. * SKPCR Power Control Register
  90. * SKCDR Clock Divider Register
  91. * SKAUD Audio Clock Divider Register
  92. * SKPMC PS/2 Mouse Clock Divider Register
  93. * SKPTC PS/2 Track Pad Clock Divider Register
  94. * SKPEN0 PWM0 Enable Register
  95. * SKPWM0 PWM0 Clock Register
  96. * SKPEN1 PWM1 Enable Register
  97. * SKPWM1 PWM1 Clock Register
  98. */
  99. #define SA1111_SKPCR 0x0200
  100. #define SA1111_SKCDR 0x0204
  101. #define SA1111_SKAUD 0x0208
  102. #define SA1111_SKPMC 0x020c
  103. #define SA1111_SKPTC 0x0210
  104. #define SA1111_SKPEN0 0x0214
  105. #define SA1111_SKPWM0 0x0218
  106. #define SA1111_SKPEN1 0x021c
  107. #define SA1111_SKPWM1 0x0220
  108. #define SKPCR_UCLKEN (1<<0)
  109. #define SKPCR_ACCLKEN (1<<1)
  110. #define SKPCR_I2SCLKEN (1<<2)
  111. #define SKPCR_L3CLKEN (1<<3)
  112. #define SKPCR_SCLKEN (1<<4)
  113. #define SKPCR_PMCLKEN (1<<5)
  114. #define SKPCR_PTCLKEN (1<<6)
  115. #define SKPCR_DCLKEN (1<<7)
  116. #define SKPCR_PWMCLKEN (1<<8)
  117. /* USB Host controller */
  118. #define SA1111_USB 0x0400
  119. /*
  120. * Serial Audio Controller
  121. *
  122. * Registers
  123. * SACR0 Serial Audio Common Control Register
  124. * SACR1 Serial Audio Alternate Mode (I2C/MSB) Control Register
  125. * SACR2 Serial Audio AC-link Control Register
  126. * SASR0 Serial Audio I2S/MSB Interface & FIFO Status Register
  127. * SASR1 Serial Audio AC-link Interface & FIFO Status Register
  128. * SASCR Serial Audio Status Clear Register
  129. * L3_CAR L3 Control Bus Address Register
  130. * L3_CDR L3 Control Bus Data Register
  131. * ACCAR AC-link Command Address Register
  132. * ACCDR AC-link Command Data Register
  133. * ACSAR AC-link Status Address Register
  134. * ACSDR AC-link Status Data Register
  135. * SADTCS Serial Audio DMA Transmit Control/Status Register
  136. * SADTSA Serial Audio DMA Transmit Buffer Start Address A
  137. * SADTCA Serial Audio DMA Transmit Buffer Count Register A
  138. * SADTSB Serial Audio DMA Transmit Buffer Start Address B
  139. * SADTCB Serial Audio DMA Transmit Buffer Count Register B
  140. * SADRCS Serial Audio DMA Receive Control/Status Register
  141. * SADRSA Serial Audio DMA Receive Buffer Start Address A
  142. * SADRCA Serial Audio DMA Receive Buffer Count Register A
  143. * SADRSB Serial Audio DMA Receive Buffer Start Address B
  144. * SADRCB Serial Audio DMA Receive Buffer Count Register B
  145. * SAITR Serial Audio Interrupt Test Register
  146. * SADR Serial Audio Data Register (16 x 32-bit)
  147. */
  148. #define SA1111_SERAUDIO 0x0600
  149. /*
  150. * These are offsets from the above base.
  151. */
  152. #define SA1111_SACR0 0x00
  153. #define SA1111_SACR1 0x04
  154. #define SA1111_SACR2 0x08
  155. #define SA1111_SASR0 0x0c
  156. #define SA1111_SASR1 0x10
  157. #define SA1111_SASCR 0x18
  158. #define SA1111_L3_CAR 0x1c
  159. #define SA1111_L3_CDR 0x20
  160. #define SA1111_ACCAR 0x24
  161. #define SA1111_ACCDR 0x28
  162. #define SA1111_ACSAR 0x2c
  163. #define SA1111_ACSDR 0x30
  164. #define SA1111_SADTCS 0x34
  165. #define SA1111_SADTSA 0x38
  166. #define SA1111_SADTCA 0x3c
  167. #define SA1111_SADTSB 0x40
  168. #define SA1111_SADTCB 0x44
  169. #define SA1111_SADRCS 0x48
  170. #define SA1111_SADRSA 0x4c
  171. #define SA1111_SADRCA 0x50
  172. #define SA1111_SADRSB 0x54
  173. #define SA1111_SADRCB 0x58
  174. #define SA1111_SAITR 0x5c
  175. #define SA1111_SADR 0x80
  176. #ifndef CONFIG_ARCH_PXA
  177. #define SACR0_ENB (1<<0)
  178. #define SACR0_BCKD (1<<2)
  179. #define SACR0_RST (1<<3)
  180. #define SACR1_AMSL (1<<0)
  181. #define SACR1_L3EN (1<<1)
  182. #define SACR1_L3MB (1<<2)
  183. #define SACR1_DREC (1<<3)
  184. #define SACR1_DRPL (1<<4)
  185. #define SACR1_ENLBF (1<<5)
  186. #define SACR2_TS3V (1<<0)
  187. #define SACR2_TS4V (1<<1)
  188. #define SACR2_WKUP (1<<2)
  189. #define SACR2_DREC (1<<3)
  190. #define SACR2_DRPL (1<<4)
  191. #define SACR2_ENLBF (1<<5)
  192. #define SACR2_RESET (1<<6)
  193. #define SASR0_TNF (1<<0)
  194. #define SASR0_RNE (1<<1)
  195. #define SASR0_BSY (1<<2)
  196. #define SASR0_TFS (1<<3)
  197. #define SASR0_RFS (1<<4)
  198. #define SASR0_TUR (1<<5)
  199. #define SASR0_ROR (1<<6)
  200. #define SASR0_L3WD (1<<16)
  201. #define SASR0_L3RD (1<<17)
  202. #define SASR1_TNF (1<<0)
  203. #define SASR1_RNE (1<<1)
  204. #define SASR1_BSY (1<<2)
  205. #define SASR1_TFS (1<<3)
  206. #define SASR1_RFS (1<<4)
  207. #define SASR1_TUR (1<<5)
  208. #define SASR1_ROR (1<<6)
  209. #define SASR1_CADT (1<<16)
  210. #define SASR1_SADR (1<<17)
  211. #define SASR1_RSTO (1<<18)
  212. #define SASR1_CLPM (1<<19)
  213. #define SASR1_CRDY (1<<20)
  214. #define SASR1_RS3V (1<<21)
  215. #define SASR1_RS4V (1<<22)
  216. #define SASCR_TUR (1<<5)
  217. #define SASCR_ROR (1<<6)
  218. #define SASCR_DTS (1<<16)
  219. #define SASCR_RDD (1<<17)
  220. #define SASCR_STO (1<<18)
  221. #define SADTCS_TDEN (1<<0)
  222. #define SADTCS_TDIE (1<<1)
  223. #define SADTCS_TDBDA (1<<3)
  224. #define SADTCS_TDSTA (1<<4)
  225. #define SADTCS_TDBDB (1<<5)
  226. #define SADTCS_TDSTB (1<<6)
  227. #define SADTCS_TBIU (1<<7)
  228. #define SADRCS_RDEN (1<<0)
  229. #define SADRCS_RDIE (1<<1)
  230. #define SADRCS_RDBDA (1<<3)
  231. #define SADRCS_RDSTA (1<<4)
  232. #define SADRCS_RDBDB (1<<5)
  233. #define SADRCS_RDSTB (1<<6)
  234. #define SADRCS_RBIU (1<<7)
  235. #define SAD_CS_DEN (1<<0)
  236. #define SAD_CS_DIE (1<<1) /* Not functional on metal 1 */
  237. #define SAD_CS_DBDA (1<<3) /* Not functional on metal 1 */
  238. #define SAD_CS_DSTA (1<<4)
  239. #define SAD_CS_DBDB (1<<5) /* Not functional on metal 1 */
  240. #define SAD_CS_DSTB (1<<6)
  241. #define SAD_CS_BIU (1<<7) /* Not functional on metal 1 */
  242. #define SAITR_TFS (1<<0)
  243. #define SAITR_RFS (1<<1)
  244. #define SAITR_TUR (1<<2)
  245. #define SAITR_ROR (1<<3)
  246. #define SAITR_CADT (1<<4)
  247. #define SAITR_SADR (1<<5)
  248. #define SAITR_RSTO (1<<6)
  249. #define SAITR_TDBDA (1<<8)
  250. #define SAITR_TDBDB (1<<9)
  251. #define SAITR_RDBDA (1<<10)
  252. #define SAITR_RDBDB (1<<11)
  253. #endif /* !CONFIG_ARCH_PXA */
  254. /*
  255. * General-Purpose I/O Interface
  256. *
  257. * Registers
  258. * PA_DDR GPIO Block A Data Direction
  259. * PA_DRR/PA_DWR GPIO Block A Data Value Register (read/write)
  260. * PA_SDR GPIO Block A Sleep Direction
  261. * PA_SSR GPIO Block A Sleep State
  262. * PB_DDR GPIO Block B Data Direction
  263. * PB_DRR/PB_DWR GPIO Block B Data Value Register (read/write)
  264. * PB_SDR GPIO Block B Sleep Direction
  265. * PB_SSR GPIO Block B Sleep State
  266. * PC_DDR GPIO Block C Data Direction
  267. * PC_DRR/PC_DWR GPIO Block C Data Value Register (read/write)
  268. * PC_SDR GPIO Block C Sleep Direction
  269. * PC_SSR GPIO Block C Sleep State
  270. */
  271. #define SA1111_GPIO 0x1000
  272. #define SA1111_GPIO_PADDR (0x000)
  273. #define SA1111_GPIO_PADRR (0x004)
  274. #define SA1111_GPIO_PADWR (0x004)
  275. #define SA1111_GPIO_PASDR (0x008)
  276. #define SA1111_GPIO_PASSR (0x00c)
  277. #define SA1111_GPIO_PBDDR (0x010)
  278. #define SA1111_GPIO_PBDRR (0x014)
  279. #define SA1111_GPIO_PBDWR (0x014)
  280. #define SA1111_GPIO_PBSDR (0x018)
  281. #define SA1111_GPIO_PBSSR (0x01c)
  282. #define SA1111_GPIO_PCDDR (0x020)
  283. #define SA1111_GPIO_PCDRR (0x024)
  284. #define SA1111_GPIO_PCDWR (0x024)
  285. #define SA1111_GPIO_PCSDR (0x028)
  286. #define SA1111_GPIO_PCSSR (0x02c)
  287. #define GPIO_A0 (1 << 0)
  288. #define GPIO_A1 (1 << 1)
  289. #define GPIO_A2 (1 << 2)
  290. #define GPIO_A3 (1 << 3)
  291. #define GPIO_B0 (1 << 8)
  292. #define GPIO_B1 (1 << 9)
  293. #define GPIO_B2 (1 << 10)
  294. #define GPIO_B3 (1 << 11)
  295. #define GPIO_B4 (1 << 12)
  296. #define GPIO_B5 (1 << 13)
  297. #define GPIO_B6 (1 << 14)
  298. #define GPIO_B7 (1 << 15)
  299. #define GPIO_C0 (1 << 16)
  300. #define GPIO_C1 (1 << 17)
  301. #define GPIO_C2 (1 << 18)
  302. #define GPIO_C3 (1 << 19)
  303. #define GPIO_C4 (1 << 20)
  304. #define GPIO_C5 (1 << 21)
  305. #define GPIO_C6 (1 << 22)
  306. #define GPIO_C7 (1 << 23)
  307. /*
  308. * Interrupt Controller
  309. *
  310. * Registers
  311. * INTTEST0 Test register 0
  312. * INTTEST1 Test register 1
  313. * INTEN0 Interrupt Enable register 0
  314. * INTEN1 Interrupt Enable register 1
  315. * INTPOL0 Interrupt Polarity selection 0
  316. * INTPOL1 Interrupt Polarity selection 1
  317. * INTTSTSEL Interrupt source selection
  318. * INTSTATCLR0 Interrupt Status/Clear 0
  319. * INTSTATCLR1 Interrupt Status/Clear 1
  320. * INTSET0 Interrupt source set 0
  321. * INTSET1 Interrupt source set 1
  322. * WAKE_EN0 Wake-up source enable 0
  323. * WAKE_EN1 Wake-up source enable 1
  324. * WAKE_POL0 Wake-up polarity selection 0
  325. * WAKE_POL1 Wake-up polarity selection 1
  326. */
  327. #define SA1111_INTC 0x1600
  328. /*
  329. * These are offsets from the above base.
  330. */
  331. #define SA1111_INTTEST0 0x0000
  332. #define SA1111_INTTEST1 0x0004
  333. #define SA1111_INTEN0 0x0008
  334. #define SA1111_INTEN1 0x000c
  335. #define SA1111_INTPOL0 0x0010
  336. #define SA1111_INTPOL1 0x0014
  337. #define SA1111_INTTSTSEL 0x0018
  338. #define SA1111_INTSTATCLR0 0x001c
  339. #define SA1111_INTSTATCLR1 0x0020
  340. #define SA1111_INTSET0 0x0024
  341. #define SA1111_INTSET1 0x0028
  342. #define SA1111_WAKEEN0 0x002c
  343. #define SA1111_WAKEEN1 0x0030
  344. #define SA1111_WAKEPOL0 0x0034
  345. #define SA1111_WAKEPOL1 0x0038
  346. /* PS/2 Trackpad and Mouse Interfaces */
  347. #define SA1111_KBD 0x0a00
  348. #define SA1111_MSE 0x0c00
  349. /* PCMCIA Interface */
  350. #define SA1111_PCMCIA 0x1600
  351. extern struct bus_type sa1111_bus_type;
  352. #define SA1111_DEVID_SBI (1 << 0)
  353. #define SA1111_DEVID_SK (1 << 1)
  354. #define SA1111_DEVID_USB (1 << 2)
  355. #define SA1111_DEVID_SAC (1 << 3)
  356. #define SA1111_DEVID_SSP (1 << 4)
  357. #define SA1111_DEVID_PS2 (3 << 5)
  358. #define SA1111_DEVID_PS2_KBD (1 << 5)
  359. #define SA1111_DEVID_PS2_MSE (1 << 6)
  360. #define SA1111_DEVID_GPIO (1 << 7)
  361. #define SA1111_DEVID_INT (1 << 8)
  362. #define SA1111_DEVID_PCMCIA (1 << 9)
  363. struct sa1111_dev {
  364. struct device dev;
  365. unsigned int devid;
  366. struct resource res;
  367. void __iomem *mapbase;
  368. unsigned int skpcr_mask;
  369. unsigned int irq[6];
  370. u64 dma_mask;
  371. };
  372. #define SA1111_DEV(_d) container_of((_d), struct sa1111_dev, dev)
  373. #define sa1111_get_drvdata(d) dev_get_drvdata(&(d)->dev)
  374. #define sa1111_set_drvdata(d,p) dev_set_drvdata(&(d)->dev, p)
  375. struct sa1111_driver {
  376. struct device_driver drv;
  377. unsigned int devid;
  378. int (*probe)(struct sa1111_dev *);
  379. int (*remove)(struct sa1111_dev *);
  380. int (*suspend)(struct sa1111_dev *, pm_message_t);
  381. int (*resume)(struct sa1111_dev *);
  382. void (*shutdown)(struct sa1111_dev *);
  383. };
  384. #define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv)
  385. #define SA1111_DRIVER_NAME(_sadev) ((_sadev)->dev.driver->name)
  386. /*
  387. * These frob the SKPCR register, and call platform specific
  388. * enable/disable functions.
  389. */
  390. int sa1111_enable_device(struct sa1111_dev *);
  391. void sa1111_disable_device(struct sa1111_dev *);
  392. unsigned int sa1111_pll_clock(struct sa1111_dev *);
  393. #define SA1111_AUDIO_ACLINK 0
  394. #define SA1111_AUDIO_I2S 1
  395. void sa1111_select_audio_mode(struct sa1111_dev *sadev, int mode);
  396. int sa1111_set_audio_rate(struct sa1111_dev *sadev, int rate);
  397. int sa1111_get_audio_rate(struct sa1111_dev *sadev);
  398. int sa1111_check_dma_bug(dma_addr_t addr);
  399. int sa1111_driver_register(struct sa1111_driver *);
  400. void sa1111_driver_unregister(struct sa1111_driver *);
  401. void sa1111_set_io_dir(struct sa1111_dev *sadev, unsigned int bits, unsigned int dir, unsigned int sleep_dir);
  402. void sa1111_set_io(struct sa1111_dev *sadev, unsigned int bits, unsigned int v);
  403. void sa1111_set_sleep_io(struct sa1111_dev *sadev, unsigned int bits, unsigned int v);
  404. struct sa1111_platform_data {
  405. int irq_base; /* base for cascaded on-chip IRQs */
  406. unsigned disable_devs;
  407. void *data;
  408. int (*enable)(void *, unsigned);
  409. void (*disable)(void *, unsigned);
  410. };
  411. #endif /* _ASM_ARCH_SA1111 */