ct-ca9x4.c 5.5 KB

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