90d3e73378e1e6cb32c4a78903e3ffbd257754e6
[openwrt.git] / target / linux / brcm63xx / base-files / lib / brcm63xx.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2007 OpenWrt.org
4 #
5 #
6
7 board_id=""
8 sys_mtd_part=""
9 ifname=""
10
11 brcm63xx_dt_detect() {
12         local board_name
13
14         case "$1" in
15         "ADB P.DG A4001N")
16                 board_name="a4001n"
17                 ;;
18         "ADB P.DG A4001N1")
19                 board_name="a4001n1"
20                 ;;
21         "Alcatel RG100A")
22                 board_name="rg100a"
23                 ;;
24         "ASMAX AR 1004g")
25                 board_name="ar100g"
26                 ;;
27         "Belkin F5D7633")
28                 board_name="f5d7633"
29                 ;;
30         "Broadcom 96348R reference board")
31                 board_name="bcm96348r"
32                 ;;
33         "Broadcom BCM963268BU_P300 reference board")
34                 board_name="bcm963268bu_p300"
35                 ;;
36         "Broadcom bcm963281TAN reference board")
37                 board_name="bcm963281tan"
38                 ;;
39         "Broadcom BCM96328avng reference board")
40                 board_name="bcm96328avng"
41                 ;;
42         "Broadcom BCM96345GW2 reference board")
43                 board_name="bcm96345gw2"
44                 ;;
45         "Broadcom BCM96348GW-10 reference board")
46                 board_name="bcm96348gw-10"
47                 ;;
48         "Broadcom BCM96348GW-11 reference board")
49                 board_name="bcm96348gw-11"
50                 ;;
51         "Broadcom BCM96348GW reference board")
52                 board_name="bcm96358gw"
53                 ;;
54         "Broadcom BCM96358VW reference board")
55                 board_name="bcm96358vw"
56                 ;;
57         "Broadcom BCM96358VW2 reference board")
58                 board_name="bcm96358vw2"
59                 ;;
60         "Broadcom BCM96368MVNgr reference board")
61                 board_name="bcm96368mvngr"
62                 ;;
63         "Broadcom BCM96368MVWG reference board")
64                 board_name="bcm96368mvwg"
65                 ;;
66         "BT Home Hub 2.0 Type A")
67                 board_name="homehub2a"
68                 ;;
69         "BT Voyager V2500V")
70                 board_name="v2500v_bb"
71                 ;;
72         "Comtrend AR-5381u")
73                 board_name="ar-5381u"
74                 ;;
75         "Comtrend AR-5387un")
76                 board_name="ar-5387un"
77                 ;;
78         "Comtrend CT-5365")
79                 board_name="ct-5365"
80                 ;;
81         "Comtrend CT-536+/CT-5621T")
82                 board_name="ct-536p_5621t"
83                 ;;
84         "Comtrend CT-6373")
85                 board_name="ct-6373"
86                 ;;
87         "Comtrend VR-3025u")
88                 board_name="vr-3025u"
89                 ;;
90         "Comtrend VR-3025un")
91                 board_name="vr-3025un"
92                 ;;
93         "Comtrend WAP-5813n")
94                 board_name="wap-5813n"
95                 ;;
96         "Davolink DV-201AMR")
97                 board_name="dv-201amr"
98                 ;;
99         "D-Link DSL-2640B rev B2")
100                 board_name="dsl-2640b-b"
101                 ;;
102         "D-Link DSL-2640U/BRU/C")
103                 board_name="dsl-2640u"
104                 ;;
105         "D-Link DSL-2650U")
106                 board_name="dsl-2650u"
107                 ;;
108         "D-Link DSL-2740B/DSL-2741B rev C2/3")
109                 board_name="dsl-274xb-c"
110                 ;;
111         "D-Link DSL-2740B/DSL-2741B rev F1")
112                 board_name="dsl-274xb-f"
113                 ;;
114         "D-Link DVA-G3810BN/TL")
115                 board_name="dva-g3810bn"
116                 ;;
117         "Dynalink RTA770BW")
118                 board_name="rta770bw"
119                 ;;
120         "Dynalink RTA770W")
121                 board_name="rta770w"
122                 ;;
123         "Dynalink RTA1025W")
124                 board_name="rta1025w"
125                 ;;
126         "Dynalink RTA1320")
127                 board_name="rta1320"
128                 ;;
129         "Huawei EchoLife HG520v")
130                 board_name="hg520v"
131                 ;;
132         "Huawei EchoLife HG553")
133                 board_name="hg553"
134                 ;;
135         "Huawei EchoLife HG556a (version A)")
136                 board_name="hg556a_a"
137                 ;;
138         "Huawei EchoLife HG556a (version B)")
139                 board_name="hg556a_b"
140                 ;;
141         "Huawei EchoLife HG556a (version C)")
142                 board_name="hg556a_c"
143                 ;;
144         "Inventel Livebox 1")
145                 board_name="livebox1"
146                 ;;
147         "Netgear CVG834G")
148                 board_name="cvg834g"
149                 ;;
150         "Netgear DG834GT/PN")
151                 board_name="dg834gt"
152                 ;;
153         "Netgear DG834G v4")
154                 board_name="dg834g_v4"
155                 ;;
156         "Netgear DGND3700v1/DGND3800B")
157                 board_name="dgnd3700v1_dgnd3800b"
158                 ;;
159         "Pirelli A226G")
160                 board_name="a226g"
161                 ;;
162         "Pirelli A226M")
163                 board_name="a226m"
164                 ;;
165         "Pirelli A226M-FWB")
166                 board_name="a226m-fwb"
167                 ;;
168         "Pirelli Alice Gate AGPF-S0")
169                 board_name="agpf-s0"
170                 ;;
171         "Sagem F@ST2404")
172                 board_name="fast2404"
173                 ;;
174         "Sagem F@ST2504n")
175                 board_name="fast2504n"
176                 ;;
177         "Sagem F@ST2604")
178                 board_name="fast2604"
179                 ;;
180         "Sagem F@ST2704V2")
181                 board_name="fast2704v2"
182                 ;;
183         "SFR Neuf Box 4"*)
184                 board_name="neufbox4"
185                 ;;
186         "SFR neufbox 6 (Sercomm)")
187                 board_name="neufbox6"
188                 ;;
189         "T-Com Speedport W303 V")
190                 board_name="spw303v"
191                 ;;
192         "T-Com Speedport W500 V")
193                 board_name="spw500v"
194                 ;;
195         "TECOM GW6000")
196                 board_name="g6000"
197                 ;;
198         "TECOM GW6200")
199                 board_name="g6200"
200                 ;;
201         "Telsey CVPA502+")
202                 board_name="cpva502p"
203                 ;;
204         "Telsey CPVA642-type (CPA-ZNTE60T)")
205                 board_name="cpva642"
206                 ;;
207         "Telsey MAGIC")
208                 board_name="magic"
209                 ;;
210         "TP-Link TD-W8900GB")
211                 board_name="td-w8900gb"
212                 ;;
213         "USRobotics 9108")
214                 board_name="usr9108"
215                 ;;
216         "Zyxel P870HW-51a v2")
217                 board_name="p870hw-51a_v2"
218                 ;;
219         *)
220                 board_name="unknown"
221                 ;;
222         esac
223
224         echo "$board_name"
225 }
226
227 brcm63xx_legacy_detect() {
228         local board_name
229
230         case "$1" in
231         V2110)
232                 board_name="v2110"
233                 ;;
234         VW6339GU)
235                 board_namge="vg50"
236                 ;;
237         *)
238                 board_name="unknown"
239                 ;;
240         esac
241
242         echo "$board_name"
243 }
244
245 brcm63xx_detect() {
246         local board_name model
247
248         board_id=$(awk 'BEGIN{FS="[ \t:/]+"} /system type/ {print $4}' /proc/cpuinfo)
249
250         if [ -e /proc/device-tree ]; then
251                 model=$(cat /proc/device-tree/model)
252                 board_name=$(brcm63xx_dt_detect "$model")
253         else
254                 model="Unknown bcm63xx board"
255                 board_name=$(brcm63xx_legacy_detect "$board_id")
256         fi
257
258         [ -e "/tmp/sysinfo" ] || mkdir -p "/tmp/sysinfo"
259
260         echo "$board_name" > /tmp/sysinfo/board_name
261         echo "$model" > /tmp/sysinfo/model
262 }
263
264 brcm63xx_board_name() {
265         local name
266
267         [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
268         [ -n "$name" ] || name="unknown"
269
270         echo $name
271 }