ct-ca9x4.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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 <asm/clkdev.h>
  12. #include <asm/pgtable.h>
  13. #include <asm/hardware/arm_timer.h>
  14. #include <asm/hardware/cache-l2x0.h>
  15. #include <asm/hardware/gic.h>
  16. #include <asm/mach-types.h>
  17. #include <asm/pmu.h>
  18. #include <asm/smp_twd.h>
  19. #include <mach/clkdev.h>
  20. #include <mach/ct-ca9x4.h>
  21. #include <plat/timer-sp.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach/map.h>
  24. #include <asm/mach/time.h>
  25. #include "core.h"
  26. #include <mach/motherboard.h>
  27. #define V2M_PA_CS7 0x10000000
  28. static struct map_desc ct_ca9x4_io_desc[] __initdata = {
  29. {
  30. .virtual = __MMIO_P2V(CT_CA9X4_MPIC),
  31. .pfn = __phys_to_pfn(CT_CA9X4_MPIC),
  32. .length = SZ_16K,
  33. .type = MT_DEVICE,
  34. }, {
  35. .virtual = __MMIO_P2V(CT_CA9X4_SP804_TIMER),
  36. .pfn = __phys_to_pfn(CT_CA9X4_SP804_TIMER),
  37. .length = SZ_4K,
  38. .type = MT_DEVICE,
  39. }, {
  40. .virtual = __MMIO_P2V(CT_CA9X4_L2CC),
  41. .pfn = __phys_to_pfn(CT_CA9X4_L2CC),
  42. .length = SZ_4K,
  43. .type = MT_DEVICE,
  44. },
  45. };
  46. static void __init ct_ca9x4_map_io(void)
  47. {
  48. #ifdef CONFIG_LOCAL_TIMERS
  49. twd_base = MMIO_P2V(A9_MPCORE_TWD);
  50. #endif
  51. v2m_map_io(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
  52. }
  53. void __iomem *gic_cpu_base_addr;
  54. static void __init ct_ca9x4_init_irq(void)
  55. {
  56. gic_cpu_base_addr = MMIO_P2V(A9_MPCORE_GIC_CPU);
  57. gic_dist_init(0, MMIO_P2V(A9_MPCORE_GIC_DIST), 29);
  58. gic_cpu_init(0, gic_cpu_base_addr);
  59. }
  60. #if 0
  61. static void __init ct_ca9x4_timer_init(void)
  62. {
  63. writel(0, MMIO_P2V(CT_CA9X4_TIMER0) + TIMER_CTRL);
  64. writel(0, MMIO_P2V(CT_CA9X4_TIMER1) + TIMER_CTRL);
  65. sp804_clocksource_init(MMIO_P2V(CT_CA9X4_TIMER1));
  66. sp804_clockevents_init(MMIO_P2V(CT_CA9X4_TIMER0), IRQ_CT_CA9X4_TIMER0);
  67. }
  68. static struct sys_timer ct_ca9x4_timer = {
  69. .init = ct_ca9x4_timer_init,
  70. };
  71. #endif
  72. static struct clcd_panel xvga_panel = {
  73. .mode = {
  74. .name = "XVGA",
  75. .refresh = 60,
  76. .xres = 1024,
  77. .yres = 768,
  78. .pixclock = 15384,
  79. .left_margin = 168,
  80. .right_margin = 8,
  81. .upper_margin = 29,
  82. .lower_margin = 3,
  83. .hsync_len = 144,
  84. .vsync_len = 6,
  85. .sync = 0,
  86. .vmode = FB_VMODE_NONINTERLACED,
  87. },
  88. .width = -1,
  89. .height = -1,
  90. .tim2 = TIM2_BCD | TIM2_IPC,
  91. .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
  92. .bpp = 16,
  93. };
  94. static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
  95. {
  96. v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE_DB1, 0);
  97. v2m_cfg_write(SYS_CFG_DVIMODE | SYS_CFG_SITE_DB1, 2);
  98. }
  99. static int ct_ca9x4_clcd_setup(struct clcd_fb *fb)
  100. {
  101. unsigned long framesize = 1024 * 768 * 2;
  102. dma_addr_t dma;
  103. fb->panel = &xvga_panel;
  104. fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
  105. &dma, GFP_KERNEL);
  106. if (!fb->fb.screen_base) {
  107. printk(KERN_ERR "CLCD: unable to map frame buffer\n");
  108. return -ENOMEM;
  109. }
  110. fb->fb.fix.smem_start = dma;
  111. fb->fb.fix.smem_len = framesize;
  112. return 0;
  113. }
  114. static int ct_ca9x4_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
  115. {
  116. return dma_mmap_writecombine(&fb->dev->dev, vma, fb->fb.screen_base,
  117. fb->fb.fix.smem_start, fb->fb.fix.smem_len);
  118. }
  119. static void ct_ca9x4_clcd_remove(struct clcd_fb *fb)
  120. {
  121. dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
  122. fb->fb.screen_base, fb->fb.fix.smem_start);
  123. }
  124. static struct clcd_board ct_ca9x4_clcd_data = {
  125. .name = "CT-CA9X4",
  126. .check = clcdfb_check,
  127. .decode = clcdfb_decode,
  128. .enable = ct_ca9x4_clcd_enable,
  129. .setup = ct_ca9x4_clcd_setup,
  130. .mmap = ct_ca9x4_clcd_mmap,
  131. .remove = ct_ca9x4_clcd_remove,
  132. };
  133. static AMBA_DEVICE(clcd, "ct:clcd", CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data);
  134. static AMBA_DEVICE(dmc, "ct:dmc", CT_CA9X4_DMC, NULL);
  135. static AMBA_DEVICE(smc, "ct:smc", CT_CA9X4_SMC, NULL);
  136. static AMBA_DEVICE(gpio, "ct:gpio", CT_CA9X4_GPIO, NULL);
  137. static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
  138. &clcd_device,
  139. &dmc_device,
  140. &smc_device,
  141. &gpio_device,
  142. };
  143. static long ct_round(struct clk *clk, unsigned long rate)
  144. {
  145. return rate;
  146. }
  147. static int ct_set(struct clk *clk, unsigned long rate)
  148. {
  149. return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_DB1 | 1, rate);
  150. }
  151. static const struct clk_ops osc1_clk_ops = {
  152. .round = ct_round,
  153. .set = ct_set,
  154. };
  155. static struct clk osc1_clk = {
  156. .ops = &osc1_clk_ops,
  157. .rate = 24000000,
  158. };
  159. static struct clk_lookup lookups[] = {
  160. { /* CLCD */
  161. .dev_id = "ct:clcd",
  162. .clk = &osc1_clk,
  163. },
  164. };
  165. static struct resource pmu_resources[] = {
  166. [0] = {
  167. .start = IRQ_CT_CA9X4_PMU_CPU0,
  168. .end = IRQ_CT_CA9X4_PMU_CPU0,
  169. .flags = IORESOURCE_IRQ,
  170. },
  171. [1] = {
  172. .start = IRQ_CT_CA9X4_PMU_CPU1,
  173. .end = IRQ_CT_CA9X4_PMU_CPU1,
  174. .flags = IORESOURCE_IRQ,
  175. },
  176. [2] = {
  177. .start = IRQ_CT_CA9X4_PMU_CPU2,
  178. .end = IRQ_CT_CA9X4_PMU_CPU2,
  179. .flags = IORESOURCE_IRQ,
  180. },
  181. [3] = {
  182. .start = IRQ_CT_CA9X4_PMU_CPU3,
  183. .end = IRQ_CT_CA9X4_PMU_CPU3,
  184. .flags = IORESOURCE_IRQ,
  185. },
  186. };
  187. static struct platform_device pmu_device = {
  188. .name = "arm-pmu",
  189. .id = ARM_PMU_DEVICE_CPU,
  190. .num_resources = ARRAY_SIZE(pmu_resources),
  191. .resource = pmu_resources,
  192. };
  193. static void __init ct_ca9x4_init(void)
  194. {
  195. int i;
  196. #ifdef CONFIG_CACHE_L2X0
  197. void __iomem *l2x0_base = MMIO_P2V(CT_CA9X4_L2CC);
  198. /* set RAM latencies to 1 cycle for this core tile. */
  199. writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL);
  200. writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL);
  201. l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff);
  202. #endif
  203. clkdev_add_table(lookups, ARRAY_SIZE(lookups));
  204. for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++)
  205. amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
  206. platform_device_register(&pmu_device);
  207. }
  208. MACHINE_START(VEXPRESS, "ARM-Versatile Express CA9x4")
  209. .boot_params = PHYS_OFFSET + 0x00000100,
  210. .map_io = ct_ca9x4_map_io,
  211. .init_irq = ct_ca9x4_init_irq,
  212. #if 0
  213. .timer = &ct_ca9x4_timer,
  214. #else
  215. .timer = &v2m_timer,
  216. #endif
  217. .init_machine = ct_ca9x4_init,
  218. MACHINE_END