hardware.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. /*
  2. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  3. *
  4. * Based on:
  5. *
  6. * -------------------------------------------------------------------------
  7. *
  8. * linux/include/asm-arm/arch-davinci/hardware.h
  9. *
  10. * Copyright (C) 2006 Texas Instruments.
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the
  14. * Free Software Foundation; either version 2 of the License, or (at your
  15. * option) any later version.
  16. *
  17. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  20. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  23. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  24. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. * You should have received a copy of the GNU General Public License along
  29. * with this program; if not, write to the Free Software Foundation, Inc.,
  30. * 675 Mass Ave, Cambridge, MA 02139, USA.
  31. *
  32. */
  33. #ifndef __ASM_ARCH_HARDWARE_H
  34. #define __ASM_ARCH_HARDWARE_H
  35. #include <config.h>
  36. #include <asm/sizes.h>
  37. #define REG(addr) (*(volatile unsigned int *)(addr))
  38. #define REG_P(addr) ((volatile unsigned int *)(addr))
  39. typedef volatile unsigned int dv_reg;
  40. typedef volatile unsigned int * dv_reg_p;
  41. /*
  42. * Base register addresses
  43. *
  44. * NOTE: some of these DM6446-specific addresses DO NOT WORK
  45. * on other DaVinci chips. Double check them before you try
  46. * using the addresses ... or PSC module identifiers, etc.
  47. */
  48. #ifndef CONFIG_SOC_DA8XX
  49. #define DAVINCI_DMA_3PCC_BASE (0x01c00000)
  50. #define DAVINCI_DMA_3PTC0_BASE (0x01c10000)
  51. #define DAVINCI_DMA_3PTC1_BASE (0x01c10400)
  52. #define DAVINCI_UART0_BASE (0x01c20000)
  53. #define DAVINCI_UART1_BASE (0x01c20400)
  54. #define DAVINCI_I2C_BASE (0x01c21000)
  55. #define DAVINCI_TIMER0_BASE (0x01c21400)
  56. #define DAVINCI_TIMER1_BASE (0x01c21800)
  57. #define DAVINCI_WDOG_BASE (0x01c21c00)
  58. #define DAVINCI_PWM0_BASE (0x01c22000)
  59. #define DAVINCI_PWM1_BASE (0x01c22400)
  60. #define DAVINCI_PWM2_BASE (0x01c22800)
  61. #define DAVINCI_SYSTEM_MODULE_BASE (0x01c40000)
  62. #define DAVINCI_PLL_CNTRL0_BASE (0x01c40800)
  63. #define DAVINCI_PLL_CNTRL1_BASE (0x01c40c00)
  64. #define DAVINCI_PWR_SLEEP_CNTRL_BASE (0x01c41000)
  65. #define DAVINCI_ARM_INTC_BASE (0x01c48000)
  66. #define DAVINCI_USB_OTG_BASE (0x01c64000)
  67. #define DAVINCI_CFC_ATA_BASE (0x01c66000)
  68. #define DAVINCI_SPI_BASE (0x01c66800)
  69. #define DAVINCI_GPIO_BASE (0x01c67000)
  70. #define DAVINCI_VPSS_REGS_BASE (0x01c70000)
  71. #if !defined(CONFIG_SOC_DM646X)
  72. #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE (0x02000000)
  73. #define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE (0x04000000)
  74. #define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE (0x06000000)
  75. #define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE (0x08000000)
  76. #endif
  77. #define DAVINCI_DDR_BASE (0x80000000)
  78. #ifdef CONFIG_SOC_DM644X
  79. #define DAVINCI_UART2_BASE 0x01c20800
  80. #define DAVINCI_UHPI_BASE 0x01c67800
  81. #define DAVINCI_EMAC_CNTRL_REGS_BASE 0x01c80000
  82. #define DAVINCI_EMAC_WRAPPER_CNTRL_REGS_BASE 0x01c81000
  83. #define DAVINCI_EMAC_WRAPPER_RAM_BASE 0x01c82000
  84. #define DAVINCI_MDIO_CNTRL_REGS_BASE 0x01c84000
  85. #define DAVINCI_IMCOP_BASE 0x01cc0000
  86. #define DAVINCI_ASYNC_EMIF_CNTRL_BASE 0x01e00000
  87. #define DAVINCI_VLYNQ_BASE 0x01e01000
  88. #define DAVINCI_ASP_BASE 0x01e02000
  89. #define DAVINCI_MMC_SD_BASE 0x01e10000
  90. #define DAVINCI_MS_BASE 0x01e20000
  91. #define DAVINCI_VLYNQ_REMOTE_BASE 0x0c000000
  92. #elif defined(CONFIG_SOC_DM355)
  93. #define DAVINCI_MMC_SD1_BASE 0x01e00000
  94. #define DAVINCI_ASP0_BASE 0x01e02000
  95. #define DAVINCI_ASP1_BASE 0x01e04000
  96. #define DAVINCI_UART2_BASE 0x01e06000
  97. #define DAVINCI_ASYNC_EMIF_CNTRL_BASE 0x01e10000
  98. #define DAVINCI_MMC_SD0_BASE 0x01e11000
  99. #elif defined(CONFIG_SOC_DM365)
  100. #define DAVINCI_MMC_SD1_BASE 0x01d00000
  101. #define DAVINCI_ASYNC_EMIF_CNTRL_BASE 0x01d10000
  102. #define DAVINCI_MMC_SD0_BASE 0x01d11000
  103. #elif defined(CONFIG_SOC_DM646X)
  104. #define DAVINCI_ASYNC_EMIF_CNTRL_BASE 0x20008000
  105. #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x42000000
  106. #define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE 0x44000000
  107. #define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE 0x46000000
  108. #define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE 0x48000000
  109. #endif
  110. #else /* CONFIG_SOC_DA8XX */
  111. #define DAVINCI_UART0_BASE 0x01c42000
  112. #define DAVINCI_UART1_BASE 0x01d0c000
  113. #define DAVINCI_UART2_BASE 0x01d0d000
  114. #define DAVINCI_I2C0_BASE 0x01c22000
  115. #define DAVINCI_I2C1_BASE 0x01e28000
  116. #define DAVINCI_TIMER0_BASE 0x01c20000
  117. #define DAVINCI_TIMER1_BASE 0x01c21000
  118. #define DAVINCI_WDOG_BASE 0x01c21000
  119. #define DAVINCI_PLL_CNTRL0_BASE 0x01c11000
  120. #define DAVINCI_PSC0_BASE 0x01c10000
  121. #define DAVINCI_PSC1_BASE 0x01e27000
  122. #define DAVINCI_SPI0_BASE 0x01c41000
  123. #define DAVINCI_USB_OTG_BASE 0x01e00000
  124. #define DAVINCI_SPI1_BASE 0x01e12000
  125. #define DAVINCI_GPIO_BASE 0x01e26000
  126. #define DAVINCI_EMAC_CNTRL_REGS_BASE 0x01e23000
  127. #define DAVINCI_EMAC_WRAPPER_CNTRL_REGS_BASE 0x01e22000
  128. #define DAVINCI_EMAC_WRAPPER_RAM_BASE 0x01e20000
  129. #define DAVINCI_MDIO_CNTRL_REGS_BASE 0x01e24000
  130. #define DAVINCI_ASYNC_EMIF_CNTRL_BASE 0x68000000
  131. #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x40000000
  132. #define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE 0x60000000
  133. #define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE 0x62000000
  134. #define DAVINCI_ASYNC_EMIF_DATA_CE4_BASE 0x64000000
  135. #define DAVINCI_ASYNC_EMIF_DATA_CE5_BASE 0x66000000
  136. #define DAVINCI_DDR_EMIF_CTRL_BASE 0xb0000000
  137. #define DAVINCI_DDR_EMIF_DATA_BASE 0xc0000000
  138. #define DAVINCI_INTC_BASE 0xfffee000
  139. #define DAVINCI_BOOTCFG_BASE 0x01c14000
  140. #endif /* CONFIG_SOC_DA8XX */
  141. /* Power and Sleep Controller (PSC) Domains */
  142. #define DAVINCI_GPSC_ARMDOMAIN 0
  143. #define DAVINCI_GPSC_DSPDOMAIN 1
  144. #ifndef CONFIG_SOC_DA8XX
  145. #define DAVINCI_LPSC_VPSSMSTR 0
  146. #define DAVINCI_LPSC_VPSSSLV 1
  147. #define DAVINCI_LPSC_TPCC 2
  148. #define DAVINCI_LPSC_TPTC0 3
  149. #define DAVINCI_LPSC_TPTC1 4
  150. #define DAVINCI_LPSC_EMAC 5
  151. #define DAVINCI_LPSC_EMAC_WRAPPER 6
  152. #define DAVINCI_LPSC_MDIO 7
  153. #define DAVINCI_LPSC_IEEE1394 8
  154. #define DAVINCI_LPSC_USB 9
  155. #define DAVINCI_LPSC_ATA 10
  156. #define DAVINCI_LPSC_VLYNQ 11
  157. #define DAVINCI_LPSC_UHPI 12
  158. #define DAVINCI_LPSC_DDR_EMIF 13
  159. #define DAVINCI_LPSC_AEMIF 14
  160. #define DAVINCI_LPSC_MMC_SD 15
  161. #define DAVINCI_LPSC_MEMSTICK 16
  162. #define DAVINCI_LPSC_McBSP 17
  163. #define DAVINCI_LPSC_I2C 18
  164. #define DAVINCI_LPSC_UART0 19
  165. #define DAVINCI_LPSC_UART1 20
  166. #define DAVINCI_LPSC_UART2 21
  167. #define DAVINCI_LPSC_SPI 22
  168. #define DAVINCI_LPSC_PWM0 23
  169. #define DAVINCI_LPSC_PWM1 24
  170. #define DAVINCI_LPSC_PWM2 25
  171. #define DAVINCI_LPSC_GPIO 26
  172. #define DAVINCI_LPSC_TIMER0 27
  173. #define DAVINCI_LPSC_TIMER1 28
  174. #define DAVINCI_LPSC_TIMER2 29
  175. #define DAVINCI_LPSC_SYSTEM_SUBSYS 30
  176. #define DAVINCI_LPSC_ARM 31
  177. #define DAVINCI_LPSC_SCR2 32
  178. #define DAVINCI_LPSC_SCR3 33
  179. #define DAVINCI_LPSC_SCR4 34
  180. #define DAVINCI_LPSC_CROSSBAR 35
  181. #define DAVINCI_LPSC_CFG27 36
  182. #define DAVINCI_LPSC_CFG3 37
  183. #define DAVINCI_LPSC_CFG5 38
  184. #define DAVINCI_LPSC_GEM 39
  185. #define DAVINCI_LPSC_IMCOP 40
  186. #define DAVINCI_DM646X_LPSC_EMAC 14
  187. #define DAVINCI_DM646X_LPSC_UART0 26
  188. #define DAVINCI_DM646X_LPSC_I2C 31
  189. #else /* CONFIG_SOC_DA8XX */
  190. enum davinci_lpsc_ids {
  191. DAVINCI_LPSC_TPCC = 0,
  192. DAVINCI_LPSC_TPTC0,
  193. DAVINCI_LPSC_TPTC1,
  194. DAVINCI_LPSC_AEMIF,
  195. DAVINCI_LPSC_SPI0,
  196. DAVINCI_LPSC_MMC_SD,
  197. DAVINCI_LPSC_AINTC,
  198. DAVINCI_LPSC_ARM_RAM_ROM,
  199. DAVINCI_LPSC_SECCTL_KEYMGR,
  200. DAVINCI_LPSC_UART0,
  201. DAVINCI_LPSC_SCR0,
  202. DAVINCI_LPSC_SCR1,
  203. DAVINCI_LPSC_SCR2,
  204. DAVINCI_LPSC_DMAX,
  205. DAVINCI_LPSC_ARM,
  206. DAVINCI_LPSC_GEM,
  207. /* for LPSCs in PSC1, offset from 32 for differentiation */
  208. DAVINCI_LPSC_PSC1_BASE = 32,
  209. DAVINCI_LPSC_USB11,
  210. DAVINCI_LPSC_USB20,
  211. DAVINCI_LPSC_GPIO,
  212. DAVINCI_LPSC_UHPI,
  213. DAVINCI_LPSC_EMAC,
  214. DAVINCI_LPSC_DDR_EMIF,
  215. DAVINCI_LPSC_McASP0,
  216. DAVINCI_LPSC_McASP1,
  217. DAVINCI_LPSC_McASP2,
  218. DAVINCI_LPSC_SPI1,
  219. DAVINCI_LPSC_I2C1,
  220. DAVINCI_LPSC_UART1,
  221. DAVINCI_LPSC_UART2,
  222. DAVINCI_LPSC_LCDC,
  223. DAVINCI_LPSC_ePWM,
  224. DAVINCI_LPSC_eCAP,
  225. DAVINCI_LPSC_eQEP,
  226. DAVINCI_LPSC_SCR_P0,
  227. DAVINCI_LPSC_SCR_P1,
  228. DAVINCI_LPSC_CR_P3,
  229. DAVINCI_LPSC_L3_CBA_RAM
  230. };
  231. #endif /* CONFIG_SOC_DA8XX */
  232. void lpsc_on(unsigned int id);
  233. void dsp_on(void);
  234. void davinci_enable_uart0(void);
  235. void davinci_enable_emac(void);
  236. void davinci_enable_i2c(void);
  237. void davinci_errata_workarounds(void);
  238. #ifndef CONFIG_SOC_DA8XX
  239. /* Some PSC defines */
  240. #define PSC_CHP_SHRTSW (0x01c40038)
  241. #define PSC_GBLCTL (0x01c41010)
  242. #define PSC_EPCPR (0x01c41070)
  243. #define PSC_EPCCR (0x01c41078)
  244. #define PSC_PTCMD (0x01c41120)
  245. #define PSC_PTSTAT (0x01c41128)
  246. #define PSC_PDSTAT (0x01c41200)
  247. #define PSC_PDSTAT1 (0x01c41204)
  248. #define PSC_PDCTL (0x01c41300)
  249. #define PSC_PDCTL1 (0x01c41304)
  250. #define PSC_MDCTL_BASE (0x01c41a00)
  251. #define PSC_MDSTAT_BASE (0x01c41800)
  252. #define VDD3P3V_PWDN (0x01c40048)
  253. #define UART0_PWREMU_MGMT (0x01c20030)
  254. #define PSC_SILVER_BULLET (0x01c41a20)
  255. #else /* CONFIG_SOC_DA8XX */
  256. #define PSC_PSC0_MODULE_ID_CNT 16
  257. #define PSC_PSC1_MODULE_ID_CNT 32
  258. struct davinci_psc_regs {
  259. dv_reg revid;
  260. dv_reg rsvd0[71];
  261. dv_reg ptcmd;
  262. dv_reg rsvd1;
  263. dv_reg ptstat;
  264. dv_reg rsvd2[437];
  265. union {
  266. struct {
  267. dv_reg mdstat[PSC_PSC0_MODULE_ID_CNT];
  268. dv_reg rsvd3[112];
  269. dv_reg mdctl[PSC_PSC0_MODULE_ID_CNT];
  270. } psc0;
  271. struct {
  272. dv_reg mdstat[PSC_PSC1_MODULE_ID_CNT];
  273. dv_reg rsvd3[96];
  274. dv_reg mdctl[PSC_PSC1_MODULE_ID_CNT];
  275. } psc1;
  276. };
  277. };
  278. #define davinci_psc0_regs ((struct davinci_psc_regs *)DAVINCI_PSC0_BASE)
  279. #define davinci_psc1_regs ((struct davinci_psc_regs *)DAVINCI_PSC1_BASE)
  280. #endif /* CONFIG_SOC_DA8XX */
  281. #ifndef CONFIG_SOC_DA8XX
  282. /* Miscellania... */
  283. #define VBPR (0x20000020)
  284. /* NOTE: system control modules are *highly* chip-specific, both
  285. * as to register content (e.g. for muxing) and which registers exist.
  286. */
  287. #define PINMUX0 0x01c40000
  288. #define PINMUX1 0x01c40004
  289. #define PINMUX2 0x01c40008
  290. #define PINMUX3 0x01c4000c
  291. #define PINMUX4 0x01c40010
  292. #else /* CONFIG_SOC_DA8XX */
  293. struct davinci_pllc_regs {
  294. dv_reg revid;
  295. dv_reg rsvd1[56];
  296. dv_reg rstype;
  297. dv_reg rsvd2[6];
  298. dv_reg pllctl;
  299. dv_reg ocsel;
  300. dv_reg rsvd3[2];
  301. dv_reg pllm;
  302. dv_reg prediv;
  303. dv_reg plldiv1;
  304. dv_reg plldiv2;
  305. dv_reg plldiv3;
  306. dv_reg oscdiv;
  307. dv_reg postdiv;
  308. dv_reg rsvd4[3];
  309. dv_reg pllcmd;
  310. dv_reg pllstat;
  311. dv_reg alnctl;
  312. dv_reg dchange;
  313. dv_reg cken;
  314. dv_reg ckstat;
  315. dv_reg systat;
  316. dv_reg rsvd5[3];
  317. dv_reg plldiv4;
  318. dv_reg plldiv5;
  319. dv_reg plldiv6;
  320. dv_reg plldiv7;
  321. dv_reg rsvd6[32];
  322. dv_reg emucnt0;
  323. dv_reg emucnt1;
  324. };
  325. #define davinci_pllc_regs ((struct davinci_pllc_regs *)DAVINCI_PLL_CNTRL0_BASE)
  326. #define DAVINCI_PLLC_DIV_MASK 0x1f
  327. /* Clock IDs */
  328. enum davinci_clk_ids {
  329. DAVINCI_SPI0_CLKID = 2,
  330. DAVINCI_UART2_CLKID = 2,
  331. DAVINCI_MDIO_CLKID = 4,
  332. DAVINCI_ARM_CLKID = 6,
  333. DAVINCI_PLLM_CLKID = 0xff,
  334. DAVINCI_PLLC_CLKID = 0x100,
  335. DAVINCI_AUXCLK_CLKID = 0x101
  336. };
  337. int clk_get(enum davinci_clk_ids id);
  338. /* Boot config */
  339. struct davinci_syscfg_regs {
  340. dv_reg revid;
  341. dv_reg rsvd[71];
  342. dv_reg pinmux[20];
  343. dv_reg suspsrc;
  344. dv_reg chipsig;
  345. dv_reg chipsig_clr;
  346. dv_reg cfgchip0;
  347. dv_reg cfgchip1;
  348. dv_reg cfgchip2;
  349. dv_reg cfgchip3;
  350. dv_reg cfgchip4;
  351. };
  352. #define davinci_syscfg_regs \
  353. ((struct davinci_syscfg_regs *)DAVINCI_BOOTCFG_BASE)
  354. /* Emulation suspend bits */
  355. #define DAVINCI_SYSCFG_SUSPSRC_EMAC (1 << 5)
  356. #define DAVINCI_SYSCFG_SUSPSRC_I2C (1 << 16)
  357. #define DAVINCI_SYSCFG_SUSPSRC_SPI0 (1 << 21)
  358. #define DAVINCI_SYSCFG_SUSPSRC_SPI1 (1 << 22)
  359. #define DAVINCI_SYSCFG_SUSPSRC_UART2 (1 << 20)
  360. #define DAVINCI_SYSCFG_SUSPSRC_TIMER0 (1 << 27)
  361. /* Interrupt controller */
  362. struct davinci_aintc_regs {
  363. dv_reg revid;
  364. dv_reg cr;
  365. dv_reg dummy0[2];
  366. dv_reg ger;
  367. dv_reg dummy1[219];
  368. dv_reg ecr1;
  369. dv_reg ecr2;
  370. dv_reg ecr3;
  371. dv_reg dummy2[1117];
  372. dv_reg hier;
  373. };
  374. #define davinci_aintc_regs ((struct davinci_aintc_regs *)DAVINCI_INTC_BASE)
  375. struct davinci_uart_ctrl_regs {
  376. dv_reg revid1;
  377. dv_reg revid2;
  378. dv_reg pwremu_mgmt;
  379. dv_reg mdr;
  380. };
  381. #define DAVINCI_UART_CTRL_BASE 0x28
  382. #define DAVINCI_UART0_CTRL_ADDR (DAVINCI_UART0_BASE + DAVINCI_UART_CTRL_BASE)
  383. #define DAVINCI_UART1_CTRL_ADDR (DAVINCI_UART1_BASE + DAVINCI_UART_CTRL_BASE)
  384. #define DAVINCI_UART2_CTRL_ADDR (DAVINCI_UART2_BASE + DAVINCI_UART_CTRL_BASE)
  385. #define davinci_uart0_ctrl_regs \
  386. ((struct davinci_uart_ctrl_regs *)DAVINCI_UART0_CTRL_ADDR)
  387. #define davinci_uart1_ctrl_regs \
  388. ((struct davinci_uart_ctrl_regs *)DAVINCI_UART1_CTRL_ADDR)
  389. #define davinci_uart2_ctrl_regs \
  390. ((struct davinci_uart_ctrl_regs *)DAVINCI_UART2_CTRL_ADDR)
  391. /* UART PWREMU_MGMT definitions */
  392. #define DAVINCI_UART_PWREMU_MGMT_FREE (1 << 0)
  393. #define DAVINCI_UART_PWREMU_MGMT_URRST (1 << 13)
  394. #define DAVINCI_UART_PWREMU_MGMT_UTRST (1 << 14)
  395. #endif /* CONFIG_SOC_DA8XX */
  396. #endif /* __ASM_ARCH_HARDWARE_H */