cpu.c 7.6 KB

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