cpu.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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/device.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 <plat/tv-core.h>
  28. #include <mach/regs-irq.h>
  29. #include <mach/regs-pmu.h>
  30. unsigned int gic_bank_offset __read_mostly;
  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)S3C_VA_USB_HSPHY,
  106. .pfn = __phys_to_pfn(EXYNOS4_PA_HSPHY),
  107. .length = SZ_4K,
  108. .type = MT_DEVICE,
  109. },
  110. };
  111. static struct map_desc exynos4_iodesc0[] __initdata = {
  112. {
  113. .virtual = (unsigned long)S5P_VA_SYSRAM,
  114. .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM0),
  115. .length = SZ_4K,
  116. .type = MT_DEVICE,
  117. },
  118. };
  119. static struct map_desc exynos4_iodesc1[] __initdata = {
  120. {
  121. .virtual = (unsigned long)S5P_VA_SYSRAM,
  122. .pfn = __phys_to_pfn(EXYNOS4_PA_SYSRAM1),
  123. .length = SZ_4K,
  124. .type = MT_DEVICE,
  125. },
  126. };
  127. static void exynos_idle(void)
  128. {
  129. if (!need_resched())
  130. cpu_do_idle();
  131. local_irq_enable();
  132. }
  133. static void exynos4_sw_reset(void)
  134. {
  135. __raw_writel(0x1, S5P_SWRESET);
  136. }
  137. /*
  138. * exynos_map_io
  139. *
  140. * register the standard cpu IO areas
  141. */
  142. void __init exynos4_map_io(void)
  143. {
  144. iotable_init(exynos_iodesc, ARRAY_SIZE(exynos_iodesc));
  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. s5p_hdmi_setname("exynos4-hdmi");
  166. }
  167. void __init exynos4_init_clocks(int xtal)
  168. {
  169. printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
  170. s3c24xx_register_baseclocks(xtal);
  171. s5p_register_clocks(xtal);
  172. if (soc_is_exynos4210())
  173. exynos4210_register_clocks();
  174. else if (soc_is_exynos4212() || soc_is_exynos4412())
  175. exynos4212_register_clocks();
  176. exynos4_register_clocks();
  177. exynos4_setup_clocks();
  178. }
  179. static void exynos4_gic_irq_fix_base(struct irq_data *d)
  180. {
  181. struct gic_chip_data *gic_data = irq_data_get_irq_chip_data(d);
  182. gic_data->cpu_base = S5P_VA_GIC_CPU +
  183. (gic_bank_offset * smp_processor_id());
  184. gic_data->dist_base = S5P_VA_GIC_DIST +
  185. (gic_bank_offset * smp_processor_id());
  186. }
  187. void __init exynos4_init_irq(void)
  188. {
  189. int irq;
  190. gic_bank_offset = soc_is_exynos4412() ? 0x4000 : 0x8000;
  191. gic_init(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU);
  192. gic_arch_extn.irq_eoi = exynos4_gic_irq_fix_base;
  193. gic_arch_extn.irq_unmask = exynos4_gic_irq_fix_base;
  194. gic_arch_extn.irq_mask = exynos4_gic_irq_fix_base;
  195. for (irq = 0; irq < MAX_COMBINER_NR; irq++) {
  196. combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
  197. COMBINER_IRQ(irq, 0));
  198. combiner_cascade_irq(irq, IRQ_SPI(irq));
  199. }
  200. /* The parameters of s5p_init_irq() are for VIC init.
  201. * Theses parameters should be NULL and 0 because EXYNOS4
  202. * uses GIC instead of VIC.
  203. */
  204. s5p_init_irq(NULL, 0);
  205. }
  206. struct bus_type exynos4_subsys = {
  207. .name = "exynos4-core",
  208. .dev_name = "exynos4-core",
  209. };
  210. static struct device exynos4_dev = {
  211. .bus = &exynos4_subsys,
  212. };
  213. static int __init exynos4_core_init(void)
  214. {
  215. return subsys_system_register(&exynos4_subsys, NULL);
  216. }
  217. core_initcall(exynos4_core_init);
  218. #ifdef CONFIG_CACHE_L2X0
  219. static int __init exynos4_l2x0_cache_init(void)
  220. {
  221. /* TAG, Data Latency Control: 2cycle */
  222. __raw_writel(0x110, S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL);
  223. if (soc_is_exynos4210())
  224. __raw_writel(0x110, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
  225. else if (soc_is_exynos4212() || soc_is_exynos4412())
  226. __raw_writel(0x120, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
  227. /* L2X0 Prefetch Control */
  228. __raw_writel(0x30000007, S5P_VA_L2CC + L2X0_PREFETCH_CTRL);
  229. /* L2X0 Power Control */
  230. __raw_writel(L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN,
  231. S5P_VA_L2CC + L2X0_POWER_CTRL);
  232. l2x0_init(S5P_VA_L2CC, 0x7C470001, 0xC200ffff);
  233. return 0;
  234. }
  235. early_initcall(exynos4_l2x0_cache_init);
  236. #endif
  237. int __init exynos_init(void)
  238. {
  239. printk(KERN_INFO "EXYNOS: Initializing architecture\n");
  240. /* set idle function */
  241. pm_idle = exynos_idle;
  242. /* set sw_reset function */
  243. if (soc_is_exynos4210() || soc_is_exynos4212() || soc_is_exynos4412())
  244. s5p_reset_hook = exynos4_sw_reset;
  245. return device_register(&exynos4_dev);
  246. }