2 * arch/arm/mach-orion5x/wrt350n-v2-setup.c
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
8 #include <linux/gpio.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11 #include <linux/platform_device.h>
12 #include <linux/pci.h>
13 #include <linux/irq.h>
14 #include <linux/delay.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/mv643xx_eth.h>
17 #include <linux/ethtool.h>
18 #include <linux/leds.h>
19 #include <linux/gpio_keys.h>
20 #include <linux/input.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/pci.h>
25 #include <mach/orion5x.h>
30 * LEDs attached to GPIO
32 static struct gpio_led wrt350n_v2_led_pins
[] = {
34 .name
= "wrt350nv2:green:power",
38 .name
= "wrt350nv2:green:security",
42 .name
= "wrt350nv2:orange:power",
46 .name
= "wrt350nv2:green:usb",
50 .name
= "wrt350nv2:green:wireless",
56 static struct gpio_led_platform_data wrt350n_v2_led_data
= {
57 .leds
= wrt350n_v2_led_pins
,
58 .num_leds
= ARRAY_SIZE(wrt350n_v2_led_pins
),
61 static struct platform_device wrt350n_v2_leds
= {
65 .platform_data
= &wrt350n_v2_led_data
,
70 * Buttons attached to GPIO
72 static struct gpio_keys_button wrt350n_v2_buttons
[] = {
76 .desc
= "Reset Button",
79 .code
= KEY_WPS_BUTTON
,
86 static struct gpio_keys_platform_data wrt350n_v2_button_data
= {
87 .buttons
= wrt350n_v2_buttons
,
88 .nbuttons
= ARRAY_SIZE(wrt350n_v2_buttons
),
91 static struct platform_device wrt350n_v2_button_device
= {
96 .platform_data
= &wrt350n_v2_button_data
,
103 static unsigned int wrt350n_v2_mpp_modes
[] __initdata
= {
104 MPP0_GPIO
, /* Power LED green (0=on) */
105 MPP1_GPIO
, /* Security LED (0=on) */
106 MPP2_GPIO
, /* Internal Button (0=on) */
107 MPP3_GPIO
, /* Reset Button (0=on) */
108 MPP4_GPIO
, /* PCI int */
109 MPP5_GPIO
, /* Power LED orange (0=on) */
110 MPP6_GPIO
, /* USB LED (0=on) */
111 MPP7_GPIO
, /* Wireless LED (0=on) */
112 MPP8_UNUSED
, /* ??? */
113 MPP9_GIGE
, /* GE_RXERR */
114 MPP10_UNUSED
, /* ??? */
115 MPP11_UNUSED
, /* ??? */
116 MPP12_GIGE
, /* GE_TXD[4] */
117 MPP13_GIGE
, /* GE_TXD[5] */
118 MPP14_GIGE
, /* GE_TXD[6] */
119 MPP15_GIGE
, /* GE_TXD[7] */
120 MPP16_GIGE
, /* GE_RXD[4] */
121 MPP17_GIGE
, /* GE_RXD[5] */
122 MPP18_GIGE
, /* GE_RXD[6] */
123 MPP19_GIGE
, /* GE_RXD[7] */
128 * 8M NOR flash Device bus boot chip select
130 #define WRT350N_V2_NOR_BOOT_BASE 0xf4000000
131 #define WRT350N_V2_NOR_BOOT_SIZE SZ_8M
133 static struct mtd_partition wrt350n_v2_nor_flash_partitions
[] = {
136 .offset
= 0x00000000,
140 .offset
= 0x001a0000,
144 .offset
= 0x00760000,
148 .offset
= 0x007a0000,
152 .offset
= 0x007c0000,
157 static struct physmap_flash_data wrt350n_v2_nor_flash_data
= {
159 .parts
= wrt350n_v2_nor_flash_partitions
,
160 .nr_parts
= ARRAY_SIZE(wrt350n_v2_nor_flash_partitions
),
163 static struct resource wrt350n_v2_nor_flash_resource
= {
164 .flags
= IORESOURCE_MEM
,
165 .start
= WRT350N_V2_NOR_BOOT_BASE
,
166 .end
= WRT350N_V2_NOR_BOOT_BASE
+ WRT350N_V2_NOR_BOOT_SIZE
- 1,
169 static struct platform_device wrt350n_v2_nor_flash
= {
170 .name
= "physmap-flash",
173 .platform_data
= &wrt350n_v2_nor_flash_data
,
176 .resource
= &wrt350n_v2_nor_flash_resource
,
179 static struct mv643xx_eth_platform_data wrt350n_v2_eth_data
= {
180 .phy_addr
= MV643XX_ETH_PHY_NONE
,
182 .duplex
= DUPLEX_FULL
,
185 static struct dsa_chip_data wrt350n_v2_switch_chip_data
= {
186 .port_names
[0] = "lan2",
187 .port_names
[1] = "lan1",
188 .port_names
[2] = "wan",
189 .port_names
[3] = "cpu",
190 .port_names
[5] = "lan3",
191 .port_names
[7] = "lan4",
194 static struct dsa_platform_data wrt350n_v2_switch_plat_data
= {
196 .chip
= &wrt350n_v2_switch_chip_data
,
199 static void __init
wrt350n_v2_init(void)
202 * Setup basic Orion functions. Need to be called early.
206 orion5x_mpp_conf(wrt350n_v2_mpp_modes
);
209 * Configure peripherals.
211 orion5x_ehci0_init();
212 orion5x_eth_init(&wrt350n_v2_eth_data
);
213 orion5x_eth_switch_init(&wrt350n_v2_switch_plat_data
, NO_IRQ
);
214 orion5x_uart0_init();
216 mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET
,
217 ORION_MBUS_DEVBUS_BOOT_ATTR
,
218 WRT350N_V2_NOR_BOOT_BASE
,
219 WRT350N_V2_NOR_BOOT_SIZE
);
220 platform_device_register(&wrt350n_v2_nor_flash
);
221 platform_device_register(&wrt350n_v2_leds
);
222 platform_device_register(&wrt350n_v2_button_device
);
225 static int __init
wrt350n_v2_pci_map_irq(const struct pci_dev
*dev
, u8 slot
,
231 * Check for devices with hard-wired IRQs.
233 irq
= orion5x_pci_map_irq(dev
, slot
, pin
);
241 return gpio_to_irq(4);
246 static struct hw_pci wrt350n_v2_pci __initdata
= {
248 .setup
= orion5x_pci_sys_setup
,
249 .scan
= orion5x_pci_sys_scan_bus
,
250 .map_irq
= wrt350n_v2_pci_map_irq
,
253 static int __init
wrt350n_v2_pci_init(void)
255 if (machine_is_wrt350n_v2())
256 pci_common_init(&wrt350n_v2_pci
);
260 subsys_initcall(wrt350n_v2_pci_init
);
262 MACHINE_START(WRT350N_V2
, "Linksys WRT350N v2")
263 /* Maintainer: Lennert Buytenhek <buytenh@marvell.com> */
264 .atag_offset
= 0x100,
265 .init_machine
= wrt350n_v2_init
,
266 .map_io
= orion5x_map_io
,
267 .init_early
= orion5x_init_early
,
268 .init_irq
= orion5x_init_irq
,
269 .init_time
= orion5x_timer_init
,
270 .fixup
= tag_fixup_mem32
,
271 .restart
= orion5x_restart
,