blob: fa041beebf78de53421a889795a3747f0ad3355d [file] [log] [blame]
Zvikomborero VIncent Zvikarambaa25011a2016-07-21 16:32:35 -04001#!/system/bin/sh
2# Copyright (c) 2012, 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#
30chown -h root.system /sys/devices/platform/msm_hsusb/gadget/wakeup
31chmod -h 220 /sys/devices/platform/msm_hsusb/gadget/wakeup
32
33#
34# Allow persistent usb charging disabling
35# User needs to set usb charging disabled in persist.usb.chgdisabled
36#
37target=`getprop ro.board.platform`
38usbchgdisabled=`getprop persist.usb.chgdisabled`
39case "$usbchgdisabled" in
40 "") ;; #Do nothing here
41 * )
42 case $target in
43 "msm8660")
44 echo "$usbchgdisabled" > /sys/module/pmic8058_charger/parameters/disabled
45 echo "$usbchgdisabled" > /sys/module/smb137b/parameters/disabled
46 ;;
47 "msm8960")
48 echo "$usbchgdisabled" > /sys/module/pm8921_charger/parameters/disabled
49 ;;
50 esac
51esac
52
53usbcurrentlimit=`getprop persist.usb.currentlimit`
54case "$usbcurrentlimit" in
55 "") ;; #Do nothing here
56 * )
57 case $target in
58 "msm8960")
59 echo "$usbcurrentlimit" > /sys/module/pm8921_charger/parameters/usb_max_current
60 ;;
61 esac
62esac
63
64#
65# Check ESOC for external MDM
66#
67# Note: currently only a single MDM is supported
68#
69if [ -d /sys/bus/esoc/devices ]; then
70for f in /sys/bus/esoc/devices/*; do
71 if [ -d $f ]; then
72 esoc_name=`cat $f/esoc_name`
73 if [ "$esoc_name" = "MDM9x25" -o "$esoc_name" = "MDM9x35" ]; then
74 esoc_link=`cat $f/esoc_link`
75 break
76 fi
77 fi
78done
79fi
80
81target=`getprop ro.board.platform`
82
83#
84# Allow USB enumeration with default PID/VID
85#
86baseband=`getprop ro.baseband`
87echo 1 > /sys/class/android_usb/f_mass_storage/lun/nofua
88usb_config=`getprop persist.sys.usb.config`
89case "$usb_config" in
90 "" | "adb") #USB persist config not set, select default configuration
91 case "$esoc_link" in
92 "HSIC")
93 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb
94 setprop persist.rmnet.mux enabled
95 ;;
96 "HSIC+PCIe")
97 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,rmnet_qti_ether,mass_storage,adb
98 ;;
99 "PCIe")
100 setprop persist.sys.usb.config diag,diag_mdm,serial_tty,rmnet_qti_ether,mass_storage,adb
101 ;;
102 *)
103 case "$baseband" in
104 "mdm")
105 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb
106 ;;
107 "mdm2")
108 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb
109 ;;
110 "sglte")
111 setprop persist.sys.usb.config diag,diag_qsc,serial_smd,serial_tty,serial_hsuart,rmnet_hsuart,mass_storage,adb
112 ;;
113 "dsda" | "sglte2")
114 setprop persist.sys.usb.config diag,diag_mdm,diag_qsc,serial_hsic,serial_hsuart,rmnet_hsic,rmnet_hsuart,mass_storage,adb
115 ;;
116 "dsda2")
117 setprop persist.sys.usb.config diag,diag_mdm,diag_mdm2,serial_hsic,serial_hsusb,rmnet_hsic,rmnet_hsusb,mass_storage,adb
118 ;;
119 *)
120 case "$target" in
121 "msm8916")
122 setprop persist.sys.usb.config diag,serial_smd,rmnet_bam,adb
123 ;;
124 "msm8994")
125 setprop persist.sys.usb.config diag,serial_smd,serial_tty,rmnet_ipa,mass_storage,adb
126 ;;
127 "msm8909")
128 setprop persist.sys.usb.config diag,serial_smd,rmnet_qti_bam,adb
129 ;;
130 *)
131 setprop persist.sys.usb.config diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb
132 ;;
133 esac
134 ;;
135 esac
136 ;;
137 esac
138 ;;
139 * ) ;; #USB persist config exists, do nothing
140esac
141
142#
143# Do target specific things
144#
145case "$target" in
146 "msm8974")
147# Select USB BAM - 2.0 or 3.0
148 echo ssusb > /sys/bus/platform/devices/usb_bam/enable
149 ;;
150 "apq8084")
151 if [ "$baseband" == "apq" ]; then
152 echo "msm_hsic_host" > /sys/bus/platform/drivers/xhci_msm_hsic/unbind
153 fi
154 ;;
155 "msm8226")
156 if [ -e /sys/bus/platform/drivers/msm_hsic_host ]; then
157 if [ ! -L /sys/bus/usb/devices/1-1 ]; then
158 echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind
159 fi
160 fi
161 ;;
162 "msm8994")
163 echo BAM2BAM_IPA > /sys/class/android_usb/android0/f_rndis_qc/rndis_transports
164 echo 1 > /sys/class/android_usb/android0/f_rndis_qc/max_pkt_per_xfer # Disable RNDIS UL aggregation
165 ;;
166esac
167
168#
169# set module params for embedded rmnet devices
170#
171rmnetmux=`getprop persist.rmnet.mux`
172case "$baseband" in
173 "mdm" | "dsda" | "sglte2")
174 case "$rmnetmux" in
175 "enabled")
176 echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled
177 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
178 echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
179 ;;
180 esac
181 echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init
182 # Allow QMUX daemon to assign port open wait time
183 chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
184 ;;
185 "dsda2")
186 echo 2 > /sys/module/rmnet_usb/parameters/no_rmnet_devs
187 echo hsicctl,hsusbctl > /sys/module/rmnet_usb/parameters/rmnet_dev_names
188 case "$rmnetmux" in
189 "enabled") #mux is neabled on both mdms
190 echo 3 > /sys/module/rmnet_usb/parameters/mux_enabled
191 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
192 echo 17 > write /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
193 ;;
194 "enabled_hsic") #mux is enabled on hsic mdm
195 echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled
196 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
197 echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
198 ;;
199 "enabled_hsusb") #mux is enabled on hsusb mdm
200 echo 2 > /sys/module/rmnet_usb/parameters/mux_enabled
201 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
202 echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
203 ;;
204 esac
205 echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init
206 # Allow QMUX daemon to assign port open wait time
207 chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
208 ;;
209esac
210
211#
212# Add support for exposing lun0 as cdrom in mass-storage
213#
214cdromname="/system/etc/cdrom_install.iso"
215platformver=`cat /sys/devices/soc0/hw_platform`
216case "$target" in
217 "msm8226" | "msm8610" | "msm8916")
218 case $platformver in
219 "QRD")
220 echo "mounting usbcdrom lun"
221 echo $cdromname > /sys/class/android_usb/android0/f_mass_storage/rom/file
222 chmod 0444 /sys/class/android_usb/android0/f_mass_storage/rom/file
223 ;;
224 esac
225 ;;
226esac
227
228#
229# Initialize RNDIS Diag option. If unset, set it to 'none'.
230#
231diag_extra=`getprop persist.sys.usb.config.extra`
232if [ "$diag_extra" == "" ]; then
233 setprop persist.sys.usb.config.extra none
234fi
235
236# soc_ids for 8916/8939 differentiation
237if [ -f /sys/devices/soc0/soc_id ]; then
238 soc_id=`cat /sys/devices/soc0/soc_id`
239else
240 soc_id=`cat /sys/devices/system/soc/soc0/id`
241fi
242
243# enable rps cpus on msm8939 target
244setprop sys.usb.rps_mask 0
245case "$soc_id" in
246 "239" | "241" | "263")
247 setprop sys.usb.rps_mask 10
248 ;;
249esac