ct-ca9x4.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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/clkdev.h>
  12. #include <asm/hardware/arm_timer.h>
  13. #include <asm/hardware/cache-l2x0.h>
  14. #include <asm/hardware/gic.h>
  15. #include <asm/smp_scu.h>
  16. #include <asm/smp_twd.h>
  17. #include <mach/ct-ca9x4.h>
  18. #include <asm/hardware/timer-sp.h>
  19. #include <asm/mach/map.h>
  20. #include <asm/mach/time.h>
  21. #include "core.h"
  22. #include <mach/motherboard.h>
  23. #include <plat/clcd.h>
  24. static struct map_desc ct_ca9x4_io_desc[] __initdata = {
  25. {
  26. .virtual = V2T_PERIPH,
  27. .pfn = __phys_to_pfn(CT_CA9X4_MPIC),
  28. .length = SZ_8K,
  29. .type = MT_DEVICE,
  30. },
  31. };
  32. static void __init ct_ca9x4_map_io(void)
  33. {
  34. iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
  35. }
  36. #ifdef CONFIG_HAVE_ARM_TWD
  37. static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER);
  38. static void __init ca9x4_twd_init(void)
  39. {
  40. int err = twd_local_timer_register(&twd_local_timer);
  41. if (err)
  42. pr_err("twd_local_timer_register failed %d\n", err);
  43. }
  44. #else
  45. #define ca9x4_twd_init() do {} while(0)
  46. #endif
  47. static void __init ct_ca9x4_init_irq(void)
  48. {
  49. gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K),
  50. ioremap(A9_MPCORE_GIC_CPU, SZ_256));
  51. ca9x4_twd_init();
  52. }
  53. static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
  54. {
  55. u32 site = v2m_get_master_site();
  56. /*
  57. * Old firmware was using the "site" component of the command
  58. * to control the DVI muxer (while it should be always 0 ie. MB).
  59. * Newer firmware uses the data register. Keep both for compatibility.
  60. */
  61. v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE(site), site);
  62. v2m_cfg_write(SYS_CFG_DVIMODE | SYS_CFG_SITE(SYS_CFG_SITE_MB), 2);
  63. }
  64. static int ct_ca9x4_clcd_setup(struct clcd_fb *fb)
  65. {
  66. unsigned long framesize = 1024 * 768 * 2;
  67. fb->panel = versatile_clcd_get_panel("XVGA");
  68. if (!fb->panel)
  69. return -EINVAL;
  70. return versatile_clcd_setup_dma(fb, framesize);
  71. }
  72. static struct clcd_board ct_ca9x4_clcd_data = {
  73. .name = "CT-CA9X4",
  74. .caps = CLCD_CAP_5551 | CLCD_CAP_565,
  75. .check = clcdfb_check,
  76. .decode = clcdfb_decode,
  77. .enable = ct_ca9x4_clcd_enable,
  78. .setup = ct_ca9x4_clcd_setup,
  79. .mmap = versatile_clcd_mmap_dma,
  80. .remove = versatile_clcd_remove_dma,
  81. };
  82. static AMBA_AHB_DEVICE(clcd, "ct:clcd", 0, CT_CA9X4_CLCDC, IRQ_CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data);
  83. static AMBA_APB_DEVICE(dmc, "ct:dmc", 0, CT_CA9X4_DMC, IRQ_CT_CA9X4_DMC, NULL);
  84. static AMBA_APB_DEVICE(smc, "ct:smc", 0, CT_CA9X4_SMC, IRQ_CT_CA9X4_SMC, NULL);
  85. static AMBA_APB_DEVICE(gpio, "ct:gpio", 0, CT_CA9X4_GPIO, IRQ_CT_CA9X4_GPIO, NULL);
  86. static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
  87. &clcd_device,
  88. &dmc_device,
  89. &smc_device,
  90. &gpio_device,
  91. };
  92. static struct v2m_osc ct_osc1 = {
  93. .osc = 1,
  94. .rate_min = 10000000,
  95. .rate_max = 80000000,
  96. .rate_default = 23750000,
  97. };
  98. static struct resource pmu_resources[] = {
  99. [0] = {
  100. .start = IRQ_CT_CA9X4_PMU_CPU0,
  101. .end = IRQ_CT_CA9X4_PMU_CPU0,
  102. .flags = IORESOURCE_IRQ,
  103. },
  104. [1] = {
  105. .start = IRQ_CT_CA9X4_PMU_CPU1,
  106. .end = IRQ_CT_CA9X4_PMU_CPU1,
  107. .flags = IORESOURCE_IRQ,
  108. },
  109. [2] = {
  110. .start = IRQ_CT_CA9X4_PMU_CPU2,
  111. .end = IRQ_CT_CA9X4_PMU_CPU2,
  112. .flags = IORESOURCE_IRQ,
  113. },
  114. [3] = {
  115. .start = IRQ_CT_CA9X4_PMU_CPU3,
  116. .end = IRQ_CT_CA9X4_PMU_CPU3,
  117. .flags = IORESOURCE_IRQ,
  118. },
  119. };
  120. static struct platform_device pmu_device = {
  121. .name = "arm-pmu",
  122. .id = -1,
  123. .num_resources = ARRAY_SIZE(pmu_resources),
  124. .resource = pmu_resources,
  125. };
  126. static void __init ct_ca9x4_init(void)
  127. {
  128. int i;
  129. struct clk *clk;
  130. #ifdef CONFIG_CACHE_L2X0
  131. void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K);
  132. /* set RAM latencies to 1 cycle for this core tile. */
  133. writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL);
  134. writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL);
  135. l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff);
  136. #endif
  137. ct_osc1.site = v2m_get_master_site();
  138. clk = v2m_osc_register("ct:osc1", &ct_osc1);
  139. clk_register_clkdev(clk, NULL, "ct:clcd");
  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. }
  144. #ifdef CONFIG_SMP
  145. static void *ct_ca9x4_scu_base __initdata;
  146. static void __init ct_ca9x4_init_cpu_map(void)
  147. {
  148. int i, ncores;
  149. ct_ca9x4_scu_base = ioremap(A9_MPCORE_SCU, SZ_128);
  150. if (WARN_ON(!ct_ca9x4_scu_base))
  151. return;
  152. ncores = scu_get_core_count(ct_ca9x4_scu_base);
  153. if (ncores > nr_cpu_ids) {
  154. pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
  155. ncores, nr_cpu_ids);
  156. ncores = nr_cpu_ids;
  157. }
  158. for (i = 0; i < ncores; ++i)
  159. set_cpu_possible(i, true);
  160. set_smp_cross_call(gic_raise_softirq);
  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. };