io.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /*
  2. * linux/arch/arm/mach-omap2/io.c
  3. *
  4. * OMAP2 I/O mapping code
  5. *
  6. * Copyright (C) 2005 Nokia Corporation
  7. * Copyright (C) 2007-2009 Texas Instruments
  8. *
  9. * Author:
  10. * Juha Yrjola <juha.yrjola@nokia.com>
  11. * Syed Khasim <x0khasim@ti.com>
  12. *
  13. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License version 2 as
  17. * published by the Free Software Foundation.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/io.h>
  23. #include <linux/clk.h>
  24. #include <linux/omapfb.h>
  25. #include <asm/tlb.h>
  26. #include <asm/mach/map.h>
  27. #include <plat/sram.h>
  28. #include <plat/sdrc.h>
  29. #include <plat/gpmc.h>
  30. #include <plat/serial.h>
  31. #include "clock2xxx.h"
  32. #include "clock3xxx.h"
  33. #include "clock44xx.h"
  34. #include "io.h"
  35. #include <plat/omap-pm.h>
  36. #include <plat/powerdomain.h>
  37. #include "powerdomains.h"
  38. #include <plat/clockdomain.h>
  39. #include "clockdomains.h"
  40. #include <plat/omap_hwmod.h>
  41. /*
  42. * The machine specific code may provide the extra mapping besides the
  43. * default mapping provided here.
  44. */
  45. #ifdef CONFIG_ARCH_OMAP2
  46. static struct map_desc omap24xx_io_desc[] __initdata = {
  47. {
  48. .virtual = L3_24XX_VIRT,
  49. .pfn = __phys_to_pfn(L3_24XX_PHYS),
  50. .length = L3_24XX_SIZE,
  51. .type = MT_DEVICE
  52. },
  53. {
  54. .virtual = L4_24XX_VIRT,
  55. .pfn = __phys_to_pfn(L4_24XX_PHYS),
  56. .length = L4_24XX_SIZE,
  57. .type = MT_DEVICE
  58. },
  59. };
  60. #ifdef CONFIG_ARCH_OMAP2420
  61. static struct map_desc omap242x_io_desc[] __initdata = {
  62. {
  63. .virtual = DSP_MEM_2420_VIRT,
  64. .pfn = __phys_to_pfn(DSP_MEM_2420_PHYS),
  65. .length = DSP_MEM_2420_SIZE,
  66. .type = MT_DEVICE
  67. },
  68. {
  69. .virtual = DSP_IPI_2420_VIRT,
  70. .pfn = __phys_to_pfn(DSP_IPI_2420_PHYS),
  71. .length = DSP_IPI_2420_SIZE,
  72. .type = MT_DEVICE
  73. },
  74. {
  75. .virtual = DSP_MMU_2420_VIRT,
  76. .pfn = __phys_to_pfn(DSP_MMU_2420_PHYS),
  77. .length = DSP_MMU_2420_SIZE,
  78. .type = MT_DEVICE
  79. },
  80. };
  81. #endif
  82. #ifdef CONFIG_ARCH_OMAP2430
  83. static struct map_desc omap243x_io_desc[] __initdata = {
  84. {
  85. .virtual = L4_WK_243X_VIRT,
  86. .pfn = __phys_to_pfn(L4_WK_243X_PHYS),
  87. .length = L4_WK_243X_SIZE,
  88. .type = MT_DEVICE
  89. },
  90. {
  91. .virtual = OMAP243X_GPMC_VIRT,
  92. .pfn = __phys_to_pfn(OMAP243X_GPMC_PHYS),
  93. .length = OMAP243X_GPMC_SIZE,
  94. .type = MT_DEVICE
  95. },
  96. {
  97. .virtual = OMAP243X_SDRC_VIRT,
  98. .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS),
  99. .length = OMAP243X_SDRC_SIZE,
  100. .type = MT_DEVICE
  101. },
  102. {
  103. .virtual = OMAP243X_SMS_VIRT,
  104. .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS),
  105. .length = OMAP243X_SMS_SIZE,
  106. .type = MT_DEVICE
  107. },
  108. };
  109. #endif
  110. #endif
  111. #ifdef CONFIG_ARCH_OMAP3
  112. static struct map_desc omap34xx_io_desc[] __initdata = {
  113. {
  114. .virtual = L3_34XX_VIRT,
  115. .pfn = __phys_to_pfn(L3_34XX_PHYS),
  116. .length = L3_34XX_SIZE,
  117. .type = MT_DEVICE
  118. },
  119. {
  120. .virtual = L4_34XX_VIRT,
  121. .pfn = __phys_to_pfn(L4_34XX_PHYS),
  122. .length = L4_34XX_SIZE,
  123. .type = MT_DEVICE
  124. },
  125. {
  126. .virtual = OMAP34XX_GPMC_VIRT,
  127. .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS),
  128. .length = OMAP34XX_GPMC_SIZE,
  129. .type = MT_DEVICE
  130. },
  131. {
  132. .virtual = OMAP343X_SMS_VIRT,
  133. .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS),
  134. .length = OMAP343X_SMS_SIZE,
  135. .type = MT_DEVICE
  136. },
  137. {
  138. .virtual = OMAP343X_SDRC_VIRT,
  139. .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS),
  140. .length = OMAP343X_SDRC_SIZE,
  141. .type = MT_DEVICE
  142. },
  143. {
  144. .virtual = L4_PER_34XX_VIRT,
  145. .pfn = __phys_to_pfn(L4_PER_34XX_PHYS),
  146. .length = L4_PER_34XX_SIZE,
  147. .type = MT_DEVICE
  148. },
  149. {
  150. .virtual = L4_EMU_34XX_VIRT,
  151. .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS),
  152. .length = L4_EMU_34XX_SIZE,
  153. .type = MT_DEVICE
  154. },
  155. #if defined(CONFIG_DEBUG_LL) && \
  156. (defined(CONFIG_MACH_OMAP_ZOOM2) || defined(CONFIG_MACH_OMAP_ZOOM3))
  157. {
  158. .virtual = ZOOM_UART_VIRT,
  159. .pfn = __phys_to_pfn(ZOOM_UART_BASE),
  160. .length = SZ_1M,
  161. .type = MT_DEVICE
  162. },
  163. #endif
  164. };
  165. #endif
  166. #ifdef CONFIG_ARCH_OMAP4
  167. static struct map_desc omap44xx_io_desc[] __initdata = {
  168. {
  169. .virtual = L3_44XX_VIRT,
  170. .pfn = __phys_to_pfn(L3_44XX_PHYS),
  171. .length = L3_44XX_SIZE,
  172. .type = MT_DEVICE,
  173. },
  174. {
  175. .virtual = L4_44XX_VIRT,
  176. .pfn = __phys_to_pfn(L4_44XX_PHYS),
  177. .length = L4_44XX_SIZE,
  178. .type = MT_DEVICE,
  179. },
  180. {
  181. .virtual = OMAP44XX_GPMC_VIRT,
  182. .pfn = __phys_to_pfn(OMAP44XX_GPMC_PHYS),
  183. .length = OMAP44XX_GPMC_SIZE,
  184. .type = MT_DEVICE,
  185. },
  186. {
  187. .virtual = OMAP44XX_EMIF1_VIRT,
  188. .pfn = __phys_to_pfn(OMAP44XX_EMIF1_PHYS),
  189. .length = OMAP44XX_EMIF1_SIZE,
  190. .type = MT_DEVICE,
  191. },
  192. {
  193. .virtual = OMAP44XX_EMIF2_VIRT,
  194. .pfn = __phys_to_pfn(OMAP44XX_EMIF2_PHYS),
  195. .length = OMAP44XX_EMIF2_SIZE,
  196. .type = MT_DEVICE,
  197. },
  198. {
  199. .virtual = OMAP44XX_DMM_VIRT,
  200. .pfn = __phys_to_pfn(OMAP44XX_DMM_PHYS),
  201. .length = OMAP44XX_DMM_SIZE,
  202. .type = MT_DEVICE,
  203. },
  204. {
  205. .virtual = L4_PER_44XX_VIRT,
  206. .pfn = __phys_to_pfn(L4_PER_44XX_PHYS),
  207. .length = L4_PER_44XX_SIZE,
  208. .type = MT_DEVICE,
  209. },
  210. {
  211. .virtual = L4_EMU_44XX_VIRT,
  212. .pfn = __phys_to_pfn(L4_EMU_44XX_PHYS),
  213. .length = L4_EMU_44XX_SIZE,
  214. .type = MT_DEVICE,
  215. },
  216. };
  217. #endif
  218. static void __init _omap2_map_common_io(void)
  219. {
  220. /* Normally devicemaps_init() would flush caches and tlb after
  221. * mdesc->map_io(), but we must also do it here because of the CPU
  222. * revision check below.
  223. */
  224. local_flush_tlb_all();
  225. flush_cache_all();
  226. omap2_check_revision();
  227. omap_sram_init();
  228. }
  229. #ifdef CONFIG_ARCH_OMAP2420
  230. void __init omap242x_map_common_io(void)
  231. {
  232. iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
  233. iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
  234. _omap2_map_common_io();
  235. }
  236. #endif
  237. #ifdef CONFIG_ARCH_OMAP2430
  238. void __init omap243x_map_common_io(void)
  239. {
  240. iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
  241. iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
  242. _omap2_map_common_io();
  243. }
  244. #endif
  245. #ifdef CONFIG_ARCH_OMAP3
  246. void __init omap34xx_map_common_io(void)
  247. {
  248. iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
  249. _omap2_map_common_io();
  250. }
  251. #endif
  252. #ifdef CONFIG_ARCH_OMAP4
  253. void __init omap44xx_map_common_io(void)
  254. {
  255. iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
  256. _omap2_map_common_io();
  257. }
  258. #endif
  259. /*
  260. * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
  261. *
  262. * Sets the CORE DPLL3 M2 divider to the same value that it's at
  263. * currently. This has the effect of setting the SDRC SDRAM AC timing
  264. * registers to the values currently defined by the kernel. Currently
  265. * only defined for OMAP3; will return 0 if called on OMAP2. Returns
  266. * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2,
  267. * or passes along the return value of clk_set_rate().
  268. */
  269. static int __init _omap2_init_reprogram_sdrc(void)
  270. {
  271. struct clk *dpll3_m2_ck;
  272. int v = -EINVAL;
  273. long rate;
  274. if (!cpu_is_omap34xx())
  275. return 0;
  276. dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
  277. if (!dpll3_m2_ck)
  278. return -EINVAL;
  279. rate = clk_get_rate(dpll3_m2_ck);
  280. pr_info("Reprogramming SDRC clock to %ld Hz\n", rate);
  281. v = clk_set_rate(dpll3_m2_ck, rate);
  282. if (v)
  283. pr_err("dpll3_m2_clk rate change failed: %d\n", v);
  284. clk_put(dpll3_m2_ck);
  285. return v;
  286. }
  287. void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
  288. struct omap_sdrc_params *sdrc_cs1)
  289. {
  290. u8 skip_setup_idle = 0;
  291. pwrdm_init(powerdomains_omap);
  292. clkdm_init(clockdomains_omap, clkdm_autodeps);
  293. if (cpu_is_omap242x())
  294. omap2420_hwmod_init();
  295. else if (cpu_is_omap243x())
  296. omap2430_hwmod_init();
  297. else if (cpu_is_omap34xx())
  298. omap3xxx_hwmod_init();
  299. else if (cpu_is_omap44xx())
  300. omap44xx_hwmod_init();
  301. /* The OPP tables have to be registered before a clk init */
  302. omap_pm_if_early_init(mpu_opps, dsp_opps, l3_opps);
  303. if (cpu_is_omap2420())
  304. omap2420_clk_init();
  305. else if (cpu_is_omap2430())
  306. omap2430_clk_init();
  307. else if (cpu_is_omap34xx())
  308. omap3xxx_clk_init();
  309. else if (cpu_is_omap44xx())
  310. omap4xxx_clk_init();
  311. else
  312. pr_err("Could not init clock framework - unknown CPU\n");
  313. omap_serial_early_init();
  314. #ifndef CONFIG_PM_RUNTIME
  315. skip_setup_idle = 1;
  316. #endif
  317. omap_hwmod_late_init(skip_setup_idle);
  318. if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
  319. omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
  320. _omap2_init_reprogram_sdrc();
  321. }
  322. gpmc_init();
  323. }