blob: 1f02257a9cde24600f8fae5ca74e6f2d8240164e [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.product.device`
82target=${target:0:7}
83
84#
85# Allow USB enumeration with default PID/VID
86#
87baseband=`getprop ro.baseband`
88echo 1 > /sys/class/android_usb/f_mass_storage/lun/nofua
89usb_config=`getprop persist.sys.usb.config`
90case "$usb_config" in
91 "" | "adb") #USB persist config not set, select default configuration
92 case "$esoc_link" in
93 "HSIC")
94 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb
95 setprop persist.rmnet.mux enabled
96 ;;
97 "HSIC+PCIe")
98 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,rmnet_qti_ether,mass_storage,adb
99 ;;
100 "PCIe")
101 setprop persist.sys.usb.config diag,diag_mdm,serial_tty,rmnet_qti_ether,mass_storage,adb
102 ;;
103 *)
104 case "$baseband" in
105 "mdm")
106 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb
107 ;;
108 "mdm2")
109 setprop persist.sys.usb.config diag,diag_mdm,serial_hsic,serial_tty,rmnet_hsic,mass_storage,adb
110 ;;
111 "sglte")
112 setprop persist.sys.usb.config diag,diag_qsc,serial_smd,serial_tty,serial_hsuart,rmnet_hsuart,mass_storage,adb
113 ;;
114 "dsda" | "sglte2")
115 setprop persist.sys.usb.config diag,diag_mdm,diag_qsc,serial_hsic,serial_hsuart,rmnet_hsic,rmnet_hsuart,mass_storage,adb
116 ;;
117 "dsda2")
118 setprop persist.sys.usb.config diag,diag_mdm,diag_mdm2,serial_hsic,serial_hsusb,rmnet_hsic,rmnet_hsusb,mass_storage,adb
119 ;;
120 *)
121 case "$target" in
122 "msm8916" | "msm8939")
123 #setprop persist.sys.usb.config diag,serial_smd,rmnet_bam,adb
124 setprop persist.sys.usb.config mtp,adb
125 ;;
126 *)
127 setprop persist.sys.usb.config diag,serial_smd,serial_tty,rmnet_bam,mass_storage,adb
128 ;;
129 esac
130 ;;
131 esac
132 ;;
133 esac
134 ;;
135 * ) ;; #USB persist config exists, do nothing
136esac
137
138#
139# Do target specific things
140#
141case "$target" in
142 "msm8974")
143# Select USB BAM - 2.0 or 3.0
144 echo ssusb > /sys/bus/platform/devices/usb_bam/enable
145 ;;
146 "apq8084")
147 if [ "$baseband" == "apq" ]; then
148 echo "msm_hsic_host" > /sys/bus/platform/drivers/xhci_msm_hsic/unbind
149 fi
150 ;;
151 "msm8226")
152 if [ -e /sys/bus/platform/drivers/msm_hsic_host ]; then
153 if [ ! -L /sys/bus/usb/devices/1-1 ]; then
154 echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind
155 fi
156 fi
157 ;;
158esac
159
160#
161# set module params for embedded rmnet devices
162#
163rmnetmux=`getprop persist.rmnet.mux`
164case "$baseband" in
165 "mdm" | "dsda" | "sglte2")
166 case "$rmnetmux" in
167 "enabled")
168 echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled
169 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
170 echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
171 ;;
172 esac
173 echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init
174 # Allow QMUX daemon to assign port open wait time
175 chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
176 ;;
177 "dsda2")
178 echo 2 > /sys/module/rmnet_usb/parameters/no_rmnet_devs
179 echo hsicctl,hsusbctl > /sys/module/rmnet_usb/parameters/rmnet_dev_names
180 case "$rmnetmux" in
181 "enabled") #mux is neabled on both mdms
182 echo 3 > /sys/module/rmnet_usb/parameters/mux_enabled
183 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
184 echo 17 > write /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
185 ;;
186 "enabled_hsic") #mux is enabled on hsic mdm
187 echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled
188 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
189 echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
190 ;;
191 "enabled_hsusb") #mux is enabled on hsusb mdm
192 echo 2 > /sys/module/rmnet_usb/parameters/mux_enabled
193 echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
194 echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
195 ;;
196 esac
197 echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init
198 # Allow QMUX daemon to assign port open wait time
199 chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
200 ;;
201esac
202
203#
204# Add support for exposing lun0 as cdrom in mass-storage
205#
206cdromname="/system/etc/cdrom_install.iso"
207platformver=`cat /sys/devices/soc0/hw_platform`
208case "$target" in
209 "msm8226" | "msm8610" | "msm8916")
210 case $platformver in
211 "QRD")
212 echo "mounting usbcdrom lun"
213 echo $cdromname > /sys/class/android_usb/android0/f_mass_storage/rom/file
214 chmod 0444 /sys/class/android_usb/android0/f_mass_storage/rom/file
215 ;;
216 esac
217 ;;
218esac
219
220#
221# Initialize RNDIS Diag option. If unset, set it to 'none'.
222#
223diag_extra=`getprop persist.sys.usb.config.extra`
224if [ "$diag_extra" == "" ]; then
225 setprop persist.sys.usb.config.extra none
226fi