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