cpu.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /* linux/arch/arm/mach-exynos/cpu.c
  2. *
  3. * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/sched.h>
  11. #include <linux/sysdev.h>
  12. #include <asm/mach/map.h>
  13. #include <asm/mach/irq.h>
  14. #include <asm/proc-fns.h>
  15. #include <asm/exception.h>
  16. #include <asm/hardware/cache-l2x0.h>
  17. #include <asm/hardware/gic.h>
  18. #include <plat/cpu.h>
  19. #include <plat/clock.h>
  20. #include <plat/devs.h>
  21. #include <plat/exynos4.h>
  22. #include <plat/adc-core.h>
  23. #include <plat/sdhci.h>
  24. #include <plat/fb-core.h>
  25. #include <plat/fimc-core.h>
  26. #include <plat/iic-core.h>
  27. #include <plat/reset.h>
  28. #include <plat/tv-core.h>
  29. #include <mach/regs-irq.h>
  30. #include <mach/regs-pmu.h>
  31. extern int combiner_init(unsigned int combiner_nr, void __iomem *base,
  32. unsigned int irq_start);
  33. extern void combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq);
  34. /* Initial IO mappings */
  35. static struct map_desc exynos_iodesc[] __initdata = {
  36. {
  37. .virtual = (unsigned long)S5P_VA_SYSTIMER,
  38. .pfn = __phys_to_pfn(EXYNOS_PA_SYSTIMER),
  39. .length = SZ_4K,
  40. .type = MT_DEVICE,
  41. }, {
  42. .virtual = (unsigned long)S5P_VA_PMU,
  43. .pfn = __phys_to_pfn(EXYNOS_PA_PMU),
  44. .length = SZ_64K,
  45. .type = MT_DEVICE,
  46. }, {
  47. .virtual = (unsigned long)S5P_VA_COMBINER_BASE,
  48. .pfn = __phys_to_pfn(EXYNOS_PA_COMBINER),
  49. .length = SZ_4K,
  50. .type = MT_DEVICE,
  51. }, {
  52. .virtual = (unsigned long)S5P_VA_GIC_CPU,
  53. .pfn = __phys_to_pfn(EXYNOS_PA_GIC_CPU),
  54. .length = SZ_64K,
  55. .type = MT_DEVICE,
  56. }, {
  57. .virtual = (unsigned long)S5P_VA_GIC_DIST,
  58. .pfn = __phys_to_pfn(EXYNOS_PA_GIC_DIST),
  59. .length = SZ_64K,
  60. .type = MT_DEVICE,
  61. }, {
  62. .virtual = (unsigned long)S3C_VA_UART,
  63. .pfn = __phys_to_pfn(S3C_PA_UART),
  64. .length = SZ_512K,
  65. .type = MT_DEVICE,
  66. },
  67. };
  68. static struct map_desc exynos4_iodesc[] __initdata = {
  69. {
  70. .virtual = (unsigned long)S5P_VA_CMU,
  71. .pfn = __phys_to_pfn(EXYNOS4_PA_CMU),
  72. .length = SZ_128K,
  73. .type = MT_DEVICE,
  74. }, {
  75. .virtual = (unsigned long)S5P_VA_COREPERI_BASE,
  76. .pfn = __phys_to_pfn(EXYNOS4_PA_COREPERI),
  77. .length = SZ_8K,
  78. .type = MT_DEVICE,
  79. }, {
  80. .virtual = (unsigned long)S5P_VA_L2CC,
  81. .pfn = __phys_to_pfn(EXYNOS4_PA_L2CC),
  82. .length = SZ_4K,
  83. .type = MT_DEVICE,
  84. }, {
  85. .virtual = (unsigned long)S5P_VA_GPIO1,
  86. .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO1),
  87. .length = SZ_4K,
  88. .type = MT_DEVICE,
  89. }, {
  90. .virtual = (unsigned long)S5P_VA_GPIO2,
  91. .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO2),
  92. .length = SZ_4K,
  93. .type = MT_DEVICE,
  94. }, {
  95. .virtual = (unsigned long)S5P_VA_GPIO3,
  96. .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO3),
  97. .length = SZ_256,
  98. .type = MT_DEVICE,
  99. }, {
  100. .virtual = (unsigned long)S5P_VA_DMC0,
  101. .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0),
  102. .length = SZ_4K,
  103. .type = MT_DEVICE,
  104. }, {
  105. .virtual = (unsigned long)S5P_VA_SROMC,
  106. .pfn = __phys_to_pfn(EXYNOS4_PA_SROMC),
  107. .length = SZ_4K,
  108. .type = MT_DEVICE,
  109. }, {
  110. .virtual = (unsigned long)S3C_VA_USB_HSPHY,
  111. .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY),
  112. .length = SZ_4K,
  113. .type = MT_DEVICE,
  114. },
  115. };
  116. static struct map_desc exynos4_iodesc0[] __initdata = {
  117. {
  118. .virtual = (unsigned long)S5P_VA_SYSRAM,
  119. .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM0),
  120. .length = SZ_4K,
  121. .type = MT_DEVICE,
  122. },
  123. };
  124. static struct map_desc exynos4_iodesc1[] __initdata = {
  125. {
  126. .virtual = (unsigned long)S5P_VA_SYSRAM,
  127. .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM1),
  128. .length = SZ_4K,
  129. .type = MT_DEVICE,
  130. },
  131. };
  132. static void exynos_idle(void)
  133. {
  134. if (!need_resched())
  135. cpu_do_idle();
  136. local_irq_enable();
  137. }
  138. static void exynos4_sw_reset(void)
  139. {
  140. __raw_writel(0x1, S5P_SWRESET);
  141. }
  142. /*
  143. * exynos_map_io
  144. *
  145. * register the standard cpu IO areas
  146. */
  147. void __init exynos4_map_io(void)
  148. {
  149. iotable_init(exynos_iodesc, ARRAY_SIZE(exynos_iodesc));
  150. iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
  151. if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_0)
  152. iotable_init(exynos4_iodesc0, ARRAY_SIZE(exynos4_iodesc0));
  153. else
  154. iotable_init(exynos4_iodesc1, ARRAY_SIZE(exynos4_iodesc1));
  155. /* initialize device information early */
  156. exynos4_default_sdhci0();
  157. exynos4_default_sdhci1();
  158. exynos4_default_sdhci2();
  159. exynos4_default_sdhci3();
  160. s3c_adc_setname("samsung-adc-v3");
  161. s3c_fimc_setname(0, "exynos4-fimc");
  162. s3c_fimc_setname(1, "exynos4-fimc");
  163. s3c_fimc_setname(2, "exynos4-fimc");
  164. s3c_fimc_setname(3, "exynos4-fimc");
  165. /* The I2C bus controllers are directly compatible with s3c2440 */
  166. s3c_i2c0_setname("s3c2440-i2c");
  167. s3c_i2c1_setname("s3c2440-i2c");
  168. s3c_i2c2_setname("s3c2440-i2c");
  169. s5p_fb_setname(0, "exynos4-fb");
  170. s5p_hdmi_setname("exynos4-hdmi");
  171. }
  172. void __init exynos4_init_clocks(int xtal)
  173. {
  174. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  175. s3c24xx_register_baseclocks(xtal);
  176. s5p_register_clocks(xtal);
  177. if (soc_is_exynos4210())
  178. exynos4210_register_clocks();
  179. else if (soc_is_exynos4212() || soc_is_exynos4412())
  180. exynos4212_register_clocks();
  181. exynos4_register_clocks();
  182. exynos4_setup_clocks();
  183. }
  184. void __init exynos4_init_irq(void)
  185. {
  186. int irq;
  187. unsigned int gic_bank_offset;
  188. gic_bank_offset = soc_is_exynos4412() ? 0x4000 : 0x8000;
  189. gic_init_bases(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU, gic_bank_offset);
  190. for (irq = 0; irq < MAX_COMBINER_NR; irq++) {
  191. combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
  192. COMBINER_IRQ(irq, 0));
  193. combiner_cascade_irq(irq, IRQ_SPI(irq));
  194. }
  195. /* The parameters of s5p_init_irq() are for VIC init.
  196. * Theses parameters should be NULL and 0 because EXYNOS4
  197. * uses GIC instead of VIC.
  198. */
  199. s5p_init_irq(NULL, 0);
  200. }
  201. struct sysdev_class exynos4_sysclass = {
  202. .name = "exynos4-core",
  203. };
  204. static struct sys_device exynos4_sysdev = {
  205. .cls = &exynos4_sysclass,
  206. };
  207. static int __init exynos4_core_init(void)
  208. {
  209. return sysdev_class_register(&exynos4_sysclass);
  210. }
  211. core_initcall(exynos4_core_init);
  212. #ifdef CONFIG_CACHE_L2X0
  213. static int __init exynos4_l2x0_cache_init(void)
  214. {
  215. /* TAG, Data Latency Control: 2cycle */
  216. __raw_writel(0x110, S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL);
  217. if (soc_is_exynos4210())
  218. __raw_writel(0x110, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
  219. else if (soc_is_exynos4212() || soc_is_exynos4412())
  220. __raw_writel(0x120, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
  221. /* L2X0 Prefetch Control */
  222. __raw_writel(0x30000007, S5P_VA_L2CC + L2X0_PREFETCH_CTRL);
  223. /* L2X0 Power Control */
  224. __raw_writel(L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN,
  225. S5P_VA_L2CC + L2X0_POWER_CTRL);
  226. l2x0_init(S5P_VA_L2CC, 0x7C470001, 0xC200ffff);
  227. return 0;
  228. }
  229. early_initcall(exynos4_l2x0_cache_init);
  230. #endif
  231. int __init exynos_init(void)
  232. {
  233. printk(KERN_INFO "EXYNOS: Initializing architecture\n");
  234. /* set idle function */
  235. pm_idle = exynos_idle;
  236. /* set sw_reset function */
  237. if (soc_is_exynos4210() || soc_is_exynos4212() || soc_is_exynos4412())
  238. s5p_reset_hook = exynos4_sw_reset;
  239. return sysdev_register(&exynos4_sysdev);
  240. }