source: trunk/target/linux/ar71xx/base-files/etc/uci-defaults/leds @ 29631

Last change on this file since 29631 was 29631, checked in by juhosg, 4 years ago

ar71xx: define LAN/WAN LEDs for the TL-WR741N/ND boards

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#!/bin/sh
2#
3# Copyright (C) 2011 OpenWrt.org
4#
5
6COMMIT_SYSTEM=0
7
8set_led_netdev() {
9        local cfg="led_$1"
10        local name=$2
11        local sysfs=$3
12        local dev=$4
13
14        uci -q get system.$cfg && return 0
15
16        uci batch <<EOF
17set system.$cfg='led'
18set system.$cfg.name='$name'
19set system.$cfg.sysfs='$sysfs'
20set system.$cfg.trigger='netdev'
21set system.$cfg.dev='$dev'
22set system.$cfg.mode='link tx rx'
23EOF
24        COMMIT_SYSTEM=1
25}
26
27set_led_usbdev() {
28        local cfg="led_$1"
29        local name=$2
30        local sysfs=$3
31        local dev=$4
32
33        uci -q get system.$cfg && return 0
34
35        uci batch <<EOF
36set system.$cfg='led'
37set system.$cfg.name='$name'
38set system.$cfg.sysfs='$sysfs'
39set system.$cfg.trigger='usbdev'
40set system.$cfg.dev='$dev'
41set system.$cfg.interval='50'
42EOF
43        COMMIT_SYSTEM=1
44}
45
46set_led_wlan() {
47        local cfg="led_$1"
48        local name=$2
49        local sysfs=$3
50        local trigger=$4
51
52        uci -q get system.$cfg && return 0
53
54        uci batch <<EOF
55set system.$cfg='led'
56set system.$cfg.name='$name'
57set system.$cfg.sysfs='$sysfs'
58set system.$cfg.trigger='$trigger'
59EOF
60        COMMIT_SYSTEM=1
61}
62
63set_led_switch() {
64        local cfg="led_$1"
65        local name=$2
66        local sysfs=$3
67        local trigger=$4
68        local port_mask=$5
69
70        uci -q get system.$cfg && return 0
71
72        uci batch <<EOF
73set system.$cfg='led'
74set system.$cfg.name='$name'
75set system.$cfg.sysfs='$sysfs'
76set system.$cfg.trigger='$trigger'
77set system.$cfg.port_mask='$port_mask'
78EOF
79        COMMIT_SYSTEM=1
80}
81
82set_led_default() {
83        local cfg="led_$1"
84        local name=$2
85        local sysfs=$3
86        local default=$4
87
88        uci -q get system.$cfg && return 0
89
90        uci batch <<EOF
91set system.$cfg='led'
92set system.$cfg.name='$name'
93set system.$cfg.sysfs='$sysfs'
94set system.$cfg.default='$default'
95EOF
96        COMMIT_SYSTEM=1
97}
98
99. /lib/ar71xx.sh
100
101board=$(ar71xx_board_name)
102
103case "$board" in
104rb750)
105        set_led_default "act" "act" "rb750:green:act" "1"
106        set_led_netdev "port1" "port1" "rb750:green:port1" "eth1"
107        ;;
108
109dir-825-b1)
110        set_led_usbdev "usb" "USB" "dir825b1:blue:usb" "1-1"
111        ;;
112
113hornet-ub)
114        set_led_netdev "lan" "LAN" "alfa:blue:lan" "eth0"
115        set_led_netdev "wan" "WAN" "alfa:blue:wan" "eth1"
116        set_led_wlan "wlan" "WLAN" "alfa:blue:wlan" "phy0tpt"
117        set_led_usbdev "usb" "USB" "alfa:blue:usb" "1-1"
118        ;;
119
120mzk-w04u)
121        set_led_usbdev "usb" "USB" "planex:green:usb" "1-1"
122        ;;
123
124nbg460n_550n_550nh)
125        set_led_wlan "wlan" "WLAN" "nbg460n:green:wlan" "phy0tpt"
126        ;;
127
128om2p)
129        set_led_netdev "port1" "port1" "om2p:blue:wan" "eth0"
130        set_led_netdev "port2" "port2" "om2p:blue:lan" "eth1"
131        ;;
132
133tl-mr3220 | \
134tl-mr3420 )
135        set_led_usbdev "usb" "USB" "tp-link:green:3g" "1-1"
136        ;;
137
138tl-wr741nd)
139        set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
140        set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x02"
141        set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x04"
142        set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x08"
143        set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x10"
144        ;;
145
146tl-wr741nd-v4)
147        set_led_netdev "wan" "WAN" "tp-link:green:wan" "eth1"
148        set_led_switch "lan1" "LAN1" "tp-link:green:lan1" "switch0" "0x04"
149        set_led_switch "lan2" "LAN2" "tp-link:green:lan2" "switch0" "0x08"
150        set_led_switch "lan3" "LAN3" "tp-link:green:lan3" "switch0" "0x10"
151        set_led_switch "lan4" "LAN4" "tp-link:green:lan4" "switch0" "0x02"
152        ;;
153
154tl-wr941nd)
155        set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
156        ;;
157
158tl-wr1043nd)
159        set_led_usbdev "usb" "USB" "tp-link:green:usb" "1-1"
160        set_led_wlan "wlan" "WLAN" "tp-link:green:wlan" "phy0tpt"
161        ;;
162
163wrt160nl)
164        set_led_wlan "wlan" "WLAN" "wrt160nl:blue:wlan" "phy0tpt"
165        ;;
166
167wndr3700)
168        set_led_default "wan" "WAN LED (green)" "wndr3700:green:wan" "0"
169        set_led_usbdev "usb" "USB" "wndr3700:green:usb" "1-1"
170        ;;
171
172wzr-hp-g300nh)
173        set_led_wlan "wlan" "Wireless" "buffalo:green:wireless" "phy0tpt"
174        set_led_netdev "router" "Router" "buffalo:green:router" "eth1"
175        set_led_usbdev "usb" "USB" "buffalo:blue:usb" "1-1"
176        ;;
177
178zcn-1523h-2)
179        set_led_netdev "lan1" "lan1" "zcn-1523h:green:lan1" "eth0"
180        ;;
181
182zcn-1523h-5)
183        set_led_netdev "lan1" "lan1" "zcn-1523h:green:lan1" "eth0"
184        set_led_netdev "lan2" "lan2" "zcn-1523h:green:lan2" "eth1"
185        ;;
186esac
187
188[ "$COMMIT_SYSTEM" == "1" ] && uci commit system
189
190exit 0
Note: See TracBrowser for help on using the repository browser.