2 * Ralink RT288x SoC platform device registration
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/etherdevice.h>
18 #include <asm/addrspace.h>
20 #include <asm/mach-ralink/rt288x.h>
21 #include <asm/mach-ralink/rt288x_regs.h>
22 #include <asm/mach-ralink/ramips_eth_platform.h>
26 static struct resource rt288x_flash0_resources
[] = {
28 .flags
= IORESOURCE_MEM
,
29 .start
= KSEG1ADDR(RT2880_FLASH0_BASE
),
30 .end
= KSEG1ADDR(RT2880_FLASH0_BASE
) +
31 RT2880_FLASH0_SIZE
- 1,
35 static struct platform_device rt288x_flash0_device
= {
36 .name
= "physmap-flash",
37 .resource
= rt288x_flash0_resources
,
38 .num_resources
= ARRAY_SIZE(rt288x_flash0_resources
),
41 static struct resource rt288x_flash1_resources
[] = {
43 .flags
= IORESOURCE_MEM
,
44 .start
= KSEG1ADDR(RT2880_FLASH1_BASE
),
45 .end
= KSEG1ADDR(RT2880_FLASH1_BASE
) +
46 RT2880_FLASH1_SIZE
- 1,
50 static struct platform_device rt288x_flash1_device
= {
51 .name
= "physmap-flash",
52 .resource
= rt288x_flash1_resources
,
53 .num_resources
= ARRAY_SIZE(rt288x_flash1_resources
),
56 static int rt288x_flash_instance __initdata
;
57 void __init
rt288x_register_flash(unsigned int id
,
58 struct physmap_flash_data
*pdata
)
60 struct platform_device
*pdev
;
66 pdev
= &rt288x_flash0_device
;
67 reg
= MEMC_REG_FLASH_CFG0
;
70 pdev
= &rt288x_flash1_device
;
71 reg
= MEMC_REG_FLASH_CFG1
;
77 t
= rt288x_memc_rr(reg
);
78 t
= (t
>> FLASH_CFG_WIDTH_SHIFT
) & FLASH_CFG_WIDTH_MASK
;
81 case FLASH_CFG_WIDTH_8BIT
:
84 case FLASH_CFG_WIDTH_16BIT
:
87 case FLASH_CFG_WIDTH_32BIT
:
91 printk(KERN_ERR
"RT288x: flash bank%u witdh is invalid\n", id
);
95 pdev
->dev
.platform_data
= pdata
;
96 pdev
->id
= rt288x_flash_instance
;
98 platform_device_register(pdev
);
99 rt288x_flash_instance
++;
102 static struct resource rt288x_wifi_resources
[] = {
104 .start
= RT2880_WMAC_BASE
,
105 .end
= RT2880_WMAC_BASE
+ 0x3FFFF,
106 .flags
= IORESOURCE_MEM
,
108 .start
= RT288X_CPU_IRQ_WNIC
,
109 .end
= RT288X_CPU_IRQ_WNIC
,
110 .flags
= IORESOURCE_IRQ
,
114 static struct platform_device rt288x_wifi_device
= {
115 .name
= "rt2800_wmac",
116 .resource
= rt288x_wifi_resources
,
117 .num_resources
= ARRAY_SIZE(rt288x_wifi_resources
),
119 .platform_data
= NULL
,
123 void __init
rt288x_register_wifi(void)
125 platform_device_register(&rt288x_wifi_device
);
128 static void rt288x_fe_reset(void)
130 rt288x_sysc_wr(RT2880_RESET_FE
, SYSC_REG_RESET_CTRL
);
133 static struct resource rt288x_eth_resources
[] = {
135 .start
= RT2880_FE_BASE
,
136 .end
= RT2880_FE_BASE
+ PAGE_SIZE
- 1,
137 .flags
= IORESOURCE_MEM
,
139 .start
= RT288X_CPU_IRQ_FE
,
140 .end
= RT288X_CPU_IRQ_FE
,
141 .flags
= IORESOURCE_IRQ
,
145 struct ramips_eth_platform_data rt288x_eth_data
;
146 static struct platform_device rt288x_eth_device
= {
147 .name
= "ramips_eth",
148 .resource
= rt288x_eth_resources
,
149 .num_resources
= ARRAY_SIZE(rt288x_eth_resources
),
151 .platform_data
= &rt288x_eth_data
,
155 void __init
rt288x_register_ethernet(void)
157 rt288x_eth_data
.sys_freq
= rt288x_sys_freq
;
158 rt288x_eth_data
.reset_fe
= rt288x_fe_reset
;
159 rt288x_eth_data
.min_pkt_len
= 64;
161 if (!is_valid_ether_addr(rt288x_eth_data
.mac
))
162 random_ether_addr(rt288x_eth_data
.mac
);
164 platform_device_register(&rt288x_eth_device
);