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>
16 #include <linux/mtd/physmap.h>
18 #include <asm/mach-types.h>
19 #include <asm/sizes.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach/map.h>
22 #include <asm/mach/time.h>
23 #include <asm/hardware/arm_timer.h>
24 #include <asm/hardware/timer-sp.h>
25 #include <asm/hardware/sp810.h>
27 #include <mach/ct-ca9x4.h>
28 #include <mach/motherboard.h>
30 #include <plat/sched_clock.h>
34 #define V2M_PA_CS0 0x40000000
35 #define V2M_PA_CS1 0x44000000
36 #define V2M_PA_CS2 0x48000000
37 #define V2M_PA_CS3 0x4c000000
38 #define V2M_PA_CS7 0x10000000
40 static struct map_desc v2m_io_desc
[] __initdata
= {
42 .virtual = __MMIO_P2V(V2M_PA_CS7
),
43 .pfn
= __phys_to_pfn(V2M_PA_CS7
),
49 static void __init
v2m_init_early(void)
51 ct_desc
->init_early();
52 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ
), 24000000);
55 static void __init
v2m_timer_init(void)
59 /* Select 1MHz TIMCLK as the reference clock for SP804 timers */
60 scctrl
= readl(MMIO_P2V(V2M_SYSCTL
+ SCCTRL
));
61 scctrl
|= SCCTRL_TIMEREN0SEL_TIMCLK
;
62 scctrl
|= SCCTRL_TIMEREN1SEL_TIMCLK
;
63 writel(scctrl
, MMIO_P2V(V2M_SYSCTL
+ SCCTRL
));
65 writel(0, MMIO_P2V(V2M_TIMER0
) + TIMER_CTRL
);
66 writel(0, MMIO_P2V(V2M_TIMER1
) + TIMER_CTRL
);
68 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1
), "v2m-timer1");
69 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0
), IRQ_V2M_TIMER0
,
73 static struct sys_timer v2m_timer
= {
74 .init
= v2m_timer_init
,
78 static DEFINE_SPINLOCK(v2m_cfg_lock
);
80 int v2m_cfg_write(u32 devfn
, u32 data
)
82 /* Configuration interface broken? */
85 printk("%s: writing %08x to %08x\n", __func__
, data
, devfn
);
87 devfn
|= SYS_CFG_START
| SYS_CFG_WRITE
;
89 spin_lock(&v2m_cfg_lock
);
90 val
= readl(MMIO_P2V(V2M_SYS_CFGSTAT
));
91 writel(val
& ~SYS_CFG_COMPLETE
, MMIO_P2V(V2M_SYS_CFGSTAT
));
93 writel(data
, MMIO_P2V(V2M_SYS_CFGDATA
));
94 writel(devfn
, MMIO_P2V(V2M_SYS_CFGCTRL
));
97 val
= readl(MMIO_P2V(V2M_SYS_CFGSTAT
));
99 spin_unlock(&v2m_cfg_lock
);
101 return !!(val
& SYS_CFG_ERR
);
104 int v2m_cfg_read(u32 devfn
, u32
*data
)
108 devfn
|= SYS_CFG_START
;
110 spin_lock(&v2m_cfg_lock
);
111 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT
));
112 writel(devfn
, MMIO_P2V(V2M_SYS_CFGCTRL
));
118 val
= readl(MMIO_P2V(V2M_SYS_CFGSTAT
));
121 *data
= readl(MMIO_P2V(V2M_SYS_CFGDATA
));
122 spin_unlock(&v2m_cfg_lock
);
124 return !!(val
& SYS_CFG_ERR
);
128 static struct resource v2m_pcie_i2c_resource
= {
129 .start
= V2M_SERIAL_BUS_PCI
,
130 .end
= V2M_SERIAL_BUS_PCI
+ SZ_4K
- 1,
131 .flags
= IORESOURCE_MEM
,
134 static struct platform_device v2m_pcie_i2c_device
= {
135 .name
= "versatile-i2c",
138 .resource
= &v2m_pcie_i2c_resource
,
141 static struct resource v2m_ddc_i2c_resource
= {
142 .start
= V2M_SERIAL_BUS_DVI
,
143 .end
= V2M_SERIAL_BUS_DVI
+ SZ_4K
- 1,
144 .flags
= IORESOURCE_MEM
,
147 static struct platform_device v2m_ddc_i2c_device
= {
148 .name
= "versatile-i2c",
151 .resource
= &v2m_ddc_i2c_resource
,
154 static struct resource v2m_eth_resources
[] = {
156 .start
= V2M_LAN9118
,
157 .end
= V2M_LAN9118
+ SZ_64K
- 1,
158 .flags
= IORESOURCE_MEM
,
160 .start
= IRQ_V2M_LAN9118
,
161 .end
= IRQ_V2M_LAN9118
,
162 .flags
= IORESOURCE_IRQ
,
166 static struct smsc911x_platform_config v2m_eth_config
= {
167 .flags
= SMSC911X_USE_32BIT
,
168 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
169 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
170 .phy_interface
= PHY_INTERFACE_MODE_MII
,
173 static struct platform_device v2m_eth_device
= {
176 .resource
= v2m_eth_resources
,
177 .num_resources
= ARRAY_SIZE(v2m_eth_resources
),
178 .dev
.platform_data
= &v2m_eth_config
,
181 static struct resource v2m_usb_resources
[] = {
183 .start
= V2M_ISP1761
,
184 .end
= V2M_ISP1761
+ SZ_128K
- 1,
185 .flags
= IORESOURCE_MEM
,
187 .start
= IRQ_V2M_ISP1761
,
188 .end
= IRQ_V2M_ISP1761
,
189 .flags
= IORESOURCE_IRQ
,
193 static struct isp1760_platform_data v2m_usb_config
= {
195 .bus_width_16
= false,
198 .dack_polarity_high
= false,
199 .dreq_polarity_high
= false,
202 static struct platform_device v2m_usb_device
= {
205 .resource
= v2m_usb_resources
,
206 .num_resources
= ARRAY_SIZE(v2m_usb_resources
),
207 .dev
.platform_data
= &v2m_usb_config
,
210 static void v2m_flash_set_vpp(struct platform_device
*pdev
, int on
)
212 writel(on
!= 0, MMIO_P2V(V2M_SYS_FLASH
));
215 static struct physmap_flash_data v2m_flash_data
= {
217 .set_vpp
= v2m_flash_set_vpp
,
220 static struct resource v2m_flash_resources
[] = {
223 .end
= V2M_NOR0
+ SZ_64M
- 1,
224 .flags
= IORESOURCE_MEM
,
227 .end
= V2M_NOR1
+ SZ_64M
- 1,
228 .flags
= IORESOURCE_MEM
,
232 static struct platform_device v2m_flash_device
= {
233 .name
= "physmap-flash",
235 .resource
= v2m_flash_resources
,
236 .num_resources
= ARRAY_SIZE(v2m_flash_resources
),
237 .dev
.platform_data
= &v2m_flash_data
,
240 static struct pata_platform_info v2m_pata_data
= {
244 static struct resource v2m_pata_resources
[] = {
247 .end
= V2M_CF
+ 0xff,
248 .flags
= IORESOURCE_MEM
,
250 .start
= V2M_CF
+ 0x100,
251 .end
= V2M_CF
+ SZ_4K
- 1,
252 .flags
= IORESOURCE_MEM
,
256 static struct platform_device v2m_cf_device
= {
257 .name
= "pata_platform",
259 .resource
= v2m_pata_resources
,
260 .num_resources
= ARRAY_SIZE(v2m_pata_resources
),
261 .dev
.platform_data
= &v2m_pata_data
,
264 static unsigned int v2m_mmci_status(struct device
*dev
)
266 return readl(MMIO_P2V(V2M_SYS_MCI
)) & (1 << 0);
269 static struct mmci_platform_data v2m_mmci_data
= {
270 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
271 .status
= v2m_mmci_status
,
274 static AMBA_DEVICE(aaci
, "mb:aaci", V2M_AACI
, NULL
);
275 static AMBA_DEVICE(mmci
, "mb:mmci", V2M_MMCI
, &v2m_mmci_data
);
276 static AMBA_DEVICE(kmi0
, "mb:kmi0", V2M_KMI0
, NULL
);
277 static AMBA_DEVICE(kmi1
, "mb:kmi1", V2M_KMI1
, NULL
);
278 static AMBA_DEVICE(uart0
, "mb:uart0", V2M_UART0
, NULL
);
279 static AMBA_DEVICE(uart1
, "mb:uart1", V2M_UART1
, NULL
);
280 static AMBA_DEVICE(uart2
, "mb:uart2", V2M_UART2
, NULL
);
281 static AMBA_DEVICE(uart3
, "mb:uart3", V2M_UART3
, NULL
);
282 static AMBA_DEVICE(wdt
, "mb:wdt", V2M_WDT
, NULL
);
283 static AMBA_DEVICE(rtc
, "mb:rtc", V2M_RTC
, NULL
);
285 static struct amba_device
*v2m_amba_devs
[] __initdata
= {
299 static long v2m_osc_round(struct clk
*clk
, unsigned long rate
)
304 static int v2m_osc1_set(struct clk
*clk
, unsigned long rate
)
306 return v2m_cfg_write(SYS_CFG_OSC
| SYS_CFG_SITE_MB
| 1, rate
);
309 static const struct clk_ops osc1_clk_ops
= {
310 .round
= v2m_osc_round
,
314 static struct clk osc1_clk
= {
315 .ops
= &osc1_clk_ops
,
319 static struct clk osc2_clk
= {
323 static struct clk v2m_sp804_clk
= {
327 static struct clk dummy_apb_pclk
;
329 static struct clk_lookup v2m_lookups
[] = {
330 { /* AMBA bus clock */
331 .con_id
= "apb_pclk",
332 .clk
= &dummy_apb_pclk
,
334 .dev_id
= "mb:uart0",
337 .dev_id
= "mb:uart1",
340 .dev_id
= "mb:uart2",
343 .dev_id
= "mb:uart3",
357 }, { /* SP804 timers */
359 .con_id
= "v2m-timer0",
360 .clk
= &v2m_sp804_clk
,
361 }, { /* SP804 timers */
363 .con_id
= "v2m-timer1",
364 .clk
= &v2m_sp804_clk
,
368 static void v2m_power_off(void)
370 if (v2m_cfg_write(SYS_CFG_SHUTDOWN
| SYS_CFG_SITE_MB
, 0))
371 printk(KERN_EMERG
"Unable to shutdown\n");
374 static void v2m_restart(char str
, const char *cmd
)
376 if (v2m_cfg_write(SYS_CFG_REBOOT
| SYS_CFG_SITE_MB
, 0))
377 printk(KERN_EMERG
"Unable to reboot\n");
380 struct ct_desc
*ct_desc
;
382 static struct ct_desc
*ct_descs
[] __initdata
= {
383 #ifdef CONFIG_ARCH_VEXPRESS_CA9X4
388 static void __init
v2m_populate_ct_desc(void)
394 current_tile_id
= readl(MMIO_P2V(V2M_SYS_PROCID0
)) & V2M_CT_ID_MASK
;
396 for (i
= 0; i
< ARRAY_SIZE(ct_descs
) && !ct_desc
; ++i
)
397 if (ct_descs
[i
]->id
== current_tile_id
)
398 ct_desc
= ct_descs
[i
];
401 panic("vexpress: failed to populate core tile description "
402 "for tile ID 0x%8x\n", current_tile_id
);
405 static void __init
v2m_map_io(void)
407 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
408 v2m_populate_ct_desc();
412 static void __init
v2m_init_irq(void)
417 static void __init
v2m_init(void)
421 clkdev_add_table(v2m_lookups
, ARRAY_SIZE(v2m_lookups
));
423 platform_device_register(&v2m_pcie_i2c_device
);
424 platform_device_register(&v2m_ddc_i2c_device
);
425 platform_device_register(&v2m_flash_device
);
426 platform_device_register(&v2m_cf_device
);
427 platform_device_register(&v2m_eth_device
);
428 platform_device_register(&v2m_usb_device
);
430 for (i
= 0; i
< ARRAY_SIZE(v2m_amba_devs
); i
++)
431 amba_device_register(v2m_amba_devs
[i
], &iomem_resource
);
433 pm_power_off
= v2m_power_off
;
434 arm_pm_restart
= v2m_restart
;
436 ct_desc
->init_tile();
439 MACHINE_START(VEXPRESS
, "ARM-Versatile Express")
440 .boot_params
= PLAT_PHYS_OFFSET
+ 0x00000100,
441 .map_io
= v2m_map_io
,
442 .init_early
= v2m_init_early
,
443 .init_irq
= v2m_init_irq
,
445 .init_machine
= v2m_init
,