ct-ca9x4.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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/pmu.h>
  16. #include <asm/smp_scu.h>
  17. #include <asm/smp_twd.h>
  18. #include <mach/ct-ca9x4.h>
  19. #include <asm/hardware/timer-sp.h>
  20. #include <asm/mach/map.h>
  21. #include <asm/mach/time.h>
  22. #include "core.h"
  23. #include <mach/motherboard.h>
  24. #include <plat/clcd.h>
  25. static struct map_desc ct_ca9x4_io_desc[] __initdata = {
  26. {
  27. .virtual = V2T_PERIPH,
  28. .pfn = __phys_to_pfn(CT_CA9X4_MPIC),
  29. .length = SZ_8K,
  30. .type = MT_DEVICE,
  31. },
  32. };
  33. static void __init ct_ca9x4_map_io(void)
  34. {
  35. iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
  36. #ifdef CONFIG_LOCAL_TIMERS
  37. twd_base = ioremap(A9_MPCORE_TWD, SZ_32);
  38. #endif
  39. }
  40. static void __init ct_ca9x4_init_irq(void)
  41. {
  42. gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K),
  43. ioremap(A9_MPCORE_GIC_CPU, SZ_256));
  44. }
  45. static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
  46. {
  47. v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE_DB1, 0);
  48. v2m_cfg_write(SYS_CFG_DVIMODE | SYS_CFG_SITE_DB1, 2);
  49. }
  50. static int ct_ca9x4_clcd_setup(struct clcd_fb *fb)
  51. {
  52. unsigned long framesize = 1024 * 768 * 2;
  53. fb->panel = versatile_clcd_get_panel("XVGA");
  54. if (!fb->panel)
  55. return -EINVAL;
  56. return versatile_clcd_setup_dma(fb, framesize);
  57. }
  58. static struct clcd_board ct_ca9x4_clcd_data = {
  59. .name = "CT-CA9X4",
  60. .caps = CLCD_CAP_5551 | CLCD_CAP_565,
  61. .check = clcdfb_check,
  62. .decode = clcdfb_decode,
  63. .enable = ct_ca9x4_clcd_enable,
  64. .setup = ct_ca9x4_clcd_setup,
  65. .mmap = versatile_clcd_mmap_dma,
  66. .remove = versatile_clcd_remove_dma,
  67. };
  68. static AMBA_DEVICE(clcd, "ct:clcd", CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data);
  69. static AMBA_DEVICE(dmc, "ct:dmc", CT_CA9X4_DMC, NULL);
  70. static AMBA_DEVICE(smc, "ct:smc", CT_CA9X4_SMC, NULL);
  71. static AMBA_DEVICE(gpio, "ct:gpio", CT_CA9X4_GPIO, NULL);
  72. static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
  73. &clcd_device,
  74. &dmc_device,
  75. &smc_device,
  76. &gpio_device,
  77. };
  78. static long ct_round(struct clk *clk, unsigned long rate)
  79. {
  80. return rate;
  81. }
  82. static int ct_set(struct clk *clk, unsigned long rate)
  83. {
  84. return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_DB1 | 1, rate);
  85. }
  86. static const struct clk_ops osc1_clk_ops = {
  87. .round = ct_round,
  88. .set = ct_set,
  89. };
  90. static struct clk osc1_clk = {
  91. .ops = &osc1_clk_ops,
  92. .rate = 24000000,
  93. };
  94. static struct clk ct_sp804_clk = {
  95. .rate = 1000000,
  96. };
  97. static struct clk_lookup lookups[] = {
  98. { /* CLCD */
  99. .dev_id = "ct:clcd",
  100. .clk = &osc1_clk,
  101. }, { /* SP804 timers */
  102. .dev_id = "sp804",
  103. .con_id = "ct-timer0",
  104. .clk = &ct_sp804_clk,
  105. }, { /* SP804 timers */
  106. .dev_id = "sp804",
  107. .con_id = "ct-timer1",
  108. .clk = &ct_sp804_clk,
  109. },
  110. };
  111. static struct resource pmu_resources[] = {
  112. [0] = {
  113. .start = IRQ_CT_CA9X4_PMU_CPU0,
  114. .end = IRQ_CT_CA9X4_PMU_CPU0,
  115. .flags = IORESOURCE_IRQ,
  116. },
  117. [1] = {
  118. .start = IRQ_CT_CA9X4_PMU_CPU1,
  119. .end = IRQ_CT_CA9X4_PMU_CPU1,
  120. .flags = IORESOURCE_IRQ,
  121. },
  122. [2] = {
  123. .start = IRQ_CT_CA9X4_PMU_CPU2,
  124. .end = IRQ_CT_CA9X4_PMU_CPU2,
  125. .flags = IORESOURCE_IRQ,
  126. },
  127. [3] = {
  128. .start = IRQ_CT_CA9X4_PMU_CPU3,
  129. .end = IRQ_CT_CA9X4_PMU_CPU3,
  130. .flags = IORESOURCE_IRQ,
  131. },
  132. };
  133. static struct platform_device pmu_device = {
  134. .name = "arm-pmu",
  135. .id = ARM_PMU_DEVICE_CPU,
  136. .num_resources = ARRAY_SIZE(pmu_resources),
  137. .resource = pmu_resources,
  138. };
  139. static void __init ct_ca9x4_init_early(void)
  140. {
  141. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  142. }
  143. static void __init ct_ca9x4_init(void)
  144. {
  145. int i;
  146. #ifdef CONFIG_CACHE_L2X0
  147. void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K);
  148. /* set RAM latencies to 1 cycle for this core tile. */
  149. writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL);
  150. writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL);
  151. l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff);
  152. #endif
  153. for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++)
  154. amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
  155. platform_device_register(&pmu_device);
  156. }
  157. #ifdef CONFIG_SMP
  158. static void *ct_ca9x4_scu_base __initdata;
  159. static void __init ct_ca9x4_init_cpu_map(void)
  160. {
  161. int i, ncores;
  162. ct_ca9x4_scu_base = ioremap(A9_MPCORE_SCU, SZ_128);
  163. if (WARN_ON(!ct_ca9x4_scu_base))
  164. return;
  165. ncores = scu_get_core_count(ct_ca9x4_scu_base);
  166. if (ncores > nr_cpu_ids) {
  167. pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
  168. ncores, nr_cpu_ids);
  169. ncores = nr_cpu_ids;
  170. }
  171. for (i = 0; i < ncores; ++i)
  172. set_cpu_possible(i, true);
  173. set_smp_cross_call(gic_raise_softirq);
  174. }
  175. static void __init ct_ca9x4_smp_enable(unsigned int max_cpus)
  176. {
  177. scu_enable(ct_ca9x4_scu_base);
  178. }
  179. #endif
  180. struct ct_desc ct_ca9x4_desc __initdata = {
  181. .id = V2M_CT_ID_CA9,
  182. .name = "CA9x4",
  183. .map_io = ct_ca9x4_map_io,
  184. .init_early = ct_ca9x4_init_early,
  185. .init_irq = ct_ca9x4_init_irq,
  186. .init_tile = ct_ca9x4_init,
  187. #ifdef CONFIG_SMP
  188. .init_cpu_map = ct_ca9x4_init_cpu_map,
  189. .smp_enable = ct_ca9x4_smp_enable,
  190. #endif
  191. };