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/smsc911x.h>
11 #include <linux/spinlock.h>
12 #include <linux/sysdev.h>
13 #include <linux/usb/isp1760.h>
15 #include <asm/clkdev.h>
16 #include <asm/sizes.h>
17 #include <asm/mach/flash.h>
18 #include <asm/mach/map.h>
19 #include <asm/mach/time.h>
20 #include <asm/hardware/arm_timer.h>
21 #include <asm/hardware/timer-sp.h>
23 #include <mach/clkdev.h>
24 #include <mach/motherboard.h>
26 #include <plat/sched_clock.h>
30 #define V2M_PA_CS0 0x40000000
31 #define V2M_PA_CS1 0x44000000
32 #define V2M_PA_CS2 0x48000000
33 #define V2M_PA_CS3 0x4c000000
34 #define V2M_PA_CS7 0x10000000
36 static struct map_desc v2m_io_desc[] __initdata = {
38 .virtual = __MMIO_P2V(V2M_PA_CS7),
39 .pfn = __phys_to_pfn(V2M_PA_CS7),
45 void __init v2m_map_io(struct map_desc *tile, size_t num)
47 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
48 iotable_init(tile, num);
52 static void __init v2m_timer_init(void)
54 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
56 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
57 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
59 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1));
60 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0);
63 struct sys_timer v2m_timer = {
64 .init = v2m_timer_init,
68 static DEFINE_SPINLOCK(v2m_cfg_lock);
70 int v2m_cfg_write(u32 devfn, u32 data)
72 /* Configuration interface broken? */
75 printk("%s: writing %08x to %08x\n", __func__, data, devfn);
77 devfn |= SYS_CFG_START | SYS_CFG_WRITE;
79 spin_lock(&v2m_cfg_lock);
80 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
81 writel(val & ~SYS_CFG_COMPLETE, MMIO_P2V(V2M_SYS_CFGSTAT));
83 writel(data, MMIO_P2V(V2M_SYS_CFGDATA));
84 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
87 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
89 spin_unlock(&v2m_cfg_lock);
91 return !!(val & SYS_CFG_ERR);
94 int v2m_cfg_read(u32 devfn, u32 *data)
98 devfn |= SYS_CFG_START;
100 spin_lock(&v2m_cfg_lock);
101 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT));
102 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
108 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
111 *data = readl(MMIO_P2V(V2M_SYS_CFGDATA));
112 spin_unlock(&v2m_cfg_lock);
114 return !!(val & SYS_CFG_ERR);
118 static struct resource v2m_pcie_i2c_resource = {
119 .start = V2M_SERIAL_BUS_PCI,
120 .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
121 .flags = IORESOURCE_MEM,
124 static struct platform_device v2m_pcie_i2c_device = {
125 .name = "versatile-i2c",
128 .resource = &v2m_pcie_i2c_resource,
131 static struct resource v2m_ddc_i2c_resource = {
132 .start = V2M_SERIAL_BUS_DVI,
133 .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
134 .flags = IORESOURCE_MEM,
137 static struct platform_device v2m_ddc_i2c_device = {
138 .name = "versatile-i2c",
141 .resource = &v2m_ddc_i2c_resource,
144 static struct resource v2m_eth_resources[] = {
146 .start = V2M_LAN9118,
147 .end = V2M_LAN9118 + SZ_64K - 1,
148 .flags = IORESOURCE_MEM,
150 .start = IRQ_V2M_LAN9118,
151 .end = IRQ_V2M_LAN9118,
152 .flags = IORESOURCE_IRQ,
156 static struct smsc911x_platform_config v2m_eth_config = {
157 .flags = SMSC911X_USE_32BIT,
158 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
159 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
160 .phy_interface = PHY_INTERFACE_MODE_MII,
163 static struct platform_device v2m_eth_device = {
166 .resource = v2m_eth_resources,
167 .num_resources = ARRAY_SIZE(v2m_eth_resources),
168 .dev.platform_data = &v2m_eth_config,
171 static struct resource v2m_usb_resources[] = {
173 .start = V2M_ISP1761,
174 .end = V2M_ISP1761 + SZ_128K - 1,
175 .flags = IORESOURCE_MEM,
177 .start = IRQ_V2M_ISP1761,
178 .end = IRQ_V2M_ISP1761,
179 .flags = IORESOURCE_IRQ,
183 static struct isp1760_platform_data v2m_usb_config = {
185 .bus_width_16 = false,
188 .dack_polarity_high = false,
189 .dreq_polarity_high = false,
192 static struct platform_device v2m_usb_device = {
195 .resource = v2m_usb_resources,
196 .num_resources = ARRAY_SIZE(v2m_usb_resources),
197 .dev.platform_data = &v2m_usb_config,
200 static int v2m_flash_init(void)
202 writel(0, MMIO_P2V(V2M_SYS_FLASH));
206 static void v2m_flash_exit(void)
208 writel(0, MMIO_P2V(V2M_SYS_FLASH));
211 static void v2m_flash_set_vpp(int on)
213 writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
216 static struct flash_platform_data v2m_flash_data = {
217 .map_name = "cfi_probe",
219 .init = v2m_flash_init,
220 .exit = v2m_flash_exit,
221 .set_vpp = v2m_flash_set_vpp,
224 static struct resource v2m_flash_resources[] = {
227 .end = V2M_NOR0 + SZ_64M - 1,
228 .flags = IORESOURCE_MEM,
231 .end = V2M_NOR1 + SZ_64M - 1,
232 .flags = IORESOURCE_MEM,
236 static struct platform_device v2m_flash_device = {
239 .resource = v2m_flash_resources,
240 .num_resources = ARRAY_SIZE(v2m_flash_resources),
241 .dev.platform_data = &v2m_flash_data,
245 static unsigned int v2m_mmci_status(struct device *dev)
247 return readl(MMIO_P2V(V2M_SYS_MCI)) & (1 << 0);
250 static struct mmci_platform_data v2m_mmci_data = {
251 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
252 .status = v2m_mmci_status,
255 static AMBA_DEVICE(aaci, "mb:aaci", V2M_AACI, NULL);
256 static AMBA_DEVICE(mmci, "mb:mmci", V2M_MMCI, &v2m_mmci_data);
257 static AMBA_DEVICE(kmi0, "mb:kmi0", V2M_KMI0, NULL);
258 static AMBA_DEVICE(kmi1, "mb:kmi1", V2M_KMI1, NULL);
259 static AMBA_DEVICE(uart0, "mb:uart0", V2M_UART0, NULL);
260 static AMBA_DEVICE(uart1, "mb:uart1", V2M_UART1, NULL);
261 static AMBA_DEVICE(uart2, "mb:uart2", V2M_UART2, NULL);
262 static AMBA_DEVICE(uart3, "mb:uart3", V2M_UART3, NULL);
263 static AMBA_DEVICE(wdt, "mb:wdt", V2M_WDT, NULL);
264 static AMBA_DEVICE(rtc, "mb:rtc", V2M_RTC, NULL);
266 static struct amba_device *v2m_amba_devs[] __initdata = {
280 static long v2m_osc_round(struct clk *clk, unsigned long rate)
285 static int v2m_osc1_set(struct clk *clk, unsigned long rate)
287 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_MB | 1, rate);
290 static const struct clk_ops osc1_clk_ops = {
291 .round = v2m_osc_round,
295 static struct clk osc1_clk = {
296 .ops = &osc1_clk_ops,
300 static struct clk osc2_clk = {
304 static struct clk dummy_apb_pclk;
306 static struct clk_lookup v2m_lookups[] = {
307 { /* AMBA bus clock */
308 .con_id = "apb_pclk",
309 .clk = &dummy_apb_pclk,
311 .dev_id = "mb:uart0",
314 .dev_id = "mb:uart1",
317 .dev_id = "mb:uart2",
320 .dev_id = "mb:uart3",
337 static void v2m_power_off(void)
339 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0))
340 printk(KERN_EMERG "Unable to shutdown\n");
343 static void v2m_restart(char str, const char *cmd)
345 if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE_MB, 0))
346 printk(KERN_EMERG "Unable to reboot\n");
349 static int __init v2m_init(void)
353 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
355 platform_device_register(&v2m_pcie_i2c_device);
356 platform_device_register(&v2m_ddc_i2c_device);
357 platform_device_register(&v2m_flash_device);
358 platform_device_register(&v2m_eth_device);
359 platform_device_register(&v2m_usb_device);
361 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
362 amba_device_register(v2m_amba_devs[i], &iomem_resource);
364 pm_power_off = v2m_power_off;
365 arm_pm_restart = v2m_restart;
369 arch_initcall(v2m_init);