2 * Netgear WNDR3700 board support
4 * Copyright (C) 2009 Marco Porsch
5 * Copyright (C) 2009 Gabor Juhos <juhosg@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/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
17 #include <linux/input.h>
18 #include <linux/pci.h>
19 #include <linux/ath9k_platform.h>
21 #include <asm/mips_machine.h>
22 #include <asm/mach-ar71xx/ar71xx.h>
23 #include <asm/mach-ar71xx/pci.h>
27 #define WNDR3700_GPIO_LED_WPS_ORANGE 0
28 #define WNDR3700_GPIO_LED_POWER_ORANGE 1
29 #define WNDR3700_GPIO_LED_POWER_GREEN 2
30 #define WNDR3700_GPIO_LED_WPS_GREEN 4
32 #define WNDR3700_GPIO_BTN_WPS 3
33 #define WNDR3700_GPIO_BTN_RESET 8
34 #define WNDR3700_GPIO_BTN_WIFI 11
36 #define WNDR3700_BUTTONS_POLL_INTERVAL 20
38 #ifdef CONFIG_MTD_PARTITIONS
39 static struct mtd_partition wndr3700_partitions[] = {
44 .mask_flags = MTD_WRITEABLE,
49 .mask_flags = MTD_WRITEABLE,
58 .mask_flags = MTD_WRITEABLE,
63 .mask_flags = MTD_WRITEABLE,
68 .mask_flags = MTD_WRITEABLE,
70 .name = "traffic_meter",
73 .mask_flags = MTD_WRITEABLE,
78 .mask_flags = MTD_WRITEABLE,
83 .mask_flags = MTD_WRITEABLE,
86 #endif /* CONFIG_MTD_PARTITIONS */
88 static struct flash_platform_data wndr3700_flash_data = {
89 #ifdef CONFIG_MTD_PARTITIONS
90 .parts = wndr3700_partitions,
91 .nr_parts = ARRAY_SIZE(wndr3700_partitions),
96 static struct ar71xx_pci_irq wndr3700_pci_irqs[] __initdata = {
100 .irq = AR71XX_PCI_IRQ_DEV0,
104 .irq = AR71XX_PCI_IRQ_DEV1,
108 static struct ath9k_platform_data wndr3700_wmac0_data;
109 static struct ath9k_platform_data wndr3700_wmac1_data;
111 static int wndr3700_pci_plat_dev_init(struct pci_dev *dev)
113 switch (PCI_SLOT(dev->devfn)) {
115 dev->dev.platform_data = &wndr3700_wmac0_data;
118 dev->dev.platform_data = &wndr3700_wmac1_data;
125 static void __init wndr3700_pci_init(void)
129 ee = (u8 *) KSEG1ADDR(0x1fff1000);
130 memcpy(wndr3700_wmac0_data.eeprom_data, ee,
131 sizeof(wndr3700_wmac0_data.eeprom_data));
133 ee = (u8 *) KSEG1ADDR(0x1fff5000);
134 memcpy(wndr3700_wmac1_data.eeprom_data, ee,
135 sizeof(wndr3700_wmac1_data.eeprom_data));
137 ar71xx_pci_plat_dev_init = wndr3700_pci_plat_dev_init;
138 ar71xx_pci_init(ARRAY_SIZE(wndr3700_pci_irqs), wndr3700_pci_irqs);
141 static inline void wndr3700_pci_init(void) { };
142 #endif /* CONFIG_PCI */
144 static struct spi_board_info wndr3700_spi_info[] = {
148 .max_speed_hz = 25000000,
149 .modalias = "m25p80",
150 .platform_data = &wndr3700_flash_data,
154 static struct gpio_led wndr3700_leds_gpio[] __initdata = {
156 .name = "wndr3700:green:power",
157 .gpio = WNDR3700_GPIO_LED_POWER_GREEN,
160 .name = "wndr3700:orange:power",
161 .gpio = WNDR3700_GPIO_LED_POWER_ORANGE,
164 .name = "wndr3700:green:wps",
165 .gpio = WNDR3700_GPIO_LED_WPS_GREEN,
168 .name = "wndr3700:orange:wps",
169 .gpio = WNDR3700_GPIO_LED_WPS_ORANGE,
174 static struct gpio_button wndr3700_gpio_buttons[] __initdata = {
180 .gpio = WNDR3700_GPIO_BTN_RESET,
186 .gpio = WNDR3700_GPIO_BTN_WPS,
192 .gpio = WNDR3700_GPIO_BTN_WIFI,
196 static void __init wndr3700_setup(void)
198 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
200 ar71xx_set_mac_base(mac);
201 ar71xx_add_device_mdio(0x0);
203 ar71xx_eth0_pll_data.pll_1000 = 0x11110000;
204 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
205 ar71xx_eth0_data.phy_mask = 0xf;
206 ar71xx_eth0_data.speed = SPEED_1000;
207 ar71xx_eth0_data.duplex = DUPLEX_FULL;
209 ar71xx_eth1_pll_data.pll_1000 = 0x11110000;
210 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
211 ar71xx_eth1_data.phy_mask = 0x10;
213 ar71xx_add_device_eth(0);
214 ar71xx_add_device_eth(1);
216 ar71xx_add_device_usb();
218 ar71xx_add_device_spi(NULL, wndr3700_spi_info,
219 ARRAY_SIZE(wndr3700_spi_info));
221 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
224 ar71xx_add_device_gpio_buttons(-1, WNDR3700_BUTTONS_POLL_INTERVAL,
225 ARRAY_SIZE(wndr3700_gpio_buttons),
226 wndr3700_gpio_buttons);
231 MIPS_MACHINE(AR71XX_MACH_WNDR3700, "NETGEAR WNDR3700", wndr3700_setup);