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