ct-ca9x4.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * Versatile Express Core Tile Cortex A9x4 Support
  3. */
  4. #include <linux/init.h>
  5. #include <linux/gfp.h>
  6. #include <linux/device.h>
  7. #include <linux/dma-mapping.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/amba/bus.h>
  10. #include <linux/amba/clcd.h>
  11. #include <linux/platform_data/video-clcd-versatile.h>
  12. #include <linux/clkdev.h>
  13. #include <linux/vexpress.h>
  14. #include <linux/irqchip/arm-gic.h>
  15. #include <asm/hardware/arm_timer.h>
  16. #include <asm/hardware/cache-l2x0.h>
  17. #include <asm/smp_scu.h>
  18. #include <asm/smp_twd.h>
  19. #include <mach/ct-ca9x4.h>
  20. #include <asm/hardware/timer-sp.h>
  21. #include <asm/mach/map.h>
  22. #include <asm/mach/time.h>
  23. #include "core.h"
  24. #include <mach/motherboard.h>
  25. #include <mach/irqs.h>
  26. static struct map_desc ct_ca9x4_io_desc[] __initdata = {
  27. {
  28. .virtual = V2T_PERIPH,
  29. .pfn = __phys_to_pfn(CT_CA9X4_MPIC),
  30. .length = SZ_8K,
  31. .type = MT_DEVICE,
  32. },
  33. };
  34. static void __init ct_ca9x4_map_io(void)
  35. {
  36. iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
  37. }
  38. static void __init ca9x4_l2_init(void)
  39. {
  40. #ifdef CONFIG_CACHE_L2X0
  41. void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K);
  42. if (l2x0_base) {
  43. /* set RAM latencies to 1 cycle for this core tile. */
  44. writel(0, l2x0_base + L310_TAG_LATENCY_CTRL);
  45. writel(0, l2x0_base + L310_DATA_LATENCY_CTRL);
  46. l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff);
  47. } else {
  48. pr_err("L2C: unable to map L2 cache controller\n");
  49. }
  50. #endif
  51. }
  52. #ifdef CONFIG_HAVE_ARM_TWD
  53. static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER);
  54. static void __init ca9x4_twd_init(void)
  55. {
  56. int err = twd_local_timer_register(&twd_local_timer);
  57. if (err)
  58. pr_err("twd_local_timer_register failed %d\n", err);
  59. }
  60. #else
  61. #define ca9x4_twd_init() do {} while(0)
  62. #endif
  63. static void __init ct_ca9x4_init_irq(void)
  64. {
  65. gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K),
  66. ioremap(A9_MPCORE_GIC_CPU, SZ_256));
  67. ca9x4_twd_init();
  68. ca9x4_l2_init();
  69. }
  70. static int ct_ca9x4_clcd_setup(struct clcd_fb *fb)
  71. {
  72. unsigned long framesize = 1024 * 768 * 2;
  73. fb->panel = versatile_clcd_get_panel("XVGA");
  74. if (!fb->panel)
  75. return -EINVAL;
  76. return versatile_clcd_setup_dma(fb, framesize);
  77. }
  78. static struct clcd_board ct_ca9x4_clcd_data = {
  79. .name = "CT-CA9X4",
  80. .caps = CLCD_CAP_5551 | CLCD_CAP_565,
  81. .check = clcdfb_check,
  82. .decode = clcdfb_decode,
  83. .setup = ct_ca9x4_clcd_setup,
  84. .mmap = versatile_clcd_mmap_dma,
  85. .remove = versatile_clcd_remove_dma,
  86. };
  87. static AMBA_AHB_DEVICE(clcd, "ct:clcd", 0, CT_CA9X4_CLCDC, IRQ_CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data);
  88. static AMBA_APB_DEVICE(dmc, "ct:dmc", 0, CT_CA9X4_DMC, IRQ_CT_CA9X4_DMC, NULL);
  89. static AMBA_APB_DEVICE(smc, "ct:smc", 0, CT_CA9X4_SMC, IRQ_CT_CA9X4_SMC, NULL);
  90. static AMBA_APB_DEVICE(gpio, "ct:gpio", 0, CT_CA9X4_GPIO, IRQ_CT_CA9X4_GPIO, NULL);
  91. static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
  92. &clcd_device,
  93. &dmc_device,
  94. &smc_device,
  95. &gpio_device,
  96. };
  97. static struct resource pmu_resources[] = {
  98. [0] = {
  99. .start = IRQ_CT_CA9X4_PMU_CPU0,
  100. .end = IRQ_CT_CA9X4_PMU_CPU0,
  101. .flags = IORESOURCE_IRQ,
  102. },
  103. [1] = {
  104. .start = IRQ_CT_CA9X4_PMU_CPU1,
  105. .end = IRQ_CT_CA9X4_PMU_CPU1,
  106. .flags = IORESOURCE_IRQ,
  107. },
  108. [2] = {
  109. .start = IRQ_CT_CA9X4_PMU_CPU2,
  110. .end = IRQ_CT_CA9X4_PMU_CPU2,
  111. .flags = IORESOURCE_IRQ,
  112. },
  113. [3] = {
  114. .start = IRQ_CT_CA9X4_PMU_CPU3,
  115. .end = IRQ_CT_CA9X4_PMU_CPU3,
  116. .flags = IORESOURCE_IRQ,
  117. },
  118. };
  119. static struct platform_device pmu_device = {
  120. .name = "arm-pmu",
  121. .id = -1,
  122. .num_resources = ARRAY_SIZE(pmu_resources),
  123. .resource = pmu_resources,
  124. };
  125. static struct clk_lookup osc1_lookup = {
  126. .dev_id = "ct:clcd",
  127. };
  128. static struct platform_device osc1_device = {
  129. .name = "vexpress-osc",
  130. .id = 1,
  131. .num_resources = 1,
  132. .resource = (struct resource []) {
  133. VEXPRESS_RES_FUNC(0xf, 1),
  134. },
  135. .dev.platform_data = &osc1_lookup,
  136. };
  137. static void __init ct_ca9x4_init(void)
  138. {
  139. int i;
  140. for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++)
  141. amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
  142. platform_device_register(&pmu_device);
  143. vexpress_syscfg_device_register(&osc1_device);
  144. }
  145. #ifdef CONFIG_SMP
  146. static void *ct_ca9x4_scu_base __initdata;
  147. static void __init ct_ca9x4_init_cpu_map(void)
  148. {
  149. int i, ncores;
  150. ct_ca9x4_scu_base = ioremap(A9_MPCORE_SCU, SZ_128);
  151. if (WARN_ON(!ct_ca9x4_scu_base))
  152. return;
  153. ncores = scu_get_core_count(ct_ca9x4_scu_base);
  154. if (ncores > nr_cpu_ids) {
  155. pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
  156. ncores, nr_cpu_ids);
  157. ncores = nr_cpu_ids;
  158. }
  159. for (i = 0; i < ncores; ++i)
  160. set_cpu_possible(i, true);
  161. }
  162. static void __init ct_ca9x4_smp_enable(unsigned int max_cpus)
  163. {
  164. scu_enable(ct_ca9x4_scu_base);
  165. }
  166. #endif
  167. struct ct_desc ct_ca9x4_desc __initdata = {
  168. .id = V2M_CT_ID_CA9,
  169. .name = "CA9x4",
  170. .map_io = ct_ca9x4_map_io,
  171. .init_irq = ct_ca9x4_init_irq,
  172. .init_tile = ct_ca9x4_init,
  173. #ifdef CONFIG_SMP
  174. .init_cpu_map = ct_ca9x4_init_cpu_map,
  175. .smp_enable = ct_ca9x4_smp_enable,
  176. #endif
  177. };