ocfs2: Make the left masklogs compat.
[taoma-kernel.git] / arch / arm / mach-vexpress / v2m.c
blob1edae65a0e72c4cec6edea8810b8f841a4c1b46a
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>
22 #include <asm/hardware/sp810.h>
24 #include <mach/motherboard.h>
26 #include <plat/sched_clock.h>
28 #include "core.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),
40 .length = SZ_128K,
41 .type = MT_DEVICE,
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 u32 scctrl;
56 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000);
58 /* Select 1MHz TIMCLK as the reference clock for SP804 timers */
59 scctrl = readl(MMIO_P2V(V2M_SYSCTL + SCCTRL));
60 scctrl |= SCCTRL_TIMEREN0SEL_TIMCLK;
61 scctrl |= SCCTRL_TIMEREN1SEL_TIMCLK;
62 writel(scctrl, MMIO_P2V(V2M_SYSCTL + SCCTRL));
64 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL);
65 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL);
67 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1));
68 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0);
71 struct sys_timer v2m_timer = {
72 .init = v2m_timer_init,
76 static DEFINE_SPINLOCK(v2m_cfg_lock);
78 int v2m_cfg_write(u32 devfn, u32 data)
80 /* Configuration interface broken? */
81 u32 val;
83 printk("%s: writing %08x to %08x\n", __func__, data, devfn);
85 devfn |= SYS_CFG_START | SYS_CFG_WRITE;
87 spin_lock(&v2m_cfg_lock);
88 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
89 writel(val & ~SYS_CFG_COMPLETE, MMIO_P2V(V2M_SYS_CFGSTAT));
91 writel(data, MMIO_P2V(V2M_SYS_CFGDATA));
92 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
94 do {
95 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
96 } while (val == 0);
97 spin_unlock(&v2m_cfg_lock);
99 return !!(val & SYS_CFG_ERR);
102 int v2m_cfg_read(u32 devfn, u32 *data)
104 u32 val;
106 devfn |= SYS_CFG_START;
108 spin_lock(&v2m_cfg_lock);
109 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT));
110 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL));
112 mb();
114 do {
115 cpu_relax();
116 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT));
117 } while (val == 0);
119 *data = readl(MMIO_P2V(V2M_SYS_CFGDATA));
120 spin_unlock(&v2m_cfg_lock);
122 return !!(val & SYS_CFG_ERR);
126 static struct resource v2m_pcie_i2c_resource = {
127 .start = V2M_SERIAL_BUS_PCI,
128 .end = V2M_SERIAL_BUS_PCI + SZ_4K - 1,
129 .flags = IORESOURCE_MEM,
132 static struct platform_device v2m_pcie_i2c_device = {
133 .name = "versatile-i2c",
134 .id = 0,
135 .num_resources = 1,
136 .resource = &v2m_pcie_i2c_resource,
139 static struct resource v2m_ddc_i2c_resource = {
140 .start = V2M_SERIAL_BUS_DVI,
141 .end = V2M_SERIAL_BUS_DVI + SZ_4K - 1,
142 .flags = IORESOURCE_MEM,
145 static struct platform_device v2m_ddc_i2c_device = {
146 .name = "versatile-i2c",
147 .id = 1,
148 .num_resources = 1,
149 .resource = &v2m_ddc_i2c_resource,
152 static struct resource v2m_eth_resources[] = {
154 .start = V2M_LAN9118,
155 .end = V2M_LAN9118 + SZ_64K - 1,
156 .flags = IORESOURCE_MEM,
157 }, {
158 .start = IRQ_V2M_LAN9118,
159 .end = IRQ_V2M_LAN9118,
160 .flags = IORESOURCE_IRQ,
164 static struct smsc911x_platform_config v2m_eth_config = {
165 .flags = SMSC911X_USE_32BIT,
166 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
167 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
168 .phy_interface = PHY_INTERFACE_MODE_MII,
171 static struct platform_device v2m_eth_device = {
172 .name = "smsc911x",
173 .id = -1,
174 .resource = v2m_eth_resources,
175 .num_resources = ARRAY_SIZE(v2m_eth_resources),
176 .dev.platform_data = &v2m_eth_config,
179 static struct resource v2m_usb_resources[] = {
181 .start = V2M_ISP1761,
182 .end = V2M_ISP1761 + SZ_128K - 1,
183 .flags = IORESOURCE_MEM,
184 }, {
185 .start = IRQ_V2M_ISP1761,
186 .end = IRQ_V2M_ISP1761,
187 .flags = IORESOURCE_IRQ,
191 static struct isp1760_platform_data v2m_usb_config = {
192 .is_isp1761 = true,
193 .bus_width_16 = false,
194 .port1_otg = true,
195 .analog_oc = false,
196 .dack_polarity_high = false,
197 .dreq_polarity_high = false,
200 static struct platform_device v2m_usb_device = {
201 .name = "isp1760",
202 .id = -1,
203 .resource = v2m_usb_resources,
204 .num_resources = ARRAY_SIZE(v2m_usb_resources),
205 .dev.platform_data = &v2m_usb_config,
208 static int v2m_flash_init(void)
210 writel(0, MMIO_P2V(V2M_SYS_FLASH));
211 return 0;
214 static void v2m_flash_exit(void)
216 writel(0, MMIO_P2V(V2M_SYS_FLASH));
219 static void v2m_flash_set_vpp(int on)
221 writel(on != 0, MMIO_P2V(V2M_SYS_FLASH));
224 static struct flash_platform_data v2m_flash_data = {
225 .map_name = "cfi_probe",
226 .width = 4,
227 .init = v2m_flash_init,
228 .exit = v2m_flash_exit,
229 .set_vpp = v2m_flash_set_vpp,
232 static struct resource v2m_flash_resources[] = {
234 .start = V2M_NOR0,
235 .end = V2M_NOR0 + SZ_64M - 1,
236 .flags = IORESOURCE_MEM,
237 }, {
238 .start = V2M_NOR1,
239 .end = V2M_NOR1 + SZ_64M - 1,
240 .flags = IORESOURCE_MEM,
244 static struct platform_device v2m_flash_device = {
245 .name = "armflash",
246 .id = -1,
247 .resource = v2m_flash_resources,
248 .num_resources = ARRAY_SIZE(v2m_flash_resources),
249 .dev.platform_data = &v2m_flash_data,
253 static unsigned int v2m_mmci_status(struct device *dev)
255 return readl(MMIO_P2V(V2M_SYS_MCI)) & (1 << 0);
258 static struct mmci_platform_data v2m_mmci_data = {
259 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
260 .status = v2m_mmci_status,
263 static AMBA_DEVICE(aaci, "mb:aaci", V2M_AACI, NULL);
264 static AMBA_DEVICE(mmci, "mb:mmci", V2M_MMCI, &v2m_mmci_data);
265 static AMBA_DEVICE(kmi0, "mb:kmi0", V2M_KMI0, NULL);
266 static AMBA_DEVICE(kmi1, "mb:kmi1", V2M_KMI1, NULL);
267 static AMBA_DEVICE(uart0, "mb:uart0", V2M_UART0, NULL);
268 static AMBA_DEVICE(uart1, "mb:uart1", V2M_UART1, NULL);
269 static AMBA_DEVICE(uart2, "mb:uart2", V2M_UART2, NULL);
270 static AMBA_DEVICE(uart3, "mb:uart3", V2M_UART3, NULL);
271 static AMBA_DEVICE(wdt, "mb:wdt", V2M_WDT, NULL);
272 static AMBA_DEVICE(rtc, "mb:rtc", V2M_RTC, NULL);
274 static struct amba_device *v2m_amba_devs[] __initdata = {
275 &aaci_device,
276 &mmci_device,
277 &kmi0_device,
278 &kmi1_device,
279 &uart0_device,
280 &uart1_device,
281 &uart2_device,
282 &uart3_device,
283 &wdt_device,
284 &rtc_device,
288 static long v2m_osc_round(struct clk *clk, unsigned long rate)
290 return rate;
293 static int v2m_osc1_set(struct clk *clk, unsigned long rate)
295 return v2m_cfg_write(SYS_CFG_OSC | SYS_CFG_SITE_MB | 1, rate);
298 static const struct clk_ops osc1_clk_ops = {
299 .round = v2m_osc_round,
300 .set = v2m_osc1_set,
303 static struct clk osc1_clk = {
304 .ops = &osc1_clk_ops,
305 .rate = 24000000,
308 static struct clk osc2_clk = {
309 .rate = 24000000,
312 static struct clk dummy_apb_pclk;
314 static struct clk_lookup v2m_lookups[] = {
315 { /* AMBA bus clock */
316 .con_id = "apb_pclk",
317 .clk = &dummy_apb_pclk,
318 }, { /* UART0 */
319 .dev_id = "mb:uart0",
320 .clk = &osc2_clk,
321 }, { /* UART1 */
322 .dev_id = "mb:uart1",
323 .clk = &osc2_clk,
324 }, { /* UART2 */
325 .dev_id = "mb:uart2",
326 .clk = &osc2_clk,
327 }, { /* UART3 */
328 .dev_id = "mb:uart3",
329 .clk = &osc2_clk,
330 }, { /* KMI0 */
331 .dev_id = "mb:kmi0",
332 .clk = &osc2_clk,
333 }, { /* KMI1 */
334 .dev_id = "mb:kmi1",
335 .clk = &osc2_clk,
336 }, { /* MMC0 */
337 .dev_id = "mb:mmci",
338 .clk = &osc2_clk,
339 }, { /* CLCD */
340 .dev_id = "mb:clcd",
341 .clk = &osc1_clk,
345 static void v2m_power_off(void)
347 if (v2m_cfg_write(SYS_CFG_SHUTDOWN | SYS_CFG_SITE_MB, 0))
348 printk(KERN_EMERG "Unable to shutdown\n");
351 static void v2m_restart(char str, const char *cmd)
353 if (v2m_cfg_write(SYS_CFG_REBOOT | SYS_CFG_SITE_MB, 0))
354 printk(KERN_EMERG "Unable to reboot\n");
357 static int __init v2m_init(void)
359 int i;
361 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
363 platform_device_register(&v2m_pcie_i2c_device);
364 platform_device_register(&v2m_ddc_i2c_device);
365 platform_device_register(&v2m_flash_device);
366 platform_device_register(&v2m_eth_device);
367 platform_device_register(&v2m_usb_device);
369 for (i = 0; i < ARRAY_SIZE(v2m_amba_devs); i++)
370 amba_device_register(v2m_amba_devs[i], &iomem_resource);
372 pm_power_off = v2m_power_off;
373 arm_pm_restart = v2m_restart;
375 return 0;
377 arch_initcall(v2m_init);