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