Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Versatile Express V2M Motherboard Support |
| 3 | */ |
| 4 | #include <linux/device.h> |
| 5 | #include <linux/amba/bus.h> |
| 6 | #include <linux/amba/mmci.h> |
| 7 | #include <linux/io.h> |
| 8 | #include <linux/init.h> |
| 9 | #include <linux/platform_device.h> |
Nick Bowler | 95c34f8 | 2011-01-21 15:51:06 +0100 | [diff] [blame] | 10 | #include <linux/ata_platform.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 11 | #include <linux/smsc911x.h> |
| 12 | #include <linux/spinlock.h> |
Kay Sievers | edbaa60 | 2011-12-21 16:26:03 -0800 | [diff] [blame] | 13 | #include <linux/device.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 14 | #include <linux/usb/isp1760.h> |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 15 | #include <linux/clkdev.h> |
Marc Zyngier | 0f71fd4 | 2011-05-18 10:51:51 +0100 | [diff] [blame] | 16 | #include <linux/mtd/physmap.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 17 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 18 | #include <asm/mach-types.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 19 | #include <asm/sizes.h> |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 20 | #include <asm/mach/arch.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 21 | #include <asm/mach/map.h> |
| 22 | #include <asm/mach/time.h> |
| 23 | #include <asm/hardware/arm_timer.h> |
Russell King | 58daf18 | 2011-01-05 18:09:03 +0000 | [diff] [blame] | 24 | #include <asm/hardware/timer-sp.h> |
Pawel Moll | baaece2 | 2011-01-25 15:53:03 +0100 | [diff] [blame] | 25 | #include <asm/hardware/sp810.h> |
Marc Zyngier | abd3ca5 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 26 | #include <asm/hardware/gic.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 27 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 28 | #include <mach/ct-ca9x4.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 29 | #include <mach/motherboard.h> |
| 30 | |
Russell King | 0af85dd | 2010-12-15 21:58:50 +0000 | [diff] [blame] | 31 | #include <plat/sched_clock.h> |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 32 | |
| 33 | #include "core.h" |
| 34 | |
| 35 | #define V2M_PA_CS0 0x40000000 |
| 36 | #define V2M_PA_CS1 0x44000000 |
| 37 | #define V2M_PA_CS2 0x48000000 |
| 38 | #define V2M_PA_CS3 0x4c000000 |
| 39 | #define V2M_PA_CS7 0x10000000 |
| 40 | |
| 41 | static struct map_desc v2m_io_desc[] __initdata = { |
| 42 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 43 | .virtual = V2M_PERIPH, |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 44 | .pfn = __phys_to_pfn(V2M_PA_CS7), |
| 45 | .length = SZ_128K, |
| 46 | .type = MT_DEVICE, |
| 47 | }, |
| 48 | }; |
| 49 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 50 | static void __iomem *v2m_sysreg_base; |
| 51 | |
| 52 | static void __init v2m_sysctl_init(void __iomem *base) |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 53 | { |
Pawel Moll | baaece2 | 2011-01-25 15:53:03 +0100 | [diff] [blame] | 54 | u32 scctrl; |
| 55 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 56 | if (WARN_ON(!base)) |
| 57 | return; |
| 58 | |
Pawel Moll | baaece2 | 2011-01-25 15:53:03 +0100 | [diff] [blame] | 59 | /* Select 1MHz TIMCLK as the reference clock for SP804 timers */ |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 60 | scctrl = readl(base + SCCTRL); |
Pawel Moll | baaece2 | 2011-01-25 15:53:03 +0100 | [diff] [blame] | 61 | scctrl |= SCCTRL_TIMEREN0SEL_TIMCLK; |
| 62 | scctrl |= SCCTRL_TIMEREN1SEL_TIMCLK; |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 63 | writel(scctrl, base + SCCTRL); |
| 64 | } |
Pawel Moll | baaece2 | 2011-01-25 15:53:03 +0100 | [diff] [blame] | 65 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 66 | static void __init v2m_sp804_init(void __iomem *base, unsigned int irq) |
| 67 | { |
| 68 | if (WARN_ON(!base || irq == NO_IRQ)) |
| 69 | return; |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 70 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 71 | writel(0, base + TIMER_1_BASE + TIMER_CTRL); |
| 72 | writel(0, base + TIMER_2_BASE + TIMER_CTRL); |
| 73 | |
| 74 | sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1"); |
| 75 | sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0"); |
| 76 | } |
| 77 | |
| 78 | static void __init v2m_timer_init(void) |
| 79 | { |
| 80 | v2m_sysctl_init(ioremap(V2M_SYSCTL, SZ_4K)); |
| 81 | v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 84 | static struct sys_timer v2m_timer = { |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 85 | .init = v2m_timer_init, |
| 86 | }; |
| 87 | |
| 88 | |
| 89 | static DEFINE_SPINLOCK(v2m_cfg_lock); |
| 90 | |
| 91 | int v2m_cfg_write(u32 devfn, u32 data) |
| 92 | { |
| 93 | /* Configuration interface broken? */ |
| 94 | u32 val; |
| 95 | |
| 96 | printk("%s: writing %08x to %08x\n", __func__, data, devfn); |
| 97 | |
| 98 | devfn |= SYS_CFG_START | SYS_CFG_WRITE; |
| 99 | |
| 100 | spin_lock(&v2m_cfg_lock); |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 101 | val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT); |
| 102 | writel(val & ~SYS_CFG_COMPLETE, v2m_sysreg_base + V2M_SYS_CFGSTAT); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 103 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 104 | writel(data, v2m_sysreg_base + V2M_SYS_CFGDATA); |
| 105 | writel(devfn, v2m_sysreg_base + V2M_SYS_CFGCTRL); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 106 | |
| 107 | do { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 108 | val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 109 | } while (val == 0); |
| 110 | spin_unlock(&v2m_cfg_lock); |
| 111 | |
| 112 | return !!(val & SYS_CFG_ERR); |
| 113 | } |
| 114 | |
| 115 | int v2m_cfg_read(u32 devfn, u32 *data) |
| 116 | { |
| 117 | u32 val; |
| 118 | |
| 119 | devfn |= SYS_CFG_START; |
| 120 | |
| 121 | spin_lock(&v2m_cfg_lock); |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 122 | writel(0, v2m_sysreg_base + V2M_SYS_CFGSTAT); |
| 123 | writel(devfn, v2m_sysreg_base + V2M_SYS_CFGCTRL); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 124 | |
| 125 | mb(); |
| 126 | |
| 127 | do { |
| 128 | cpu_relax(); |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 129 | val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 130 | } while (val == 0); |
| 131 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 132 | *data = readl(v2m_sysreg_base + V2M_SYS_CFGDATA); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 133 | spin_unlock(&v2m_cfg_lock); |
| 134 | |
| 135 | return !!(val & SYS_CFG_ERR); |
| 136 | } |
| 137 | |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 138 | void __init v2m_flags_set(u32 data) |
| 139 | { |
| 140 | writel(~0, v2m_sysreg_base + V2M_SYS_FLAGSCLR); |
| 141 | writel(data, v2m_sysreg_base + V2M_SYS_FLAGSSET); |
| 142 | } |
| 143 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 144 | |
| 145 | static struct resource v2m_pcie_i2c_resource = { |
| 146 | .start = V2M_SERIAL_BUS_PCI, |
| 147 | .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1, |
| 148 | .flags = IORESOURCE_MEM, |
| 149 | }; |
| 150 | |
| 151 | static struct platform_device v2m_pcie_i2c_device = { |
| 152 | .name = "versatile-i2c", |
| 153 | .id = 0, |
| 154 | .num_resources = 1, |
| 155 | .resource = &v2m_pcie_i2c_resource, |
| 156 | }; |
| 157 | |
| 158 | static struct resource v2m_ddc_i2c_resource = { |
| 159 | .start = V2M_SERIAL_BUS_DVI, |
| 160 | .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1, |
| 161 | .flags = IORESOURCE_MEM, |
| 162 | }; |
| 163 | |
| 164 | static struct platform_device v2m_ddc_i2c_device = { |
| 165 | .name = "versatile-i2c", |
| 166 | .id = 1, |
| 167 | .num_resources = 1, |
| 168 | .resource = &v2m_ddc_i2c_resource, |
| 169 | }; |
| 170 | |
| 171 | static struct resource v2m_eth_resources[] = { |
| 172 | { |
| 173 | .start = V2M_LAN9118, |
| 174 | .end = V2M_LAN9118 + SZ_64K - 1, |
| 175 | .flags = IORESOURCE_MEM, |
| 176 | }, { |
| 177 | .start = IRQ_V2M_LAN9118, |
| 178 | .end = IRQ_V2M_LAN9118, |
| 179 | .flags = IORESOURCE_IRQ, |
| 180 | }, |
| 181 | }; |
| 182 | |
| 183 | static struct smsc911x_platform_config v2m_eth_config = { |
| 184 | .flags = SMSC911X_USE_32BIT, |
| 185 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, |
| 186 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 187 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 188 | }; |
| 189 | |
| 190 | static struct platform_device v2m_eth_device = { |
| 191 | .name = "smsc911x", |
| 192 | .id = -1, |
| 193 | .resource = v2m_eth_resources, |
| 194 | .num_resources = ARRAY_SIZE(v2m_eth_resources), |
| 195 | .dev.platform_data = &v2m_eth_config, |
| 196 | }; |
| 197 | |
| 198 | static struct resource v2m_usb_resources[] = { |
| 199 | { |
| 200 | .start = V2M_ISP1761, |
| 201 | .end = V2M_ISP1761 + SZ_128K - 1, |
| 202 | .flags = IORESOURCE_MEM, |
| 203 | }, { |
| 204 | .start = IRQ_V2M_ISP1761, |
| 205 | .end = IRQ_V2M_ISP1761, |
| 206 | .flags = IORESOURCE_IRQ, |
| 207 | }, |
| 208 | }; |
| 209 | |
| 210 | static struct isp1760_platform_data v2m_usb_config = { |
| 211 | .is_isp1761 = true, |
| 212 | .bus_width_16 = false, |
| 213 | .port1_otg = true, |
| 214 | .analog_oc = false, |
| 215 | .dack_polarity_high = false, |
| 216 | .dreq_polarity_high = false, |
| 217 | }; |
| 218 | |
| 219 | static struct platform_device v2m_usb_device = { |
| 220 | .name = "isp1760", |
| 221 | .id = -1, |
| 222 | .resource = v2m_usb_resources, |
| 223 | .num_resources = ARRAY_SIZE(v2m_usb_resources), |
| 224 | .dev.platform_data = &v2m_usb_config, |
| 225 | }; |
| 226 | |
Marc Zyngier | 667f390 | 2011-05-18 10:51:55 +0100 | [diff] [blame] | 227 | static void v2m_flash_set_vpp(struct platform_device *pdev, int on) |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 228 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 229 | writel(on != 0, v2m_sysreg_base + V2M_SYS_FLASH); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Marc Zyngier | 0f71fd4 | 2011-05-18 10:51:51 +0100 | [diff] [blame] | 232 | static struct physmap_flash_data v2m_flash_data = { |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 233 | .width = 4, |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 234 | .set_vpp = v2m_flash_set_vpp, |
| 235 | }; |
| 236 | |
| 237 | static struct resource v2m_flash_resources[] = { |
| 238 | { |
| 239 | .start = V2M_NOR0, |
| 240 | .end = V2M_NOR0 + SZ_64M - 1, |
| 241 | .flags = IORESOURCE_MEM, |
| 242 | }, { |
| 243 | .start = V2M_NOR1, |
| 244 | .end = V2M_NOR1 + SZ_64M - 1, |
| 245 | .flags = IORESOURCE_MEM, |
| 246 | }, |
| 247 | }; |
| 248 | |
| 249 | static struct platform_device v2m_flash_device = { |
Marc Zyngier | 0f71fd4 | 2011-05-18 10:51:51 +0100 | [diff] [blame] | 250 | .name = "physmap-flash", |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 251 | .id = -1, |
| 252 | .resource = v2m_flash_resources, |
| 253 | .num_resources = ARRAY_SIZE(v2m_flash_resources), |
| 254 | .dev.platform_data = &v2m_flash_data, |
| 255 | }; |
| 256 | |
Nick Bowler | 95c34f8 | 2011-01-21 15:51:06 +0100 | [diff] [blame] | 257 | static struct pata_platform_info v2m_pata_data = { |
| 258 | .ioport_shift = 2, |
| 259 | }; |
| 260 | |
| 261 | static struct resource v2m_pata_resources[] = { |
| 262 | { |
| 263 | .start = V2M_CF, |
| 264 | .end = V2M_CF + 0xff, |
| 265 | .flags = IORESOURCE_MEM, |
| 266 | }, { |
| 267 | .start = V2M_CF + 0x100, |
| 268 | .end = V2M_CF + SZ_4K - 1, |
| 269 | .flags = IORESOURCE_MEM, |
| 270 | }, |
| 271 | }; |
| 272 | |
| 273 | static struct platform_device v2m_cf_device = { |
| 274 | .name = "pata_platform", |
| 275 | .id = -1, |
| 276 | .resource = v2m_pata_resources, |
| 277 | .num_resources = ARRAY_SIZE(v2m_pata_resources), |
| 278 | .dev.platform_data = &v2m_pata_data, |
| 279 | }; |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 280 | |
| 281 | static unsigned int v2m_mmci_status(struct device *dev) |
| 282 | { |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 283 | return readl(v2m_sysreg_base + V2M_SYS_MCI) & (1 << 0); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | static struct mmci_platform_data v2m_mmci_data = { |
| 287 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 288 | .status = v2m_mmci_status, |
| 289 | }; |
| 290 | |
| 291 | static AMBA_DEVICE(aaci, "mb:aaci", V2M_AACI, NULL); |
| 292 | static AMBA_DEVICE(mmci, "mb:mmci", V2M_MMCI, &v2m_mmci_data); |
| 293 | static AMBA_DEVICE(kmi0, "mb:kmi0", V2M_KMI0, NULL); |
| 294 | static AMBA_DEVICE(kmi1, "mb:kmi1", V2M_KMI1, NULL); |
| 295 | static AMBA_DEVICE(uart0, "mb:uart0", V2M_UART0, NULL); |
| 296 | static AMBA_DEVICE(uart1, "mb:uart1", V2M_UART1, NULL); |
| 297 | static AMBA_DEVICE(uart2, "mb:uart2", V2M_UART2, NULL); |
| 298 | static AMBA_DEVICE(uart3, "mb:uart3", V2M_UART3, NULL); |
| 299 | static AMBA_DEVICE(wdt, "mb:wdt", V2M_WDT, NULL); |
| 300 | static AMBA_DEVICE(rtc, "mb:rtc", V2M_RTC, NULL); |
| 301 | |
| 302 | static struct amba_device *v2m_amba_devs[] __initdata = { |
| 303 | &aaci_device, |
| 304 | &mmci_device, |
| 305 | &kmi0_device, |
| 306 | &kmi1_device, |
| 307 | &uart0_device, |
| 308 | &uart1_device, |
| 309 | &uart2_device, |
| 310 | &uart3_device, |
| 311 | &wdt_device, |
| 312 | &rtc_device, |
| 313 | }; |
| 314 | |
| 315 | |
| 316 | static long v2m_osc_round(struct clk *clk, unsigned long rate) |
| 317 | { |
| 318 | return rate; |
| 319 | } |
| 320 | |
| 321 | static int v2m_osc1_set(struct clk *clk, unsigned long rate) |
| 322 | { |
| 323 | return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_MB | 1, rate); |
| 324 | } |
| 325 | |
| 326 | static const struct clk_ops osc1_clk_ops = { |
| 327 | .round = v2m_osc_round, |
| 328 | .set = v2m_osc1_set, |
| 329 | }; |
| 330 | |
| 331 | static struct clk osc1_clk = { |
| 332 | .ops = &osc1_clk_ops, |
| 333 | .rate = 24000000, |
| 334 | }; |
| 335 | |
| 336 | static struct clk osc2_clk = { |
| 337 | .rate = 24000000, |
| 338 | }; |
| 339 | |
Russell King | 7ff550d | 2011-05-12 13:31:48 +0100 | [diff] [blame] | 340 | static struct clk v2m_sp804_clk = { |
| 341 | .rate = 1000000, |
| 342 | }; |
| 343 | |
Nick Bowler | 0ebb962 | 2011-07-20 15:43:42 +0100 | [diff] [blame] | 344 | static struct clk v2m_ref_clk = { |
| 345 | .rate = 32768, |
| 346 | }; |
| 347 | |
Russell King | 3126c7b | 2010-07-15 11:01:17 +0100 | [diff] [blame] | 348 | static struct clk dummy_apb_pclk; |
| 349 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 350 | static struct clk_lookup v2m_lookups[] = { |
Russell King | 3126c7b | 2010-07-15 11:01:17 +0100 | [diff] [blame] | 351 | { /* AMBA bus clock */ |
| 352 | .con_id = "apb_pclk", |
| 353 | .clk = &dummy_apb_pclk, |
| 354 | }, { /* UART0 */ |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 355 | .dev_id = "mb:uart0", |
| 356 | .clk = &osc2_clk, |
| 357 | }, { /* UART1 */ |
| 358 | .dev_id = "mb:uart1", |
| 359 | .clk = &osc2_clk, |
| 360 | }, { /* UART2 */ |
| 361 | .dev_id = "mb:uart2", |
| 362 | .clk = &osc2_clk, |
| 363 | }, { /* UART3 */ |
| 364 | .dev_id = "mb:uart3", |
| 365 | .clk = &osc2_clk, |
| 366 | }, { /* KMI0 */ |
| 367 | .dev_id = "mb:kmi0", |
| 368 | .clk = &osc2_clk, |
| 369 | }, { /* KMI1 */ |
| 370 | .dev_id = "mb:kmi1", |
| 371 | .clk = &osc2_clk, |
| 372 | }, { /* MMC0 */ |
| 373 | .dev_id = "mb:mmci", |
| 374 | .clk = &osc2_clk, |
| 375 | }, { /* CLCD */ |
| 376 | .dev_id = "mb:clcd", |
| 377 | .clk = &osc1_clk, |
Nick Bowler | 0ebb962 | 2011-07-20 15:43:42 +0100 | [diff] [blame] | 378 | }, { /* SP805 WDT */ |
| 379 | .dev_id = "mb:wdt", |
| 380 | .clk = &v2m_ref_clk, |
Russell King | 7ff550d | 2011-05-12 13:31:48 +0100 | [diff] [blame] | 381 | }, { /* SP804 timers */ |
| 382 | .dev_id = "sp804", |
Russell King | 23828a7 | 2011-05-12 15:45:16 +0100 | [diff] [blame] | 383 | .con_id = "v2m-timer0", |
| 384 | .clk = &v2m_sp804_clk, |
| 385 | }, { /* SP804 timers */ |
| 386 | .dev_id = "sp804", |
Russell King | 7ff550d | 2011-05-12 13:31:48 +0100 | [diff] [blame] | 387 | .con_id = "v2m-timer1", |
| 388 | .clk = &v2m_sp804_clk, |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 389 | }, |
| 390 | }; |
| 391 | |
Rob Herring | 2fdf999 | 2011-05-30 19:44:22 +0100 | [diff] [blame] | 392 | static void __init v2m_init_early(void) |
| 393 | { |
| 394 | ct_desc->init_early(); |
| 395 | clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups)); |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 396 | versatile_sched_clock_init(v2m_sysreg_base + V2M_SYS_24MHZ, 24000000); |
Rob Herring | 2fdf999 | 2011-05-30 19:44:22 +0100 | [diff] [blame] | 397 | } |
| 398 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 399 | static void v2m_power_off(void) |
| 400 | { |
| 401 | if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0)) |
| 402 | printk(KERN_EMERG "Unable to shutdown\n"); |
| 403 | } |
| 404 | |
| 405 | static void v2m_restart(char str, const char *cmd) |
| 406 | { |
| 407 | if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE_MB, 0)) |
| 408 | printk(KERN_EMERG "Unable to reboot\n"); |
| 409 | } |
| 410 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 411 | struct ct_desc *ct_desc; |
| 412 | |
| 413 | static struct ct_desc *ct_descs[] __initdata = { |
| 414 | #ifdef CONFIG_ARCH_VEXPRESS_CA9X4 |
| 415 | &ct_ca9x4_desc, |
| 416 | #endif |
| 417 | }; |
| 418 | |
| 419 | static void __init v2m_populate_ct_desc(void) |
| 420 | { |
| 421 | int i; |
| 422 | u32 current_tile_id; |
| 423 | |
| 424 | ct_desc = NULL; |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 425 | current_tile_id = readl(v2m_sysreg_base + V2M_SYS_PROCID0) |
| 426 | & V2M_CT_ID_MASK; |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 427 | |
| 428 | for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i) |
| 429 | if (ct_descs[i]->id == current_tile_id) |
| 430 | ct_desc = ct_descs[i]; |
| 431 | |
| 432 | if (!ct_desc) |
| 433 | panic("vexpress: failed to populate core tile description " |
| 434 | "for tile ID 0x%8x\n", current_tile_id); |
| 435 | } |
| 436 | |
| 437 | static void __init v2m_map_io(void) |
| 438 | { |
| 439 | iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc)); |
Pawel Moll | 98ed4ce | 2012-01-25 15:37:29 +0000 | [diff] [blame^] | 440 | v2m_sysreg_base = ioremap(V2M_SYSREGS, SZ_4K); |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 441 | v2m_populate_ct_desc(); |
| 442 | ct_desc->map_io(); |
| 443 | } |
| 444 | |
| 445 | static void __init v2m_init_irq(void) |
| 446 | { |
| 447 | ct_desc->init_irq(); |
| 448 | } |
| 449 | |
| 450 | static void __init v2m_init(void) |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 451 | { |
| 452 | int i; |
| 453 | |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 454 | platform_device_register(&v2m_pcie_i2c_device); |
| 455 | platform_device_register(&v2m_ddc_i2c_device); |
| 456 | platform_device_register(&v2m_flash_device); |
Nick Bowler | 95c34f8 | 2011-01-21 15:51:06 +0100 | [diff] [blame] | 457 | platform_device_register(&v2m_cf_device); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 458 | platform_device_register(&v2m_eth_device); |
| 459 | platform_device_register(&v2m_usb_device); |
| 460 | |
| 461 | for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++) |
| 462 | amba_device_register(v2m_amba_devs[i], &iomem_resource); |
| 463 | |
| 464 | pm_power_off = v2m_power_off; |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 465 | |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 466 | ct_desc->init_tile(); |
Russell King | ceade89 | 2010-02-11 21:44:53 +0000 | [diff] [blame] | 467 | } |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 468 | |
| 469 | MACHINE_START(VEXPRESS, "ARM-Versatile Express") |
Nicolas Pitre | e9ce8e5 | 2011-07-05 22:38:18 -0400 | [diff] [blame] | 470 | .atag_offset = 0x100, |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 471 | .map_io = v2m_map_io, |
| 472 | .init_early = v2m_init_early, |
| 473 | .init_irq = v2m_init_irq, |
| 474 | .timer = &v2m_timer, |
Marc Zyngier | abd3ca5 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 475 | .handle_irq = gic_handle_irq, |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 476 | .init_machine = v2m_init, |
Russell King | f5733a1 | 2011-11-04 15:47:50 +0000 | [diff] [blame] | 477 | .restart = v2m_restart, |
Will Deacon | 80b5efbd | 2011-02-28 17:01:04 +0100 | [diff] [blame] | 478 | MACHINE_END |