io.c 8.1 KB

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