Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / arm / mach-vexpress / ct-ca9x4.c
blob86150d7a2e7d977c1767795cfd3da082efae0013
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 <linux/clkdev.h>
12 #include <linux/vexpress.h>
13 #include <linux/irqchip/arm-gic.h>
15 #include <asm/hardware/arm_timer.h>
16 #include <asm/hardware/cache-l2x0.h>
17 #include <asm/smp_scu.h>
18 #include <asm/smp_twd.h>
20 #include <mach/ct-ca9x4.h>
22 #include <asm/hardware/timer-sp.h>
24 #include <asm/mach/map.h>
25 #include <asm/mach/time.h>
27 #include "core.h"
29 #include <mach/motherboard.h>
30 #include <mach/irqs.h>
32 #include <plat/clcd.h>
34 static struct map_desc ct_ca9x4_io_desc[] __initdata = {
36 .virtual = V2T_PERIPH,
37 .pfn = __phys_to_pfn(CT_CA9X4_MPIC),
38 .length = SZ_8K,
39 .type = MT_DEVICE,
43 static void __init ct_ca9x4_map_io(void)
45 iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
48 static void __init ca9x4_l2_init(void)
50 #ifdef CONFIG_CACHE_L2X0
51 void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K);
53 if (l2x0_base) {
54 /* set RAM latencies to 1 cycle for this core tile. */
55 writel(0, l2x0_base + L310_TAG_LATENCY_CTRL);
56 writel(0, l2x0_base + L310_DATA_LATENCY_CTRL);
58 l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff);
59 } else {
60 pr_err("L2C: unable to map L2 cache controller\n");
62 #endif
65 #ifdef CONFIG_HAVE_ARM_TWD
66 static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER);
68 static void __init ca9x4_twd_init(void)
70 int err = twd_local_timer_register(&twd_local_timer);
71 if (err)
72 pr_err("twd_local_timer_register failed %d\n", err);
74 #else
75 #define ca9x4_twd_init() do {} while(0)
76 #endif
78 static void __init ct_ca9x4_init_irq(void)
80 gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K),
81 ioremap(A9_MPCORE_GIC_CPU, SZ_256));
82 ca9x4_twd_init();
83 ca9x4_l2_init();
86 static int ct_ca9x4_clcd_setup(struct clcd_fb *fb)
88 unsigned long framesize = 1024 * 768 * 2;
90 fb->panel = versatile_clcd_get_panel("XVGA");
91 if (!fb->panel)
92 return -EINVAL;
94 return versatile_clcd_setup_dma(fb, framesize);
97 static struct clcd_board ct_ca9x4_clcd_data = {
98 .name = "CT-CA9X4",
99 .caps = CLCD_CAP_5551 | CLCD_CAP_565,
100 .check = clcdfb_check,
101 .decode = clcdfb_decode,
102 .setup = ct_ca9x4_clcd_setup,
103 .mmap = versatile_clcd_mmap_dma,
104 .remove = versatile_clcd_remove_dma,
107 static AMBA_AHB_DEVICE(clcd, "ct:clcd", 0, CT_CA9X4_CLCDC, IRQ_CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data);
108 static AMBA_APB_DEVICE(dmc, "ct:dmc", 0, CT_CA9X4_DMC, IRQ_CT_CA9X4_DMC, NULL);
109 static AMBA_APB_DEVICE(smc, "ct:smc", 0, CT_CA9X4_SMC, IRQ_CT_CA9X4_SMC, NULL);
110 static AMBA_APB_DEVICE(gpio, "ct:gpio", 0, CT_CA9X4_GPIO, IRQ_CT_CA9X4_GPIO, NULL);
112 static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
113 &clcd_device,
114 &dmc_device,
115 &smc_device,
116 &gpio_device,
119 static struct resource pmu_resources[] = {
120 [0] = {
121 .start = IRQ_CT_CA9X4_PMU_CPU0,
122 .end = IRQ_CT_CA9X4_PMU_CPU0,
123 .flags = IORESOURCE_IRQ,
125 [1] = {
126 .start = IRQ_CT_CA9X4_PMU_CPU1,
127 .end = IRQ_CT_CA9X4_PMU_CPU1,
128 .flags = IORESOURCE_IRQ,
130 [2] = {
131 .start = IRQ_CT_CA9X4_PMU_CPU2,
132 .end = IRQ_CT_CA9X4_PMU_CPU2,
133 .flags = IORESOURCE_IRQ,
135 [3] = {
136 .start = IRQ_CT_CA9X4_PMU_CPU3,
137 .end = IRQ_CT_CA9X4_PMU_CPU3,
138 .flags = IORESOURCE_IRQ,
142 static struct platform_device pmu_device = {
143 .name = "arm-pmu",
144 .id = -1,
145 .num_resources = ARRAY_SIZE(pmu_resources),
146 .resource = pmu_resources,
149 static struct clk_lookup osc1_lookup = {
150 .dev_id = "ct:clcd",
153 static struct platform_device osc1_device = {
154 .name = "vexpress-osc",
155 .id = 1,
156 .num_resources = 1,
157 .resource = (struct resource []) {
158 VEXPRESS_RES_FUNC(0xf, 1),
160 .dev.platform_data = &osc1_lookup,
163 static void __init ct_ca9x4_init(void)
165 int i;
167 for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++)
168 amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource);
170 platform_device_register(&pmu_device);
171 vexpress_syscfg_device_register(&osc1_device);
174 #ifdef CONFIG_SMP
175 static void *ct_ca9x4_scu_base __initdata;
177 static void __init ct_ca9x4_init_cpu_map(void)
179 int i, ncores;
181 ct_ca9x4_scu_base = ioremap(A9_MPCORE_SCU, SZ_128);
182 if (WARN_ON(!ct_ca9x4_scu_base))
183 return;
185 ncores = scu_get_core_count(ct_ca9x4_scu_base);
187 if (ncores > nr_cpu_ids) {
188 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
189 ncores, nr_cpu_ids);
190 ncores = nr_cpu_ids;
193 for (i = 0; i < ncores; ++i)
194 set_cpu_possible(i, true);
197 static void __init ct_ca9x4_smp_enable(unsigned int max_cpus)
199 scu_enable(ct_ca9x4_scu_base);
201 #endif
203 struct ct_desc ct_ca9x4_desc __initdata = {
204 .id = V2M_CT_ID_CA9,
205 .name = "CA9x4",
206 .map_io = ct_ca9x4_map_io,
207 .init_irq = ct_ca9x4_init_irq,
208 .init_tile = ct_ca9x4_init,
209 #ifdef CONFIG_SMP
210 .init_cpu_map = ct_ca9x4_init_cpu_map,
211 .smp_enable = ct_ca9x4_smp_enable,
212 #endif