2 * NETGEAR WNDR3700v4/WNDR4300 board support
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2014 Ralph Perlich <rpsoft@arcor.de>
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/pci.h>
13 #include <linux/phy.h>
14 #include <linux/gpio.h>
15 #include <linux/platform_device.h>
16 #include <linux/ath9k_platform.h>
17 #include <linux/ar8216_platform.h>
18 #include <linux/mtd/mtd.h>
19 #include <linux/mtd/nand.h>
20 #include <linux/platform/ar934x_nfc.h>
22 #include <asm/mach-ath79/ar71xx_regs.h>
25 #include "dev-ap9x-pci.h"
27 #include "dev-gpio-buttons.h"
28 #include "dev-leds-gpio.h"
32 #include "machtypes.h"
35 #define WNDR4300_GPIO_LED_POWER_GREEN 0
36 #define WNDR4300_GPIO_LED_POWER_AMBER 2
37 #define WNDR4300_GPIO_LED_USB 13
38 #define WNDR4300_GPIO_LED_WAN_GREEN 1
39 #define WNDR4300_GPIO_LED_WAN_AMBER 3
40 #define WNDR4300_GPIO_LED_WLAN2G 11
41 #define WNDR4300_GPIO_LED_WLAN5G 14
42 #define WNDR4300_GPIO_LED_WPS_GREEN 16
43 #define WNDR4300_GPIO_LED_WPS_AMBER 17
45 #define WNDR4300_GPIO_BTN_RESET 21
46 #define WNDR4300_GPIO_BTN_WIRELESS 15
47 #define WNDR4300_GPIO_BTN_WPS 12
50 #define WNDR4300_GPIO_USB_5V 0
52 #define WNDR4300_KEYS_POLL_INTERVAL 20 /* msecs */
53 #define WNDR4300_KEYS_DEBOUNCE_INTERVAL (3 * WNDR4300_KEYS_POLL_INTERVAL)
55 static struct gpio_led wndr4300_leds_gpio
[] __initdata
= {
57 .name
= "netgear:green:power",
58 .gpio
= WNDR4300_GPIO_LED_POWER_GREEN
,
62 .name
= "netgear:amber:power",
63 .gpio
= WNDR4300_GPIO_LED_POWER_AMBER
,
67 .name
= "netgear:green:wan",
68 .gpio
= WNDR4300_GPIO_LED_WAN_GREEN
,
72 .name
= "netgear:amber:wan",
73 .gpio
= WNDR4300_GPIO_LED_WAN_AMBER
,
77 .name
= "netgear:green:usb",
78 .gpio
= WNDR4300_GPIO_LED_USB
,
82 .name
= "netgear:green:wps",
83 .gpio
= WNDR4300_GPIO_LED_WPS_GREEN
,
87 .name
= "netgear:amber:wps",
88 .gpio
= WNDR4300_GPIO_LED_WPS_AMBER
,
92 .name
= "netgear:green:wlan2g",
93 .gpio
= WNDR4300_GPIO_LED_WLAN2G
,
97 .name
= "netgear:blue:wlan5g",
98 .gpio
= WNDR4300_GPIO_LED_WLAN5G
,
103 static struct gpio_keys_button wndr4300_gpio_keys
[] __initdata
= {
105 .desc
= "Reset button",
108 .debounce_interval
= WNDR4300_KEYS_DEBOUNCE_INTERVAL
,
109 .gpio
= WNDR4300_GPIO_BTN_RESET
,
113 .desc
= "WPS button",
115 .code
= KEY_WPS_BUTTON
,
116 .debounce_interval
= WNDR4300_KEYS_DEBOUNCE_INTERVAL
,
117 .gpio
= WNDR4300_GPIO_BTN_WPS
,
121 .desc
= "Wireless button",
124 .debounce_interval
= WNDR4300_KEYS_DEBOUNCE_INTERVAL
,
125 .gpio
= WNDR4300_GPIO_BTN_WIRELESS
,
130 static struct ar8327_pad_cfg wndr4300_ar8327_pad0_cfg
= {
131 .mode
= AR8327_PAD_MAC_RGMII
,
132 .txclk_delay_en
= true,
133 .rxclk_delay_en
= true,
134 .txclk_delay_sel
= AR8327_CLK_DELAY_SEL1
,
135 .rxclk_delay_sel
= AR8327_CLK_DELAY_SEL2
,
138 static struct ar8327_led_cfg wndr4300_ar8327_led_cfg
= {
139 .led_ctrl0
= 0xc737c737,
140 .led_ctrl1
= 0x00000000,
141 .led_ctrl2
= 0x00000000,
142 .led_ctrl3
= 0x0030c300,
146 static struct ar8327_platform_data wndr4300_ar8327_data
= {
147 .pad0_cfg
= &wndr4300_ar8327_pad0_cfg
,
150 .speed
= AR8327_PORT_SPEED_1000
,
155 .led_cfg
= &wndr4300_ar8327_led_cfg
,
158 static struct mdio_board_info wndr4300_mdio0_info
[] = {
160 .bus_id
= "ag71xx-mdio.0",
162 .platform_data
= &wndr4300_ar8327_data
,
166 static void __init
wndr4300_setup(void)
170 for (i
= 0; i
< ARRAY_SIZE(wndr4300_leds_gpio
); i
++)
171 ath79_gpio_output_select(wndr4300_leds_gpio
[i
].gpio
,
172 AR934X_GPIO_OUT_GPIO
);
174 ath79_register_leds_gpio(-1, ARRAY_SIZE(wndr4300_leds_gpio
),
176 ath79_register_gpio_keys_polled(-1, WNDR4300_KEYS_POLL_INTERVAL
,
177 ARRAY_SIZE(wndr4300_gpio_keys
),
180 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0
);
182 mdiobus_register_board_info(wndr4300_mdio0_info
,
183 ARRAY_SIZE(wndr4300_mdio0_info
));
185 ath79_register_mdio(0, 0x0);
187 /* GMAC0 is connected to an AR8327N switch */
188 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
189 ath79_eth0_data
.phy_mask
= BIT(0);
190 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
191 ath79_eth0_pll_data
.pll_1000
= 0x06000000;
192 ath79_register_eth(0);
194 ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW
);
195 ath79_register_nfc();
196 ath79_register_usb();
198 ath79_register_wmac_simple();
200 /* enable power for the USB port */
201 ap9x_pci_setup_wmac_gpio(0, BIT(WNDR4300_GPIO_USB_5V
),
202 BIT(WNDR4300_GPIO_USB_5V
));
204 ap91_pci_init_simple();
207 MIPS_MACHINE(ATH79_MACH_WNDR4300
, "WNDR4300", "NETGEAR WNDR3700v4/WNDR4300",