Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Versatile Express V2M Motherboard Support |
| 3 | */ |
Rob Herring | 0583fe4 | 2013-04-10 18:27:51 -0500 | [diff] [blame] | 4 | #include <linux/clocksource.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 5 | #include <linux/device.h> |
| 6 | #include <linux/amba/bus.h> |
| 7 | #include <linux/amba/mmci.h> |
| 8 | #include <linux/io.h> |
Rob Herring | da4a686 | 2013-02-06 21:17:47 -0600 | [diff] [blame] | 9 | #include <linux/clocksource.h> |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 10 | #include <linux/smp.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 11 | #include <linux/init.h> |
Rob Herring | 0529e315 | 2012-11-05 16:18:28 -0600 | [diff] [blame] | 12 | #include <linux/irqchip.h> |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 13 | #include <linux/of_address.h> |
| 14 | #include <linux/of_fdt.h> |
| 15 | #include <linux/of_irq.h> |
| 16 | #include <linux/of_platform.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Nick Bowler | 95c34f8 | 2011-01-21 15:51:06 +0100 | [diff] [blame] | 18 | #include <linux/ata_platform.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 19 | #include <linux/smsc911x.h> |
| 20 | #include <linux/spinlock.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 21 | #include <linux/usb/isp1760.h> |
Marc Zyngier | 0f71fd4 | 2011-05-18 10:51:51 +0100 | [diff] [blame] | 22 | #include <linux/mtd/physmap.h> |
Pawel Moll | b2a54ff | 2012-07-09 11:33:47 +0100 | [diff] [blame] | 23 | #include <linux/regulator/fixed.h> |
| 24 | #include <linux/regulator/machine.h> |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 25 | #include <linux/vexpress.h> |
Pawel Moll | 6e973d2 | 2013-04-18 18:23:22 +0100 | [diff] [blame] | 26 | #include <linux/clk-provider.h> |
| 27 | #include <linux/clkdev.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 28 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 29 | #include <asm/mach-types.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 30 | #include <asm/sizes.h> |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 31 | #include <asm/mach/arch.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 32 | #include <asm/mach/map.h> |
| 33 | #include <asm/mach/time.h> |
| 34 | #include <asm/hardware/arm_timer.h> |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 35 | #include <asm/hardware/cache-l2x0.h> |
Russell King | 58daf18 | 2011-01-05 18:09:03 +0000 | [diff] [blame] | 36 | #include <asm/hardware/timer-sp.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 37 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 38 | #include <mach/ct-ca9x4.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 39 | #include <mach/motherboard.h> |
| 40 | |
Russell King | 0af85dd | 2010-12-15 21:58:50 +0000 | [diff] [blame] | 41 | #include <plat/sched_clock.h> |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 42 | #include <plat/platsmp.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 43 | |
| 44 | #include "core.h" |
| 45 | |
| 46 | #define V2M_PA_CS0 0x40000000 |
| 47 | #define V2M_PA_CS1 0x44000000 |
| 48 | #define V2M_PA_CS2 0x48000000 |
| 49 | #define V2M_PA_CS3 0x4c000000 |
| 50 | #define V2M_PA_CS7 0x10000000 |
| 51 | |
| 52 | static struct map_desc v2m_io_desc[] __initdata = { |
| 53 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 54 | .virtual = V2M_PERIPH, |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 55 | .pfn = __phys_to_pfn(V2M_PA_CS7), |
| 56 | .length = SZ_128K, |
| 57 | .type = MT_DEVICE, |
| 58 | }, |
| 59 | }; |
| 60 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 61 | static void __init v2m_sp804_init(void __iomem *base, unsigned int irq) |
| 62 | { |
| 63 | if (WARN_ON(!base || irq == NO_IRQ)) |
| 64 | return; |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 65 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 66 | sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1"); |
| 67 | sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0"); |
| 68 | } |
| 69 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 70 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 71 | static struct resource v2m_pcie_i2c_resource = { |
| 72 | .start = V2M_SERIAL_BUS_PCI, |
| 73 | .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1, |
| 74 | .flags = IORESOURCE_MEM, |
| 75 | }; |
| 76 | |
| 77 | static struct platform_device v2m_pcie_i2c_device = { |
| 78 | .name = "versatile-i2c", |
| 79 | .id = 0, |
| 80 | .num_resources = 1, |
| 81 | .resource = &v2m_pcie_i2c_resource, |
| 82 | }; |
| 83 | |
| 84 | static struct resource v2m_ddc_i2c_resource = { |
| 85 | .start = V2M_SERIAL_BUS_DVI, |
| 86 | .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1, |
| 87 | .flags = IORESOURCE_MEM, |
| 88 | }; |
| 89 | |
| 90 | static struct platform_device v2m_ddc_i2c_device = { |
| 91 | .name = "versatile-i2c", |
| 92 | .id = 1, |
| 93 | .num_resources = 1, |
| 94 | .resource = &v2m_ddc_i2c_resource, |
| 95 | }; |
| 96 | |
| 97 | static struct resource v2m_eth_resources[] = { |
| 98 | { |
| 99 | .start = V2M_LAN9118, |
| 100 | .end = V2M_LAN9118 + SZ_64K - 1, |
| 101 | .flags = IORESOURCE_MEM, |
| 102 | }, { |
| 103 | .start = IRQ_V2M_LAN9118, |
| 104 | .end = IRQ_V2M_LAN9118, |
| 105 | .flags = IORESOURCE_IRQ, |
| 106 | }, |
| 107 | }; |
| 108 | |
| 109 | static struct smsc911x_platform_config v2m_eth_config = { |
| 110 | .flags = SMSC911X_USE_32BIT, |
| 111 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, |
| 112 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 113 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 114 | }; |
| 115 | |
| 116 | static struct platform_device v2m_eth_device = { |
| 117 | .name = "smsc911x", |
| 118 | .id = -1, |
| 119 | .resource = v2m_eth_resources, |
| 120 | .num_resources = ARRAY_SIZE(v2m_eth_resources), |
| 121 | .dev.platform_data = &v2m_eth_config, |
| 122 | }; |
| 123 | |
Pawel Moll | b2a54ff | 2012-07-09 11:33:47 +0100 | [diff] [blame] | 124 | static struct regulator_consumer_supply v2m_eth_supplies[] = { |
| 125 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 126 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 127 | }; |
| 128 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 129 | static struct resource v2m_usb_resources[] = { |
| 130 | { |
| 131 | .start = V2M_ISP1761, |
| 132 | .end = V2M_ISP1761 + SZ_128K - 1, |
| 133 | .flags = IORESOURCE_MEM, |
| 134 | }, { |
| 135 | .start = IRQ_V2M_ISP1761, |
| 136 | .end = IRQ_V2M_ISP1761, |
| 137 | .flags = IORESOURCE_IRQ, |
| 138 | }, |
| 139 | }; |
| 140 | |
| 141 | static struct isp1760_platform_data v2m_usb_config = { |
| 142 | .is_isp1761 = true, |
| 143 | .bus_width_16 = false, |
| 144 | .port1_otg = true, |
| 145 | .analog_oc = false, |
| 146 | .dack_polarity_high = false, |
| 147 | .dreq_polarity_high = false, |
| 148 | }; |
| 149 | |
| 150 | static struct platform_device v2m_usb_device = { |
| 151 | .name = "isp1760", |
| 152 | .id = -1, |
| 153 | .resource = v2m_usb_resources, |
| 154 | .num_resources = ARRAY_SIZE(v2m_usb_resources), |
| 155 | .dev.platform_data = &v2m_usb_config, |
| 156 | }; |
| 157 | |
Marc Zyngier | 0f71fd4 | 2011-05-18 10:51:51 +0100 | [diff] [blame] | 158 | static struct physmap_flash_data v2m_flash_data = { |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 159 | .width = 4, |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | static struct resource v2m_flash_resources[] = { |
| 163 | { |
| 164 | .start = V2M_NOR0, |
| 165 | .end = V2M_NOR0 + SZ_64M - 1, |
| 166 | .flags = IORESOURCE_MEM, |
| 167 | }, { |
| 168 | .start = V2M_NOR1, |
| 169 | .end = V2M_NOR1 + SZ_64M - 1, |
| 170 | .flags = IORESOURCE_MEM, |
| 171 | }, |
| 172 | }; |
| 173 | |
| 174 | static struct platform_device v2m_flash_device = { |
Marc Zyngier | 0f71fd4 | 2011-05-18 10:51:51 +0100 | [diff] [blame] | 175 | .name = "physmap-flash", |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 176 | .id = -1, |
| 177 | .resource = v2m_flash_resources, |
| 178 | .num_resources = ARRAY_SIZE(v2m_flash_resources), |
| 179 | .dev.platform_data = &v2m_flash_data, |
| 180 | }; |
| 181 | |
Nick Bowler | 95c34f8 | 2011-01-21 15:51:06 +0100 | [diff] [blame] | 182 | static struct pata_platform_info v2m_pata_data = { |
| 183 | .ioport_shift = 2, |
| 184 | }; |
| 185 | |
| 186 | static struct resource v2m_pata_resources[] = { |
| 187 | { |
| 188 | .start = V2M_CF, |
| 189 | .end = V2M_CF + 0xff, |
| 190 | .flags = IORESOURCE_MEM, |
| 191 | }, { |
| 192 | .start = V2M_CF + 0x100, |
| 193 | .end = V2M_CF + SZ_4K - 1, |
| 194 | .flags = IORESOURCE_MEM, |
| 195 | }, |
| 196 | }; |
| 197 | |
| 198 | static struct platform_device v2m_cf_device = { |
| 199 | .name = "pata_platform", |
| 200 | .id = -1, |
| 201 | .resource = v2m_pata_resources, |
| 202 | .num_resources = ARRAY_SIZE(v2m_pata_resources), |
| 203 | .dev.platform_data = &v2m_pata_data, |
| 204 | }; |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 205 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 206 | static struct mmci_platform_data v2m_mmci_data = { |
| 207 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 208 | .gpio_wp = VEXPRESS_GPIO_MMC_WPROT, |
| 209 | .gpio_cd = VEXPRESS_GPIO_MMC_CARDIN, |
| 210 | }; |
| 211 | |
| 212 | static struct resource v2m_sysreg_resources[] = { |
| 213 | { |
| 214 | .start = V2M_SYSREGS, |
| 215 | .end = V2M_SYSREGS + 0xfff, |
| 216 | .flags = IORESOURCE_MEM, |
| 217 | }, |
| 218 | }; |
| 219 | |
| 220 | static struct platform_device v2m_sysreg_device = { |
| 221 | .name = "vexpress-sysreg", |
| 222 | .id = -1, |
| 223 | .resource = v2m_sysreg_resources, |
| 224 | .num_resources = ARRAY_SIZE(v2m_sysreg_resources), |
| 225 | }; |
| 226 | |
| 227 | static struct platform_device v2m_muxfpga_device = { |
| 228 | .name = "vexpress-muxfpga", |
| 229 | .id = 0, |
| 230 | .num_resources = 1, |
| 231 | .resource = (struct resource []) { |
| 232 | VEXPRESS_RES_FUNC(0, 7), |
| 233 | } |
| 234 | }; |
| 235 | |
| 236 | static struct platform_device v2m_shutdown_device = { |
| 237 | .name = "vexpress-shutdown", |
| 238 | .id = 0, |
| 239 | .num_resources = 1, |
| 240 | .resource = (struct resource []) { |
| 241 | VEXPRESS_RES_FUNC(0, 8), |
| 242 | } |
| 243 | }; |
| 244 | |
| 245 | static struct platform_device v2m_reboot_device = { |
| 246 | .name = "vexpress-reboot", |
| 247 | .id = 0, |
| 248 | .num_resources = 1, |
| 249 | .resource = (struct resource []) { |
| 250 | VEXPRESS_RES_FUNC(0, 9), |
| 251 | } |
| 252 | }; |
| 253 | |
| 254 | static struct platform_device v2m_dvimode_device = { |
| 255 | .name = "vexpress-dvimode", |
| 256 | .id = 0, |
| 257 | .num_resources = 1, |
| 258 | .resource = (struct resource []) { |
| 259 | VEXPRESS_RES_FUNC(0, 11), |
| 260 | } |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 261 | }; |
| 262 | |
Russell King | cdd4e1a | 2011-12-18 12:07:09 +0000 | [diff] [blame] | 263 | static AMBA_APB_DEVICE(aaci, "mb:aaci", 0, V2M_AACI, IRQ_V2M_AACI, NULL); |
| 264 | static AMBA_APB_DEVICE(mmci, "mb:mmci", 0, V2M_MMCI, IRQ_V2M_MMCI, &v2m_mmci_data); |
| 265 | static AMBA_APB_DEVICE(kmi0, "mb:kmi0", 0, V2M_KMI0, IRQ_V2M_KMI0, NULL); |
| 266 | static AMBA_APB_DEVICE(kmi1, "mb:kmi1", 0, V2M_KMI1, IRQ_V2M_KMI1, NULL); |
| 267 | static AMBA_APB_DEVICE(uart0, "mb:uart0", 0, V2M_UART0, IRQ_V2M_UART0, NULL); |
| 268 | static AMBA_APB_DEVICE(uart1, "mb:uart1", 0, V2M_UART1, IRQ_V2M_UART1, NULL); |
| 269 | static AMBA_APB_DEVICE(uart2, "mb:uart2", 0, V2M_UART2, IRQ_V2M_UART2, NULL); |
| 270 | static AMBA_APB_DEVICE(uart3, "mb:uart3", 0, V2M_UART3, IRQ_V2M_UART3, NULL); |
| 271 | static AMBA_APB_DEVICE(wdt, "mb:wdt", 0, V2M_WDT, IRQ_V2M_WDT, NULL); |
| 272 | static AMBA_APB_DEVICE(rtc, "mb:rtc", 0, V2M_RTC, IRQ_V2M_RTC, NULL); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 273 | |
| 274 | static struct amba_device *v2m_amba_devs[] __initdata = { |
| 275 | &aaci_device, |
| 276 | &mmci_device, |
| 277 | &kmi0_device, |
| 278 | &kmi1_device, |
| 279 | &uart0_device, |
| 280 | &uart1_device, |
| 281 | &uart2_device, |
| 282 | &uart3_device, |
| 283 | &wdt_device, |
| 284 | &rtc_device, |
| 285 | }; |
| 286 | |
Pawel Moll | d1b8a77 | 2012-07-13 11:48:16 +0100 | [diff] [blame] | 287 | static void __init v2m_timer_init(void) |
| 288 | { |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 289 | vexpress_clk_init(ioremap(V2M_SYSCTL, SZ_4K)); |
Pawel Moll | d1b8a77 | 2012-07-13 11:48:16 +0100 | [diff] [blame] | 290 | v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0); |
| 291 | } |
| 292 | |
Rob Herring | 2fdf999 | 2011-05-30 19:44:22 +0100 | [diff] [blame] | 293 | static void __init v2m_init_early(void) |
| 294 | { |
Pawel Moll | d1b8a77 | 2012-07-13 11:48:16 +0100 | [diff] [blame] | 295 | if (ct_desc->init_early) |
| 296 | ct_desc->init_early(); |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 297 | versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), 24000000); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 298 | } |
| 299 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 300 | struct ct_desc *ct_desc; |
| 301 | |
| 302 | static struct ct_desc *ct_descs[] __initdata = { |
| 303 | #ifdef CONFIG_ARCH_VEXPRESS_CA9X4 |
| 304 | &ct_ca9x4_desc, |
| 305 | #endif |
| 306 | }; |
| 307 | |
| 308 | static void __init v2m_populate_ct_desc(void) |
| 309 | { |
| 310 | int i; |
| 311 | u32 current_tile_id; |
| 312 | |
| 313 | ct_desc = NULL; |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 314 | current_tile_id = vexpress_get_procid(VEXPRESS_SITE_MASTER) |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame] | 315 | & V2M_CT_ID_MASK; |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 316 | |
| 317 | for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i) |
| 318 | if (ct_descs[i]->id == current_tile_id) |
| 319 | ct_desc = ct_descs[i]; |
| 320 | |
| 321 | if (!ct_desc) |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 322 | panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n" |
| 323 | "You may need a device tree blob or a different kernel to boot on this board.\n", |
| 324 | current_tile_id); |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | static void __init v2m_map_io(void) |
| 328 | { |
| 329 | iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc)); |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 330 | vexpress_sysreg_early_init(ioremap(V2M_SYSREGS, SZ_4K)); |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 331 | v2m_populate_ct_desc(); |
| 332 | ct_desc->map_io(); |
| 333 | } |
| 334 | |
| 335 | static void __init v2m_init_irq(void) |
| 336 | { |
| 337 | ct_desc->init_irq(); |
| 338 | } |
| 339 | |
| 340 | static void __init v2m_init(void) |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 341 | { |
| 342 | int i; |
| 343 | |
Pawel Moll | b2a54ff | 2012-07-09 11:33:47 +0100 | [diff] [blame] | 344 | regulator_register_fixed(0, v2m_eth_supplies, |
| 345 | ARRAY_SIZE(v2m_eth_supplies)); |
| 346 | |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 347 | platform_device_register(&v2m_muxfpga_device); |
| 348 | platform_device_register(&v2m_shutdown_device); |
| 349 | platform_device_register(&v2m_reboot_device); |
| 350 | platform_device_register(&v2m_dvimode_device); |
| 351 | |
| 352 | platform_device_register(&v2m_sysreg_device); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 353 | platform_device_register(&v2m_pcie_i2c_device); |
| 354 | platform_device_register(&v2m_ddc_i2c_device); |
| 355 | platform_device_register(&v2m_flash_device); |
Nick Bowler | 95c34f8 | 2011-01-21 15:51:06 +0100 | [diff] [blame] | 356 | platform_device_register(&v2m_cf_device); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 357 | platform_device_register(&v2m_eth_device); |
| 358 | platform_device_register(&v2m_usb_device); |
| 359 | |
| 360 | for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++) |
| 361 | amba_device_register(v2m_amba_devs[i], &iomem_resource); |
| 362 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 363 | ct_desc->init_tile(); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 364 | } |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 365 | |
| 366 | MACHINE_START(VEXPRESS, "ARM-Versatile Express") |
Nicolas Pitre | e9ce8e5 | 2011-07-05 22:38:18 -0400 | [diff] [blame] | 367 | .atag_offset = 0x100, |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 368 | .smp = smp_ops(vexpress_smp_ops), |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 369 | .map_io = v2m_map_io, |
| 370 | .init_early = v2m_init_early, |
| 371 | .init_irq = v2m_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 372 | .init_time = v2m_timer_init, |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 373 | .init_machine = v2m_init, |
| 374 | MACHINE_END |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 375 | |
Pawel Moll | 6a37195 | 2011-12-09 18:47:39 +0000 | [diff] [blame] | 376 | static struct map_desc v2m_rs1_io_desc __initdata = { |
| 377 | .virtual = V2M_PERIPH, |
| 378 | .pfn = __phys_to_pfn(0x1c000000), |
| 379 | .length = SZ_2M, |
| 380 | .type = MT_DEVICE, |
| 381 | }; |
| 382 | |
| 383 | static int __init v2m_dt_scan_memory_map(unsigned long node, const char *uname, |
| 384 | int depth, void *data) |
| 385 | { |
| 386 | const char **map = data; |
| 387 | |
| 388 | if (strcmp(uname, "motherboard") != 0) |
| 389 | return 0; |
| 390 | |
| 391 | *map = of_get_flat_dt_prop(node, "arm,v2m-memory-map", NULL); |
| 392 | |
| 393 | return 1; |
| 394 | } |
| 395 | |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 396 | void __init v2m_dt_map_io(void) |
| 397 | { |
Pawel Moll | 6a37195 | 2011-12-09 18:47:39 +0000 | [diff] [blame] | 398 | const char *map = NULL; |
| 399 | |
| 400 | of_scan_flat_dt(v2m_dt_scan_memory_map, &map); |
| 401 | |
| 402 | if (map && strcmp(map, "rs1") == 0) |
| 403 | iotable_init(&v2m_rs1_io_desc, 1); |
| 404 | else |
| 405 | iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc)); |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 406 | |
| 407 | #if defined(CONFIG_SMP) |
| 408 | vexpress_dt_smp_map_io(); |
| 409 | #endif |
| 410 | } |
| 411 | |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 412 | void __init v2m_dt_init_early(void) |
| 413 | { |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 414 | u32 dt_hbi; |
| 415 | |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 416 | vexpress_sysreg_of_early_init(); |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 417 | |
| 418 | /* Confirm board type against DT property, if available */ |
Randy Dunlap | 465aac6 | 2012-11-30 10:01:51 +0000 | [diff] [blame] | 419 | if (of_property_read_u32(of_allnodes, "arm,hbi", &dt_hbi) == 0) { |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 420 | u32 hbi = vexpress_get_hbi(VEXPRESS_SITE_MASTER); |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 421 | |
| 422 | if (WARN_ON(dt_hbi != hbi)) |
| 423 | pr_warning("vexpress: DT HBI (%x) is not matching " |
| 424 | "hardware (%x)!\n", dt_hbi, hbi); |
| 425 | } |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 426 | } |
| 427 | |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 428 | static void __init v2m_dt_timer_init(void) |
| 429 | { |
Pawel Moll | 6e973d2 | 2013-04-18 18:23:22 +0100 | [diff] [blame] | 430 | of_clk_init(NULL); |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 431 | |
Rob Herring | da4a686 | 2013-02-06 21:17:47 -0600 | [diff] [blame] | 432 | clocksource_of_init(); |
Pawel Moll | d1b8a77 | 2012-07-13 11:48:16 +0100 | [diff] [blame] | 433 | |
Rob Herring | 0583fe4 | 2013-04-10 18:27:51 -0500 | [diff] [blame] | 434 | versatile_sched_clock_init(vexpress_get_24mhz_clock_base(), |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 435 | 24000000); |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 436 | } |
| 437 | |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 438 | static const struct of_device_id v2m_dt_bus_match[] __initconst = { |
| 439 | { .compatible = "simple-bus", }, |
| 440 | { .compatible = "arm,amba-bus", }, |
| 441 | { .compatible = "arm,vexpress,config-bus", }, |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 442 | {} |
| 443 | }; |
| 444 | |
| 445 | static void __init v2m_dt_init(void) |
| 446 | { |
| 447 | l2x0_of_init(0x00400000, 0xfe0fffff); |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 448 | of_platform_populate(NULL, v2m_dt_bus_match, NULL, NULL); |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 449 | } |
| 450 | |
Pawel Moll | 38669e0 | 2012-10-09 12:56:36 +0100 | [diff] [blame] | 451 | static const char * const v2m_dt_match[] __initconst = { |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 452 | "arm,vexpress", |
| 453 | NULL, |
| 454 | }; |
| 455 | |
| 456 | DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express") |
| 457 | .dt_compat = v2m_dt_match, |
Marc Zyngier | 3695adc | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 458 | .smp = smp_ops(vexpress_smp_ops), |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 459 | .map_io = v2m_dt_map_io, |
| 460 | .init_early = v2m_dt_init_early, |
Rob Herring | 0529e315 | 2012-11-05 16:18:28 -0600 | [diff] [blame] | 461 | .init_irq = irqchip_init, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 462 | .init_time = v2m_dt_timer_init, |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 463 | .init_machine = v2m_dt_init, |
Pawel Moll | 8deed17 | 2012-02-23 13:04:51 +0000 | [diff] [blame] | 464 | MACHINE_END |