[OpenWrt-Devel] [PATCH 3/3] ar71xx: WNR612v2: enable control of all LEDs and buttons
Michal
michal.cieslakiewicz at wp.pl
Sun Feb 21 17:06:30 EST 2016
From: Michal Cieslakiewicz <michal.cieslakiewicz at wp.pl>
Date: Sun, 21 Feb 2016 18:33:11 +0100
Subject: [PATCH 3/3] ar71xx: WNR612v2: enable control of all LEDs and buttons
This patch provides full GPIO support for WNR612v2 (LEDs and buttons).
It exposes all LEDs to operating system, including Ethernet ones.
Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz at wp.pl>
---
Note: This patchset requires two other patchsets applied as it
relies heavily on functionality provided there and modifies
the same files (WNR612v2 is a smaller version of WNR2000v3):
[PATCH v4 1/8] mac80211: ath9k: enable platform WLAN LED name
[PATCH v4 2/8] mac80211: ath9k: set default state for platform LEDs
[PATCH v4 3/8] mac80211: ath9k: show platform MAC address in kernel
[PATCH v4 4/8] mac80211: ath9k: enable access to GPIO
[PATCH v5 5/8] mac80211: ath9k: enable GPIO buttons
([PATCH v5 6/8] ar71xx: WNR2000v3: exclude USB modules from image - in trunk now)
[PATCH v5 7/8] ar71xx: WNR2000v3: fix for random WLAN MAC
[PATCH v5 8/8] ar71xx: WNR2000v3: enable control of all LEDs and buttons
[PATCH 1/4] switch: make port_mask file write handler use kstrtoul()
[PATCH v2 2/4] switch: allow Ethernet port LEDs to show specific port speeds only
[PATCH v2 3/4] uci: add support for speed mask to switch config init scripts
[PATCH 4/4] ar71xx: WNR2000v3: add speed_mask to Ethernet port LED
target/linux/ar71xx/base-files/etc/board.d/01_leds | 7 +++
.../ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c | 69 +++++++++++++++++++++-
2 files changed, 74 insertions(+), 2 deletions(-)
diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index 37ee3d3..6cec5df 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -700,6 +700,13 @@ wnr2000-v4)
ucidef_set_led_usbdev "usb" "USB" "netgear:amber:status" "1-1"
;;
+wnr612-v2)
+ ucidef_set_led_netdev "wan" "WAN" "netgear:green:wan" "eth0"
+ ucidef_set_led_netdev "wlan" "WLAN" "netgear:green:wlan" "wlan0"
+ ucidef_set_led_switch "lan1" "LAN1" "netgear:green:lan1" "switch0" "0x02" "0x0f"
+ ucidef_set_led_switch "lan2" "LAN2" "netgear:green:lan2" "switch0" "0x04" "0x0f"
+ ;;
+
wpn824n)
ucidef_set_led_netdev "wan-amber" "WAN (amber)" "netgear:amber:wan" "eth0"
ucidef_set_led_wlan "wlan" "WLAN" "netgear:blue:wlan" "phy0tpt"
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
index f29086b..13d1285 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wnr2000-v3.c
@@ -49,7 +49,15 @@
#define WNR2000V3_GPIO_WMAC_BTN_RESET 8
#define WNR2000V3_GPIO_WMAC_BTN_RFKILL 9
-#define WNR612V2_GPIO_LED_PWR_GREEN 11
+/* WNR612v2 - connected through AR7241 */
+#define WNR612V2_GPIO_LED_POWER_GREEN 11
+#define WNR612V2_GPIO_LED_LAN1_GREEN 13
+#define WNR612V2_GPIO_LED_LAN2_GREEN 14
+#define WNR612V2_GPIO_LED_WAN_GREEN 17
+
+/* WNR612v2 - connected through AR9285 */
+#define WNR612V2_GPIO_WMAC_LED_WLAN_GREEN 1
+#define WNR612V2_GPIO_WMAC_BTN_RESET 7
#define WNR1000V2_GPIO_LED_PWR_AMBER 1
#define WNR1000V2_GPIO_LED_PWR_GREEN 11
@@ -152,11 +160,25 @@ static const char *wnr2000v3_wmac_led_name = "netgear:blue:wlan";
static struct gpio_led wnr612v2_leds_gpio[] __initdata = {
{
.name = "netgear:green:power",
- .gpio = WNR612V2_GPIO_LED_PWR_GREEN,
+ .gpio = WNR612V2_GPIO_LED_POWER_GREEN,
+ .active_low = 1,
+ }, {
+ .name = "netgear:green:lan1",
+ .gpio = WNR612V2_GPIO_LED_LAN1_GREEN,
+ .active_low = 1,
+ }, {
+ .name = "netgear:green:lan2",
+ .gpio = WNR612V2_GPIO_LED_LAN2_GREEN,
+ .active_low = 1,
+ }, {
+ .name = "netgear:green:wan",
+ .gpio = WNR612V2_GPIO_LED_WAN_GREEN,
.active_low = 1,
}
};
+static const char *wnr612v2_wmac_led_name = "netgear:green:wlan";
+
static struct gpio_led wnr1000v2_leds_gpio[] __initdata = {
{
.name = "netgear:green:power",
@@ -270,6 +292,17 @@ static struct gpio_keys_button wnr2000v3_wmac_keys_gpio[] = {
}
};
+static struct gpio_keys_button wnr612v2_wmac_keys_gpio[] = {
+ {
+ .desc = "reset",
+ .type = EV_KEY,
+ .code = KEY_RESTART,
+ .debounce_interval = WNR2000V3_KEYS_DEBOUNCE_INTERVAL,
+ .gpio = WNR612V2_GPIO_WMAC_BTN_RESET,
+ .active_low = 1,
+ }
+};
+
/*
* For WNR2000v3 ART flash area used for WLAN MAC is usually empty (0xff)
* so ath9k driver uses random MAC instead each time module is loaded.
@@ -375,6 +408,25 @@ static void __init wnr612v2_setup(void)
{
u8 wlan_mac_addr[6];
+ /*
+ * Disable JTAG and CLKs. Allow OS to control all link LEDs.
+ * Note: U-Boot for WNR612v2 sets undocumented bit 15 but
+ * we leave it for now.
+ */
+ ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE |
+ AR724X_GPIO_FUNC_UART_EN,
+ AR724X_GPIO_FUNC_CLK_OBS1_EN |
+ AR724X_GPIO_FUNC_CLK_OBS2_EN |
+ AR724X_GPIO_FUNC_CLK_OBS3_EN |
+ AR724X_GPIO_FUNC_CLK_OBS4_EN |
+ AR724X_GPIO_FUNC_CLK_OBS5_EN |
+ AR724X_GPIO_FUNC_GE0_MII_CLK_EN |
+ AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
+ AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
+ AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
+ AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
+ AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
wnr_get_wmac(wlan_mac_addr, WNR2000V3_MAC0_OFFSET,
WNR2000V3_MAC1_OFFSET, WNR2000V3_WMAC_OFFSET);
@@ -382,6 +434,19 @@ static void __init wnr612v2_setup(void)
ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr612v2_leds_gpio),
wnr612v2_leds_gpio);
+
+ /*
+ * This device has no buttons on AR7241 GPIO and no extra LEDs
+ * connected to AR9285 so setup is simpler than for WNR2000v3.
+ */
+ ap9x_pci_setup_wmac_led_pin(0, WNR612V2_GPIO_WMAC_LED_WLAN_GREEN);
+ ap9x_pci_setup_wmac_led_name(0, wnr612v2_wmac_led_name);
+
+ ap9x_pci_setup_wmac_leds(0, NULL, 0);
+
+ ap9x_pci_setup_wmac_btns(0, wnr612v2_wmac_keys_gpio,
+ ARRAY_SIZE(wnr612v2_wmac_keys_gpio),
+ WNR2000V3_KEYS_POLL_INTERVAL);
}
MIPS_MACHINE(ATH79_MACH_WNR612_V2, "WNR612V2", "NETGEAR WNR612 V2", wnr612v2_setup);
--
2.6.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list