da850.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. /*
  2. * TI DA850/OMAP-L138 chip specific setup
  3. *
  4. * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * Derived from: arch/arm/mach-davinci/da830.c
  7. * Original Copyrights follow:
  8. *
  9. * 2009 (c) MontaVista Software, Inc. This file is licensed under
  10. * the terms of the GNU General Public License version 2. This program
  11. * is licensed "as is" without any warranty of any kind, whether express
  12. * or implied.
  13. */
  14. #include <linux/clk-provider.h>
  15. #include <linux/clk/davinci.h>
  16. #include <linux/clkdev.h>
  17. #include <linux/cpufreq.h>
  18. #include <linux/gpio.h>
  19. #include <linux/init.h>
  20. #include <linux/mfd/da8xx-cfgchip.h>
  21. #include <linux/platform_data/clk-da8xx-cfgchip.h>
  22. #include <linux/platform_data/clk-davinci-pll.h>
  23. #include <linux/platform_data/gpio-davinci.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/regmap.h>
  26. #include <linux/regulator/consumer.h>
  27. #include <asm/mach/map.h>
  28. #include <mach/common.h>
  29. #include <mach/cpufreq.h>
  30. #include <mach/cputype.h>
  31. #include <mach/da8xx.h>
  32. #include <mach/irqs.h>
  33. #include <mach/pm.h>
  34. #include <mach/time.h>
  35. #include "mux.h"
  36. #define DA850_PLL1_BASE 0x01e1a000
  37. #define DA850_TIMER64P2_BASE 0x01f0c000
  38. #define DA850_TIMER64P3_BASE 0x01f0d000
  39. #define DA850_REF_FREQ 24000000
  40. /*
  41. * Device specific mux setup
  42. *
  43. * soc description mux mode mode mux dbg
  44. * reg offset mask mode
  45. */
  46. static const struct mux_config da850_pins[] = {
  47. #ifdef CONFIG_DAVINCI_MUX
  48. /* UART0 function */
  49. MUX_CFG(DA850, NUART0_CTS, 3, 24, 15, 2, false)
  50. MUX_CFG(DA850, NUART0_RTS, 3, 28, 15, 2, false)
  51. MUX_CFG(DA850, UART0_RXD, 3, 16, 15, 2, false)
  52. MUX_CFG(DA850, UART0_TXD, 3, 20, 15, 2, false)
  53. /* UART1 function */
  54. MUX_CFG(DA850, UART1_RXD, 4, 24, 15, 2, false)
  55. MUX_CFG(DA850, UART1_TXD, 4, 28, 15, 2, false)
  56. /* UART2 function */
  57. MUX_CFG(DA850, UART2_RXD, 4, 16, 15, 2, false)
  58. MUX_CFG(DA850, UART2_TXD, 4, 20, 15, 2, false)
  59. /* I2C1 function */
  60. MUX_CFG(DA850, I2C1_SCL, 4, 16, 15, 4, false)
  61. MUX_CFG(DA850, I2C1_SDA, 4, 20, 15, 4, false)
  62. /* I2C0 function */
  63. MUX_CFG(DA850, I2C0_SDA, 4, 12, 15, 2, false)
  64. MUX_CFG(DA850, I2C0_SCL, 4, 8, 15, 2, false)
  65. /* EMAC function */
  66. MUX_CFG(DA850, MII_TXEN, 2, 4, 15, 8, false)
  67. MUX_CFG(DA850, MII_TXCLK, 2, 8, 15, 8, false)
  68. MUX_CFG(DA850, MII_COL, 2, 12, 15, 8, false)
  69. MUX_CFG(DA850, MII_TXD_3, 2, 16, 15, 8, false)
  70. MUX_CFG(DA850, MII_TXD_2, 2, 20, 15, 8, false)
  71. MUX_CFG(DA850, MII_TXD_1, 2, 24, 15, 8, false)
  72. MUX_CFG(DA850, MII_TXD_0, 2, 28, 15, 8, false)
  73. MUX_CFG(DA850, MII_RXCLK, 3, 0, 15, 8, false)
  74. MUX_CFG(DA850, MII_RXDV, 3, 4, 15, 8, false)
  75. MUX_CFG(DA850, MII_RXER, 3, 8, 15, 8, false)
  76. MUX_CFG(DA850, MII_CRS, 3, 12, 15, 8, false)
  77. MUX_CFG(DA850, MII_RXD_3, 3, 16, 15, 8, false)
  78. MUX_CFG(DA850, MII_RXD_2, 3, 20, 15, 8, false)
  79. MUX_CFG(DA850, MII_RXD_1, 3, 24, 15, 8, false)
  80. MUX_CFG(DA850, MII_RXD_0, 3, 28, 15, 8, false)
  81. MUX_CFG(DA850, MDIO_CLK, 4, 0, 15, 8, false)
  82. MUX_CFG(DA850, MDIO_D, 4, 4, 15, 8, false)
  83. MUX_CFG(DA850, RMII_TXD_0, 14, 12, 15, 8, false)
  84. MUX_CFG(DA850, RMII_TXD_1, 14, 8, 15, 8, false)
  85. MUX_CFG(DA850, RMII_TXEN, 14, 16, 15, 8, false)
  86. MUX_CFG(DA850, RMII_CRS_DV, 15, 4, 15, 8, false)
  87. MUX_CFG(DA850, RMII_RXD_0, 14, 24, 15, 8, false)
  88. MUX_CFG(DA850, RMII_RXD_1, 14, 20, 15, 8, false)
  89. MUX_CFG(DA850, RMII_RXER, 14, 28, 15, 8, false)
  90. MUX_CFG(DA850, RMII_MHZ_50_CLK, 15, 0, 15, 0, false)
  91. /* McASP function */
  92. MUX_CFG(DA850, ACLKR, 0, 0, 15, 1, false)
  93. MUX_CFG(DA850, ACLKX, 0, 4, 15, 1, false)
  94. MUX_CFG(DA850, AFSR, 0, 8, 15, 1, false)
  95. MUX_CFG(DA850, AFSX, 0, 12, 15, 1, false)
  96. MUX_CFG(DA850, AHCLKR, 0, 16, 15, 1, false)
  97. MUX_CFG(DA850, AHCLKX, 0, 20, 15, 1, false)
  98. MUX_CFG(DA850, AMUTE, 0, 24, 15, 1, false)
  99. MUX_CFG(DA850, AXR_15, 1, 0, 15, 1, false)
  100. MUX_CFG(DA850, AXR_14, 1, 4, 15, 1, false)
  101. MUX_CFG(DA850, AXR_13, 1, 8, 15, 1, false)
  102. MUX_CFG(DA850, AXR_12, 1, 12, 15, 1, false)
  103. MUX_CFG(DA850, AXR_11, 1, 16, 15, 1, false)
  104. MUX_CFG(DA850, AXR_10, 1, 20, 15, 1, false)
  105. MUX_CFG(DA850, AXR_9, 1, 24, 15, 1, false)
  106. MUX_CFG(DA850, AXR_8, 1, 28, 15, 1, false)
  107. MUX_CFG(DA850, AXR_7, 2, 0, 15, 1, false)
  108. MUX_CFG(DA850, AXR_6, 2, 4, 15, 1, false)
  109. MUX_CFG(DA850, AXR_5, 2, 8, 15, 1, false)
  110. MUX_CFG(DA850, AXR_4, 2, 12, 15, 1, false)
  111. MUX_CFG(DA850, AXR_3, 2, 16, 15, 1, false)
  112. MUX_CFG(DA850, AXR_2, 2, 20, 15, 1, false)
  113. MUX_CFG(DA850, AXR_1, 2, 24, 15, 1, false)
  114. MUX_CFG(DA850, AXR_0, 2, 28, 15, 1, false)
  115. /* LCD function */
  116. MUX_CFG(DA850, LCD_D_7, 16, 8, 15, 2, false)
  117. MUX_CFG(DA850, LCD_D_6, 16, 12, 15, 2, false)
  118. MUX_CFG(DA850, LCD_D_5, 16, 16, 15, 2, false)
  119. MUX_CFG(DA850, LCD_D_4, 16, 20, 15, 2, false)
  120. MUX_CFG(DA850, LCD_D_3, 16, 24, 15, 2, false)
  121. MUX_CFG(DA850, LCD_D_2, 16, 28, 15, 2, false)
  122. MUX_CFG(DA850, LCD_D_1, 17, 0, 15, 2, false)
  123. MUX_CFG(DA850, LCD_D_0, 17, 4, 15, 2, false)
  124. MUX_CFG(DA850, LCD_D_15, 17, 8, 15, 2, false)
  125. MUX_CFG(DA850, LCD_D_14, 17, 12, 15, 2, false)
  126. MUX_CFG(DA850, LCD_D_13, 17, 16, 15, 2, false)
  127. MUX_CFG(DA850, LCD_D_12, 17, 20, 15, 2, false)
  128. MUX_CFG(DA850, LCD_D_11, 17, 24, 15, 2, false)
  129. MUX_CFG(DA850, LCD_D_10, 17, 28, 15, 2, false)
  130. MUX_CFG(DA850, LCD_D_9, 18, 0, 15, 2, false)
  131. MUX_CFG(DA850, LCD_D_8, 18, 4, 15, 2, false)
  132. MUX_CFG(DA850, LCD_PCLK, 18, 24, 15, 2, false)
  133. MUX_CFG(DA850, LCD_HSYNC, 19, 0, 15, 2, false)
  134. MUX_CFG(DA850, LCD_VSYNC, 19, 4, 15, 2, false)
  135. MUX_CFG(DA850, NLCD_AC_ENB_CS, 19, 24, 15, 2, false)
  136. /* MMC/SD0 function */
  137. MUX_CFG(DA850, MMCSD0_DAT_0, 10, 8, 15, 2, false)
  138. MUX_CFG(DA850, MMCSD0_DAT_1, 10, 12, 15, 2, false)
  139. MUX_CFG(DA850, MMCSD0_DAT_2, 10, 16, 15, 2, false)
  140. MUX_CFG(DA850, MMCSD0_DAT_3, 10, 20, 15, 2, false)
  141. MUX_CFG(DA850, MMCSD0_CLK, 10, 0, 15, 2, false)
  142. MUX_CFG(DA850, MMCSD0_CMD, 10, 4, 15, 2, false)
  143. /* MMC/SD1 function */
  144. MUX_CFG(DA850, MMCSD1_DAT_0, 18, 8, 15, 2, false)
  145. MUX_CFG(DA850, MMCSD1_DAT_1, 19, 16, 15, 2, false)
  146. MUX_CFG(DA850, MMCSD1_DAT_2, 19, 12, 15, 2, false)
  147. MUX_CFG(DA850, MMCSD1_DAT_3, 19, 8, 15, 2, false)
  148. MUX_CFG(DA850, MMCSD1_CLK, 18, 12, 15, 2, false)
  149. MUX_CFG(DA850, MMCSD1_CMD, 18, 16, 15, 2, false)
  150. /* EMIF2.5/EMIFA function */
  151. MUX_CFG(DA850, EMA_D_7, 9, 0, 15, 1, false)
  152. MUX_CFG(DA850, EMA_D_6, 9, 4, 15, 1, false)
  153. MUX_CFG(DA850, EMA_D_5, 9, 8, 15, 1, false)
  154. MUX_CFG(DA850, EMA_D_4, 9, 12, 15, 1, false)
  155. MUX_CFG(DA850, EMA_D_3, 9, 16, 15, 1, false)
  156. MUX_CFG(DA850, EMA_D_2, 9, 20, 15, 1, false)
  157. MUX_CFG(DA850, EMA_D_1, 9, 24, 15, 1, false)
  158. MUX_CFG(DA850, EMA_D_0, 9, 28, 15, 1, false)
  159. MUX_CFG(DA850, EMA_A_1, 12, 24, 15, 1, false)
  160. MUX_CFG(DA850, EMA_A_2, 12, 20, 15, 1, false)
  161. MUX_CFG(DA850, NEMA_CS_3, 7, 4, 15, 1, false)
  162. MUX_CFG(DA850, NEMA_CS_4, 7, 8, 15, 1, false)
  163. MUX_CFG(DA850, NEMA_WE, 7, 16, 15, 1, false)
  164. MUX_CFG(DA850, NEMA_OE, 7, 20, 15, 1, false)
  165. MUX_CFG(DA850, EMA_A_0, 12, 28, 15, 1, false)
  166. MUX_CFG(DA850, EMA_A_3, 12, 16, 15, 1, false)
  167. MUX_CFG(DA850, EMA_A_4, 12, 12, 15, 1, false)
  168. MUX_CFG(DA850, EMA_A_5, 12, 8, 15, 1, false)
  169. MUX_CFG(DA850, EMA_A_6, 12, 4, 15, 1, false)
  170. MUX_CFG(DA850, EMA_A_7, 12, 0, 15, 1, false)
  171. MUX_CFG(DA850, EMA_A_8, 11, 28, 15, 1, false)
  172. MUX_CFG(DA850, EMA_A_9, 11, 24, 15, 1, false)
  173. MUX_CFG(DA850, EMA_A_10, 11, 20, 15, 1, false)
  174. MUX_CFG(DA850, EMA_A_11, 11, 16, 15, 1, false)
  175. MUX_CFG(DA850, EMA_A_12, 11, 12, 15, 1, false)
  176. MUX_CFG(DA850, EMA_A_13, 11, 8, 15, 1, false)
  177. MUX_CFG(DA850, EMA_A_14, 11, 4, 15, 1, false)
  178. MUX_CFG(DA850, EMA_A_15, 11, 0, 15, 1, false)
  179. MUX_CFG(DA850, EMA_A_16, 10, 28, 15, 1, false)
  180. MUX_CFG(DA850, EMA_A_17, 10, 24, 15, 1, false)
  181. MUX_CFG(DA850, EMA_A_18, 10, 20, 15, 1, false)
  182. MUX_CFG(DA850, EMA_A_19, 10, 16, 15, 1, false)
  183. MUX_CFG(DA850, EMA_A_20, 10, 12, 15, 1, false)
  184. MUX_CFG(DA850, EMA_A_21, 10, 8, 15, 1, false)
  185. MUX_CFG(DA850, EMA_A_22, 10, 4, 15, 1, false)
  186. MUX_CFG(DA850, EMA_A_23, 10, 0, 15, 1, false)
  187. MUX_CFG(DA850, EMA_D_8, 8, 28, 15, 1, false)
  188. MUX_CFG(DA850, EMA_D_9, 8, 24, 15, 1, false)
  189. MUX_CFG(DA850, EMA_D_10, 8, 20, 15, 1, false)
  190. MUX_CFG(DA850, EMA_D_11, 8, 16, 15, 1, false)
  191. MUX_CFG(DA850, EMA_D_12, 8, 12, 15, 1, false)
  192. MUX_CFG(DA850, EMA_D_13, 8, 8, 15, 1, false)
  193. MUX_CFG(DA850, EMA_D_14, 8, 4, 15, 1, false)
  194. MUX_CFG(DA850, EMA_D_15, 8, 0, 15, 1, false)
  195. MUX_CFG(DA850, EMA_BA_1, 5, 24, 15, 1, false)
  196. MUX_CFG(DA850, EMA_CLK, 6, 0, 15, 1, false)
  197. MUX_CFG(DA850, EMA_WAIT_1, 6, 24, 15, 1, false)
  198. MUX_CFG(DA850, NEMA_CS_2, 7, 0, 15, 1, false)
  199. /* GPIO function */
  200. MUX_CFG(DA850, GPIO2_4, 6, 12, 15, 8, false)
  201. MUX_CFG(DA850, GPIO2_6, 6, 4, 15, 8, false)
  202. MUX_CFG(DA850, GPIO2_8, 5, 28, 15, 8, false)
  203. MUX_CFG(DA850, GPIO2_15, 5, 0, 15, 8, false)
  204. MUX_CFG(DA850, GPIO3_12, 7, 12, 15, 8, false)
  205. MUX_CFG(DA850, GPIO3_13, 7, 8, 15, 8, false)
  206. MUX_CFG(DA850, GPIO4_0, 10, 28, 15, 8, false)
  207. MUX_CFG(DA850, GPIO4_1, 10, 24, 15, 8, false)
  208. MUX_CFG(DA850, GPIO6_9, 13, 24, 15, 8, false)
  209. MUX_CFG(DA850, GPIO6_10, 13, 20, 15, 8, false)
  210. MUX_CFG(DA850, GPIO6_13, 13, 8, 15, 8, false)
  211. MUX_CFG(DA850, RTC_ALARM, 0, 28, 15, 2, false)
  212. /* VPIF Capture */
  213. MUX_CFG(DA850, VPIF_DIN0, 15, 4, 15, 1, false)
  214. MUX_CFG(DA850, VPIF_DIN1, 15, 0, 15, 1, false)
  215. MUX_CFG(DA850, VPIF_DIN2, 14, 28, 15, 1, false)
  216. MUX_CFG(DA850, VPIF_DIN3, 14, 24, 15, 1, false)
  217. MUX_CFG(DA850, VPIF_DIN4, 14, 20, 15, 1, false)
  218. MUX_CFG(DA850, VPIF_DIN5, 14, 16, 15, 1, false)
  219. MUX_CFG(DA850, VPIF_DIN6, 14, 12, 15, 1, false)
  220. MUX_CFG(DA850, VPIF_DIN7, 14, 8, 15, 1, false)
  221. MUX_CFG(DA850, VPIF_DIN8, 16, 4, 15, 1, false)
  222. MUX_CFG(DA850, VPIF_DIN9, 16, 0, 15, 1, false)
  223. MUX_CFG(DA850, VPIF_DIN10, 15, 28, 15, 1, false)
  224. MUX_CFG(DA850, VPIF_DIN11, 15, 24, 15, 1, false)
  225. MUX_CFG(DA850, VPIF_DIN12, 15, 20, 15, 1, false)
  226. MUX_CFG(DA850, VPIF_DIN13, 15, 16, 15, 1, false)
  227. MUX_CFG(DA850, VPIF_DIN14, 15, 12, 15, 1, false)
  228. MUX_CFG(DA850, VPIF_DIN15, 15, 8, 15, 1, false)
  229. MUX_CFG(DA850, VPIF_CLKIN0, 14, 0, 15, 1, false)
  230. MUX_CFG(DA850, VPIF_CLKIN1, 14, 4, 15, 1, false)
  231. MUX_CFG(DA850, VPIF_CLKIN2, 19, 8, 15, 1, false)
  232. MUX_CFG(DA850, VPIF_CLKIN3, 19, 16, 15, 1, false)
  233. /* VPIF Display */
  234. MUX_CFG(DA850, VPIF_DOUT0, 17, 4, 15, 1, false)
  235. MUX_CFG(DA850, VPIF_DOUT1, 17, 0, 15, 1, false)
  236. MUX_CFG(DA850, VPIF_DOUT2, 16, 28, 15, 1, false)
  237. MUX_CFG(DA850, VPIF_DOUT3, 16, 24, 15, 1, false)
  238. MUX_CFG(DA850, VPIF_DOUT4, 16, 20, 15, 1, false)
  239. MUX_CFG(DA850, VPIF_DOUT5, 16, 16, 15, 1, false)
  240. MUX_CFG(DA850, VPIF_DOUT6, 16, 12, 15, 1, false)
  241. MUX_CFG(DA850, VPIF_DOUT7, 16, 8, 15, 1, false)
  242. MUX_CFG(DA850, VPIF_DOUT8, 18, 4, 15, 1, false)
  243. MUX_CFG(DA850, VPIF_DOUT9, 18, 0, 15, 1, false)
  244. MUX_CFG(DA850, VPIF_DOUT10, 17, 28, 15, 1, false)
  245. MUX_CFG(DA850, VPIF_DOUT11, 17, 24, 15, 1, false)
  246. MUX_CFG(DA850, VPIF_DOUT12, 17, 20, 15, 1, false)
  247. MUX_CFG(DA850, VPIF_DOUT13, 17, 16, 15, 1, false)
  248. MUX_CFG(DA850, VPIF_DOUT14, 17, 12, 15, 1, false)
  249. MUX_CFG(DA850, VPIF_DOUT15, 17, 8, 15, 1, false)
  250. MUX_CFG(DA850, VPIF_CLKO2, 19, 12, 15, 1, false)
  251. MUX_CFG(DA850, VPIF_CLKO3, 19, 20, 15, 1, false)
  252. #endif
  253. };
  254. const short da850_i2c0_pins[] __initconst = {
  255. DA850_I2C0_SDA, DA850_I2C0_SCL,
  256. -1
  257. };
  258. const short da850_i2c1_pins[] __initconst = {
  259. DA850_I2C1_SCL, DA850_I2C1_SDA,
  260. -1
  261. };
  262. const short da850_lcdcntl_pins[] __initconst = {
  263. DA850_LCD_D_0, DA850_LCD_D_1, DA850_LCD_D_2, DA850_LCD_D_3,
  264. DA850_LCD_D_4, DA850_LCD_D_5, DA850_LCD_D_6, DA850_LCD_D_7,
  265. DA850_LCD_D_8, DA850_LCD_D_9, DA850_LCD_D_10, DA850_LCD_D_11,
  266. DA850_LCD_D_12, DA850_LCD_D_13, DA850_LCD_D_14, DA850_LCD_D_15,
  267. DA850_LCD_PCLK, DA850_LCD_HSYNC, DA850_LCD_VSYNC, DA850_NLCD_AC_ENB_CS,
  268. -1
  269. };
  270. const short da850_vpif_capture_pins[] __initconst = {
  271. DA850_VPIF_DIN0, DA850_VPIF_DIN1, DA850_VPIF_DIN2, DA850_VPIF_DIN3,
  272. DA850_VPIF_DIN4, DA850_VPIF_DIN5, DA850_VPIF_DIN6, DA850_VPIF_DIN7,
  273. DA850_VPIF_DIN8, DA850_VPIF_DIN9, DA850_VPIF_DIN10, DA850_VPIF_DIN11,
  274. DA850_VPIF_DIN12, DA850_VPIF_DIN13, DA850_VPIF_DIN14, DA850_VPIF_DIN15,
  275. DA850_VPIF_CLKIN0, DA850_VPIF_CLKIN1, DA850_VPIF_CLKIN2,
  276. DA850_VPIF_CLKIN3,
  277. -1
  278. };
  279. const short da850_vpif_display_pins[] __initconst = {
  280. DA850_VPIF_DOUT0, DA850_VPIF_DOUT1, DA850_VPIF_DOUT2, DA850_VPIF_DOUT3,
  281. DA850_VPIF_DOUT4, DA850_VPIF_DOUT5, DA850_VPIF_DOUT6, DA850_VPIF_DOUT7,
  282. DA850_VPIF_DOUT8, DA850_VPIF_DOUT9, DA850_VPIF_DOUT10,
  283. DA850_VPIF_DOUT11, DA850_VPIF_DOUT12, DA850_VPIF_DOUT13,
  284. DA850_VPIF_DOUT14, DA850_VPIF_DOUT15, DA850_VPIF_CLKO2,
  285. DA850_VPIF_CLKO3,
  286. -1
  287. };
  288. /* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */
  289. static u8 da850_default_priorities[DA850_N_CP_INTC_IRQ] = {
  290. [IRQ_DA8XX_COMMTX] = 7,
  291. [IRQ_DA8XX_COMMRX] = 7,
  292. [IRQ_DA8XX_NINT] = 7,
  293. [IRQ_DA8XX_EVTOUT0] = 7,
  294. [IRQ_DA8XX_EVTOUT1] = 7,
  295. [IRQ_DA8XX_EVTOUT2] = 7,
  296. [IRQ_DA8XX_EVTOUT3] = 7,
  297. [IRQ_DA8XX_EVTOUT4] = 7,
  298. [IRQ_DA8XX_EVTOUT5] = 7,
  299. [IRQ_DA8XX_EVTOUT6] = 7,
  300. [IRQ_DA8XX_EVTOUT7] = 7,
  301. [IRQ_DA8XX_CCINT0] = 7,
  302. [IRQ_DA8XX_CCERRINT] = 7,
  303. [IRQ_DA8XX_TCERRINT0] = 7,
  304. [IRQ_DA8XX_AEMIFINT] = 7,
  305. [IRQ_DA8XX_I2CINT0] = 7,
  306. [IRQ_DA8XX_MMCSDINT0] = 7,
  307. [IRQ_DA8XX_MMCSDINT1] = 7,
  308. [IRQ_DA8XX_ALLINT0] = 7,
  309. [IRQ_DA8XX_RTC] = 7,
  310. [IRQ_DA8XX_SPINT0] = 7,
  311. [IRQ_DA8XX_TINT12_0] = 7,
  312. [IRQ_DA8XX_TINT34_0] = 7,
  313. [IRQ_DA8XX_TINT12_1] = 7,
  314. [IRQ_DA8XX_TINT34_1] = 7,
  315. [IRQ_DA8XX_UARTINT0] = 7,
  316. [IRQ_DA8XX_KEYMGRINT] = 7,
  317. [IRQ_DA850_MPUADDRERR0] = 7,
  318. [IRQ_DA8XX_CHIPINT0] = 7,
  319. [IRQ_DA8XX_CHIPINT1] = 7,
  320. [IRQ_DA8XX_CHIPINT2] = 7,
  321. [IRQ_DA8XX_CHIPINT3] = 7,
  322. [IRQ_DA8XX_TCERRINT1] = 7,
  323. [IRQ_DA8XX_C0_RX_THRESH_PULSE] = 7,
  324. [IRQ_DA8XX_C0_RX_PULSE] = 7,
  325. [IRQ_DA8XX_C0_TX_PULSE] = 7,
  326. [IRQ_DA8XX_C0_MISC_PULSE] = 7,
  327. [IRQ_DA8XX_C1_RX_THRESH_PULSE] = 7,
  328. [IRQ_DA8XX_C1_RX_PULSE] = 7,
  329. [IRQ_DA8XX_C1_TX_PULSE] = 7,
  330. [IRQ_DA8XX_C1_MISC_PULSE] = 7,
  331. [IRQ_DA8XX_MEMERR] = 7,
  332. [IRQ_DA8XX_GPIO0] = 7,
  333. [IRQ_DA8XX_GPIO1] = 7,
  334. [IRQ_DA8XX_GPIO2] = 7,
  335. [IRQ_DA8XX_GPIO3] = 7,
  336. [IRQ_DA8XX_GPIO4] = 7,
  337. [IRQ_DA8XX_GPIO5] = 7,
  338. [IRQ_DA8XX_GPIO6] = 7,
  339. [IRQ_DA8XX_GPIO7] = 7,
  340. [IRQ_DA8XX_GPIO8] = 7,
  341. [IRQ_DA8XX_I2CINT1] = 7,
  342. [IRQ_DA8XX_LCDINT] = 7,
  343. [IRQ_DA8XX_UARTINT1] = 7,
  344. [IRQ_DA8XX_MCASPINT] = 7,
  345. [IRQ_DA8XX_ALLINT1] = 7,
  346. [IRQ_DA8XX_SPINT1] = 7,
  347. [IRQ_DA8XX_UHPI_INT1] = 7,
  348. [IRQ_DA8XX_USB_INT] = 7,
  349. [IRQ_DA8XX_IRQN] = 7,
  350. [IRQ_DA8XX_RWAKEUP] = 7,
  351. [IRQ_DA8XX_UARTINT2] = 7,
  352. [IRQ_DA8XX_DFTSSINT] = 7,
  353. [IRQ_DA8XX_EHRPWM0] = 7,
  354. [IRQ_DA8XX_EHRPWM0TZ] = 7,
  355. [IRQ_DA8XX_EHRPWM1] = 7,
  356. [IRQ_DA8XX_EHRPWM1TZ] = 7,
  357. [IRQ_DA850_SATAINT] = 7,
  358. [IRQ_DA850_TINTALL_2] = 7,
  359. [IRQ_DA8XX_ECAP0] = 7,
  360. [IRQ_DA8XX_ECAP1] = 7,
  361. [IRQ_DA8XX_ECAP2] = 7,
  362. [IRQ_DA850_MMCSDINT0_1] = 7,
  363. [IRQ_DA850_MMCSDINT1_1] = 7,
  364. [IRQ_DA850_T12CMPINT0_2] = 7,
  365. [IRQ_DA850_T12CMPINT1_2] = 7,
  366. [IRQ_DA850_T12CMPINT2_2] = 7,
  367. [IRQ_DA850_T12CMPINT3_2] = 7,
  368. [IRQ_DA850_T12CMPINT4_2] = 7,
  369. [IRQ_DA850_T12CMPINT5_2] = 7,
  370. [IRQ_DA850_T12CMPINT6_2] = 7,
  371. [IRQ_DA850_T12CMPINT7_2] = 7,
  372. [IRQ_DA850_T12CMPINT0_3] = 7,
  373. [IRQ_DA850_T12CMPINT1_3] = 7,
  374. [IRQ_DA850_T12CMPINT2_3] = 7,
  375. [IRQ_DA850_T12CMPINT3_3] = 7,
  376. [IRQ_DA850_T12CMPINT4_3] = 7,
  377. [IRQ_DA850_T12CMPINT5_3] = 7,
  378. [IRQ_DA850_T12CMPINT6_3] = 7,
  379. [IRQ_DA850_T12CMPINT7_3] = 7,
  380. [IRQ_DA850_RPIINT] = 7,
  381. [IRQ_DA850_VPIFINT] = 7,
  382. [IRQ_DA850_CCINT1] = 7,
  383. [IRQ_DA850_CCERRINT1] = 7,
  384. [IRQ_DA850_TCERRINT2] = 7,
  385. [IRQ_DA850_TINTALL_3] = 7,
  386. [IRQ_DA850_MCBSP0RINT] = 7,
  387. [IRQ_DA850_MCBSP0XINT] = 7,
  388. [IRQ_DA850_MCBSP1RINT] = 7,
  389. [IRQ_DA850_MCBSP1XINT] = 7,
  390. [IRQ_DA8XX_ARMCLKSTOPREQ] = 7,
  391. };
  392. static struct map_desc da850_io_desc[] = {
  393. {
  394. .virtual = IO_VIRT,
  395. .pfn = __phys_to_pfn(IO_PHYS),
  396. .length = IO_SIZE,
  397. .type = MT_DEVICE
  398. },
  399. {
  400. .virtual = DA8XX_CP_INTC_VIRT,
  401. .pfn = __phys_to_pfn(DA8XX_CP_INTC_BASE),
  402. .length = DA8XX_CP_INTC_SIZE,
  403. .type = MT_DEVICE
  404. },
  405. };
  406. /* Contents of JTAG ID register used to identify exact cpu type */
  407. static struct davinci_id da850_ids[] = {
  408. {
  409. .variant = 0x0,
  410. .part_no = 0xb7d1,
  411. .manufacturer = 0x017, /* 0x02f >> 1 */
  412. .cpu_id = DAVINCI_CPU_ID_DA850,
  413. .name = "da850/omap-l138",
  414. },
  415. {
  416. .variant = 0x1,
  417. .part_no = 0xb7d1,
  418. .manufacturer = 0x017, /* 0x02f >> 1 */
  419. .cpu_id = DAVINCI_CPU_ID_DA850,
  420. .name = "da850/omap-l138/am18x",
  421. },
  422. };
  423. static struct davinci_timer_instance da850_timer_instance[4] = {
  424. {
  425. .base = DA8XX_TIMER64P0_BASE,
  426. .bottom_irq = IRQ_DA8XX_TINT12_0,
  427. .top_irq = IRQ_DA8XX_TINT34_0,
  428. },
  429. {
  430. .base = DA8XX_TIMER64P1_BASE,
  431. .bottom_irq = IRQ_DA8XX_TINT12_1,
  432. .top_irq = IRQ_DA8XX_TINT34_1,
  433. },
  434. {
  435. .base = DA850_TIMER64P2_BASE,
  436. .bottom_irq = IRQ_DA850_TINT12_2,
  437. .top_irq = IRQ_DA850_TINT34_2,
  438. },
  439. {
  440. .base = DA850_TIMER64P3_BASE,
  441. .bottom_irq = IRQ_DA850_TINT12_3,
  442. .top_irq = IRQ_DA850_TINT34_3,
  443. },
  444. };
  445. /*
  446. * T0_BOT: Timer 0, bottom : Used for clock_event
  447. * T0_TOP: Timer 0, top : Used for clocksource
  448. * T1_BOT, T1_TOP: Timer 1, bottom & top: Used for watchdog timer
  449. */
  450. static struct davinci_timer_info da850_timer_info = {
  451. .timers = da850_timer_instance,
  452. .clockevent_id = T0_BOT,
  453. .clocksource_id = T0_TOP,
  454. };
  455. #ifdef CONFIG_CPU_FREQ
  456. /*
  457. * Notes:
  458. * According to the TRM, minimum PLLM results in maximum power savings.
  459. * The OPP definitions below should keep the PLLM as low as possible.
  460. *
  461. * The output of the PLLM must be between 300 to 600 MHz.
  462. */
  463. struct da850_opp {
  464. unsigned int freq; /* in KHz */
  465. unsigned int prediv;
  466. unsigned int mult;
  467. unsigned int postdiv;
  468. unsigned int cvdd_min; /* in uV */
  469. unsigned int cvdd_max; /* in uV */
  470. };
  471. static const struct da850_opp da850_opp_456 = {
  472. .freq = 456000,
  473. .prediv = 1,
  474. .mult = 19,
  475. .postdiv = 1,
  476. .cvdd_min = 1300000,
  477. .cvdd_max = 1350000,
  478. };
  479. static const struct da850_opp da850_opp_408 = {
  480. .freq = 408000,
  481. .prediv = 1,
  482. .mult = 17,
  483. .postdiv = 1,
  484. .cvdd_min = 1300000,
  485. .cvdd_max = 1350000,
  486. };
  487. static const struct da850_opp da850_opp_372 = {
  488. .freq = 372000,
  489. .prediv = 2,
  490. .mult = 31,
  491. .postdiv = 1,
  492. .cvdd_min = 1200000,
  493. .cvdd_max = 1320000,
  494. };
  495. static const struct da850_opp da850_opp_300 = {
  496. .freq = 300000,
  497. .prediv = 1,
  498. .mult = 25,
  499. .postdiv = 2,
  500. .cvdd_min = 1200000,
  501. .cvdd_max = 1320000,
  502. };
  503. static const struct da850_opp da850_opp_200 = {
  504. .freq = 200000,
  505. .prediv = 1,
  506. .mult = 25,
  507. .postdiv = 3,
  508. .cvdd_min = 1100000,
  509. .cvdd_max = 1160000,
  510. };
  511. static const struct da850_opp da850_opp_96 = {
  512. .freq = 96000,
  513. .prediv = 1,
  514. .mult = 20,
  515. .postdiv = 5,
  516. .cvdd_min = 1000000,
  517. .cvdd_max = 1050000,
  518. };
  519. #define OPP(freq) \
  520. { \
  521. .driver_data = (unsigned int) &da850_opp_##freq, \
  522. .frequency = freq * 1000, \
  523. }
  524. static struct cpufreq_frequency_table da850_freq_table[] = {
  525. OPP(456),
  526. OPP(408),
  527. OPP(372),
  528. OPP(300),
  529. OPP(200),
  530. OPP(96),
  531. {
  532. .driver_data = 0,
  533. .frequency = CPUFREQ_TABLE_END,
  534. },
  535. };
  536. #ifdef CONFIG_REGULATOR
  537. static int da850_set_voltage(unsigned int index);
  538. static int da850_regulator_init(void);
  539. #endif
  540. static struct davinci_cpufreq_config cpufreq_info = {
  541. .freq_table = da850_freq_table,
  542. #ifdef CONFIG_REGULATOR
  543. .init = da850_regulator_init,
  544. .set_voltage = da850_set_voltage,
  545. #endif
  546. };
  547. #ifdef CONFIG_REGULATOR
  548. static struct regulator *cvdd;
  549. static int da850_set_voltage(unsigned int index)
  550. {
  551. struct da850_opp *opp;
  552. if (!cvdd)
  553. return -ENODEV;
  554. opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data;
  555. return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max);
  556. }
  557. static int da850_regulator_init(void)
  558. {
  559. cvdd = regulator_get(NULL, "cvdd");
  560. if (WARN(IS_ERR(cvdd), "Unable to obtain voltage regulator for CVDD;"
  561. " voltage scaling unsupported\n")) {
  562. return PTR_ERR(cvdd);
  563. }
  564. return 0;
  565. }
  566. #endif
  567. static struct platform_device da850_cpufreq_device = {
  568. .name = "cpufreq-davinci",
  569. .dev = {
  570. .platform_data = &cpufreq_info,
  571. },
  572. .id = -1,
  573. };
  574. unsigned int da850_max_speed = 300000;
  575. int da850_register_cpufreq(char *async_clk)
  576. {
  577. int i;
  578. /* cpufreq driver can help keep an "async" clock constant */
  579. if (async_clk)
  580. clk_add_alias("async", da850_cpufreq_device.name,
  581. async_clk, NULL);
  582. for (i = 0; i < ARRAY_SIZE(da850_freq_table); i++) {
  583. if (da850_freq_table[i].frequency <= da850_max_speed) {
  584. cpufreq_info.freq_table = &da850_freq_table[i];
  585. break;
  586. }
  587. }
  588. return platform_device_register(&da850_cpufreq_device);
  589. }
  590. #else
  591. int __init da850_register_cpufreq(char *async_clk)
  592. {
  593. return 0;
  594. }
  595. #endif
  596. /* VPIF resource, platform data */
  597. static u64 da850_vpif_dma_mask = DMA_BIT_MASK(32);
  598. static struct resource da850_vpif_resource[] = {
  599. {
  600. .start = DA8XX_VPIF_BASE,
  601. .end = DA8XX_VPIF_BASE + 0xfff,
  602. .flags = IORESOURCE_MEM,
  603. }
  604. };
  605. static struct platform_device da850_vpif_dev = {
  606. .name = "vpif",
  607. .id = -1,
  608. .dev = {
  609. .dma_mask = &da850_vpif_dma_mask,
  610. .coherent_dma_mask = DMA_BIT_MASK(32),
  611. },
  612. .resource = da850_vpif_resource,
  613. .num_resources = ARRAY_SIZE(da850_vpif_resource),
  614. };
  615. static struct resource da850_vpif_display_resource[] = {
  616. {
  617. .start = IRQ_DA850_VPIFINT,
  618. .end = IRQ_DA850_VPIFINT,
  619. .flags = IORESOURCE_IRQ,
  620. },
  621. };
  622. static struct platform_device da850_vpif_display_dev = {
  623. .name = "vpif_display",
  624. .id = -1,
  625. .dev = {
  626. .dma_mask = &da850_vpif_dma_mask,
  627. .coherent_dma_mask = DMA_BIT_MASK(32),
  628. },
  629. .resource = da850_vpif_display_resource,
  630. .num_resources = ARRAY_SIZE(da850_vpif_display_resource),
  631. };
  632. static struct resource da850_vpif_capture_resource[] = {
  633. {
  634. .start = IRQ_DA850_VPIFINT,
  635. .end = IRQ_DA850_VPIFINT,
  636. .flags = IORESOURCE_IRQ,
  637. },
  638. {
  639. .start = IRQ_DA850_VPIFINT,
  640. .end = IRQ_DA850_VPIFINT,
  641. .flags = IORESOURCE_IRQ,
  642. },
  643. };
  644. static struct platform_device da850_vpif_capture_dev = {
  645. .name = "vpif_capture",
  646. .id = -1,
  647. .dev = {
  648. .dma_mask = &da850_vpif_dma_mask,
  649. .coherent_dma_mask = DMA_BIT_MASK(32),
  650. },
  651. .resource = da850_vpif_capture_resource,
  652. .num_resources = ARRAY_SIZE(da850_vpif_capture_resource),
  653. };
  654. int __init da850_register_vpif(void)
  655. {
  656. return platform_device_register(&da850_vpif_dev);
  657. }
  658. int __init da850_register_vpif_display(struct vpif_display_config
  659. *display_config)
  660. {
  661. da850_vpif_display_dev.dev.platform_data = display_config;
  662. return platform_device_register(&da850_vpif_display_dev);
  663. }
  664. int __init da850_register_vpif_capture(struct vpif_capture_config
  665. *capture_config)
  666. {
  667. da850_vpif_capture_dev.dev.platform_data = capture_config;
  668. return platform_device_register(&da850_vpif_capture_dev);
  669. }
  670. static struct davinci_gpio_platform_data da850_gpio_platform_data = {
  671. .ngpio = 144,
  672. };
  673. int __init da850_register_gpio(void)
  674. {
  675. return da8xx_register_gpio(&da850_gpio_platform_data);
  676. }
  677. static const struct davinci_soc_info davinci_soc_info_da850 = {
  678. .io_desc = da850_io_desc,
  679. .io_desc_num = ARRAY_SIZE(da850_io_desc),
  680. .jtag_id_reg = DA8XX_SYSCFG0_BASE + DA8XX_JTAG_ID_REG,
  681. .ids = da850_ids,
  682. .ids_num = ARRAY_SIZE(da850_ids),
  683. .pinmux_base = DA8XX_SYSCFG0_BASE + 0x120,
  684. .pinmux_pins = da850_pins,
  685. .pinmux_pins_num = ARRAY_SIZE(da850_pins),
  686. .intc_base = DA8XX_CP_INTC_BASE,
  687. .intc_type = DAVINCI_INTC_TYPE_CP_INTC,
  688. .intc_irq_prios = da850_default_priorities,
  689. .intc_irq_num = DA850_N_CP_INTC_IRQ,
  690. .timer_info = &da850_timer_info,
  691. .emac_pdata = &da8xx_emac_pdata,
  692. .sram_dma = DA8XX_SHARED_RAM_BASE,
  693. .sram_len = SZ_128K,
  694. };
  695. void __init da850_init(void)
  696. {
  697. davinci_common_init(&davinci_soc_info_da850);
  698. da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K);
  699. if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module"))
  700. return;
  701. da8xx_syscfg1_base = ioremap(DA8XX_SYSCFG1_BASE, SZ_4K);
  702. WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module");
  703. }
  704. void __init da850_init_time(void)
  705. {
  706. void __iomem *pll0;
  707. struct regmap *cfgchip;
  708. struct clk *clk;
  709. clk_register_fixed_rate(NULL, "ref_clk", NULL, 0, DA850_REF_FREQ);
  710. pll0 = ioremap(DA8XX_PLL0_BASE, SZ_4K);
  711. cfgchip = da8xx_get_cfgchip();
  712. da850_pll0_init(NULL, pll0, cfgchip);
  713. clk = clk_get(NULL, "timer0");
  714. davinci_timer_init(clk);
  715. }
  716. static struct resource da850_pll1_resources[] = {
  717. {
  718. .start = DA850_PLL1_BASE,
  719. .end = DA850_PLL1_BASE + SZ_4K - 1,
  720. .flags = IORESOURCE_MEM,
  721. },
  722. };
  723. static struct davinci_pll_platform_data da850_pll1_pdata;
  724. static struct platform_device da850_pll1_device = {
  725. .name = "da850-pll1",
  726. .id = -1,
  727. .resource = da850_pll1_resources,
  728. .num_resources = ARRAY_SIZE(da850_pll1_resources),
  729. .dev = {
  730. .platform_data = &da850_pll1_pdata,
  731. },
  732. };
  733. static struct resource da850_psc0_resources[] = {
  734. {
  735. .start = DA8XX_PSC0_BASE,
  736. .end = DA8XX_PSC0_BASE + SZ_4K - 1,
  737. .flags = IORESOURCE_MEM,
  738. },
  739. };
  740. static struct platform_device da850_psc0_device = {
  741. .name = "da850-psc0",
  742. .id = -1,
  743. .resource = da850_psc0_resources,
  744. .num_resources = ARRAY_SIZE(da850_psc0_resources),
  745. };
  746. static struct resource da850_psc1_resources[] = {
  747. {
  748. .start = DA8XX_PSC1_BASE,
  749. .end = DA8XX_PSC1_BASE + SZ_4K - 1,
  750. .flags = IORESOURCE_MEM,
  751. },
  752. };
  753. static struct platform_device da850_psc1_device = {
  754. .name = "da850-psc1",
  755. .id = -1,
  756. .resource = da850_psc1_resources,
  757. .num_resources = ARRAY_SIZE(da850_psc1_resources),
  758. };
  759. static struct da8xx_cfgchip_clk_platform_data da850_async1_pdata;
  760. static struct platform_device da850_async1_clksrc_device = {
  761. .name = "da850-async1-clksrc",
  762. .id = -1,
  763. .dev = {
  764. .platform_data = &da850_async1_pdata,
  765. },
  766. };
  767. static struct da8xx_cfgchip_clk_platform_data da850_async3_pdata;
  768. static struct platform_device da850_async3_clksrc_device = {
  769. .name = "da850-async3-clksrc",
  770. .id = -1,
  771. .dev = {
  772. .platform_data = &da850_async3_pdata,
  773. },
  774. };
  775. static struct da8xx_cfgchip_clk_platform_data da850_tbclksync_pdata;
  776. static struct platform_device da850_tbclksync_device = {
  777. .name = "da830-tbclksync",
  778. .id = -1,
  779. .dev = {
  780. .platform_data = &da850_tbclksync_pdata,
  781. },
  782. };
  783. void __init da850_register_clocks(void)
  784. {
  785. /* PLL0 is registered in da850_init_time() */
  786. da850_pll1_pdata.cfgchip = da8xx_get_cfgchip();
  787. platform_device_register(&da850_pll1_device);
  788. da850_async1_pdata.cfgchip = da8xx_get_cfgchip();
  789. platform_device_register(&da850_async1_clksrc_device);
  790. da850_async3_pdata.cfgchip = da8xx_get_cfgchip();
  791. platform_device_register(&da850_async3_clksrc_device);
  792. platform_device_register(&da850_psc0_device);
  793. platform_device_register(&da850_psc1_device);
  794. da850_tbclksync_pdata.cfgchip = da8xx_get_cfgchip();
  795. platform_device_register(&da850_tbclksync_device);
  796. }