ramips: rt305x: add support for the Petatel PSR-680W Wireless CDMA Router
[openwrt/svn-archive/archive.git] / target / linux / ramips / base-files / lib / ramips.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010 OpenWrt.org
4 #
5
6 ramips_get_mac_binary()
7 {
8 local mtdname="$1"
9 local seek="$2"
10 local part
11
12 . /lib/functions.sh
13
14 part=$(find_mtd_part "$mtdname")
15 if [ -z "$part" ]; then
16 echo "ramips_get_mac_binary: partition $mtdname not found!" >&2
17 return
18 fi
19
20 dd bs=1 skip=$seek count=6 if=$part 2>/dev/null | /usr/sbin/maccalc bin2mac
21 }
22
23 ramips_get_mac_nvram()
24 {
25 local mtdname="$1"
26 local key="$2"
27 local part
28 local mac_dirty
29
30 . /lib/functions.sh
31
32 part=$(find_mtd_part "$mtdname")
33 if [ -z "$part" ]; then
34 echo "ramips_get_mac_nvram: partition $mtdname not found!" >&2
35 return
36 fi
37
38 mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p')
39 # "canonicalize" mac
40 /usr/sbin/maccalc add "$mac_dirty" 0
41 }
42
43 ramips_board_name() {
44 local machine
45 local name
46
47 machine=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /machine/ {print $2}' /proc/cpuinfo)
48
49 case "$machine" in
50 *"Allnet ALL0256N")
51 name="all0256n"
52 ;;
53 *"ARC FreeStation5")
54 name="freestation5"
55 ;;
56 *"Argus ATP-52B")
57 name="argus-atp52b"
58 ;;
59 *"Asus WL-330N")
60 name="wl-330n"
61 ;;
62 *"Asus WL-330N3G")
63 name="wl-330n3g"
64 ;;
65 *"Aztech HW550-3G")
66 name="hw550-3g"
67 ;;
68 *"DIR-300 B1")
69 name="dir-300-b1"
70 ;;
71 *"DIR-600 B1")
72 name="dir-600-b1"
73 ;;
74 *"DIR-600 B2")
75 name="dir-600-b2"
76 ;;
77 *"ESR-9753")
78 name="esr-9753"
79 ;;
80 *"F5D8235 v1")
81 name="f5d8235-v1"
82 ;;
83 *"F5D8235 v2")
84 name="f5d8235-v2"
85 ;;
86 *"La Fonera 2.0N")
87 name="fonera20n"
88 ;;
89 *"MoFi Network MOFI3500-3GN")
90 name="mofi3500-3gn"
91 ;;
92 *"NBG-419N")
93 name="nbg-419n"
94 ;;
95 *"NexAira BC2")
96 name="bc2"
97 ;;
98 *"NW718")
99 name="nw718"
100 ;;
101 *"Omnima MiniEMBWiFi")
102 name="omni-emb"
103 ;;
104 *"Petatel PSR-680W"*)
105 name="psr-680w"
106 ;;
107 *"PWH2004")
108 name="pwh2004"
109 ;;
110 *"RT-G32 B1")
111 name="rt-g32-b1"
112 ;;
113 *"RT-N10+")
114 name="rt-n10-plus"
115 ;;
116 *"RT-N15")
117 name="rt-n15"
118 ;;
119 *"RT-N56U")
120 name="rt-n56u"
121 ;;
122 *"Skyline SL-R7205"*)
123 name="sl-r7205"
124 ;;
125 *"Sparklan WCR-150GN")
126 name="wcr-150gn"
127 ;;
128 *"V22RW-2X2")
129 name="v22rw-2x2"
130 ;;
131 *"W502U")
132 name="w502u"
133 ;;
134 *"WHR-G300N")
135 name="whr-g300n"
136 ;;
137 *"Sitecom WL-341 v3")
138 name="wl341v3"
139 ;;
140 *"Sitecom WL-351 v1 002")
141 name="wl-351"
142 ;;
143 *"Tenda W306R V2.0")
144 name="w306r-v20"
145 ;;
146 *"Ralink V11ST-FE")
147 name="v11st-fe"
148 ;;
149 *"WLI-TX4-AG300N")
150 name="wli-tx4-ag300n"
151 ;;
152 *"WZR-AGL300NH")
153 name="wzr-agl300nh"
154 ;;
155 *"WR512-3GN-like router")
156 name="wr512-3gn"
157 ;;
158 *"UR-336UN Wireless N router")
159 name="ur-336un"
160 ;;
161 *"AWB WR6202")
162 name="wr6202"
163 ;;
164 *"XDX RN502J")
165 name="xdxrn502j"
166 ;;
167 *)
168 name="generic"
169 ;;
170 esac
171
172 echo $name
173 }