Skip to content
Snippets Groups Projects
Commit 0157dcb8 authored by Markus Gothe's avatar Markus Gothe :ok_hand: Committed by Sukru Senli
Browse files

brcm63xx: panther, tigher: button and LED handling updated

parent c791cfa8
Branches
Tags
No related merge requests found
...@@ -17,7 +17,7 @@ config board 'board' ...@@ -17,7 +17,7 @@ config board 'board'
option ethernetPorts '5' option ethernetPorts '5'
option ethernetWanPort 'eth4' option ethernetWanPort 'eth4'
option ethernetPortNames 'LAN1 LAN2 LAN3 LAN4 WAN' option ethernetPortNames 'LAN1 LAN2 LAN3 LAN4 WAN'
option ethernetPortOrder 'eth0 eth1 eth2 eth3 eth4' option ethernetPortOrder 'eth3 eth2 eth1 eth0 eth4'
option ethernetLanPorts 'eth0 eth1 eth2 eth3' option ethernetLanPorts 'eth0 eth1 eth2 eth3'
option gpio_one '67' option gpio_one '67'
option gpio_zero '40 22' option gpio_zero '40 22'
......
config board 'board' config board 'board'
# Spec # Specs
option hasAdsl '0' option hasAdsl '0'
option hasVdsl '0' option hasVdsl '0'
option hasEthWan '0' option hasEthWan '0'
option hasVoice '0' option hasVoice '0'
option hasDect '0' option hasDect '0'
option hasUsb '0' option hasUsb '1'
option VoicePorts '0'
option VoiceLeds '0'
option hasWifi '0' option hasWifi '0'
option hasSfp '1' option hasSfp '1'
# SFP
option sfpBus '/dev/i2c-0'
# Voice # Voice
option VoicePorts '0' option VoicePorts '0'
# SFP
option sfpBus '/dev/i2c-0'
# Ethernet # Ethernet
option ethernetPorts '5' option ethernetPorts '5'
option ethernetWanPort 'eth4' option ethernetWanPort 'eth4'
option ethernetPortNames 'LAN1 LAN2 LAN3 LAN4 WAN' option ethernetPortNames 'LAN1 LAN2 LAN3 LAN4 WAN'
option ethernetPortOrder 'eth0 eth1 eth2 eth3 eth4' option ethernetPortOrder 'eth0 eth1 eth2 eth3 eth4'
option ethernetLanPorts 'eth0 eth1 eth2 eth3' option ethernetLanPorts 'eth0 eth1 eth2 eth3'
###############################################################################
# Button config, start
############### gpio buttons, driver config
config gpio_button gpio_buttons
list buttons gpio_reset
config gpio_button gpio_reset
option addr 54
option active low
############### mapping function button to driver button
config button RESET
list button gpio_reset
option minpress 5000
option hotplug resetbutton
###############################################################################
# Led config, start
#
config gpio_led gpio_leds
list leds wan_yellow
list leds wan_green
list leds usb_green
list leds power_on_green
list leds alarm_red
list leds lan1_green
list leds lan1_yellow
list leds lan2_green
list leds lan2_yellow
list leds lan3_green
list leds lan3_yellow
list leds lan4_yellow
list leds lan4_green
config gpio_led wan_yellow
option active high
option sysfs_attr 2s
option mode led_linux
config gpio_led wan_green
option active high
option sysfs_attr 8s
option mode led_linux
config gpio_led power_on_green
option active high
option sysfs_attr 11s
option mode led_linux
config gpio_led alarm_red
option active high
option sysfs_attr 5s
option mode led_linux
config gpio_led lan1_yellow
option active high
option sysfs_attr 1s
option mode led_linux
config gpio_led lan1_green
option active high
option sysfs_attr 0s
option mode led_linux
config gpio_led lan2_yellow
option active high
option sysfs_attr 4s
option mode led_linux
config gpio_led lan2_green
option active high
option sysfs_attr 3s
option mode led_linux
config gpio_led lan3_yellow
option active high
option sysfs_attr 7s
option mode led_linux
config gpio_led lan3_green
option active high
option sysfs_attr 6s
option mode led_linux
config gpio_led lan4_green
option active high
option sysfs_attr 12s
option mode led_linux
config gpio_led lan4_yellow
option active high
option sysfs_attr 13s
option mode led_linux
config gpio_led usb_green
option active high
option sysfs_attr 15s
option mode led_linux
############### mapping led function to driver led
config led_map led_map
list functions status
list functions usb
list functions wan_speed
list functions lan
config led_map led_status
list led_action_ok 'power_on_green = ON'
list led_action_ok 'alarm_red = OFF'
list led_action_off 'power_on_green = OFF'
list led_action_off 'alarm_red = OFF'
list led_action_notice 'power_on_green = FLASH_SLOW'
list led_action_notice 'alarm_red = FLASH_SLOW'
list led_action_alert 'power_on_green = OFF'
list led_action_alert 'alarm_red = FLASH_SLOW'
list led_action_error 'power_on_green = OFF'
list led_action_error 'alarm_red = FLASH_FAST'
config led_map led_usb
list led_action_ok usb_green=ON
list led_action_off usb_green=OFF
list led_action_notice usb_green=FLASH_SLOW
list led_action_alert usb_green=FLASH_SLOW
list led_action_error usb_green=FLASH_FAST
config led_map led_wan_speed
list led_action_ok wan_green=ON
list led_action_ok wan_yellow=OFF
list led_action_off wan_green=OFF
list led_action_off wan_yellow=OFF
list led_action_notice wan_green=OFF
list led_action_notice wan_yellow=ON
config led_map led_lan
list led_action_ok lan1_green=ON
list led_action_ok lan1_yellow=ON
list led_action_ok lan2_green=ON
list led_action_ok lan2_yellow=ON
list led_action_ok lan3_green=ON
list led_action_ok lan3_yellow=ON
list led_action_ok lan4_green=ON
list led_action_ok lan4_yellow=ON
list led_action_off lan1_green=OFF
list led_action_off lan1_yellow=OFF
list led_action_off lan2_green=OFF
list led_action_off lan2_yellow=OFF
list led_action_off lan3_green=OFF
list led_action_off lan3_yellow=OFF
list led_action_off lan4_green=OFF
list led_action_off lan4_yellow=OFF
#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
need_to_sync_dimming_states() {
local current_brightness
local previous_brightness
local state_changed=0
json_load "$(ubus call led.status status)"
json_get_var previous_brightness brightness
for led in $(ubus list led.*); do
json_load "$(ubus call "$led" status)"
json_get_var current_brightness brightness
if [ "$current_brightness" != "$previous_brightness" ]; then
state_changed=1
break
fi
previous_brightness="$current_brightness"
done
return $((state_changed))
}
dimming_button() {
local brightness
local current_brightness
local ledname
local needs_sync=0
[ -f /etc/config/leds ] || touch /etc/config/leds
need_to_sync_dimming_states
needs_sync="$?"
if [ "$needs_sync" != "0" ]; then
for led in $(ubus list led.*); do
ubus call "$led" set "{\"brightness\":0}"
done
fi
for led in $(ubus list led.*); do
brightness=100
current_brightness=100
ledname=${led:4}
json_load "$(ubus call "$led" status)"
json_get_var current_brightness brightness
if [ "$current_brightness" -ge 100 ]; then
brightness=75
elif [ "$current_brightness" -ge 75 ]; then # Slightly dimmed
brightness=15
elif [ "$current_brightness" -ge 15 ]; then # Significantly dimmed
brightness=0
case $ledname in
status) brightness=15 ;;
esac
else
brightness=100
fi
ubus call "$led" set "{\"brightness\":$brightness}"
uci set leds.$ledname.brightness="$brightness"
done
uci commit leds
}
case "$ACTION" in
add|register)
[ "dimmingbutton" == "$INTERFACE" ] && {
printf "\n\nDimming button is pressed\n\n" > /dev/console
dimming_button
}
;;
remove|unregister)
;;
esac
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
START=9 START=8
boot() { boot() {
# steady status led to indicate boot process is complete
ubus call led.status set '{"state":"ok"}' 2>/dev/null
echo "All init.d scripts started." | tee /dev/console
# Cold plug trigger - USB LED etc.. # Cold plug trigger - USB LED etc..
udevtrigger udevtrigger
} }
#!/bin/sh
readonly BASENAME="$(basename "$DEVPATH")"
[ "${BASENAME:0:3}" = "usb" -a "$ACTION" = "add" ] && exit 0
[ "${BASENAME:0:3}" = "usb" ] && ACTION="notice" # A root-hub disappeared, this SHOULD NOT happen!
case "$ACTION" in
add)
ubus call led.usb set '{ "state": "ok" }'
;;
notice)
ubus call led.usb set '{ "state": "notice" }'
;;
*)
ubus call led.usb set '{ "state": "off" }'
;;
esac
#!/bin/sh /etc/rc.common
START=8
boot() {
# Cold plug trigger - USB LED etc..
udevtrigger
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment