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>
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>
22 #include <mach/motherboard.h>
24 #include <plat/timer-sp.h>
28 #define V2M_PA_CS0 0x40000000
29 #define V2M_PA_CS1 0x44000000
30 #define V2M_PA_CS2 0x48000000
31 #define V2M_PA_CS3 0x4c000000
32 #define V2M_PA_CS7 0x10000000
34 static struct map_desc v2m_io_desc
[] __initdata
= {
36 .virtual = __MMIO_P2V(V2M_PA_CS7
),
37 .pfn
= __phys_to_pfn(V2M_PA_CS7
),
43 void __init
v2m_map_io(struct map_desc
*tile
, size_t num
)
45 iotable_init(v2m_io_desc
, ARRAY_SIZE(v2m_io_desc
));
46 iotable_init(tile
, num
);
50 static void __init
v2m_timer_init(void)
52 writel(0, MMIO_P2V(V2M_TIMER0
) + TIMER_CTRL
);
53 writel(0, MMIO_P2V(V2M_TIMER1
) + TIMER_CTRL
);
55 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1
));
56 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0
), IRQ_V2M_TIMER0
);
59 struct sys_timer v2m_timer
= {
60 .init
= v2m_timer_init
,
64 static DEFINE_SPINLOCK(v2m_cfg_lock
);
66 int v2m_cfg_write(u32 devfn
, u32 data
)
68 /* Configuration interface broken? */
71 printk("%s: writing %08x to %08x\n", __func__
, data
, devfn
);
73 devfn
|= SYS_CFG_START
| SYS_CFG_WRITE
;
75 spin_lock(&v2m_cfg_lock
);
76 val
= readl(MMIO_P2V(V2M_SYS_CFGSTAT
));
77 writel(val
& ~SYS_CFG_COMPLETE
, MMIO_P2V(V2M_SYS_CFGSTAT
));
79 writel(data
, MMIO_P2V(V2M_SYS_CFGDATA
));
80 writel(devfn
, MMIO_P2V(V2M_SYS_CFGCTRL
));
83 val
= readl(MMIO_P2V(V2M_SYS_CFGSTAT
));
85 spin_unlock(&v2m_cfg_lock
);
87 return !!(val
& SYS_CFG_ERR
);
90 int v2m_cfg_read(u32 devfn
, u32
*data
)
94 devfn
|= SYS_CFG_START
;
96 spin_lock(&v2m_cfg_lock
);
97 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT
));
98 writel(devfn
, MMIO_P2V(V2M_SYS_CFGCTRL
));
104 val
= readl(MMIO_P2V(V2M_SYS_CFGSTAT
));
107 *data
= readl(MMIO_P2V(V2M_SYS_CFGDATA
));
108 spin_unlock(&v2m_cfg_lock
);
110 return !!(val
& SYS_CFG_ERR
);
114 static struct resource v2m_pcie_i2c_resource
= {
115 .start
= V2M_SERIAL_BUS_PCI
,
116 .end
= V2M_SERIAL_BUS_PCI
+ SZ_4K
- 1,
117 .flags
= IORESOURCE_MEM
,
120 static struct platform_device v2m_pcie_i2c_device
= {
121 .name
= "versatile-i2c",
124 .resource
= &v2m_pcie_i2c_resource
,
127 static struct resource v2m_ddc_i2c_resource
= {
128 .start
= V2M_SERIAL_BUS_DVI
,
129 .end
= V2M_SERIAL_BUS_DVI
+ SZ_4K
- 1,
130 .flags
= IORESOURCE_MEM
,
133 static struct platform_device v2m_ddc_i2c_device
= {
134 .name
= "versatile-i2c",
137 .resource
= &v2m_ddc_i2c_resource
,
140 static struct resource v2m_eth_resources
[] = {
142 .start
= V2M_LAN9118
,
143 .end
= V2M_LAN9118
+ SZ_64K
- 1,
144 .flags
= IORESOURCE_MEM
,
146 .start
= IRQ_V2M_LAN9118
,
147 .end
= IRQ_V2M_LAN9118
,
148 .flags
= IORESOURCE_IRQ
,
152 static struct smsc911x_platform_config v2m_eth_config
= {
153 .flags
= SMSC911X_USE_32BIT
,
154 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_HIGH
,
155 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
156 .phy_interface
= PHY_INTERFACE_MODE_MII
,
159 static struct platform_device v2m_eth_device
= {
162 .resource
= v2m_eth_resources
,
163 .num_resources
= ARRAY_SIZE(v2m_eth_resources
),
164 .dev
.platform_data
= &v2m_eth_config
,
167 static struct resource v2m_usb_resources
[] = {
169 .start
= V2M_ISP1761
,
170 .end
= V2M_ISP1761
+ SZ_128K
- 1,
171 .flags
= IORESOURCE_MEM
,
173 .start
= IRQ_V2M_ISP1761
,
174 .end
= IRQ_V2M_ISP1761
,
175 .flags
= IORESOURCE_IRQ
,
179 static struct isp1760_platform_data v2m_usb_config
= {
181 .bus_width_16
= false,
184 .dack_polarity_high
= false,
185 .dreq_polarity_high
= false,
188 static struct platform_device v2m_usb_device
= {
191 .resource
= v2m_usb_resources
,
192 .num_resources
= ARRAY_SIZE(v2m_usb_resources
),
193 .dev
.platform_data
= &v2m_usb_config
,
196 static int v2m_flash_init(void)
198 writel(0, MMIO_P2V(V2M_SYS_FLASH
));
202 static void v2m_flash_exit(void)
204 writel(0, MMIO_P2V(V2M_SYS_FLASH
));
207 static void v2m_flash_set_vpp(int on
)
209 writel(on
!= 0, MMIO_P2V(V2M_SYS_FLASH
));
212 static struct flash_platform_data v2m_flash_data
= {
213 .map_name
= "cfi_probe",
215 .init
= v2m_flash_init
,
216 .exit
= v2m_flash_exit
,
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
= {
235 .resource
= v2m_flash_resources
,
236 .num_resources
= ARRAY_SIZE(v2m_flash_resources
),
237 .dev
.platform_data
= &v2m_flash_data
,
241 static unsigned int v2m_mmci_status(struct device
*dev
)
243 return readl(MMIO_P2V(V2M_SYS_MCI
)) & (1 << 0);
246 static struct mmci_platform_data v2m_mmci_data
= {
247 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
248 .status
= v2m_mmci_status
,
251 static AMBA_DEVICE(aaci
, "mb:aaci", V2M_AACI
, NULL
);
252 static AMBA_DEVICE(mmci
, "mb:mmci", V2M_MMCI
, &v2m_mmci_data
);
253 static AMBA_DEVICE(kmi0
, "mb:kmi0", V2M_KMI0
, NULL
);
254 static AMBA_DEVICE(kmi1
, "mb:kmi1", V2M_KMI1
, NULL
);
255 static AMBA_DEVICE(uart0
, "mb:uart0", V2M_UART0
, NULL
);
256 static AMBA_DEVICE(uart1
, "mb:uart1", V2M_UART1
, NULL
);
257 static AMBA_DEVICE(uart2
, "mb:uart2", V2M_UART2
, NULL
);
258 static AMBA_DEVICE(uart3
, "mb:uart3", V2M_UART3
, NULL
);
259 static AMBA_DEVICE(wdt
, "mb:wdt", V2M_WDT
, NULL
);
260 static AMBA_DEVICE(rtc
, "mb:rtc", V2M_RTC
, NULL
);
262 static struct amba_device
*v2m_amba_devs
[] __initdata
= {
276 static long v2m_osc_round(struct clk
*clk
, unsigned long rate
)
281 static int v2m_osc1_set(struct clk
*clk
, unsigned long rate
)
283 return v2m_cfg_write(SYS_CFG_OSC
| SYS_CFG_SITE_MB
| 1, rate
);
286 static const struct clk_ops osc1_clk_ops
= {
287 .round
= v2m_osc_round
,
291 static struct clk osc1_clk
= {
292 .ops
= &osc1_clk_ops
,
296 static struct clk osc2_clk
= {
300 static struct clk dummy_apb_pclk
;
302 static struct clk_lookup v2m_lookups
[] = {
303 { /* AMBA bus clock */
304 .con_id
= "apb_pclk",
305 .clk
= &dummy_apb_pclk
,
307 .dev_id
= "mb:uart0",
310 .dev_id
= "mb:uart1",
313 .dev_id
= "mb:uart2",
316 .dev_id
= "mb:uart3",
333 static void v2m_power_off(void)
335 if (v2m_cfg_write(SYS_CFG_SHUTDOWN
| SYS_CFG_SITE_MB
, 0))
336 printk(KERN_EMERG
"Unable to shutdown\n");
339 static void v2m_restart(char str
, const char *cmd
)
341 if (v2m_cfg_write(SYS_CFG_REBOOT
| SYS_CFG_SITE_MB
, 0))
342 printk(KERN_EMERG
"Unable to reboot\n");
345 static int __init
v2m_init(void)
349 clkdev_add_table(v2m_lookups
, ARRAY_SIZE(v2m_lookups
));
351 platform_device_register(&v2m_pcie_i2c_device
);
352 platform_device_register(&v2m_ddc_i2c_device
);
353 platform_device_register(&v2m_flash_device
);
354 platform_device_register(&v2m_eth_device
);
355 platform_device_register(&v2m_usb_device
);
357 for (i
= 0; i
< ARRAY_SIZE(v2m_amba_devs
); i
++)
358 amba_device_register(v2m_amba_devs
[i
], &iomem_resource
);
360 pm_power_off
= v2m_power_off
;
361 arm_pm_restart
= v2m_restart
;
365 arch_initcall(v2m_init
);