ct-ca9x4.c 4.8 KB

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