-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi OpenWrt team,
attached is a patch to add GPIO LED support for LinkSys WRT350Nv2. This is a backport of a kernel patch that is already send to be included in the upstream kernel. The patch and the scripts have been tested for several weeks now. Please apply to trunk. Adds GPIO LED support for the missing LEDs on LinkSys WRT350Nv2. Signed-off by: Matthias Buecher <m...@maddes.net> and Dirk Teurlings <i...@upexia.nl> -----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkuIYMIACgkQUXXT+9wZdbX3MwCfUdYRTR4A5H0anMIO9KBfGyb1 Nk0An3RoZICxCypqoHryOzhAZGquse/s =WaaS -----END PGP SIGNATURE-----
Index: target/linux/orion/config-default =================================================================== --- target/linux/orion/config-default (revision 19876) +++ target/linux/orion/config-default (working copy) @@ -59,6 +59,8 @@ # CONFIG_GENERIC_FIND_FIRST_BIT is not set # CONFIG_GENERIC_FIND_NEXT_BIT is not set CONFIG_GENERIC_GPIO=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y # CONFIG_HAMRADIO is not set CONFIG_HARDIRQS_SW_RESEND=y CONFIG_HAS_DMA=y @@ -115,6 +117,7 @@ # CONFIG_IWLWIFI_LEDS is not set # CONFIG_LANMEDIA is not set # CONFIG_LATENCYTOP is not set +CONFIG_LEDS_GPIO=y CONFIG_LEGACY_PTY_COUNT=256 CONFIG_LEGACY_PTYS=y # CONFIG_LLC2 is not set Index: target/linux/orion/patches/150-wrt350nv2_gpio_leds_buttons.patch =================================================================== --- target/linux/orion/patches/150-wrt350nv2_gpio_leds_buttons.patch (revision 0) +++ target/linux/orion/patches/150-wrt350nv2_gpio_leds_buttons.patch (revision 0) @@ -0,0 +1,102 @@ +--- a/arch/arm/mach-orion5x/wrt350n-v2-setup.c 2009-12-08 02:39:46.000000000 +0100 ++++ b/arch/arm/mach-orion5x/wrt350n-v2-setup.c 2010-01-13 15:25:17.000000000 +0100 +@@ -15,6 +15,9 @@ + #include <linux/mtd/physmap.h> + #include <linux/mv643xx_eth.h> + #include <linux/ethtool.h> ++#include <linux/leds.h> ++#include <linux/gpio_keys.h> ++#include <linux/input.h> + #include <net/dsa.h> + #include <asm/mach-types.h> + #include <asm/gpio.h> +@@ -24,6 +27,80 @@ + #include "common.h" + #include "mpp.h" + ++/* ++ * LEDs attached to GPIO ++ */ ++static struct gpio_led wrt350n_v2_led_pins[] = { ++ { ++ .name = "wrt350nv2:green:power", ++ .gpio = 0, ++ .active_low = 1, ++ }, { ++ .name = "wrt350nv2:green:security", ++ .gpio = 1, ++ .active_low = 1, ++ }, { ++ .name = "wrt350nv2:orange:power", ++ .gpio = 5, ++ .active_low = 1, ++ }, { ++ .name = "wrt350nv2:green:usb", ++ .gpio = 6, ++ .active_low = 1, ++ }, { ++ .name = "wrt350nv2:green:wireless", ++ .gpio = 7, ++ .active_low = 1, ++ }, ++}; ++ ++static struct gpio_led_platform_data wrt350n_v2_led_data = { ++ .leds = wrt350n_v2_led_pins, ++ .num_leds = ARRAY_SIZE(wrt350n_v2_led_pins), ++}; ++ ++static struct platform_device wrt350n_v2_leds = { ++ .name = "leds-gpio", ++ .id = -1, ++ .dev = { ++ .platform_data = &wrt350n_v2_led_data, ++ }, ++}; ++ ++/* ++ * Buttons attached to GPIO ++ */ ++static struct gpio_keys_button wrt350n_v2_buttons[] = { ++ { ++ .code = KEY_RESTART, ++ .gpio = 3, ++ .desc = "Reset Button", ++ .active_low = 1, ++ }, { ++ .code = KEY_WLAN, ++ .gpio = 2, ++ .desc = "WPS Button", ++ .active_low = 1, ++ }, ++}; ++ ++static struct gpio_keys_platform_data wrt350n_v2_button_data = { ++ .buttons = wrt350n_v2_buttons, ++ .nbuttons = ARRAY_SIZE(wrt350n_v2_buttons), ++}; ++ ++static struct platform_device wrt350n_v2_button_device = { ++ .name = "gpio-keys", ++ .id = -1, ++ .num_resources = 0, ++ .dev = { ++ .platform_data = &wrt350n_v2_button_data, ++ }, ++}; ++ ++/* ++ * General setup ++ */ + static struct orion5x_mpp_mode wrt350n_v2_mpp_modes[] __initdata = { + { 0, MPP_GPIO }, /* Power LED green (0=on) */ + { 1, MPP_GPIO }, /* Security LED (0=on) */ +@@ -148,6 +225,8 @@ + orion5x_setup_dev_boot_win(WRT350N_V2_NOR_BOOT_BASE, + WRT350N_V2_NOR_BOOT_SIZE); + platform_device_register(&wrt350n_v2_nor_flash); ++ platform_device_register(&wrt350n_v2_button_device); ++ platform_device_register(&wrt350n_v2_leds); + } + + static int __init wrt350n_v2_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) Index: target/linux/orion/base-files/etc/hotplug.d/usb/10-usb =================================================================== --- target/linux/orion/base-files/etc/hotplug.d/usb/10-usb (revision 0) +++ target/linux/orion/base-files/etc/hotplug.d/usb/10-usb (revision 0) @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Copyright (C) 2009-2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +usb_led='' +usb_device='' + +led_set_attr() { + [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2" +} + +usb_led_set_timer() { + led_set_attr "${usb_led}" 'trigger' 'timer' + led_set_attr "${usb_led}" 'delay_on' "$1" + led_set_attr "${usb_led}" 'delay_off' "$2" +} + +usb_led_on() { + led_set_attr "${usb_led}" 'trigger' 'none' + led_set_attr "${usb_led}" 'brightness' 255 +} + +usb_led_off() { + led_set_attr "${usb_led}" 'trigger' 'none' + led_set_attr "${usb_led}" 'brightness' 0 +} + +get_usb_led() { + local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo` + + case "${hardware}" in + 'Linksys WRT350N v2') + usb_led='wrt350nv2:green:usb' + usb_device='1-1:1.0' + ;; + esac; +} + +get_usb_led + +case "${ACTION}" in + add) + # update LEDs + [ "${usb_device}" = "${DEVICENAME}" ] && usb_led_on + ;; + remove) + # update LEDs + [ "${usb_device}" = "${DEVICENAME}" ] && usb_led_off + ;; +esac Index: target/linux/orion/base-files/etc/uci-defaults/hardware =================================================================== --- target/linux/orion/base-files/etc/uci-defaults/hardware (revision 0) +++ target/linux/orion/base-files/etc/uci-defaults/hardware (revision 0) @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Copyright (C) 2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# +# This script sets system defaults for the hardware on firstboot +# + +local hardware=`sed -n /Hardware/s/.*:.//p /proc/cpuinfo` + +wrt350nv2_default() { +# leds + uci batch <<__EOF +set system.power_led=led +set system.power_led.name='Power LED (green)' +set system.power_led.sysfs='wrt350nv2:green:power' +set system.power_led.default='1' +set system.wifi_led=led +set system.wifi_led.name='Wireless LED (green)' +set system.wifi_led.sysfs='wrt350nv2:green:wireless' +set system.wifi_led.trigger='netdev' +set system.wifi_led.dev='wlan0' +set system.wifi_led.mode='link tx rx' +set system.wifi_led.default='0' +commit system +__EOF +} + +case "${hardware}" in + 'Linksys WRT350N v2') + wrt350nv2_default + ;; +esac
-----BEGIN PGP SIGNATURE----- Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEABECAAYFAkuIYMMACgkQUXXT+9wZdbULPACgmlWhLP13WnYudYq/meLeYLKO iVsAn1WVQEyFLchaOTPzt27KygbbX9VA =EqYn -----END PGP SIGNATURE-----
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel