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>
22 #include <mach/clkdev.h>
23 #include <mach/motherboard.h>
25 #include <plat/sched_clock.h>
27 #include <plat/timer-sp.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);
53 static void __init v2m_timer_init(void)
55 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
57 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
58 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
60 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1));
61 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0);
64 struct sys_timer v2m_timer = {
65 .init = v2m_timer_init,
69 static DEFINE_SPINLOCK(v2m_cfg_lock);
71 int v2m_cfg_write(u32 devfn, u32 data)
73 /* Configuration interface broken? */
76 printk("%s: writing %08x to %08x\n", __func__, data, devfn);
78 devfn |= SYS_CFG_START | SYS_CFG_WRITE;
80 spin_lock(&v2m_cfg_lock);
81 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
82 writel(val & ~SYS_CFG_COMPLETE, MMIO_P2V(V2M_SYS_CFGSTAT));
84 writel(data, MMIO_P2V(V2M_SYS_CFGDATA));
85 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
88 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
90 spin_unlock(&v2m_cfg_lock);
92 return !!(val & SYS_CFG_ERR);
95 int v2m_cfg_read(u32 devfn, u32 *data)
99 devfn |= SYS_CFG_START;
101 spin_lock(&v2m_cfg_lock);
102 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT));
103 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
109 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
112 *data = readl(MMIO_P2V(V2M_SYS_CFGDATA));
113 spin_unlock(&v2m_cfg_lock);
115 return !!(val & SYS_CFG_ERR);
119 static struct resource v2m_pcie_i2c_resource = {
120 .start = V2M_SERIAL_BUS_PCI,
121 .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
122 .flags = IORESOURCE_MEM,
125 static struct platform_device v2m_pcie_i2c_device = {
126 .name = "versatile-i2c",
129 .resource = &v2m_pcie_i2c_resource,
132 static struct resource v2m_ddc_i2c_resource = {
133 .start = V2M_SERIAL_BUS_DVI,
134 .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
135 .flags = IORESOURCE_MEM,
138 static struct platform_device v2m_ddc_i2c_device = {
139 .name = "versatile-i2c",
142 .resource = &v2m_ddc_i2c_resource,
145 static struct resource v2m_eth_resources[] = {
147 .start = V2M_LAN9118,
148 .end = V2M_LAN9118 + SZ_64K - 1,
149 .flags = IORESOURCE_MEM,
151 .start = IRQ_V2M_LAN9118,
152 .end = IRQ_V2M_LAN9118,
153 .flags = IORESOURCE_IRQ,
157 static struct smsc911x_platform_config v2m_eth_config = {
158 .flags = SMSC911X_USE_32BIT,
159 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
160 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
161 .phy_interface = PHY_INTERFACE_MODE_MII,
164 static struct platform_device v2m_eth_device = {
167 .resource = v2m_eth_resources,
168 .num_resources = ARRAY_SIZE(v2m_eth_resources),
169 .dev.platform_data = &v2m_eth_config,
172 static struct resource v2m_usb_resources[] = {
174 .start = V2M_ISP1761,
175 .end = V2M_ISP1761 + SZ_128K - 1,
176 .flags = IORESOURCE_MEM,
178 .start = IRQ_V2M_ISP1761,
179 .end = IRQ_V2M_ISP1761,
180 .flags = IORESOURCE_IRQ,
184 static struct isp1760_platform_data v2m_usb_config = {
186 .bus_width_16 = false,
189 .dack_polarity_high = false,
190 .dreq_polarity_high = false,
193 static struct platform_device v2m_usb_device = {
196 .resource = v2m_usb_resources,
197 .num_resources = ARRAY_SIZE(v2m_usb_resources),
198 .dev.platform_data = &v2m_usb_config,
201 static int v2m_flash_init(void)
203 writel(0, MMIO_P2V(V2M_SYS_FLASH));
207 static void v2m_flash_exit(void)
209 writel(0, MMIO_P2V(V2M_SYS_FLASH));
212 static void v2m_flash_set_vpp(int on)
214 writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
217 static struct flash_platform_data v2m_flash_data = {
218 .map_name = "cfi_probe",
220 .init = v2m_flash_init,
221 .exit = v2m_flash_exit,
222 .set_vpp = v2m_flash_set_vpp,
225 static struct resource v2m_flash_resources[] = {
228 .end = V2M_NOR0 + SZ_64M - 1,
229 .flags = IORESOURCE_MEM,
232 .end = V2M_NOR1 + SZ_64M - 1,
233 .flags = IORESOURCE_MEM,
237 static struct platform_device v2m_flash_device = {
240 .resource = v2m_flash_resources,
241 .num_resources = ARRAY_SIZE(v2m_flash_resources),
242 .dev.platform_data = &v2m_flash_data,
246 static unsigned int v2m_mmci_status(struct device *dev)
248 return readl(MMIO_P2V(V2M_SYS_MCI)) & (1 << 0);
251 static struct mmci_platform_data v2m_mmci_data = {
252 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
253 .status = v2m_mmci_status,
256 static AMBA_DEVICE(aaci, "mb:aaci", V2M_AACI, NULL);
257 static AMBA_DEVICE(mmci, "mb:mmci", V2M_MMCI, &v2m_mmci_data);
258 static AMBA_DEVICE(kmi0, "mb:kmi0", V2M_KMI0, NULL);
259 static AMBA_DEVICE(kmi1, "mb:kmi1", V2M_KMI1, NULL);
260 static AMBA_DEVICE(uart0, "mb:uart0", V2M_UART0, NULL);
261 static AMBA_DEVICE(uart1, "mb:uart1", V2M_UART1, NULL);
262 static AMBA_DEVICE(uart2, "mb:uart2", V2M_UART2, NULL);
263 static AMBA_DEVICE(uart3, "mb:uart3", V2M_UART3, NULL);
264 static AMBA_DEVICE(wdt, "mb:wdt", V2M_WDT, NULL);
265 static AMBA_DEVICE(rtc, "mb:rtc", V2M_RTC, NULL);
267 static struct amba_device *v2m_amba_devs[] __initdata = {
281 static long v2m_osc_round(struct clk *clk, unsigned long rate)
286 static int v2m_osc1_set(struct clk *clk, unsigned long rate)
288 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_MB | 1, rate);
291 static const struct clk_ops osc1_clk_ops = {
292 .round = v2m_osc_round,
296 static struct clk osc1_clk = {
297 .ops = &osc1_clk_ops,
301 static struct clk osc2_clk = {
305 static struct clk dummy_apb_pclk;
307 static struct clk_lookup v2m_lookups[] = {
308 { /* AMBA bus clock */
309 .con_id = "apb_pclk",
310 .clk = &dummy_apb_pclk,
312 .dev_id = "mb:uart0",
315 .dev_id = "mb:uart1",
318 .dev_id = "mb:uart2",
321 .dev_id = "mb:uart3",
338 static void v2m_power_off(void)
340 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0))
341 printk(KERN_EMERG "Unable to shutdown\n");
344 static void v2m_restart(char str, const char *cmd)
346 if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE_MB, 0))
347 printk(KERN_EMERG "Unable to reboot\n");
350 static int __init v2m_init(void)
354 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
356 platform_device_register(&v2m_pcie_i2c_device);
357 platform_device_register(&v2m_ddc_i2c_device);
358 platform_device_register(&v2m_flash_device);
359 platform_device_register(&v2m_eth_device);
360 platform_device_register(&v2m_usb_device);
362 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
363 amba_device_register(v2m_amba_devs[i], &iomem_resource);
365 pm_power_off = v2m_power_off;
366 arm_pm_restart = v2m_restart;
370 arch_initcall(v2m_init);