2 * Versatile Express V2M Motherboard Support
4 #include <linux/device.h>
5 #include <linux/amba/bus.h>
6 #include <linux/amba/mmci.h>
8 #include <linux/init.h>
9 #include <linux/platform_device.h>
10 #include <linux/ata_platform.h>
11 #include <linux/smsc911x.h>
12 #include <linux/spinlock.h>
13 #include <linux/sysdev.h>
14 #include <linux/usb/isp1760.h>
15 #include <linux/clkdev.h>
17 #include <asm/sizes.h>
18 #include <asm/mach/flash.h>
19 #include <asm/mach/map.h>
20 #include <asm/mach/time.h>
21 #include <asm/hardware/arm_timer.h>
22 #include <asm/hardware/timer-sp.h>
23 #include <asm/hardware/sp810.h>
25 #include <mach/motherboard.h>
27 #include <plat/sched_clock.h>
31 #define V2M_PA_CS0 0x40000000
32 #define V2M_PA_CS1 0x44000000
33 #define V2M_PA_CS2 0x48000000
34 #define V2M_PA_CS3 0x4c000000
35 #define V2M_PA_CS7 0x10000000
37 static struct map_desc v2m_io_desc[] __initdata = {
39 .virtual = __MMIO_P2V(V2M_PA_CS7),
40 .pfn = __phys_to_pfn(V2M_PA_CS7),
46 void __init v2m_map_io(struct map_desc *tile, size_t num)
48 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
49 iotable_init(tile, num);
52 void __init v2m_init_early(void)
54 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
57 static void __init v2m_timer_init(void)
61 /* Select 1MHz TIMCLK as the reference clock for SP804 timers */
62 scctrl = readl(MMIO_P2V(V2M_SYSCTL + SCCTRL));
63 scctrl |= SCCTRL_TIMEREN0SEL_TIMCLK;
64 scctrl |= SCCTRL_TIMEREN1SEL_TIMCLK;
65 writel(scctrl, MMIO_P2V(V2M_SYSCTL + SCCTRL));
67 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
68 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
70 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1));
71 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0);
74 struct sys_timer v2m_timer = {
75 .init = v2m_timer_init,
79 static DEFINE_SPINLOCK(v2m_cfg_lock);
81 int v2m_cfg_write(u32 devfn, u32 data)
83 /* Configuration interface broken? */
86 printk("%s: writing %08x to %08x\n", __func__, data, devfn);
88 devfn |= SYS_CFG_START | SYS_CFG_WRITE;
90 spin_lock(&v2m_cfg_lock);
91 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
92 writel(val & ~SYS_CFG_COMPLETE, MMIO_P2V(V2M_SYS_CFGSTAT));
94 writel(data, MMIO_P2V(V2M_SYS_CFGDATA));
95 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
98 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
100 spin_unlock(&v2m_cfg_lock);
102 return !!(val & SYS_CFG_ERR);
105 int v2m_cfg_read(u32 devfn, u32 *data)
109 devfn |= SYS_CFG_START;
111 spin_lock(&v2m_cfg_lock);
112 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT));
113 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
119 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
122 *data = readl(MMIO_P2V(V2M_SYS_CFGDATA));
123 spin_unlock(&v2m_cfg_lock);
125 return !!(val & SYS_CFG_ERR);
129 static struct resource v2m_pcie_i2c_resource = {
130 .start = V2M_SERIAL_BUS_PCI,
131 .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
132 .flags = IORESOURCE_MEM,
135 static struct platform_device v2m_pcie_i2c_device = {
136 .name = "versatile-i2c",
139 .resource = &v2m_pcie_i2c_resource,
142 static struct resource v2m_ddc_i2c_resource = {
143 .start = V2M_SERIAL_BUS_DVI,
144 .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
145 .flags = IORESOURCE_MEM,
148 static struct platform_device v2m_ddc_i2c_device = {
149 .name = "versatile-i2c",
152 .resource = &v2m_ddc_i2c_resource,
155 static struct resource v2m_eth_resources[] = {
157 .start = V2M_LAN9118,
158 .end = V2M_LAN9118 + SZ_64K - 1,
159 .flags = IORESOURCE_MEM,
161 .start = IRQ_V2M_LAN9118,
162 .end = IRQ_V2M_LAN9118,
163 .flags = IORESOURCE_IRQ,
167 static struct smsc911x_platform_config v2m_eth_config = {
168 .flags = SMSC911X_USE_32BIT,
169 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
170 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
171 .phy_interface = PHY_INTERFACE_MODE_MII,
174 static struct platform_device v2m_eth_device = {
177 .resource = v2m_eth_resources,
178 .num_resources = ARRAY_SIZE(v2m_eth_resources),
179 .dev.platform_data = &v2m_eth_config,
182 static struct resource v2m_usb_resources[] = {
184 .start = V2M_ISP1761,
185 .end = V2M_ISP1761 + SZ_128K - 1,
186 .flags = IORESOURCE_MEM,
188 .start = IRQ_V2M_ISP1761,
189 .end = IRQ_V2M_ISP1761,
190 .flags = IORESOURCE_IRQ,
194 static struct isp1760_platform_data v2m_usb_config = {
196 .bus_width_16 = false,
199 .dack_polarity_high = false,
200 .dreq_polarity_high = false,
203 static struct platform_device v2m_usb_device = {
206 .resource = v2m_usb_resources,
207 .num_resources = ARRAY_SIZE(v2m_usb_resources),
208 .dev.platform_data = &v2m_usb_config,
211 static int v2m_flash_init(void)
213 writel(0, MMIO_P2V(V2M_SYS_FLASH));
217 static void v2m_flash_exit(void)
219 writel(0, MMIO_P2V(V2M_SYS_FLASH));
222 static void v2m_flash_set_vpp(int on)
224 writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
227 static struct flash_platform_data v2m_flash_data = {
228 .map_name = "cfi_probe",
230 .init = v2m_flash_init,
231 .exit = v2m_flash_exit,
232 .set_vpp = v2m_flash_set_vpp,
235 static struct resource v2m_flash_resources[] = {
238 .end = V2M_NOR0 + SZ_64M - 1,
239 .flags = IORESOURCE_MEM,
242 .end = V2M_NOR1 + SZ_64M - 1,
243 .flags = IORESOURCE_MEM,
247 static struct platform_device v2m_flash_device = {
250 .resource = v2m_flash_resources,
251 .num_resources = ARRAY_SIZE(v2m_flash_resources),
252 .dev.platform_data = &v2m_flash_data,
255 static struct pata_platform_info v2m_pata_data = {
259 static struct resource v2m_pata_resources[] = {
262 .end = V2M_CF + 0xff,
263 .flags = IORESOURCE_MEM,
265 .start = V2M_CF + 0x100,
266 .end = V2M_CF + SZ_4K - 1,
267 .flags = IORESOURCE_MEM,
271 static struct platform_device v2m_cf_device = {
272 .name = "pata_platform",
274 .resource = v2m_pata_resources,
275 .num_resources = ARRAY_SIZE(v2m_pata_resources),
276 .dev.platform_data = &v2m_pata_data,
279 static unsigned int v2m_mmci_status(struct device *dev)
281 return readl(MMIO_P2V(V2M_SYS_MCI)) & (1 << 0);
284 static struct mmci_platform_data v2m_mmci_data = {
285 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
286 .status = v2m_mmci_status,
289 static AMBA_DEVICE(aaci, "mb:aaci", V2M_AACI, NULL);
290 static AMBA_DEVICE(mmci, "mb:mmci", V2M_MMCI, &v2m_mmci_data);
291 static AMBA_DEVICE(kmi0, "mb:kmi0", V2M_KMI0, NULL);
292 static AMBA_DEVICE(kmi1, "mb:kmi1", V2M_KMI1, NULL);
293 static AMBA_DEVICE(uart0, "mb:uart0", V2M_UART0, NULL);
294 static AMBA_DEVICE(uart1, "mb:uart1", V2M_UART1, NULL);
295 static AMBA_DEVICE(uart2, "mb:uart2", V2M_UART2, NULL);
296 static AMBA_DEVICE(uart3, "mb:uart3", V2M_UART3, NULL);
297 static AMBA_DEVICE(wdt, "mb:wdt", V2M_WDT, NULL);
298 static AMBA_DEVICE(rtc, "mb:rtc", V2M_RTC, NULL);
300 static struct amba_device *v2m_amba_devs[] __initdata = {
314 static long v2m_osc_round(struct clk *clk, unsigned long rate)
319 static int v2m_osc1_set(struct clk *clk, unsigned long rate)
321 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_MB | 1, rate);
324 static const struct clk_ops osc1_clk_ops = {
325 .round = v2m_osc_round,
329 static struct clk osc1_clk = {
330 .ops = &osc1_clk_ops,
334 static struct clk osc2_clk = {
338 static struct clk dummy_apb_pclk;
340 static struct clk_lookup v2m_lookups[] = {
341 { /* AMBA bus clock */
342 .con_id = "apb_pclk",
343 .clk = &dummy_apb_pclk,
345 .dev_id = "mb:uart0",
348 .dev_id = "mb:uart1",
351 .dev_id = "mb:uart2",
354 .dev_id = "mb:uart3",
371 static void v2m_power_off(void)
373 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0))
374 printk(KERN_EMERG "Unable to shutdown\n");
377 static void v2m_restart(char str, const char *cmd)
379 if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE_MB, 0))
380 printk(KERN_EMERG "Unable to reboot\n");
383 static int __init v2m_init(void)
387 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
389 platform_device_register(&v2m_pcie_i2c_device);
390 platform_device_register(&v2m_ddc_i2c_device);
391 platform_device_register(&v2m_flash_device);
392 platform_device_register(&v2m_cf_device);
393 platform_device_register(&v2m_eth_device);
394 platform_device_register(&v2m_usb_device);
396 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
397 amba_device_register(v2m_amba_devs[i], &iomem_resource);
399 pm_power_off = v2m_power_off;
400 arm_pm_restart = v2m_restart;
404 arch_initcall(v2m_init);