Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Versatile Express Core Tile Cortex A9x4 Support |
| 3 | */ |
| 4 | #include <linux/init.h> |
Tejun Heo | 68aaae9 | 2010-03-30 02:52:45 +0900 | [diff] [blame] | 5 | #include <linux/gfp.h> |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 6 | #include <linux/device.h> |
| 7 | #include <linux/dma-mapping.h> |
Will Deacon | f417cba | 2010-04-15 10:16:26 +0100 | [diff] [blame] | 8 | #include <linux/platform_device.h> |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 9 | #include <linux/amba/bus.h> |
| 10 | #include <linux/amba/clcd.h> |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 11 | #include <linux/clkdev.h> |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 12 | #include <linux/vexpress.h> |
Rob Herring | 520f7bd | 2012-12-27 13:10:24 -0600 | [diff] [blame] | 13 | #include <linux/irqchip/arm-gic.h> |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 14 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 15 | #include <asm/hardware/arm_timer.h> |
| 16 | #include <asm/hardware/cache-l2x0.h> |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 17 | #include <asm/smp_scu.h> |
Will Deacon | bde28b8 | 2010-07-09 13:52:09 +0100 | [diff] [blame] | 18 | #include <asm/smp_twd.h> |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 19 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 20 | #include <mach/ct-ca9x4.h> |
| 21 | |
Rob Herring | 8a9618f | 2010-10-06 16:18:08 +0100 | [diff] [blame] | 22 | #include <asm/hardware/timer-sp.h> |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 23 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 24 | #include <asm/mach/map.h> |
| 25 | #include <asm/mach/time.h> |
| 26 | |
| 27 | #include "core.h" |
| 28 | |
| 29 | #include <mach/motherboard.h> |
Arnd Bergmann | db6b672 | 2012-05-07 16:54:40 +0000 | [diff] [blame] | 30 | #include <mach/irqs.h> |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 31 | |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 32 | #include <plat/clcd.h> |
| 33 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 34 | static struct map_desc ct_ca9x4_io_desc[] __initdata = { |
| 35 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 36 | .virtual = V2T_PERIPH, |
| 37 | .pfn = __phys_to_pfn(CT_CA9X4_MPIC), |
| 38 | .length = SZ_8K, |
| 39 | .type = MT_DEVICE, |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 40 | }, |
| 41 | }; |
| 42 | |
| 43 | static void __init ct_ca9x4_map_io(void) |
| 44 | { |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 45 | iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc)); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Marc Zyngier | 7c380f2 | 2011-08-04 11:57:04 +0100 | [diff] [blame] | 48 | #ifdef CONFIG_HAVE_ARM_TWD |
| 49 | static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER); |
| 50 | |
| 51 | static void __init ca9x4_twd_init(void) |
| 52 | { |
| 53 | int err = twd_local_timer_register(&twd_local_timer); |
| 54 | if (err) |
| 55 | pr_err("twd_local_timer_register failed %d\n", err); |
| 56 | } |
| 57 | #else |
| 58 | #define ca9x4_twd_init() do {} while(0) |
| 59 | #endif |
| 60 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 61 | static void __init ct_ca9x4_init_irq(void) |
| 62 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 63 | gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K), |
| 64 | ioremap(A9_MPCORE_GIC_CPU, SZ_256)); |
Marc Zyngier | 7c380f2 | 2011-08-04 11:57:04 +0100 | [diff] [blame] | 65 | ca9x4_twd_init(); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 68 | static int ct_ca9x4_clcd_setup(struct clcd_fb *fb) |
| 69 | { |
| 70 | unsigned long framesize = 1024 * 768 * 2; |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 71 | |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 72 | fb->panel = versatile_clcd_get_panel("XVGA"); |
| 73 | if (!fb->panel) |
| 74 | return -EINVAL; |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 75 | |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 76 | return versatile_clcd_setup_dma(fb, framesize); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | static struct clcd_board ct_ca9x4_clcd_data = { |
| 80 | .name = "CT-CA9X4", |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 81 | .caps = CLCD_CAP_5551 | CLCD_CAP_565, |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 82 | .check = clcdfb_check, |
| 83 | .decode = clcdfb_decode, |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 84 | .setup = ct_ca9x4_clcd_setup, |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 85 | .mmap = versatile_clcd_mmap_dma, |
| 86 | .remove = versatile_clcd_remove_dma, |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
Russell King | cdd4e1a | 2011-12-18 12:07:09 +0000 | [diff] [blame] | 89 | static AMBA_AHB_DEVICE(clcd, "ct:clcd", 0, CT_CA9X4_CLCDC, IRQ_CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data); |
| 90 | static AMBA_APB_DEVICE(dmc, "ct:dmc", 0, CT_CA9X4_DMC, IRQ_CT_CA9X4_DMC, NULL); |
| 91 | static AMBA_APB_DEVICE(smc, "ct:smc", 0, CT_CA9X4_SMC, IRQ_CT_CA9X4_SMC, NULL); |
| 92 | static AMBA_APB_DEVICE(gpio, "ct:gpio", 0, CT_CA9X4_GPIO, IRQ_CT_CA9X4_GPIO, NULL); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 93 | |
| 94 | static struct amba_device *ct_ca9x4_amba_devs[] __initdata = { |
| 95 | &clcd_device, |
| 96 | &dmc_device, |
| 97 | &smc_device, |
| 98 | &gpio_device, |
| 99 | }; |
| 100 | |
Will Deacon | f417cba | 2010-04-15 10:16:26 +0100 | [diff] [blame] | 101 | static struct resource pmu_resources[] = { |
| 102 | [0] = { |
| 103 | .start = IRQ_CT_CA9X4_PMU_CPU0, |
| 104 | .end = IRQ_CT_CA9X4_PMU_CPU0, |
| 105 | .flags = IORESOURCE_IRQ, |
| 106 | }, |
| 107 | [1] = { |
| 108 | .start = IRQ_CT_CA9X4_PMU_CPU1, |
| 109 | .end = IRQ_CT_CA9X4_PMU_CPU1, |
| 110 | .flags = IORESOURCE_IRQ, |
| 111 | }, |
| 112 | [2] = { |
| 113 | .start = IRQ_CT_CA9X4_PMU_CPU2, |
| 114 | .end = IRQ_CT_CA9X4_PMU_CPU2, |
| 115 | .flags = IORESOURCE_IRQ, |
| 116 | }, |
| 117 | [3] = { |
| 118 | .start = IRQ_CT_CA9X4_PMU_CPU3, |
| 119 | .end = IRQ_CT_CA9X4_PMU_CPU3, |
| 120 | .flags = IORESOURCE_IRQ, |
| 121 | }, |
| 122 | }; |
| 123 | |
| 124 | static struct platform_device pmu_device = { |
| 125 | .name = "arm-pmu", |
Sudeep KarkadaNagesha | df3d17e | 2012-07-19 09:50:21 +0100 | [diff] [blame] | 126 | .id = -1, |
Will Deacon | f417cba | 2010-04-15 10:16:26 +0100 | [diff] [blame] | 127 | .num_resources = ARRAY_SIZE(pmu_resources), |
| 128 | .resource = pmu_resources, |
| 129 | }; |
| 130 | |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 131 | static struct platform_device osc1_device = { |
| 132 | .name = "vexpress-osc", |
| 133 | .id = 1, |
| 134 | .num_resources = 1, |
| 135 | .resource = (struct resource []) { |
| 136 | VEXPRESS_RES_FUNC(0xf, 1), |
| 137 | }, |
| 138 | }; |
| 139 | |
Russell King | cdaf9a2 | 2010-10-05 11:29:28 +0100 | [diff] [blame] | 140 | static void __init ct_ca9x4_init(void) |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 141 | { |
| 142 | int i; |
| 143 | |
| 144 | #ifdef CONFIG_CACHE_L2X0 |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 145 | void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K); |
Will Deacon | 2de59fe | 2010-09-27 14:55:15 +0100 | [diff] [blame] | 146 | |
| 147 | /* set RAM latencies to 1 cycle for this core tile. */ |
| 148 | writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL); |
| 149 | writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL); |
| 150 | |
| 151 | l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 152 | #endif |
| 153 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 154 | for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++) |
| 155 | amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource); |
Will Deacon | f417cba | 2010-04-15 10:16:26 +0100 | [diff] [blame] | 156 | |
| 157 | platform_device_register(&pmu_device); |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 158 | platform_device_register(&osc1_device); |
| 159 | |
| 160 | WARN_ON(clk_register_clkdev(vexpress_osc_setup(&osc1_device.dev), |
| 161 | NULL, "ct:clcd")); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 164 | #ifdef CONFIG_SMP |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 165 | static void *ct_ca9x4_scu_base __initdata; |
| 166 | |
Russell King | 94ae027 | 2012-01-18 19:40:13 +0000 | [diff] [blame] | 167 | static void __init ct_ca9x4_init_cpu_map(void) |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 168 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 169 | int i, ncores; |
| 170 | |
| 171 | ct_ca9x4_scu_base = ioremap(A9_MPCORE_SCU, SZ_128); |
| 172 | if (WARN_ON(!ct_ca9x4_scu_base)) |
| 173 | return; |
| 174 | |
| 175 | ncores = scu_get_core_count(ct_ca9x4_scu_base); |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 176 | |
Russell King | a06f916 | 2011-10-20 22:04:18 +0100 | [diff] [blame] | 177 | if (ncores > nr_cpu_ids) { |
| 178 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", |
| 179 | ncores, nr_cpu_ids); |
| 180 | ncores = nr_cpu_ids; |
| 181 | } |
| 182 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 183 | for (i = 0; i < ncores; ++i) |
| 184 | set_cpu_possible(i, true); |
| 185 | } |
| 186 | |
Russell King | 94ae027 | 2012-01-18 19:40:13 +0000 | [diff] [blame] | 187 | static void __init ct_ca9x4_smp_enable(unsigned int max_cpus) |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 188 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 189 | scu_enable(ct_ca9x4_scu_base); |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 190 | } |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 191 | #endif |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 192 | |
| 193 | struct ct_desc ct_ca9x4_desc __initdata = { |
| 194 | .id = V2M_CT_ID_CA9, |
| 195 | .name = "CA9x4", |
| 196 | .map_io = ct_ca9x4_map_io, |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 197 | .init_irq = ct_ca9x4_init_irq, |
| 198 | .init_tile = ct_ca9x4_init, |
| 199 | #ifdef CONFIG_SMP |
| 200 | .init_cpu_map = ct_ca9x4_init_cpu_map, |
| 201 | .smp_enable = ct_ca9x4_smp_enable, |
| 202 | #endif |
| 203 | }; |