ar71xx: define LAN/WAN LEDs for the TL-WR741N/ND boards
authorGabor Juhos <juhosg@openwrt.org>
Sat, 31 Dec 2011 15:02:46 +0000 (15:02 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Sat, 31 Dec 2011 15:02:46 +0000 (15:02 +0000)
SVN-Revision: 29631

target/linux/ar71xx/base-files/etc/uci-defaults/leds
target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr741nd-v4.c
target/linux/ar71xx/files/arch/mips/ar71xx/mach-tl-wr741nd.c

index 88538f84f263d3cad6c27f76a78835ad22b59328..0fdab7b2a4c9cad66d0ec501a6ce692d30500375 100755 (executable)
@@ -60,6 +60,25 @@ EOF
        COMMIT_SYSTEM=1
 }
 
+set_led_switch() {
+       local cfg="led_$1"
+       local name=$2
+       local sysfs=$3
+       local trigger=$4
+       local port_mask=$5
+
+       uci -q get system.$cfg && return 0
+
+       uci batch <<EOF
+set system.$cfg='led'
+set system.$cfg.name='$name'
+set system.$cfg.sysfs='$sysfs'
+set system.$cfg.trigger='$trigger'
+set system.$cfg.port_mask='$port_mask'
+EOF
+       COMMIT_SYSTEM=1
+}
+
 set_led_default() {
        local cfg="led_$1"
        local name=$2
@@ -116,7 +135,22 @@ tl-mr3420 )
        set_led_usbdev "usb" "USB" "tp-link:green:3g" "1-1"
        ;;
 
-tl-wr741nd-v4 | \
+tl-wr741nd)
+       set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
+       set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x02"
+       set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x04"
+       set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x08"
+       set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x10"
+       ;;
+
+tl-wr741nd-v4)
+       set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
+       set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x04"
+       set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x08"
+       set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x10"
+       set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x02"
+       ;;
+
 tl-wr941nd)
        set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
        ;;
index 47fbf85e75ceb0738c7bde68a924bcb4e684887c..8af72320cbd67bc4dcc93827b7bf06a07a71768a 100644 (file)
 
 #define TL_WR741NDV4_GPIO_LED_WLAN     0
 #define TL_WR741NDV4_GPIO_LED_QSS      1
+#define TL_WR741NDV4_GPIO_LED_WAN      13
+#define TL_WR741NDV4_GPIO_LED_LAN1     14
+#define TL_WR741NDV4_GPIO_LED_LAN2     15
+#define TL_WR741NDV4_GPIO_LED_LAN3     16
+#define TL_WR741NDV4_GPIO_LED_LAN4     17
+
 #define TL_WR741NDV4_GPIO_LED_SYSTEM   27
 
 #define TL_WR741NDV4_KEYS_POLL_INTERVAL        20      /* msecs */
@@ -40,13 +46,33 @@ static struct flash_platform_data tl_wr741ndv4_flash_data = {
 
 static struct gpio_led tl_wr741ndv4_leds_gpio[] __initdata = {
        {
-               .name           = "tp-link:green:system",
-               .gpio           = TL_WR741NDV4_GPIO_LED_SYSTEM,
+               .name           = "tp-link:green:lan1",
+               .gpio           = TL_WR741NDV4_GPIO_LED_LAN1,
+               .active_low     = 0,
+       }, {
+               .name           = "tp-link:green:lan2",
+               .gpio           = TL_WR741NDV4_GPIO_LED_LAN2,
+               .active_low     = 0,
+       }, {
+               .name           = "tp-link:green:lan3",
+               .gpio           = TL_WR741NDV4_GPIO_LED_LAN3,
+               .active_low     = 0,
+       }, {
+               .name           = "tp-link:green:lan4",
+               .gpio           = TL_WR741NDV4_GPIO_LED_LAN4,
                .active_low     = 1,
        }, {
                .name           = "tp-link:green:qss",
                .gpio           = TL_WR741NDV4_GPIO_LED_QSS,
                .active_low     = 0,
+       }, {
+               .name           = "tp-link:green:system",
+               .gpio           = TL_WR741NDV4_GPIO_LED_SYSTEM,
+               .active_low     = 1,
+       }, {
+               .name           = "tp-link:green:wan",
+               .gpio           = TL_WR741NDV4_GPIO_LED_WAN,
+               .active_low     = 0,
        }, {
                .name           = "tp-link:green:wlan",
                .gpio           = TL_WR741NDV4_GPIO_LED_WLAN,
@@ -93,6 +119,12 @@ static void __init tl_wr741ndv4_setup(void)
 
        tl_wr741ndv4_gmac_setup();
 
+       ar71xx_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
+                                    AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
+                                    AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
+                                    AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
+                                    AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
+
        ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr741ndv4_leds_gpio),
                                        tl_wr741ndv4_leds_gpio);
 
index b29c7aa9d4cde37c6c1c508ec1664f5428c6decf..f877e9882288e744ed70b3483ec0b0879298e14f 100644 (file)
 
 #define TL_WR741ND_GPIO_LED_QSS                0
 #define TL_WR741ND_GPIO_LED_SYSTEM     1
+#define TL_WR741ND_GPIO_LED_LAN1       13
+#define TL_WR741ND_GPIO_LED_LAN2       14
+#define TL_WR741ND_GPIO_LED_LAN3       15
+#define TL_WR741ND_GPIO_LED_LAN4       16
+#define TL_WR741ND_GPIO_LED_WAN                17
 
 #define TL_WR741ND_GPIO_BTN_RESET      11
 #define TL_WR741ND_GPIO_BTN_QSS                12
@@ -37,14 +42,34 @@ static struct flash_platform_data tl_wr741nd_flash_data = {
 
 static struct gpio_led tl_wr741nd_leds_gpio[] __initdata = {
        {
-               .name           = "tp-link:green:system",
-               .gpio           = TL_WR741ND_GPIO_LED_SYSTEM,
+               .name           = "tp-link:green:lan1",
+               .gpio           = TL_WR741ND_GPIO_LED_LAN1,
+               .active_low     = 1,
+       }, {
+               .name           = "tp-link:green:lan2",
+               .gpio           = TL_WR741ND_GPIO_LED_LAN2,
+               .active_low     = 1,
+       }, {
+               .name           = "tp-link:green:lan3",
+               .gpio           = TL_WR741ND_GPIO_LED_LAN3,
+               .active_low     = 1,
+       }, {
+               .name           = "tp-link:green:lan4",
+               .gpio           = TL_WR741ND_GPIO_LED_LAN4,
                .active_low     = 1,
        }, {
                .name           = "tp-link:green:qss",
                .gpio           = TL_WR741ND_GPIO_LED_QSS,
                .active_low     = 1,
-       }
+       }, {
+               .name           = "tp-link:green:system",
+               .gpio           = TL_WR741ND_GPIO_LED_SYSTEM,
+               .active_low     = 1,
+       }, {
+               .name           = "tp-link:green:wan",
+               .gpio           = TL_WR741ND_GPIO_LED_WAN,
+               .active_low     = 1,
+       },
 };
 
 static struct gpio_keys_button tl_wr741nd_gpio_keys[] __initdata = {
@@ -72,6 +97,12 @@ static void __init tl_wr741nd_setup(void)
 
        ar71xx_add_device_m25p80(&tl_wr741nd_flash_data);
 
+       ar71xx_gpio_function_disable(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);
+
        ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_wr741nd_leds_gpio),
                                        tl_wr741nd_leds_gpio);