ct-ca9x4.c 5.5 KB

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