io.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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 <asm/tlb.h>
  25. #include <asm/mach/map.h>
  26. #include <mach/mux.h>
  27. #include <mach/omapfb.h>
  28. #include <mach/sram.h>
  29. #include <mach/sdrc.h>
  30. #include <mach/gpmc.h>
  31. #ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once clkdev is ready */
  32. #include "clock.h"
  33. #include <mach/powerdomain.h>
  34. #include "powerdomains.h"
  35. #include <mach/clockdomain.h>
  36. #include "clockdomains.h"
  37. #endif
  38. /*
  39. * The machine specific code may provide the extra mapping besides the
  40. * default mapping provided here.
  41. */
  42. #ifdef CONFIG_ARCH_OMAP24XX
  43. static struct map_desc omap24xx_io_desc[] __initdata = {
  44. {
  45. .virtual = L3_24XX_VIRT,
  46. .pfn = __phys_to_pfn(L3_24XX_PHYS),
  47. .length = L3_24XX_SIZE,
  48. .type = MT_DEVICE
  49. },
  50. {
  51. .virtual = L4_24XX_VIRT,
  52. .pfn = __phys_to_pfn(L4_24XX_PHYS),
  53. .length = L4_24XX_SIZE,
  54. .type = MT_DEVICE
  55. },
  56. };
  57. #ifdef CONFIG_ARCH_OMAP2420
  58. static struct map_desc omap242x_io_desc[] __initdata = {
  59. {
  60. .virtual = DSP_MEM_24XX_VIRT,
  61. .pfn = __phys_to_pfn(DSP_MEM_24XX_PHYS),
  62. .length = DSP_MEM_24XX_SIZE,
  63. .type = MT_DEVICE
  64. },
  65. {
  66. .virtual = DSP_IPI_24XX_VIRT,
  67. .pfn = __phys_to_pfn(DSP_IPI_24XX_PHYS),
  68. .length = DSP_IPI_24XX_SIZE,
  69. .type = MT_DEVICE
  70. },
  71. {
  72. .virtual = DSP_MMU_24XX_VIRT,
  73. .pfn = __phys_to_pfn(DSP_MMU_24XX_PHYS),
  74. .length = DSP_MMU_24XX_SIZE,
  75. .type = MT_DEVICE
  76. },
  77. };
  78. #endif
  79. #ifdef CONFIG_ARCH_OMAP2430
  80. static struct map_desc omap243x_io_desc[] __initdata = {
  81. {
  82. .virtual = L4_WK_243X_VIRT,
  83. .pfn = __phys_to_pfn(L4_WK_243X_PHYS),
  84. .length = L4_WK_243X_SIZE,
  85. .type = MT_DEVICE
  86. },
  87. {
  88. .virtual = OMAP243X_GPMC_VIRT,
  89. .pfn = __phys_to_pfn(OMAP243X_GPMC_PHYS),
  90. .length = OMAP243X_GPMC_SIZE,
  91. .type = MT_DEVICE
  92. },
  93. {
  94. .virtual = OMAP243X_SDRC_VIRT,
  95. .pfn = __phys_to_pfn(OMAP243X_SDRC_PHYS),
  96. .length = OMAP243X_SDRC_SIZE,
  97. .type = MT_DEVICE
  98. },
  99. {
  100. .virtual = OMAP243X_SMS_VIRT,
  101. .pfn = __phys_to_pfn(OMAP243X_SMS_PHYS),
  102. .length = OMAP243X_SMS_SIZE,
  103. .type = MT_DEVICE
  104. },
  105. };
  106. #endif
  107. #endif
  108. #ifdef CONFIG_ARCH_OMAP34XX
  109. static struct map_desc omap34xx_io_desc[] __initdata = {
  110. {
  111. .virtual = L3_34XX_VIRT,
  112. .pfn = __phys_to_pfn(L3_34XX_PHYS),
  113. .length = L3_34XX_SIZE,
  114. .type = MT_DEVICE
  115. },
  116. {
  117. .virtual = L4_34XX_VIRT,
  118. .pfn = __phys_to_pfn(L4_34XX_PHYS),
  119. .length = L4_34XX_SIZE,
  120. .type = MT_DEVICE
  121. },
  122. {
  123. .virtual = L4_WK_34XX_VIRT,
  124. .pfn = __phys_to_pfn(L4_WK_34XX_PHYS),
  125. .length = L4_WK_34XX_SIZE,
  126. .type = MT_DEVICE
  127. },
  128. {
  129. .virtual = OMAP34XX_GPMC_VIRT,
  130. .pfn = __phys_to_pfn(OMAP34XX_GPMC_PHYS),
  131. .length = OMAP34XX_GPMC_SIZE,
  132. .type = MT_DEVICE
  133. },
  134. {
  135. .virtual = OMAP343X_SMS_VIRT,
  136. .pfn = __phys_to_pfn(OMAP343X_SMS_PHYS),
  137. .length = OMAP343X_SMS_SIZE,
  138. .type = MT_DEVICE
  139. },
  140. {
  141. .virtual = OMAP343X_SDRC_VIRT,
  142. .pfn = __phys_to_pfn(OMAP343X_SDRC_PHYS),
  143. .length = OMAP343X_SDRC_SIZE,
  144. .type = MT_DEVICE
  145. },
  146. {
  147. .virtual = L4_PER_34XX_VIRT,
  148. .pfn = __phys_to_pfn(L4_PER_34XX_PHYS),
  149. .length = L4_PER_34XX_SIZE,
  150. .type = MT_DEVICE
  151. },
  152. {
  153. .virtual = L4_EMU_34XX_VIRT,
  154. .pfn = __phys_to_pfn(L4_EMU_34XX_PHYS),
  155. .length = L4_EMU_34XX_SIZE,
  156. .type = MT_DEVICE
  157. },
  158. };
  159. #endif
  160. #ifdef CONFIG_ARCH_OMAP4
  161. static struct map_desc omap44xx_io_desc[] __initdata = {
  162. {
  163. .virtual = L3_44XX_VIRT,
  164. .pfn = __phys_to_pfn(L3_44XX_PHYS),
  165. .length = L3_44XX_SIZE,
  166. .type = MT_DEVICE,
  167. },
  168. {
  169. .virtual = L4_44XX_VIRT,
  170. .pfn = __phys_to_pfn(L4_44XX_PHYS),
  171. .length = L4_44XX_SIZE,
  172. .type = MT_DEVICE,
  173. },
  174. {
  175. .virtual = L4_WK_44XX_VIRT,
  176. .pfn = __phys_to_pfn(L4_WK_44XX_PHYS),
  177. .length = L4_WK_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 = L4_PER_44XX_VIRT,
  188. .pfn = __phys_to_pfn(L4_PER_44XX_PHYS),
  189. .length = L4_PER_44XX_SIZE,
  190. .type = MT_DEVICE,
  191. },
  192. {
  193. .virtual = L4_EMU_44XX_VIRT,
  194. .pfn = __phys_to_pfn(L4_EMU_44XX_PHYS),
  195. .length = L4_EMU_44XX_SIZE,
  196. .type = MT_DEVICE,
  197. },
  198. };
  199. #endif
  200. void __init omap2_map_common_io(void)
  201. {
  202. #if defined(CONFIG_ARCH_OMAP2420)
  203. iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
  204. iotable_init(omap242x_io_desc, ARRAY_SIZE(omap242x_io_desc));
  205. #endif
  206. #if defined(CONFIG_ARCH_OMAP2430)
  207. iotable_init(omap24xx_io_desc, ARRAY_SIZE(omap24xx_io_desc));
  208. iotable_init(omap243x_io_desc, ARRAY_SIZE(omap243x_io_desc));
  209. #endif
  210. #if defined(CONFIG_ARCH_OMAP34XX)
  211. iotable_init(omap34xx_io_desc, ARRAY_SIZE(omap34xx_io_desc));
  212. #endif
  213. #if defined(CONFIG_ARCH_OMAP4)
  214. iotable_init(omap44xx_io_desc, ARRAY_SIZE(omap44xx_io_desc));
  215. #endif
  216. /* Normally devicemaps_init() would flush caches and tlb after
  217. * mdesc->map_io(), but we must also do it here because of the CPU
  218. * revision check below.
  219. */
  220. local_flush_tlb_all();
  221. flush_cache_all();
  222. omap2_check_revision();
  223. omap_sram_init();
  224. omapfb_reserve_sdram();
  225. }
  226. /*
  227. * omap2_init_reprogram_sdrc - reprogram SDRC timing parameters
  228. *
  229. * Sets the CORE DPLL3 M2 divider to the same value that it's at
  230. * currently. This has the effect of setting the SDRC SDRAM AC timing
  231. * registers to the values currently defined by the kernel. Currently
  232. * only defined for OMAP3; will return 0 if called on OMAP2. Returns
  233. * -EINVAL if the dpll3_m2_ck cannot be found, 0 if called on OMAP2,
  234. * or passes along the return value of clk_set_rate().
  235. */
  236. static int __init _omap2_init_reprogram_sdrc(void)
  237. {
  238. struct clk *dpll3_m2_ck;
  239. int v = -EINVAL;
  240. long rate;
  241. if (!cpu_is_omap34xx())
  242. return 0;
  243. dpll3_m2_ck = clk_get(NULL, "dpll3_m2_ck");
  244. if (!dpll3_m2_ck)
  245. return -EINVAL;
  246. rate = clk_get_rate(dpll3_m2_ck);
  247. pr_info("Reprogramming SDRC clock to %ld Hz\n", rate);
  248. v = clk_set_rate(dpll3_m2_ck, rate);
  249. if (v)
  250. pr_err("dpll3_m2_clk rate change failed: %d\n", v);
  251. clk_put(dpll3_m2_ck);
  252. return v;
  253. }
  254. void __init omap2_init_common_hw(struct omap_sdrc_params *sp)
  255. {
  256. omap2_mux_init();
  257. #ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once the clkdev is ready */
  258. pwrdm_init(powerdomains_omap);
  259. clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps);
  260. omap2_clk_init();
  261. omap2_sdrc_init(sp);
  262. _omap2_init_reprogram_sdrc();
  263. #endif
  264. gpmc_init();
  265. }