2 * Versatile Express Core Tile Cortex A9x4 Support
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>
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>
16 #include <mach/clkdev.h>
17 #include <mach/ct-ca9x4.h>
19 #include <plat/timer-sp.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach/map.h>
23 #include <asm/mach/time.h>
27 #include <mach/motherboard.h>
29 #define V2M_PA_CS7 0x10000000
31 static struct map_desc ct_ca9x4_io_desc[] __initdata = {
33 .virtual = __MMIO_P2V(CT_CA9X4_MPIC),
34 .pfn = __phys_to_pfn(CT_CA9X4_MPIC),
38 .virtual = __MMIO_P2V(CT_CA9X4_SP804_TIMER),
39 .pfn = __phys_to_pfn(CT_CA9X4_SP804_TIMER),
43 .virtual = __MMIO_P2V(CT_CA9X4_L2CC),
44 .pfn = __phys_to_pfn(CT_CA9X4_L2CC),
50 static void __init ct_ca9x4_map_io(void)
52 v2m_map_io(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
55 void __iomem *gic_cpu_base_addr;
57 static void __init ct_ca9x4_init_irq(void)
59 gic_cpu_base_addr = MMIO_P2V(A9_MPCORE_GIC_CPU);
60 gic_dist_init(0, MMIO_P2V(A9_MPCORE_GIC_DIST), 29);
61 gic_cpu_init(0, gic_cpu_base_addr);
65 static void ct_ca9x4_timer_init(void)
67 writel(0, MMIO_P2V(CT_CA9X4_TIMER0) + TIMER_CTRL);
68 writel(0, MMIO_P2V(CT_CA9X4_TIMER1) + TIMER_CTRL);
70 sp804_clocksource_init(MMIO_P2V(CT_CA9X4_TIMER1));
71 sp804_clockevents_init(MMIO_P2V(CT_CA9X4_TIMER0), IRQ_CT_CA9X4_TIMER0);
74 static struct sys_timer ct_ca9x4_timer = {
75 .init = ct_ca9x4_timer_init,
79 static struct clcd_panel xvga_panel = {
93 .vmode = FB_VMODE_NONINTERLACED,
97 .tim2 = TIM2_BCD | TIM2_IPC,
98 .cntl = CNTL_LCDTFT | CNTL_BGR | CNTL_LCDVCOMP(1),
102 static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
104 v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE_DB1, 0);
105 v2m_cfg_write(SYS_CFG_DVIMODE | SYS_CFG_SITE_DB1, 2);
108 static int ct_ca9x4_clcd_setup(struct clcd_fb *fb)
110 unsigned long framesize = 1024 * 768 * 2;
113 fb->panel = &xvga_panel;
115 fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, framesize,
117 if (!fb->fb.screen_base) {
118 printk(KERN_ERR "CLCD: unable to map frame buffer\n");
121 fb->fb.fix.smem_start = dma;
122 fb->fb.fix.smem_len = framesize;
127 static int ct_ca9x4_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
129 return dma_mmap_writecombine(&fb->dev->dev, vma, fb->fb.screen_base,
130 fb->fb.fix.smem_start, fb->fb.fix.smem_len);
133 static void ct_ca9x4_clcd_remove(struct clcd_fb *fb)
135 dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
136 fb->fb.screen_base, fb->fb.fix.smem_start);
139 static struct clcd_board ct_ca9x4_clcd_data = {
141 .check = clcdfb_check,
142 .decode = clcdfb_decode,
143 .enable = ct_ca9x4_clcd_enable,
144 .setup = ct_ca9x4_clcd_setup,
145 .mmap = ct_ca9x4_clcd_mmap,
146 .remove = ct_ca9x4_clcd_remove,
149 static AMBA_DEVICE(clcd, "ct:clcd", CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data);
150 static AMBA_DEVICE(dmc, "ct:dmc", CT_CA9X4_DMC, NULL);
151 static AMBA_DEVICE(smc, "ct:smc", CT_CA9X4_SMC, NULL);
152 static AMBA_DEVICE(gpio, "ct:gpio", CT_CA9X4_GPIO, NULL);
154 static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
162 static long ct_round(struct clk *clk, unsigned long rate)
167 static int ct_set(struct clk *clk, unsigned long rate)
169 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_DB1 | 1, rate);
172 static const struct clk_ops osc1_clk_ops = {
177 static struct clk osc1_clk = {
178 .ops = &osc1_clk_ops,
182 static struct clk_lookup lookups[] = {
189 static void ct_ca9x4_init(void)
193 #ifdef CONFIG_CACHE_L2X0
194 l2x0_init(MMIO_P2V(CT_CA9X4_L2CC), 0x00000000, 0xfe0fffff);
197 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
199 for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++)
200 amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
203 MACHINE_START(VEXPRESS, "ARM-Versatile Express CA9x4")
204 .phys_io = V2M_UART0,
205 .io_pg_offst = (__MMIO_P2V(V2M_UART0) >> 18) & 0xfffc,
206 .boot_params = PHYS_OFFSET + 0x00000100,
207 .map_io = ct_ca9x4_map_io,
208 .init_irq = ct_ca9x4_init_irq,
210 .timer = &ct_ca9x4_timer,
214 .init_machine = ct_ca9x4_init,