cpu.c 7.1 KB

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