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> |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 12 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 13 | #include <asm/hardware/arm_timer.h> |
| 14 | #include <asm/hardware/cache-l2x0.h> |
| 15 | #include <asm/hardware/gic.h> |
Will Deacon | f417cba | 2010-04-15 10:16:26 +0100 | [diff] [blame] | 16 | #include <asm/pmu.h> |
Will Deacon | 80b5efb | 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 | 80b5efb | 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 void ct_ca9x4_clcd_enable(struct clcd_fb *fb) |
| 69 | { |
Pawel Moll | d927daf | 2012-06-12 16:14:03 +0100 | [diff] [blame] | 70 | u32 site = v2m_get_master_site(); |
| 71 | |
| 72 | /* |
| 73 | * Old firmware was using the "site" component of the command |
| 74 | * to control the DVI muxer (while it should be always 0 ie. MB). |
| 75 | * Newer firmware uses the data register. Keep both for compatibility. |
| 76 | */ |
| 77 | v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE(site), site); |
| 78 | v2m_cfg_write(SYS_CFG_DVIMODE | SYS_CFG_SITE(SYS_CFG_SITE_MB), 2); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | static int ct_ca9x4_clcd_setup(struct clcd_fb *fb) |
| 82 | { |
| 83 | unsigned long framesize = 1024 * 768 * 2; |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 84 | |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 85 | fb->panel = versatile_clcd_get_panel("XVGA"); |
| 86 | if (!fb->panel) |
| 87 | return -EINVAL; |
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 | return versatile_clcd_setup_dma(fb, framesize); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | static struct clcd_board ct_ca9x4_clcd_data = { |
| 93 | .name = "CT-CA9X4", |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 94 | .caps = CLCD_CAP_5551 | CLCD_CAP_565, |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 95 | .check = clcdfb_check, |
| 96 | .decode = clcdfb_decode, |
| 97 | .enable = ct_ca9x4_clcd_enable, |
| 98 | .setup = ct_ca9x4_clcd_setup, |
Russell King | 0fb44b9 | 2011-01-18 20:13:51 +0000 | [diff] [blame] | 99 | .mmap = versatile_clcd_mmap_dma, |
| 100 | .remove = versatile_clcd_remove_dma, |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
Russell King | cdd4e1a | 2011-12-18 12:07:09 +0000 | [diff] [blame] | 103 | static AMBA_AHB_DEVICE(clcd, "ct:clcd", 0, CT_CA9X4_CLCDC, IRQ_CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data); |
| 104 | static AMBA_APB_DEVICE(dmc, "ct:dmc", 0, CT_CA9X4_DMC, IRQ_CT_CA9X4_DMC, NULL); |
| 105 | static AMBA_APB_DEVICE(smc, "ct:smc", 0, CT_CA9X4_SMC, IRQ_CT_CA9X4_SMC, NULL); |
| 106 | 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] | 107 | |
| 108 | static struct amba_device *ct_ca9x4_amba_devs[] __initdata = { |
| 109 | &clcd_device, |
| 110 | &dmc_device, |
| 111 | &smc_device, |
| 112 | &gpio_device, |
| 113 | }; |
| 114 | |
| 115 | |
Pawel Moll | d1b8a77 | 2012-07-13 11:48:16 +0100 | [diff] [blame] | 116 | static struct v2m_osc ct_osc1 = { |
| 117 | .osc = 1, |
| 118 | .rate_min = 10000000, |
| 119 | .rate_max = 80000000, |
| 120 | .rate_default = 23750000, |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
Will Deacon | f417cba | 2010-04-15 10:16:26 +0100 | [diff] [blame] | 123 | static struct resource pmu_resources[] = { |
| 124 | [0] = { |
| 125 | .start = IRQ_CT_CA9X4_PMU_CPU0, |
| 126 | .end = IRQ_CT_CA9X4_PMU_CPU0, |
| 127 | .flags = IORESOURCE_IRQ, |
| 128 | }, |
| 129 | [1] = { |
| 130 | .start = IRQ_CT_CA9X4_PMU_CPU1, |
| 131 | .end = IRQ_CT_CA9X4_PMU_CPU1, |
| 132 | .flags = IORESOURCE_IRQ, |
| 133 | }, |
| 134 | [2] = { |
| 135 | .start = IRQ_CT_CA9X4_PMU_CPU2, |
| 136 | .end = IRQ_CT_CA9X4_PMU_CPU2, |
| 137 | .flags = IORESOURCE_IRQ, |
| 138 | }, |
| 139 | [3] = { |
| 140 | .start = IRQ_CT_CA9X4_PMU_CPU3, |
| 141 | .end = IRQ_CT_CA9X4_PMU_CPU3, |
| 142 | .flags = IORESOURCE_IRQ, |
| 143 | }, |
| 144 | }; |
| 145 | |
| 146 | static struct platform_device pmu_device = { |
| 147 | .name = "arm-pmu", |
| 148 | .id = ARM_PMU_DEVICE_CPU, |
| 149 | .num_resources = ARRAY_SIZE(pmu_resources), |
| 150 | .resource = pmu_resources, |
| 151 | }; |
| 152 | |
Russell King | cdaf9a2 | 2010-10-05 11:29:28 +0100 | [diff] [blame] | 153 | static void __init ct_ca9x4_init(void) |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 154 | { |
| 155 | int i; |
Pawel Moll | d1b8a77 | 2012-07-13 11:48:16 +0100 | [diff] [blame] | 156 | struct clk *clk; |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 157 | |
| 158 | #ifdef CONFIG_CACHE_L2X0 |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 159 | void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K); |
Will Deacon | 2de59fe | 2010-09-27 14:55:15 +0100 | [diff] [blame] | 160 | |
| 161 | /* set RAM latencies to 1 cycle for this core tile. */ |
| 162 | writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL); |
| 163 | writel(0, l2x0_base + L2X0_DATA_LATENCY_CTRL); |
| 164 | |
| 165 | l2x0_init(l2x0_base, 0x00400000, 0xfe0fffff); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 166 | #endif |
| 167 | |
Pawel Moll | d1b8a77 | 2012-07-13 11:48:16 +0100 | [diff] [blame] | 168 | ct_osc1.site = v2m_get_master_site(); |
| 169 | clk = v2m_osc_register("ct:osc1", &ct_osc1); |
| 170 | clk_register_clkdev(clk, NULL, "ct:clcd"); |
| 171 | |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 172 | for (i = 0; i < ARRAY_SIZE(ct_ca9x4_amba_devs); i++) |
| 173 | amba_device_register(ct_ca9x4_amba_devs[i], &iomem_resource); |
Will Deacon | f417cba | 2010-04-15 10:16:26 +0100 | [diff] [blame] | 174 | |
| 175 | platform_device_register(&pmu_device); |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 176 | } |
| 177 | |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 178 | #ifdef CONFIG_SMP |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 179 | static void *ct_ca9x4_scu_base __initdata; |
| 180 | |
Russell King | 94ae027 | 2012-01-18 19:40:13 +0000 | [diff] [blame] | 181 | static void __init ct_ca9x4_init_cpu_map(void) |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 182 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 183 | int i, ncores; |
| 184 | |
| 185 | ct_ca9x4_scu_base = ioremap(A9_MPCORE_SCU, SZ_128); |
| 186 | if (WARN_ON(!ct_ca9x4_scu_base)) |
| 187 | return; |
| 188 | |
| 189 | ncores = scu_get_core_count(ct_ca9x4_scu_base); |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 190 | |
Russell King | a06f916 | 2011-10-20 22:04:18 +0100 | [diff] [blame] | 191 | if (ncores > nr_cpu_ids) { |
| 192 | pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", |
| 193 | ncores, nr_cpu_ids); |
| 194 | ncores = nr_cpu_ids; |
| 195 | } |
| 196 | |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 197 | for (i = 0; i < ncores; ++i) |
| 198 | set_cpu_possible(i, true); |
Russell King | 0f7b332 | 2011-04-03 13:01:30 +0100 | [diff] [blame] | 199 | |
| 200 | set_smp_cross_call(gic_raise_softirq); |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 201 | } |
| 202 | |
Russell King | 94ae027 | 2012-01-18 19:40:13 +0000 | [diff] [blame] | 203 | static void __init ct_ca9x4_smp_enable(unsigned int max_cpus) |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 204 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 205 | scu_enable(ct_ca9x4_scu_base); |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 206 | } |
Russell King | fef88f1 | 2010-02-28 17:26:25 +0000 | [diff] [blame] | 207 | #endif |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 208 | |
| 209 | struct ct_desc ct_ca9x4_desc __initdata = { |
| 210 | .id = V2M_CT_ID_CA9, |
| 211 | .name = "CA9x4", |
| 212 | .map_io = ct_ca9x4_map_io, |
Will Deacon | 80b5efb | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 213 | .init_irq = ct_ca9x4_init_irq, |
| 214 | .init_tile = ct_ca9x4_init, |
| 215 | #ifdef CONFIG_SMP |
| 216 | .init_cpu_map = ct_ca9x4_init_cpu_map, |
| 217 | .smp_enable = ct_ca9x4_smp_enable, |
| 218 | #endif |
| 219 | }; |