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/rtl8366.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_KEYS_POLL_INTERVAL 20 /* msecs */
42 #define WNDR3700_KEYS_DEBOUNCE_INTERVAL (3 * WNDR3700_KEYS_POLL_INTERVAL)
44 #define WNDR3700_ETH0_MAC_OFFSET 0
45 #define WNDR3700_ETH1_MAC_OFFSET 0x6
47 #define WNDR3700_WMAC0_MAC_OFFSET 0
48 #define WNDR3700_WMAC1_MAC_OFFSET 0xc
49 #define WNDR3700_CALDATA0_OFFSET 0x1000
50 #define WNDR3700_CALDATA1_OFFSET 0x5000
52 static struct gpio_led wndr3700_leds_gpio
[] __initdata
= {
54 .name
= "wndr3700:green:power",
55 .gpio
= WNDR3700_GPIO_LED_POWER_GREEN
,
58 .name
= "wndr3700:orange:power",
59 .gpio
= WNDR3700_GPIO_LED_POWER_ORANGE
,
62 .name
= "wndr3700:green:wps",
63 .gpio
= WNDR3700_GPIO_LED_WPS_GREEN
,
66 .name
= "wndr3700:orange:wps",
67 .gpio
= WNDR3700_GPIO_LED_WPS_ORANGE
,
70 .name
= "wndr3700:green:wan",
71 .gpio
= WNDR3700_GPIO_LED_WAN_GREEN
,
76 static struct gpio_keys_button wndr3700_gpio_keys
[] __initdata
= {
81 .debounce_interval
= WNDR3700_KEYS_DEBOUNCE_INTERVAL
,
82 .gpio
= WNDR3700_GPIO_BTN_RESET
,
87 .code
= KEY_WPS_BUTTON
,
88 .debounce_interval
= WNDR3700_KEYS_DEBOUNCE_INTERVAL
,
89 .gpio
= WNDR3700_GPIO_BTN_WPS
,
95 .debounce_interval
= WNDR3700_KEYS_DEBOUNCE_INTERVAL
,
96 .gpio
= WNDR3700_GPIO_BTN_WIFI
,
101 static struct rtl8366_platform_data wndr3700_rtl8366s_data
= {
102 .gpio_sda
= WNDR3700_GPIO_RTL8366_SDA
,
103 .gpio_sck
= WNDR3700_GPIO_RTL8366_SCK
,
106 static struct platform_device wndr3700_rtl8366s_device
= {
107 .name
= RTL8366S_DRIVER_NAME
,
110 .platform_data
= &wndr3700_rtl8366s_data
,
115 * The eth0 and wmac0 interfaces share the same MAC address which
116 * can lead to problems if operated unbridged. Set the locally
117 * administered bit on the eth0 MAC to make it unique.
120 static void __init
wndr3700_init_local_mac(unsigned char *mac_base
)
122 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac_base
, 0);
123 ar71xx_eth0_data
.mac_addr
[0] |= 0x02;
126 static void __init
wndr3700_setup(void)
128 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
130 wndr3700_init_local_mac(art
+ WNDR3700_ETH0_MAC_OFFSET
);
131 ar71xx_eth0_pll_data
.pll_1000
= 0x11110000;
132 ar71xx_eth0_data
.mii_bus_dev
= &wndr3700_rtl8366s_device
.dev
;
133 ar71xx_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
134 ar71xx_eth0_data
.speed
= SPEED_1000
;
135 ar71xx_eth0_data
.duplex
= DUPLEX_FULL
;
137 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
,
138 art
+ WNDR3700_ETH1_MAC_OFFSET
, 0);
139 ar71xx_eth1_pll_data
.pll_1000
= 0x11110000;
140 ar71xx_eth1_data
.mii_bus_dev
= &wndr3700_rtl8366s_device
.dev
;
141 ar71xx_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
142 ar71xx_eth1_data
.phy_mask
= 0x10;
144 ar71xx_add_device_eth(0);
145 ar71xx_add_device_eth(1);
147 ar71xx_add_device_usb();
149 ar71xx_add_device_m25p80(NULL
);
151 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wndr3700_leds_gpio
),
154 ar71xx_register_gpio_keys_polled(-1, WNDR3700_KEYS_POLL_INTERVAL
,
155 ARRAY_SIZE(wndr3700_gpio_keys
),
158 platform_device_register(&wndr3700_rtl8366s_device
);
159 platform_device_register_simple("wndr3700-led-usb", -1, NULL
, 0);
161 ap94_pci_setup_wmac_led_pin(0, 5);
162 ap94_pci_setup_wmac_led_pin(1, 5);
164 /* 2.4 GHz uses the first fixed antenna group (1, 0, 1, 0) */
165 ap94_pci_setup_wmac_gpio(0, (0xf << 6), (0xa << 6));
167 /* 5 GHz uses the second fixed antenna group (0, 1, 1, 0) */
168 ap94_pci_setup_wmac_gpio(1, (0xf << 6), (0x6 << 6));
170 ap94_pci_init(art
+ WNDR3700_CALDATA0_OFFSET
,
171 art
+ WNDR3700_WMAC0_MAC_OFFSET
,
172 art
+ WNDR3700_CALDATA1_OFFSET
,
173 art
+ WNDR3700_WMAC1_MAC_OFFSET
);
176 MIPS_MACHINE(AR71XX_MACH_WNDR3700
, "WNDR3700",
177 "NETGEAR WNDR3700/WNDR3800/WNDRMAC",