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