exynos.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * SAMSUNG EXYNOS Flattened Device Tree enabled machine
  3. *
  4. * Copyright (c) 2010-2014 Samsung Electronics Co., Ltd.
  5. * http://www.samsung.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <linux/kernel.h>
  14. #include <linux/serial_s3c.h>
  15. #include <linux/of.h>
  16. #include <linux/of_address.h>
  17. #include <linux/of_fdt.h>
  18. #include <linux/of_platform.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/pm_domain.h>
  21. #include <linux/irqchip.h>
  22. #include <asm/cacheflush.h>
  23. #include <asm/hardware/cache-l2x0.h>
  24. #include <asm/mach/arch.h>
  25. #include <asm/mach/map.h>
  26. #include <asm/memory.h>
  27. #include <mach/map.h>
  28. #include "common.h"
  29. #include "mfc.h"
  30. #include "regs-pmu.h"
  31. void __iomem *pmu_base_addr;
  32. static struct map_desc exynos4_iodesc[] __initdata = {
  33. {
  34. .virtual = (unsigned long)S5P_VA_SROMC,
  35. .pfn = __phys_to_pfn(EXYNOS4_PA_SROMC),
  36. .length = SZ_4K,
  37. .type = MT_DEVICE,
  38. }, {
  39. .virtual = (unsigned long)S5P_VA_CMU,
  40. .pfn = __phys_to_pfn(EXYNOS4_PA_CMU),
  41. .length = SZ_128K,
  42. .type = MT_DEVICE,
  43. }, {
  44. .virtual = (unsigned long)S5P_VA_COREPERI_BASE,
  45. .pfn = __phys_to_pfn(EXYNOS4_PA_COREPERI),
  46. .length = SZ_8K,
  47. .type = MT_DEVICE,
  48. }, {
  49. .virtual = (unsigned long)S5P_VA_DMC0,
  50. .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0),
  51. .length = SZ_64K,
  52. .type = MT_DEVICE,
  53. }, {
  54. .virtual = (unsigned long)S5P_VA_DMC1,
  55. .pfn = __phys_to_pfn(EXYNOS4_PA_DMC1),
  56. .length = SZ_64K,
  57. .type = MT_DEVICE,
  58. },
  59. };
  60. static struct map_desc exynos5_iodesc[] __initdata = {
  61. {
  62. .virtual = (unsigned long)S5P_VA_SROMC,
  63. .pfn = __phys_to_pfn(EXYNOS5_PA_SROMC),
  64. .length = SZ_4K,
  65. .type = MT_DEVICE,
  66. }, {
  67. .virtual = (unsigned long)S5P_VA_CMU,
  68. .pfn = __phys_to_pfn(EXYNOS5_PA_CMU),
  69. .length = 144 * SZ_1K,
  70. .type = MT_DEVICE,
  71. },
  72. };
  73. static struct platform_device exynos_cpuidle = {
  74. .name = "exynos_cpuidle",
  75. #ifdef CONFIG_ARM_EXYNOS_CPUIDLE
  76. .dev.platform_data = exynos_enter_aftr,
  77. #endif
  78. .id = -1,
  79. };
  80. void __iomem *sysram_base_addr;
  81. void __iomem *sysram_ns_base_addr;
  82. void __init exynos_sysram_init(void)
  83. {
  84. struct device_node *node;
  85. for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram") {
  86. if (!of_device_is_available(node))
  87. continue;
  88. sysram_base_addr = of_iomap(node, 0);
  89. break;
  90. }
  91. for_each_compatible_node(node, NULL, "samsung,exynos4210-sysram-ns") {
  92. if (!of_device_is_available(node))
  93. continue;
  94. sysram_ns_base_addr = of_iomap(node, 0);
  95. break;
  96. }
  97. }
  98. static void __init exynos_init_late(void)
  99. {
  100. if (of_machine_is_compatible("samsung,exynos5440"))
  101. /* to be supported later */
  102. return;
  103. exynos_pm_init();
  104. }
  105. static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
  106. int depth, void *data)
  107. {
  108. struct map_desc iodesc;
  109. const __be32 *reg;
  110. int len;
  111. if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") &&
  112. !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock"))
  113. return 0;
  114. reg = of_get_flat_dt_prop(node, "reg", &len);
  115. if (reg == NULL || len != (sizeof(unsigned long) * 2))
  116. return 0;
  117. iodesc.pfn = __phys_to_pfn(be32_to_cpu(reg[0]));
  118. iodesc.length = be32_to_cpu(reg[1]) - 1;
  119. iodesc.virtual = (unsigned long)S5P_VA_CHIPID;
  120. iodesc.type = MT_DEVICE;
  121. iotable_init(&iodesc, 1);
  122. return 1;
  123. }
  124. /*
  125. * exynos_map_io
  126. *
  127. * register the standard cpu IO areas
  128. */
  129. static void __init exynos_map_io(void)
  130. {
  131. if (soc_is_exynos4())
  132. iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
  133. if (soc_is_exynos5())
  134. iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
  135. }
  136. static void __init exynos_init_io(void)
  137. {
  138. debug_ll_io_init();
  139. of_scan_flat_dt(exynos_fdt_map_chipid, NULL);
  140. /* detect cpu id and rev. */
  141. s5p_init_cpu(S5P_VA_CHIPID);
  142. exynos_map_io();
  143. }
  144. static const struct of_device_id exynos_dt_pmu_match[] = {
  145. { .compatible = "samsung,exynos3250-pmu" },
  146. { .compatible = "samsung,exynos4210-pmu" },
  147. { .compatible = "samsung,exynos4212-pmu" },
  148. { .compatible = "samsung,exynos4412-pmu" },
  149. { .compatible = "samsung,exynos4415-pmu" },
  150. { .compatible = "samsung,exynos5250-pmu" },
  151. { .compatible = "samsung,exynos5260-pmu" },
  152. { .compatible = "samsung,exynos5410-pmu" },
  153. { .compatible = "samsung,exynos5420-pmu" },
  154. { /*sentinel*/ },
  155. };
  156. static void exynos_map_pmu(void)
  157. {
  158. struct device_node *np;
  159. np = of_find_matching_node(NULL, exynos_dt_pmu_match);
  160. if (np)
  161. pmu_base_addr = of_iomap(np, 0);
  162. if (!pmu_base_addr)
  163. panic("failed to find exynos pmu register\n");
  164. }
  165. static void __init exynos_init_irq(void)
  166. {
  167. irqchip_init();
  168. /*
  169. * Since platsmp.c needs pmu base address by the time
  170. * DT is not unflatten so we can't use DT APIs before
  171. * init_irq
  172. */
  173. exynos_map_pmu();
  174. }
  175. static void __init exynos_dt_machine_init(void)
  176. {
  177. /*
  178. * This is called from smp_prepare_cpus if we've built for SMP, but
  179. * we still need to set it up for PM and firmware ops if not.
  180. */
  181. if (!IS_ENABLED(CONFIG_SMP))
  182. exynos_sysram_init();
  183. #ifdef CONFIG_ARM_EXYNOS_CPUIDLE
  184. if (of_machine_is_compatible("samsung,exynos4210"))
  185. exynos_cpuidle.dev.platform_data = &cpuidle_coupled_exynos_data;
  186. #endif
  187. if (of_machine_is_compatible("samsung,exynos4210") ||
  188. of_machine_is_compatible("samsung,exynos4212") ||
  189. (of_machine_is_compatible("samsung,exynos4412") &&
  190. of_machine_is_compatible("samsung,trats2")) ||
  191. of_machine_is_compatible("samsung,exynos5250"))
  192. platform_device_register(&exynos_cpuidle);
  193. platform_device_register_simple("exynos-cpufreq", -1, NULL, 0);
  194. of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
  195. }
  196. static char const *const exynos_dt_compat[] __initconst = {
  197. "samsung,exynos3",
  198. "samsung,exynos3250",
  199. "samsung,exynos4",
  200. "samsung,exynos4210",
  201. "samsung,exynos4212",
  202. "samsung,exynos4412",
  203. "samsung,exynos4415",
  204. "samsung,exynos5",
  205. "samsung,exynos5250",
  206. "samsung,exynos5260",
  207. "samsung,exynos5420",
  208. "samsung,exynos5440",
  209. NULL
  210. };
  211. static void __init exynos_reserve(void)
  212. {
  213. #ifdef CONFIG_S5P_DEV_MFC
  214. int i;
  215. char *mfc_mem[] = {
  216. "samsung,mfc-v5",
  217. "samsung,mfc-v6",
  218. "samsung,mfc-v7",
  219. "samsung,mfc-v8",
  220. };
  221. for (i = 0; i < ARRAY_SIZE(mfc_mem); i++)
  222. if (of_scan_flat_dt(s5p_fdt_alloc_mfc_mem, mfc_mem[i]))
  223. break;
  224. #endif
  225. }
  226. static void __init exynos_dt_fixup(void)
  227. {
  228. /*
  229. * Some versions of uboot pass garbage entries in the memory node,
  230. * use the old CONFIG_ARM_NR_BANKS
  231. */
  232. of_fdt_limit_memory(8);
  233. }
  234. DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
  235. /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */
  236. /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
  237. .l2c_aux_val = 0x3c400001,
  238. .l2c_aux_mask = 0xc20fffff,
  239. .smp = smp_ops(exynos_smp_ops),
  240. .map_io = exynos_init_io,
  241. .init_early = exynos_firmware_init,
  242. .init_irq = exynos_init_irq,
  243. .init_machine = exynos_dt_machine_init,
  244. .init_late = exynos_init_late,
  245. .dt_compat = exynos_dt_compat,
  246. .reserve = exynos_reserve,
  247. .dt_fixup = exynos_dt_fixup,
  248. MACHINE_END