ct-ca9x4.c 5.6 KB

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