blob: bc03f5c1785143c362723bbc32abe5ab569ac929 [file] [log] [blame]
Zvikomborero VIncent Zvikaramba566ec732016-08-19 02:18:45 -04001#!/system/bin/sh
2# Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following
11# disclaimer in the documentation and/or other materials provided
12# with the distribution.
13# * Neither the name of The Linux Foundation nor the names of its
14# contributors may be used to endorse or promote products derived
15# from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29# This script will load and unload the wifi driver to put the wifi in
30# in deep sleep mode so that there won't be voltage leakage.
31# Loading/Unloading the driver only incase if the Wifi GUI is not going
32# to Turn ON the Wifi. In the Script if the wlan driver status is
33# ok(GUI loaded the driver) or loading(GUI is loading the driver) then
34# the script won't do anything. Otherwise (GUI is not going to Turn On
35# the Wifi) the script will load/unload the driver
36# This script will get called after post bootup.
37
38target="$1"
39serialno="$2"
40
41btsoc=""
42
43# No path is set up at this point so we have to do it here.
44PATH=/sbin:/system/sbin:/system/bin:/system/xbin
45export PATH
46
47# Trigger WCNSS platform driver
48trigger_wcnss()
49{
50 # We need to trigger WCNSS platform driver, WCNSS driver
51 # will export a file which we must touch so that the
52 # driver knows that userspace is ready to handle firmware
53 # download requests.
54
55 # See if an appropriately named device file is present
56 wcnssnode=`ls /dev/wcnss*`
57 case "$wcnssnode" in
58 *wcnss*)
59 # Before triggering wcnss, let it know that
60 # caldata is available at userspace.
61 if [ -e /data/misc/wifi/WCNSS_qcom_wlan_cal.bin ]; then
62 calparm=`ls /sys/module/wcnsscore/parameters/has_calibrated_data`
63 if [ -e $calparm ] && [ ! -e /data/misc/wifi/WCN_FACTORY ]; then
64 echo 1 > $calparm
65 fi
66 fi
67 # There is a device file. Write to the file
68 # so that the driver knows userspace is
69 # available for firmware download requests
70 echo 1 > $wcnssnode
71 ;;
72
73 *)
74 # There is not a device file present, so
75 # the driver must not be available
76 echo "No WCNSS device node detected"
77 ;;
78 esac
79
80 # Plumb down the device serial number
81 if [ -f /sys/devices/*wcnss-wlan/serial_number ]; then
82 cd /sys/devices/*wcnss-wlan
83 echo $serialno > serial_number
84 cd /
85 elif [ -f /sys/devices/platform/wcnss_wlan.0/serial_number ]; then
86 echo $serialno > /sys/devices/platform/wcnss_wlan.0/serial_number
87 fi
88}
89
90
91case "$target" in
92 msm8974* | msm8226* | msm8610*)
93
94# Check whether device is plugged on the HSIC bus
95# Currently HSIC bus will be the first index
96
97 if [ -e /sys/bus/platform/drivers/msm_hsic_host ]; then
98 if [ ! -L /sys/bus/usb/devices/1-1 ]; then
99 echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind
100 fi
101
102 chown -h system.system /sys/bus/platform/drivers/msm_hsic_host/bind
103 chown -h system.system /sys/bus/platform/drivers/msm_hsic_host/unbind
104 chmod -h 0200 /sys/bus/platform/drivers/msm_hsic_host/bind
105 chmod -h 0200 /sys/bus/platform/drivers/msm_hsic_host/unbind
106 fi
107
108 wlanchip=""
109
110# force ar6004 is ar6004_wlan.conf existed.
111 if [ -f /system/etc/firmware/ath6k/AR6004/ar6004_wlan.conf ]; then
112 wlanchip=`cat /system/etc/firmware/ath6k/AR6004/ar6004_wlan.conf`
113 fi
114
115# auto detect ar6004-sdio card
116# for ar6004-sdio card, the vendor id and device id is as the following
117# vendor id device id
118# 0x0271 0x0400
119# 0x0271 0x0401
120 if [ "$wlanchip" == "" ]; then
121 sdio_vendors=`echo \`cat /sys/bus/mmc/devices/*/*/vendor\``
122 sdio_devices=`echo \`cat /sys/bus/mmc/devices/*/*/device\``
123 ven_idx=0
124
125 for vendor in $sdio_vendors; do
126 case "$vendor" in
127 "0x0271")
128 dev_idx=0
129 for device in $sdio_devices; do
130 if [ $ven_idx -eq $dev_idx ]; then
131 case "$device" in
132 "0x0400" | "0x0401" | "0x0402")
133 wlanchip="AR6004-SDIO"
134 ;;
135 *)
136 ;;
137 esac
138 fi
139 dev_idx=$(( $dev_idx + 1))
140 done
141 ;;
142 *)
143 ;;
144 esac
145 ven_idx=$(( $ven_idx + 1))
146 done
147 # auto detect ar6004-sdio card end
148 fi
149
150# for ar6004-usb card, the vendor id and device id is as the following
151# vendor id product id
152# 0x0cf3 0x9374
153# 0x0cf3 0x9372
154 if [ "$wlanchip" == "" ]; then
155 usb_vendors=`echo \`cat /sys/bus/usb/devices/*/*/idVendor\``
156 usb_products=`echo \`cat /sys/bus/usb/devices/*/*/idProduct\``
157 ven_idx=0
158
159 for vendor in $usb_vendors; do
160 case "$vendor" in
161 "0cf3")
162 dev_idx=0
163 for product in $usb_products; do
164 if [ $ven_idx -eq $dev_idx ]; then
165 case "$product" in
166 "9374" | "9372")
167 wlanchip="AR6004-USB"
168 ;;
169 *)
170 ;;
171 esac
172 fi
173 dev_idx=$(( $dev_idx + 1))
174 done
175 ;;
176 *)
177 ;;
178 esac
179 ven_idx=$(( $ven_idx + 1))
180 done
181 # auto detect ar6004-usb card end
182 fi
183
184 echo "The WLAN Chip ID is $wlanchip"
185 case "$wlanchip" in
186 "AR6004-USB")
187 echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind
188 setprop wlan.driver.ath 2
189 setprop qcom.bluetooth.soc ath3k
190 btsoc="ath3k"
191 rm /system/lib/modules/wlan.ko
192 ln -s /system/lib/modules/ath6kl-3.5/ath6kl_usb.ko \
193 /system/lib/modules/wlan.ko
194 rm /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
195 rm /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
196 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin_usb \
197 /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
198 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin_usb \
199 /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
200 rm /system/etc/firmware/ath6k/AR6004/hw3.0/bdata.bin
201 ln -s /system/etc/firmware/ath6k/AR6004/hw3.0/bdata.bin_usb \
202 /system/etc/firmware/ath6k/AR6004/hw3.0/bdata.bin
203
204 # Use different wpa_supplicant.conf template between wcn driver
205 # and ath6kl driver
206 rm /system/etc/wifi/wpa_supplicant.conf
207 ln -s /system/etc/wifi/wpa_supplicant_ath6kl.conf \
208 /system/etc/wifi/wpa_supplicant.conf
209 ;;
210
211 "AR6004-SDIO")
212 setprop wlan.driver.ath 2
213 setprop qcom.bluetooth.soc ath3k
214 btsoc="ath3k"
215 # Chown polling nodes as needed from UI running on system server
216 chmod -h 0200 /sys/devices/msm_sdcc.1/polling
217 chmod -h 0200 /sys/devices/msm_sdcc.2/polling
218 chmod -h 0200 /sys/devices/msm_sdcc.3/polling
219 chmod -h 0200 /sys/devices/msm_sdcc.4/polling
220
221 chown -h system.system /sys/devices/msm_sdcc.1/polling
222 chown -h system.system /sys/devices/msm_sdcc.2/polling
223 chown -h system.system /sys/devices/msm_sdcc.3/polling
224 chown -h system.system /sys/devices/msm_sdcc.4/polling
225
226 rm /system/lib/modules/wlan.ko
227 ln -s /system/lib/modules/ath6kl-3.5/ath6kl_sdio.ko \
228 /system/lib/modules/wlan.ko
229 rm /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
230 rm /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
231 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin_sdio \
232 /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
233 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin_sdio \
234 /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
235 rm /system/etc/firmware/ath6k/AR6004/hw3.0/bdata.bin
236 ln -s /system/etc/firmware/ath6k/AR6004/hw3.0/bdata.bin_sdio \
237 /system/etc/firmware/ath6k/AR6004/hw3.0/bdata.bin
238
239 # Use different wpa_supplicant.conf template between wcn driver
240 # and ath6kl driver
241 rm /system/etc/wifi/wpa_supplicant.conf
242 ln -s /system/etc/wifi/wpa_supplicant_ath6kl.conf \
243 /system/etc/wifi/wpa_supplicant.conf
244 ;;
245
246 *)
247 echo "*** WI-FI chip ID is not specified in /persist/wlan_chip_id **"
248 echo "*** Use the default WCN driver. **"
249 setprop wlan.driver.ath 0
250 rm /system/lib/modules/wlan.ko
251 ln -s /system/lib/modules/pronto/pronto_wlan.ko \
252 /system/lib/modules/wlan.ko
253 # Populate the writable driver configuration file
254 if [ ! -s /data/misc/wifi/WCNSS_qcom_cfg.ini ]; then
255 cp /system/etc/wifi/WCNSS_qcom_cfg.ini \
256 /data/misc/wifi/WCNSS_qcom_cfg.ini
257 chown -h system:wifi /data/misc/wifi/WCNSS_qcom_cfg.ini
258 chmod -h 660 /data/misc/wifi/WCNSS_qcom_cfg.ini
259 fi
260
261 # The property below is used in Qcom SDK for softap to determine
262 # the wifi driver config file
263 setprop wlan.driver.config /data/misc/wifi/WCNSS_qcom_cfg.ini
264
265 # Use different wpa_supplicant.conf template between wcn driver
266 # and ath6kl driver
267 rm /system/etc/wifi/wpa_supplicant.conf
268 ln -s /system/etc/wifi/wpa_supplicant_wcn.conf \
269 /system/etc/wifi/wpa_supplicant.conf
270
271 # Trigger WCNSS platform driver
272 trigger_wcnss &
273 ;;
274 esac
275 ;;
276
277 apq8084*)
278 echo "*** Use the CNSS CLD driver.**"
279 setprop wlan.driver.ath 0
280
281 # Use different wpa_supplicant.conf template between wcn driver
282 # and ath6kl driver
283 rm /system/etc/wifi/wpa_supplicant.conf
284 ln -s /system/etc/wifi/wpa_supplicant_wcn.conf \
285 /system/etc/wifi/wpa_supplicant.conf
286 ;;
287
288 msm8960*)
289
290 # Move cfg80211.ko to prima directory, the default cfg80211.ko is
291 # for wcnss solution
292 if [ ! -L /system/lib/modules/cfg80211.ko ]; then
293 mv /system/lib/modules/cfg80211.ko /system/lib/modules/prima/
294 fi
295
296 wlanchip=""
297
298 if [ -f /system/etc/firmware/ath6k/AR6004/ar6004_wlan.conf ]; then
299 wlanchip=`cat /system/etc/firmware/ath6k/AR6004/ar6004_wlan.conf`
300 fi
301
302 if [ "$wlanchip" == "" ]; then
303 # auto detect ar6004-usb card
304 # for ar6004-usb card, the vendor id and device id is as the following
305 # vendor id product id
306 # 0x0cf3 0x9374
307 # 0x0cf3 0x9372
308 usb_vendors=`echo \`cat /sys/bus/usb/devices/*/*/idVendor\``
309 usb_products=`echo \`cat /sys/bus/usb/devices/*/*/idProduct\``
310 ven_idx=0
311
312 for vendor in $usb_vendors; do
313 case "$vendor" in
314 "0cf3")
315 dev_idx=0
316 for product in $usb_products; do
317 if [ $ven_idx -eq $dev_idx ]; then
318 case "$product" in
319 "9374" | "9372")
320 wlanchip="AR6004-USB"
321 ;;
322 *)
323 ;;
324 esac
325 fi
326 dev_idx=$(( $dev_idx + 1))
327 done
328 ;;
329 *)
330 ;;
331 esac
332 ven_idx=$(( $ven_idx + 1))
333 done
334 # auto detect ar6004-usb card end
335 fi
336
337 if [ "$wlanchip" == "" ]; then
338 # auto detect ar6004-sdio card
339 # for ar6004-sdio card, the vendor id and device id is
340 # as the following
341 # vendor id device id
342 # 0x0271 0x0400
343 # 0x0271 0x0401
344 sdio_vendors=`echo \`cat /sys/bus/mmc/devices/*/*/vendor\``
345 sdio_devices=`echo \`cat /sys/bus/mmc/devices/*/*/device\``
346 ven_idx=0
347
348 for vendor in $sdio_vendors; do
349 case "$vendor" in
350 "0x0271")
351 dev_idx=0
352 for device in $sdio_devices; do
353 if [ $ven_idx -eq $dev_idx ]; then
354 case "$device" in
355 "0x0400" | "0x0401")
356 wlanchip="AR6004-SDIO"
357 ;;
358 *)
359 ;;
360 esac
361 fi
362 dev_idx=$(( $dev_idx + 1))
363 done
364 ;;
365 *)
366 ;;
367 esac
368 ven_idx=$(( $ven_idx + 1))
369 done
370 # auto detect ar6004-sdio card end
371 fi
372
373 echo "The WLAN Chip ID is $wlanchip"
374 case "$wlanchip" in
375 "AR6004-USB")
376 setprop wlan.driver.ath 2
377 rm /system/lib/modules/wlan.ko
378 rm /system/lib/modules/cfg80211.ko
379 ln -s /system/lib/modules/ath6kl-3.5/ath6kl_usb.ko \
380 /system/lib/modules/wlan.ko
381 ln -s /system/lib/modules/ath6kl-3.5/cfg80211.ko \
382 /system/lib/modules/cfg80211.ko
383 rm /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
384 rm /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
385 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin_usb \
386 /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
387 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin_usb \
388 /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
389
390 # Use different wpa_supplicant.conf template between wcn driver
391 # and ath6kl driver
392 rm /system/etc/wifi/wpa_supplicant.conf
393 ln -s /system/etc/wifi/wpa_supplicant_ath6kl.conf \
394 /system/etc/wifi/wpa_supplicant.conf
395 ;;
396 "AR6004-SDIO")
397 setprop wlan.driver.ath 2
398 setprop qcom.bluetooth.soc ath3k
399 btsoc="ath3k"
400 rm /system/lib/modules/wlan.ko
401 rm /system/lib/modules/cfg80211.ko
402 ln -s /system/lib/modules/ath6kl-3.5/ath6kl_sdio.ko \
403 /system/lib/modules/wlan.ko
404 ln -s /system/lib/modules/ath6kl-3.5/cfg80211.ko \
405 /system/lib/modules/cfg80211.ko
406 rm /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
407 rm /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
408 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin_sdio \
409 /system/etc/firmware/ath6k/AR6004/hw1.3/fw.ram.bin
410 ln -s /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin_sdio \
411 /system/etc/firmware/ath6k/AR6004/hw1.3/bdata.bin
412
413 # Use different wpa_supplicant.conf template between wcn driver
414 # and ath6kl driver
415 rm /system/etc/wifi/wpa_supplicant.conf
416 ln -s /system/etc/wifi/wpa_supplicant_ath6kl.conf \
417 /system/etc/wifi/wpa_supplicant.conf
418 ;;
419 *)
420 echo "*** WI-FI chip ID is not specified in /persist/wlan_chip_id **"
421 echo "*** Use the default WCN driver. **"
422 setprop wlan.driver.ath 0
423 rm /system/lib/modules/wlan.ko
424 rm /system/lib/modules/cfg80211.ko
425 ln -s /system/lib/modules/prima/prima_wlan.ko \
426 /system/lib/modules/wlan.ko
427 ln -s /system/lib/modules/prima/cfg80211.ko \
428 /system/lib/modules/cfg80211.ko
429
430 # The property below is used in Qcom SDK for softap to determine
431 # the wifi driver config file
432 setprop wlan.driver.config /data/misc/wifi/WCNSS_qcom_cfg.ini
433
434 # Use different wpa_supplicant.conf template between wcn driver
435 # and ath6kl driver
436 rm /system/etc/wifi/wpa_supplicant.conf
437 ln -s /system/etc/wifi/wpa_supplicant_wcn.conf \
438 /system/etc/wifi/wpa_supplicant.conf
439
440 # Trigger WCNSS platform driver
441 trigger_wcnss &
442 ;;
443 esac
444 ;;
445
446 msm7627a*)
447
448 # The default cfg80211 module is for volans
449 if [ ! -L /system/lib/modules/cfg80211.ko ]; then
450 mv /system/lib/modules/cfg80211.ko /system/lib/modules/volans/
451 fi
452
453 wlanchip=`cat /persist/wlan_chip_id`
454 echo "The WLAN Chip ID is $wlanchip"
455 case "$wlanchip" in
456 "ATH6KL")
457 setprop wlan.driver.ath 1
458 rm /system/lib/modules/wlan.ko
459 rm /system/lib/modules/cfg80211.ko
460 ln -s /system/lib/modules/ath6kl/ath6kl_sdio.ko \
461 /system/lib/modules/wlan.ko
462 ln -s /system/lib/modules/ath6kl/cfg80211.ko \
463 /system/lib/modules/cfg80211.ko
464 ;;
465 "WCN1314")
466 setprop wlan.driver.ath 0
467 rm /system/lib/modules/wlan.ko
468 rm /system/lib/modules/cfg80211.ko
469 ln -s /system/lib/modules/volans/WCN1314_rf.ko \
470 /system/lib/modules/wlan.ko
471 ln -s /system/lib/modules/volans/cfg80211.ko \
472 /system/lib/modules/cfg80211.ko
473 ;;
474 *)
475 setprop wlan.driver.ath 1
476 rm /system/lib/modules/wlan.ko
477 rm /system/lib/modules/cfg80211.ko
478 ln -s /system/lib/modules/ath6kl/ath6kl_sdio.ko \
479 /system/lib/modules/wlan.ko
480 ln -s /system/lib/modules/ath6kl/cfg80211.ko \
481 /system/lib/modules/cfg80211.ko
482 echo "************************************************************"
483 echo "*** Error:WI-FI chip ID is not specified in"
484 echo "/persist/wlan_chip_id"
485 echo "******* WI-FI may not work ***************************"
486 ;;
487 esac
488 ;;
489
490 msm7627*)
491 ln -s /data/hostapd/qcom_cfg.ini /etc/firmware/wlan/qcom_cfg.ini
492 ln -s /persist/qcom_wlan_nv.bin /etc/firmware/wlan/qcom_wlan_nv.bin
493 ;;
494
495 msm8660*)
496 ;;
497
498 msm7630*)
499 ;;
500
501 *)
502 ;;
503esac
504
505# Run audio init script
506/system/bin/sh /system/etc/init.qcom.audio.sh "$target" "$btsoc"