switch fat to ->s_d_op, close exportfs races there
[linux-2.6/x86.git] / arch / arm / mach-vexpress / v2m.c
bloba9ed3428a2fae616a75405c69692e38c2f3a7de4
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>
10 #include <linux/smsc911x.h>
11 #include <linux/spinlock.h>
12 #include <linux/sysdev.h>
13 #include <linux/usb/isp1760.h>
14 #include <linux/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/motherboard.h>
25 #include <plat/sched_clock.h>
27 #include "core.h"
29 #define V2M_PA_CS0 0x40000000
30 #define V2M_PA_CS1 0x44000000
31 #define V2M_PA_CS2 0x48000000
32 #define V2M_PA_CS3 0x4c000000
33 #define V2M_PA_CS7 0x10000000
35 static struct map_desc v2m_io_desc[] __initdata = {
37 .virtual = __MMIO_P2V(V2M_PA_CS7),
38 .pfn = __phys_to_pfn(V2M_PA_CS7),
39 .length = SZ_128K,
40 .type = MT_DEVICE,
44 void __init v2m_map_io(struct map_desc *tile, size_t num)
46 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
47 iotable_init(tile, num);
51 static void __init v2m_timer_init(void)
53 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
55 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
56 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
58 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1));
59 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0);
62 struct sys_timer v2m_timer = {
63 .init = v2m_timer_init,
67 static DEFINE_SPINLOCK(v2m_cfg_lock);
69 int v2m_cfg_write(u32 devfn, u32 data)
71 /* Configuration interface broken? */
72 u32 val;
74 printk("%s: writing %08x to %08x\n", __func__, data, devfn);
76 devfn |= SYS_CFG_START | SYS_CFG_WRITE;
78 spin_lock(&v2m_cfg_lock);
79 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
80 writel(val & ~SYS_CFG_COMPLETE, MMIO_P2V(V2M_SYS_CFGSTAT));
82 writel(data, MMIO_P2V(V2M_SYS_CFGDATA));
83 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
85 do {
86 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
87 } while (val == 0);
88 spin_unlock(&v2m_cfg_lock);
90 return !!(val & SYS_CFG_ERR);
93 int v2m_cfg_read(u32 devfn, u32 *data)
95 u32 val;
97 devfn |= SYS_CFG_START;
99 spin_lock(&v2m_cfg_lock);
100 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT));
101 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
103 mb();
105 do {
106 cpu_relax();
107 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
108 } while (val == 0);
110 *data = readl(MMIO_P2V(V2M_SYS_CFGDATA));
111 spin_unlock(&v2m_cfg_lock);
113 return !!(val & SYS_CFG_ERR);
117 static struct resource v2m_pcie_i2c_resource = {
118 .start = V2M_SERIAL_BUS_PCI,
119 .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
120 .flags = IORESOURCE_MEM,
123 static struct platform_device v2m_pcie_i2c_device = {
124 .name = "versatile-i2c",
125 .id = 0,
126 .num_resources = 1,
127 .resource = &v2m_pcie_i2c_resource,
130 static struct resource v2m_ddc_i2c_resource = {
131 .start = V2M_SERIAL_BUS_DVI,
132 .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
133 .flags = IORESOURCE_MEM,
136 static struct platform_device v2m_ddc_i2c_device = {
137 .name = "versatile-i2c",
138 .id = 1,
139 .num_resources = 1,
140 .resource = &v2m_ddc_i2c_resource,
143 static struct resource v2m_eth_resources[] = {
145 .start = V2M_LAN9118,
146 .end = V2M_LAN9118 + SZ_64K - 1,
147 .flags = IORESOURCE_MEM,
148 }, {
149 .start = IRQ_V2M_LAN9118,
150 .end = IRQ_V2M_LAN9118,
151 .flags = IORESOURCE_IRQ,
155 static struct smsc911x_platform_config v2m_eth_config = {
156 .flags = SMSC911X_USE_32BIT,
157 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
158 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
159 .phy_interface = PHY_INTERFACE_MODE_MII,
162 static struct platform_device v2m_eth_device = {
163 .name = "smsc911x",
164 .id = -1,
165 .resource = v2m_eth_resources,
166 .num_resources = ARRAY_SIZE(v2m_eth_resources),
167 .dev.platform_data = &v2m_eth_config,
170 static struct resource v2m_usb_resources[] = {
172 .start = V2M_ISP1761,
173 .end = V2M_ISP1761 + SZ_128K - 1,
174 .flags = IORESOURCE_MEM,
175 }, {
176 .start = IRQ_V2M_ISP1761,
177 .end = IRQ_V2M_ISP1761,
178 .flags = IORESOURCE_IRQ,
182 static struct isp1760_platform_data v2m_usb_config = {
183 .is_isp1761 = true,
184 .bus_width_16 = false,
185 .port1_otg = true,
186 .analog_oc = false,
187 .dack_polarity_high = false,
188 .dreq_polarity_high = false,
191 static struct platform_device v2m_usb_device = {
192 .name = "isp1760",
193 .id = -1,
194 .resource = v2m_usb_resources,
195 .num_resources = ARRAY_SIZE(v2m_usb_resources),
196 .dev.platform_data = &v2m_usb_config,
199 static int v2m_flash_init(void)
201 writel(0, MMIO_P2V(V2M_SYS_FLASH));
202 return 0;
205 static void v2m_flash_exit(void)
207 writel(0, MMIO_P2V(V2M_SYS_FLASH));
210 static void v2m_flash_set_vpp(int on)
212 writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
215 static struct flash_platform_data v2m_flash_data = {
216 .map_name = "cfi_probe",
217 .width = 4,
218 .init = v2m_flash_init,
219 .exit = v2m_flash_exit,
220 .set_vpp = v2m_flash_set_vpp,
223 static struct resource v2m_flash_resources[] = {
225 .start = V2M_NOR0,
226 .end = V2M_NOR0 + SZ_64M - 1,
227 .flags = IORESOURCE_MEM,
228 }, {
229 .start = V2M_NOR1,
230 .end = V2M_NOR1 + SZ_64M - 1,
231 .flags = IORESOURCE_MEM,
235 static struct platform_device v2m_flash_device = {
236 .name = "armflash",
237 .id = -1,
238 .resource = v2m_flash_resources,
239 .num_resources = ARRAY_SIZE(v2m_flash_resources),
240 .dev.platform_data = &v2m_flash_data,
244 static unsigned int v2m_mmci_status(struct device *dev)
246 return readl(MMIO_P2V(V2M_SYS_MCI)) & (1 << 0);
249 static struct mmci_platform_data v2m_mmci_data = {
250 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
251 .status = v2m_mmci_status,
254 static AMBA_DEVICE(aaci, "mb:aaci", V2M_AACI, NULL);
255 static AMBA_DEVICE(mmci, "mb:mmci", V2M_MMCI, &v2m_mmci_data);
256 static AMBA_DEVICE(kmi0, "mb:kmi0", V2M_KMI0, NULL);
257 static AMBA_DEVICE(kmi1, "mb:kmi1", V2M_KMI1, NULL);
258 static AMBA_DEVICE(uart0, "mb:uart0", V2M_UART0, NULL);
259 static AMBA_DEVICE(uart1, "mb:uart1", V2M_UART1, NULL);
260 static AMBA_DEVICE(uart2, "mb:uart2", V2M_UART2, NULL);
261 static AMBA_DEVICE(uart3, "mb:uart3", V2M_UART3, NULL);
262 static AMBA_DEVICE(wdt, "mb:wdt", V2M_WDT, NULL);
263 static AMBA_DEVICE(rtc, "mb:rtc", V2M_RTC, NULL);
265 static struct amba_device *v2m_amba_devs[] __initdata = {
266 &aaci_device,
267 &mmci_device,
268 &kmi0_device,
269 &kmi1_device,
270 &uart0_device,
271 &uart1_device,
272 &uart2_device,
273 &uart3_device,
274 &wdt_device,
275 &rtc_device,
279 static long v2m_osc_round(struct clk *clk, unsigned long rate)
281 return rate;
284 static int v2m_osc1_set(struct clk *clk, unsigned long rate)
286 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_MB | 1, rate);
289 static const struct clk_ops osc1_clk_ops = {
290 .round = v2m_osc_round,
291 .set = v2m_osc1_set,
294 static struct clk osc1_clk = {
295 .ops = &osc1_clk_ops,
296 .rate = 24000000,
299 static struct clk osc2_clk = {
300 .rate = 24000000,
303 static struct clk dummy_apb_pclk;
305 static struct clk_lookup v2m_lookups[] = {
306 { /* AMBA bus clock */
307 .con_id = "apb_pclk",
308 .clk = &dummy_apb_pclk,
309 }, { /* UART0 */
310 .dev_id = "mb:uart0",
311 .clk = &osc2_clk,
312 }, { /* UART1 */
313 .dev_id = "mb:uart1",
314 .clk = &osc2_clk,
315 }, { /* UART2 */
316 .dev_id = "mb:uart2",
317 .clk = &osc2_clk,
318 }, { /* UART3 */
319 .dev_id = "mb:uart3",
320 .clk = &osc2_clk,
321 }, { /* KMI0 */
322 .dev_id = "mb:kmi0",
323 .clk = &osc2_clk,
324 }, { /* KMI1 */
325 .dev_id = "mb:kmi1",
326 .clk = &osc2_clk,
327 }, { /* MMC0 */
328 .dev_id = "mb:mmci",
329 .clk = &osc2_clk,
330 }, { /* CLCD */
331 .dev_id = "mb:clcd",
332 .clk = &osc1_clk,
336 static void v2m_power_off(void)
338 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0))
339 printk(KERN_EMERG "Unable to shutdown\n");
342 static void v2m_restart(char str, const char *cmd)
344 if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE_MB, 0))
345 printk(KERN_EMERG "Unable to reboot\n");
348 static int __init v2m_init(void)
350 int i;
352 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
354 platform_device_register(&v2m_pcie_i2c_device);
355 platform_device_register(&v2m_ddc_i2c_device);
356 platform_device_register(&v2m_flash_device);
357 platform_device_register(&v2m_eth_device);
358 platform_device_register(&v2m_usb_device);
360 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
361 amba_device_register(v2m_amba_devs[i], &iomem_resource);
363 pm_power_off = v2m_power_off;
364 arm_pm_restart = v2m_restart;
366 return 0;
368 arch_initcall(v2m_init);