2 * Netgear WNDR3700 board support
4 * Copyright (C) 2009 Marco Porsch
5 * Copyright (C) 2009-2010 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/delay.h>
16 #include <linux/rtl8366s.h>
18 #include <asm/mach-ar71xx/ar71xx.h>
22 #include "dev-m25p80.h"
23 #include "dev-ap94-pci.h"
24 #include "dev-gpio-buttons.h"
25 #include "dev-leds-gpio.h"
28 #define WNDR3700_GPIO_LED_WPS_ORANGE 0
29 #define WNDR3700_GPIO_LED_POWER_ORANGE 1
30 #define WNDR3700_GPIO_LED_POWER_GREEN 2
31 #define WNDR3700_GPIO_LED_WPS_GREEN 4
32 #define WNDR3700_GPIO_LED_WAN_GREEN 6
34 #define WNDR3700_GPIO_BTN_WPS 3
35 #define WNDR3700_GPIO_BTN_RESET 8
36 #define WNDR3700_GPIO_BTN_WIFI 11
38 #define WNDR3700_GPIO_RTL8366_SDA 5
39 #define WNDR3700_GPIO_RTL8366_SCK 7
41 #define WNDR3700_BUTTONS_POLL_INTERVAL 20
43 #define WNDR3700_WMAC0_MAC_OFFSET 0
44 #define WNDR3700_WMAC1_MAC_OFFSET 0xc
45 #define WNDR3700_CALDATA0_OFFSET 0x1000
46 #define WNDR3700_CALDATA1_OFFSET 0x5000
48 #ifdef CONFIG_MTD_PARTITIONS
49 static struct mtd_partition wndr3700_partitions[] = {
54 .mask_flags = MTD_WRITEABLE,
59 .mask_flags = MTD_WRITEABLE,
68 .mask_flags = MTD_WRITEABLE,
73 .mask_flags = MTD_WRITEABLE,
78 .mask_flags = MTD_WRITEABLE,
80 .name = "traffic_meter",
83 .mask_flags = MTD_WRITEABLE,
88 .mask_flags = MTD_WRITEABLE,
93 .mask_flags = MTD_WRITEABLE,
96 #endif /* CONFIG_MTD_PARTITIONS */
98 static struct flash_platform_data wndr3700_flash_data = {
99 #ifdef CONFIG_MTD_PARTITIONS
100 .parts = wndr3700_partitions,
101 .nr_parts = ARRAY_SIZE(wndr3700_partitions),
105 static struct gpio_led wndr3700_leds_gpio[] __initdata = {
107 .name = "wndr3700:green:power",
108 .gpio = WNDR3700_GPIO_LED_POWER_GREEN,
111 .name = "wndr3700:orange:power",
112 .gpio = WNDR3700_GPIO_LED_POWER_ORANGE,
115 .name = "wndr3700:green:wps",
116 .gpio = WNDR3700_GPIO_LED_WPS_GREEN,
119 .name = "wndr3700:orange:wps",
120 .gpio = WNDR3700_GPIO_LED_WPS_ORANGE,
123 .name = "wndr3700:green:wan",
124 .gpio = WNDR3700_GPIO_LED_WAN_GREEN,
129 static struct gpio_button wndr3700_gpio_buttons[] __initdata = {
135 .gpio = WNDR3700_GPIO_BTN_RESET,
142 .gpio = WNDR3700_GPIO_BTN_WPS,
149 .gpio = WNDR3700_GPIO_BTN_WIFI,
154 static struct rtl8366s_platform_data wndr3700_rtl8366s_data = {
155 .gpio_sda = WNDR3700_GPIO_RTL8366_SDA,
156 .gpio_sck = WNDR3700_GPIO_RTL8366_SCK,
159 static struct platform_device wndr3700_rtl8366s_device = {
160 .name = RTL8366S_DRIVER_NAME,
163 .platform_data = &wndr3700_rtl8366s_data,
167 static void __init wndr3700_setup(void)
169 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
171 ar71xx_set_mac_base(art);
173 ar71xx_eth0_pll_data.pll_1000 = 0x11110000;
174 ar71xx_eth0_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
175 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
176 ar71xx_eth0_data.speed = SPEED_1000;
177 ar71xx_eth0_data.duplex = DUPLEX_FULL;
179 ar71xx_eth1_pll_data.pll_1000 = 0x11110000;
180 ar71xx_eth1_data.mii_bus_dev = &wndr3700_rtl8366s_device.dev;
181 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
182 ar71xx_eth1_data.phy_mask = 0x10;
184 ar71xx_add_device_eth(0);
185 ar71xx_add_device_eth(1);
187 ar71xx_add_device_usb();
189 ar71xx_add_device_m25p80(&wndr3700_flash_data);
191 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio),
194 ar71xx_add_device_gpio_buttons(-1, WNDR3700_BUTTONS_POLL_INTERVAL,
195 ARRAY_SIZE(wndr3700_gpio_buttons),
196 wndr3700_gpio_buttons);
198 platform_device_register(&wndr3700_rtl8366s_device);
199 platform_device_register_simple("wndr3700-led-usb", -1, NULL, 0);
201 ap94_pci_setup_wmac_led_pin(0, 5);
202 ap94_pci_setup_wmac_led_pin(1, 5);
204 /* 2.4 GHz uses the first fixed antenna group (1, 0, 1, 0) */
205 ap94_pci_setup_wmac_gpio(0, (0xf << 6), (0xa << 6));
207 /* 5 GHz uses the second fixed antenna group (0, 1, 1, 0) */
208 ap94_pci_setup_wmac_gpio(1, (0xf << 6), (0x6 << 6));
210 ap94_pci_init(art + WNDR3700_CALDATA0_OFFSET,
211 art + WNDR3700_WMAC0_MAC_OFFSET,
212 art + WNDR3700_CALDATA1_OFFSET,
213 art + WNDR3700_WMAC1_MAC_OFFSET);
216 MIPS_MACHINE(AR71XX_MACH_WNDR3700, "WNDR3700", "NETGEAR WNDR3700",