io.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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/mux.h>
  28. #include <plat/sram.h>
  29. #include <plat/sdrc.h>
  30. #include <plat/gpmc.h>
  31. #include <plat/serial.h>
  32. #include <plat/vram.h>
  33. #include "clock.h"
  34. #include <plat/omap-pm.h>
  35. #include <plat/powerdomain.h>
  36. #include "powerdomains.h"
  37. #include <plat/clockdomain.h>
  38. #include "clockdomains.h"
  39. #include <plat/omap_hwmod.h>
  40. #include "omap_hwmod_2420.h"
  41. #include "omap_hwmod_2430.h"
  42. #include "omap_hwmod_34xx.h"
  43. /*
  44. * The machine specific code may provide the extra mapping besides the
  45. * default mapping provided here.
  46. */
  47. #ifdef CONFIG_ARCH_OMAP24XX
  48. static struct map_desc omap24xx_io_desc[] __initdata = {
  49. {
  50. .virtual = L3_24XX_VIRT,
  51. .pfn = __phys_to_pfn(L3_24XX_PHYS),
  52. .length = L3_24XX_SIZE,
  53. .type = MT_DEVICE
  54. },
  55. {
  56. .virtual = L4_24XX_VIRT,
  57. .pfn = __phys_to_pfn(L4_24XX_PHYS),
  58. .length = L4_24XX_SIZE,
  59. .type = MT_DEVICE
  60. },
  61. };
  62. #ifdef CONFIG_ARCH_OMAP2420
  63. static struct map_desc omap242x_io_desc[] __initdata = {
  64. {
  65. .virtual = DSP_MEM_2420_VIRT,
  66. .pfn = __phys_to_pfn(DSP_MEM_2420_PHYS),
  67. .length = DSP_MEM_2420_SIZE,
  68. .type = MT_DEVICE
  69. },
  70. {
  71. .virtual = DSP_IPI_2420_VIRT,
  72. .pfn = __phys_to_pfn(DSP_IPI_2420_PHYS),
  73. .length = DSP_IPI_2420_SIZE,
  74. .type = MT_DEVICE
  75. },
  76. {
  77. .virtual = DSP_MMU_2420_VIRT,
  78. .pfn = __phys_to_pfn(DSP_MMU_2420_PHYS),
  79. .length = DSP_MMU_2420_SIZE,
  80. .type = MT_DEVICE
  81. },
  82. };
  83. #endif
  84. #ifdef CONFIG_ARCH_OMAP2430
  85. static struct map_desc omap243x_io_desc[] __initdata = {
  86. {
  87. .virtual = L4_WK_243X_VIRT,
  88. .pfn = __phys_to_pfn(L4_WK_243X_PHYS),
  89. .length = L4_WK_243X_SIZE,
  90. .type = MT_DEVICE
  91. },
  92. {
  93. .virtual = OMAP243X_GPMC_VIRT,
  94. .pfn = __phys_to_pfn(OMAP243X_GPMC_PHYS),
  95. .length = OMAP243X_GPMC_SIZE,
  96. .type = MT_DEVICE
  97. },
  98. {
  99. .virtual = OMAP243X_SDRC_VIRT,
  100. .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS),
  101. .length = OMAP243X_SDRC_SIZE,
  102. .type = MT_DEVICE
  103. },
  104. {
  105. .virtual = OMAP243X_SMS_VIRT,
  106. .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS),
  107. .length = OMAP243X_SMS_SIZE,
  108. .type = MT_DEVICE
  109. },
  110. };
  111. #endif
  112. #endif
  113. #ifdef CONFIG_ARCH_OMAP34XX
  114. static struct map_desc omap34xx_io_desc[] __initdata = {
  115. {
  116. .virtual = L3_34XX_VIRT,
  117. .pfn = __phys_to_pfn(L3_34XX_PHYS),
  118. .length = L3_34XX_SIZE,
  119. .type = MT_DEVICE
  120. },
  121. {
  122. .virtual = L4_34XX_VIRT,
  123. .pfn = __phys_to_pfn(L4_34XX_PHYS),
  124. .length = L4_34XX_SIZE,
  125. .type = MT_DEVICE
  126. },
  127. {
  128. .virtual = L4_WK_34XX_VIRT,
  129. .pfn = __phys_to_pfn(L4_WK_34XX_PHYS),
  130. .length = L4_WK_34XX_SIZE,
  131. .type = MT_DEVICE
  132. },
  133. {
  134. .virtual = OMAP34XX_GPMC_VIRT,
  135. .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS),
  136. .length = OMAP34XX_GPMC_SIZE,
  137. .type = MT_DEVICE
  138. },
  139. {
  140. .virtual = OMAP343X_SMS_VIRT,
  141. .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS),
  142. .length = OMAP343X_SMS_SIZE,
  143. .type = MT_DEVICE
  144. },
  145. {
  146. .virtual = OMAP343X_SDRC_VIRT,
  147. .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS),
  148. .length = OMAP343X_SDRC_SIZE,
  149. .type = MT_DEVICE
  150. },
  151. {
  152. .virtual = L4_PER_34XX_VIRT,
  153. .pfn = __phys_to_pfn(L4_PER_34XX_PHYS),
  154. .length = L4_PER_34XX_SIZE,
  155. .type = MT_DEVICE
  156. },
  157. {
  158. .virtual = L4_EMU_34XX_VIRT,
  159. .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS),
  160. .length = L4_EMU_34XX_SIZE,
  161. .type = MT_DEVICE
  162. },
  163. };
  164. #endif
  165. #ifdef CONFIG_ARCH_OMAP4
  166. static struct map_desc omap44xx_io_desc[] __initdata = {
  167. {
  168. .virtual = L3_44XX_VIRT,
  169. .pfn = __phys_to_pfn(L3_44XX_PHYS),
  170. .length = L3_44XX_SIZE,
  171. .type = MT_DEVICE,
  172. },
  173. {
  174. .virtual = L4_44XX_VIRT,
  175. .pfn = __phys_to_pfn(L4_44XX_PHYS),
  176. .length = L4_44XX_SIZE,
  177. .type = MT_DEVICE,
  178. },
  179. {
  180. .virtual = L4_WK_44XX_VIRT,
  181. .pfn = __phys_to_pfn(L4_WK_44XX_PHYS),
  182. .length = L4_WK_44XX_SIZE,
  183. .type = MT_DEVICE,
  184. },
  185. {
  186. .virtual = OMAP44XX_GPMC_VIRT,
  187. .pfn = __phys_to_pfn(OMAP44XX_GPMC_PHYS),
  188. .length = OMAP44XX_GPMC_SIZE,
  189. .type = MT_DEVICE,
  190. },
  191. {
  192. .virtual = OMAP44XX_EMIF1_VIRT,
  193. .pfn = __phys_to_pfn(OMAP44XX_EMIF1_PHYS),
  194. .length = OMAP44XX_EMIF1_SIZE,
  195. .type = MT_DEVICE,
  196. },
  197. {
  198. .virtual = OMAP44XX_EMIF2_VIRT,
  199. .pfn = __phys_to_pfn(OMAP44XX_EMIF2_PHYS),
  200. .length = OMAP44XX_EMIF2_SIZE,
  201. .type = MT_DEVICE,
  202. },
  203. {
  204. .virtual = OMAP44XX_DMM_VIRT,
  205. .pfn = __phys_to_pfn(OMAP44XX_DMM_PHYS),
  206. .length = OMAP44XX_DMM_SIZE,
  207. .type = MT_DEVICE,
  208. },
  209. {
  210. .virtual = L4_PER_44XX_VIRT,
  211. .pfn = __phys_to_pfn(L4_PER_44XX_PHYS),
  212. .length = L4_PER_44XX_SIZE,
  213. .type = MT_DEVICE,
  214. },
  215. {
  216. .virtual = L4_EMU_44XX_VIRT,
  217. .pfn = __phys_to_pfn(L4_EMU_44XX_PHYS),
  218. .length = L4_EMU_44XX_SIZE,
  219. .type = MT_DEVICE,
  220. },
  221. };
  222. #endif
  223. void __init omap2_map_common_io(void)
  224. {
  225. #if defined(CONFIG_ARCH_OMAP2420)
  226. iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
  227. iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
  228. #endif
  229. #if defined(CONFIG_ARCH_OMAP2430)
  230. iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
  231. iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
  232. #endif
  233. #if defined(CONFIG_ARCH_OMAP34XX)
  234. iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
  235. #endif
  236. #if defined(CONFIG_ARCH_OMAP4)
  237. iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
  238. #endif
  239. /* Normally devicemaps_init() would flush caches and tlb after
  240. * mdesc->map_io(), but we must also do it here because of the CPU
  241. * revision check below.
  242. */
  243. local_flush_tlb_all();
  244. flush_cache_all();
  245. omap2_check_revision();
  246. omap_sram_init();
  247. omapfb_reserve_sdram();
  248. omap_vram_reserve_sdram();
  249. }
  250. /*
  251. * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
  252. *
  253. * Sets the CORE DPLL3 M2 divider to the same value that it's at
  254. * currently. This has the effect of setting the SDRC SDRAM AC timing
  255. * registers to the values currently defined by the kernel. Currently
  256. * only defined for OMAP3; will return 0 if called on OMAP2. Returns
  257. * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2,
  258. * or passes along the return value of clk_set_rate().
  259. */
  260. static int __init _omap2_init_reprogram_sdrc(void)
  261. {
  262. struct clk *dpll3_m2_ck;
  263. int v = -EINVAL;
  264. long rate;
  265. if (!cpu_is_omap34xx())
  266. return 0;
  267. dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
  268. if (!dpll3_m2_ck)
  269. return -EINVAL;
  270. rate = clk_get_rate(dpll3_m2_ck);
  271. pr_info("Reprogramming SDRC clock to %ld Hz\n", rate);
  272. v = clk_set_rate(dpll3_m2_ck, rate);
  273. if (v)
  274. pr_err("dpll3_m2_clk rate change failed: %d\n", v);
  275. clk_put(dpll3_m2_ck);
  276. return v;
  277. }
  278. void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
  279. struct omap_sdrc_params *sdrc_cs1)
  280. {
  281. struct omap_hwmod **hwmods = NULL;
  282. if (cpu_is_omap2420())
  283. hwmods = omap2420_hwmods;
  284. else if (cpu_is_omap2430())
  285. hwmods = omap2430_hwmods;
  286. else if (cpu_is_omap34xx())
  287. hwmods = omap34xx_hwmods;
  288. #ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once the clkdev is ready */
  289. /* The OPP tables have to be registered before a clk init */
  290. omap_hwmod_init(hwmods);
  291. omap2_mux_init();
  292. omap_pm_if_early_init(mpu_opps, dsp_opps, l3_opps);
  293. pwrdm_init(powerdomains_omap);
  294. clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps);
  295. #endif
  296. omap2_clk_init();
  297. omap_serial_early_init();
  298. #ifndef CONFIG_ARCH_OMAP4
  299. omap_hwmod_late_init();
  300. omap_pm_if_init();
  301. omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
  302. _omap2_init_reprogram_sdrc();
  303. #endif
  304. gpmc_init();
  305. }