aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordd3boh <dade.garberi@gmail.com>2017-11-07 19:32:05 +0100
committerdd3boh <dade.garberi@gmail.com>2017-11-09 14:24:08 +0100
commitd552e7d1fe0b08cdcd136e51d3294e344eaa1987 (patch)
treef16ed05b3deb7bd54dc7f7a79e33147ab9eeefd7
parentf50b98a6d0513a8c795a451e9d7300cf5cecf2d4 (diff)
msm8996-common: Checkout rootdir to a sane state
Signed-off-by: dd3boh <dade.garberi@gmail.com>
-rw-r--r--rootdir/Android.mk16
-rwxr-xr-xrootdir/etc/init.qcom.bt.sh334
-rwxr-xr-xrootdir/etc/init.qcom.rc145
-rwxr-xr-xrootdir/etc/init.qcom.usb.rc5
-rwxr-xr-xrootdir/etc/init.qcom.usb.sh280
5 files changed, 757 insertions, 23 deletions
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index f0ff1d4..c3522cf 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -43,6 +43,22 @@ LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
+LOCAL_MODULE := init.qcom.usb.sh
+LOCAL_MODULE_TAGS := optional eng
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES := etc/init.qcom.usb.sh
+LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := init.qcom.bt.sh
+LOCAL_MODULE_TAGS := optional eng
+LOCAL_MODULE_CLASS := ETC
+LOCAL_SRC_FILES := etc/init.qcom.bt.sh
+LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
+include $(BUILD_PREBUILT)
+
+include $(CLEAR_VARS)
LOCAL_MODULE := ueventd.qcom.rc
LOCAL_MODULE_TAGS := optional eng
LOCAL_MODULE_CLASS := ETC
diff --git a/rootdir/etc/init.qcom.bt.sh b/rootdir/etc/init.qcom.bt.sh
new file mode 100755
index 0000000..100859c
--- /dev/null
+++ b/rootdir/etc/init.qcom.bt.sh
@@ -0,0 +1,334 @@
+#!/system/bin/sh
+# Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of The Linux Foundation nor
+# the names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+#Read the arguments passed to the script
+config="$1"
+
+BLUETOOTH_SLEEP_PATH=/proc/bluetooth/sleep/proto
+LOG_TAG="qcom-bluetooth"
+LOG_NAME="${0}:"
+
+hciattach_pid=""
+
+loge ()
+{
+ /system/bin/log -t $LOG_TAG -p e "$LOG_NAME $@"
+}
+
+logi ()
+{
+ /system/bin/log -t $LOG_TAG -p i "$LOG_NAME $@"
+}
+
+failed ()
+{
+ loge "$1: exit code $2"
+ exit $2
+}
+
+#
+# enable bluetooth profiles dynamically
+#
+config_bt ()
+{
+ baseband=`getprop ro.baseband`
+ target=`getprop ro.board.platform`
+ if [ -f /sys/devices/soc0/soc_id ]; then
+ soc_hwid=`cat /sys/devices/soc0/soc_id`
+ else
+ soc_hwid=`cat /sys/devices/system/soc/soc0/id`
+ fi
+ btsoc=`getprop qcom.bluetooth.soc`
+
+ case $baseband in
+ "apq")
+ setprop ro.qualcomm.bluetooth.opp true
+ setprop ro.qualcomm.bluetooth.ftp true
+ setprop ro.qualcomm.bluetooth.nap false
+ setprop ro.bluetooth.sap false
+ setprop ro.bluetooth.dun false
+ # For MPQ as baseband is same for both
+ case $soc_hwid in
+ "130")
+ setprop ro.qualcomm.bluetooth.hsp true
+ setprop ro.qualcomm.bluetooth.hfp true
+ setprop ro.qualcomm.bluetooth.pbap false
+ setprop ro.qualcomm.bluetooth.map false
+ ;;
+ *)
+ setprop ro.qualcomm.bluetooth.hsp false
+ setprop ro.qualcomm.bluetooth.hfp false
+ setprop ro.qualcomm.bluetooth.pbap true
+ setprop ro.qualcomm.bluetooth.map true
+ ;;
+ esac
+ ;;
+ "mdm" | "svlte2a" | "svlte1" | "csfb")
+ setprop ro.qualcomm.bluetooth.opp true
+ setprop ro.qualcomm.bluetooth.hfp true
+ setprop ro.qualcomm.bluetooth.hsp true
+ setprop ro.qualcomm.bluetooth.pbap true
+ setprop ro.qualcomm.bluetooth.ftp true
+ setprop ro.qualcomm.bluetooth.map true
+ setprop ro.qualcomm.bluetooth.nap true
+ setprop ro.bluetooth.sap true
+ case $target in
+ "apq8084")
+ setprop ro.bluetooth.dun true
+ logi "Enabling BT-DUN for APQ8084"
+ ;;
+ *)
+ setprop ro.bluetooth.dun false
+ ;;
+ esac
+ ;;
+ "msm")
+ setprop ro.qualcomm.bluetooth.opp true
+ setprop ro.qualcomm.bluetooth.hfp true
+ setprop ro.qualcomm.bluetooth.hsp true
+ setprop ro.qualcomm.bluetooth.pbap true
+ setprop ro.qualcomm.bluetooth.ftp true
+ setprop ro.qualcomm.bluetooth.nap true
+ setprop ro.bluetooth.sap true
+ setprop ro.bluetooth.dun true
+ case $btsoc in
+ "ath3k")
+ setprop ro.qualcomm.bluetooth.map false
+ ;;
+ *)
+ setprop ro.qualcomm.bluetooth.map true
+ ;;
+ esac
+ ;;
+ *)
+ setprop ro.qualcomm.bluetooth.opp true
+ setprop ro.qualcomm.bluetooth.hfp true
+ setprop ro.qualcomm.bluetooth.hsp true
+ setprop ro.qualcomm.bluetooth.pbap true
+ setprop ro.qualcomm.bluetooth.ftp true
+ setprop ro.qualcomm.bluetooth.map true
+ setprop ro.qualcomm.bluetooth.nap true
+ setprop ro.bluetooth.sap true
+ setprop ro.bluetooth.dun true
+ ;;
+ esac
+
+ #Enable Bluetooth Profiles specific to target Dynamically
+ case $target in
+ "msm8960")
+ if [ "$btsoc" != "ath3k" ] && [ "$soc_hwid" != "130" ]
+ then
+ setprop ro.bluetooth.hfp.ver 1.6
+ setprop ro.qualcomm.bt.hci_transport smd
+ fi
+ ;;
+ "msm8974" | "msm8226" | "msm8610" | "msm8916" | "msm8909" | "msm8952" )
+ if [ "$btsoc" != "ath3k" ]
+ then
+ setprop ro.bluetooth.hfp.ver 1.7
+ setprop ro.qualcomm.bt.hci_transport smd
+ fi
+ ;;
+ "apq8084" | "mpq8092" | "msm8994" | "msm8992" | "msm8996" )
+ if [ "$btsoc" != "rome" ]
+ then
+ setprop ro.qualcomm.bt.hci_transport smd
+ elif [ "$btsoc" = "rome" ]
+ then
+ setprop ro.bluetooth.hfp.ver 1.6
+ fi
+ ;;
+ *)
+ ;;
+ esac
+
+if [ -f /system/etc/bluetooth/stack.conf ]; then
+stack=`cat /system/etc/bluetooth/stack.conf`
+fi
+
+case "$stack" in
+ "bluez")
+ logi "Bluetooth stack is $stack"
+ setprop ro.qc.bluetooth.stack $stack
+ reason=`getprop vold.decrypt`
+ case "$reason" in
+ "trigger_restart_framework")
+ start dbus
+ ;;
+ esac
+ ;;
+ *)
+ logi "Bluetooth stack is Bluedroid"
+ ;;
+esac
+
+}
+
+start_hciattach ()
+{
+ /system/bin/hciattach -n $BTS_DEVICE $BTS_TYPE $BTS_BAUD &
+ hciattach_pid=$!
+ logi "start_hciattach: pid = $hciattach_pid"
+ echo 1 > $BLUETOOTH_SLEEP_PATH
+}
+
+kill_hciattach ()
+{
+ echo 0 > $BLUETOOTH_SLEEP_PATH
+ logi "kill_hciattach: pid = $hciattach_pid"
+ ## careful not to kill zero or null!
+ kill -TERM $hciattach_pid
+ # this shell doesn't exit now -- wait returns for normal exit
+}
+
+logi "init.qcom.bt.sh config = $config"
+case "$config" in
+ "onboot")
+ config_bt
+ exit 0
+ ;;
+ *)
+ ;;
+esac
+
+# mimic hciattach options parsing -- maybe a waste of effort
+USAGE="hciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] <tty> <type | id> [speed] [flow|noflow] [bdaddr]"
+
+while getopts "blnpt:s:" f
+do
+ case $f in
+ b | l | n | p) opt_flags="$opt_flags -$f" ;;
+ t) timeout=$OPTARG;;
+ s) initial_speed=$OPTARG;;
+ \?) echo $USAGE; exit 1;;
+ esac
+done
+shift $(($OPTIND-1))
+
+# Note that "hci_qcomm_init -e" prints expressions to set the shell variables
+# BTS_DEVICE, BTS_TYPE, BTS_BAUD, and BTS_ADDRESS.
+
+#Selectively Disable sleep
+BOARD=`getprop ro.board.platform`
+STACK=`getprop ro.qc.bluetooth.stack`
+
+# BR/EDR & LE power class configurations
+POWER_CLASS=`getprop qcom.bt.dev_power_class`
+LE_POWER_CLASS=`getprop qcom.bt.le_dev_pwr_class`
+
+#find the transport type
+TRANSPORT=`getprop ro.qualcomm.bt.hci_transport`
+logi "Transport : $TRANSPORT"
+case $STACK in
+ "bluez")
+ logi "** Bluez stack **"
+ ;;
+ *)
+ logi "** Bluedroid stack **"
+ setprop bluetooth.status off
+ ;;
+esac
+
+
+case $POWER_CLASS in
+ 1) PWR_CLASS="-p 0" ;
+ logi "Power Class: 1";;
+ 2) PWR_CLASS="-p 1" ;
+ logi "Power Class: 2";;
+ 3) PWR_CLASS="-p 2" ;
+ logi "Power Class: CUSTOM";;
+ *) PWR_CLASS="";
+ logi "Power Class: Ignored. Default(1) used (1-CLASS1/2-CLASS2/3-CUSTOM)";
+ logi "Power Class: To override, Before turning BT ON; setprop qcom.bt.dev_power_class <1 or 2 or 3>";;
+esac
+
+case $LE_POWER_CLASS in
+ 1) LE_PWR_CLASS="-P 0" ;
+ logi "LE Power Class: 1";;
+ 2) LE_PWR_CLASS="-P 1" ;
+ logi "LE Power Class: 2";;
+ 3) LE_PWR_CLASS="-P 2" ;
+ logi "LE Power Class: CUSTOM";;
+ *) LE_PWR_CLASS="-P 1";
+ logi "LE Power Class: Ignored. Default(2) used (1-CLASS1/2-CLASS2/3-CUSTOM)";
+ logi "LE Power Class: To override, Before turning BT ON; setprop qcom.bt.le_dev_pwr_class <1 or 2 or 3>";;
+esac
+
+eval $(/system/bin/hci_qcomm_init -e $PWR_CLASS $LE_PWR_CLASS && echo "exit_code_hci_qcomm_init=0" || echo "exit_code_hci_qcomm_init=1")
+
+case $exit_code_hci_qcomm_init in
+ 0) logi "Bluetooth QSoC firmware download succeeded, $BTS_DEVICE $BTS_TYPE $BTS_BAUD $BTS_ADDRESS";;
+ *) failed "Bluetooth QSoC firmware download failed" $exit_code_hci_qcomm_init;
+ case $STACK in
+ "bluez")
+ logi "** Bluez stack **"
+ ;;
+ *)
+ logi "** Bluedroid stack **"
+ setprop bluetooth.status off
+ ;;
+ esac
+
+ exit $exit_code_hci_qcomm_init;;
+esac
+
+# init does SIGTERM on ctl.stop for service
+trap "kill_hciattach" TERM INT
+
+case $TRANSPORT in
+ "smd")
+ case $STACK in
+ "bluez")
+ logi "** Bluez stack **"
+ echo 1 > /sys/module/hci_smd/parameters/hcismd_set
+ ;;
+ *)
+ logi "** Bluedroid stack **"
+ setprop bluetooth.status on
+ ;;
+ esac
+ ;;
+ *)
+ logi "start hciattach"
+ start_hciattach
+ case $STACK in
+ "bluez")
+ logi "Bluetooth is turning On with Bluez stack "
+ ;;
+ *)
+ logi "** Bluedroid stack **"
+ setprop bluetooth.status on
+ ;;
+ esac
+
+ wait $hciattach_pid
+ logi "Bluetooth stopped"
+ ;;
+esac
+
+exit 0
diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc
index 9bfec3a..94d3d54 100755
--- a/rootdir/etc/init.qcom.rc
+++ b/rootdir/etc/init.qcom.rc
@@ -686,7 +686,7 @@ service tlocd /system/bin/tloc_daemon
user system
group drmrpc gps net_raw
-service readmac /system/bin/readmac
+service readmac /system/vendor/bin/readmac
class main
user root
group root
@@ -706,7 +706,7 @@ service mdtpd /system/vendor/bin/mdtpd
service qcomsysd /system/bin/qcom-system-daemon
class main
user root
- group root diag
+ group root oem_2901
service ssr_setup /system/bin/ssr_setup
oneshot
@@ -790,6 +790,12 @@ service cnd /system/bin/cnd
group root wakelock
writepid /dev/cpuset/system-background/tasks
+service dpmd /system/bin/dpmd
+ class late_start
+ socket dpmd stream 660 root system
+ group system readproc
+ writepid /dev/cpuset/system-background/tasks
+
service irsc_util /system/bin/irsc_util "/etc/sec_config"
class core
user root
@@ -815,16 +821,63 @@ on property:wc_transport.start_hci=false
service start_hci_filter /system/bin/wcnss_filter
class late_start
user bluetooth
- group bluetooth diag system wakelock
- seclabel u:r:bluetooth:s0
+ group bluetooth oem_2901
+ disabled
+on property:wc_transport.start_root=true
+ start hci_filter_root
+
+on property:wc_transport.start_root=false
+ stop hci_filter_root
+
+service hci_filter_root /system/bin/wcnss_filter
+ class late_start
+ user bluetooth
+ group bluetooth diag system
disabled
+service config_bt_addr /system/bin/btnvtool -O
+ class core
+ user bluetooth
+ group bluetooth radio
+ oneshot
+
+on property:wc_transport.start_root=true
+ start hci_filter_root
+
+on property:wc_transport.start_root=false
+ stop hci_filter_root
+
+service hci_filter_root /system/bin/wcnss_filter
+ class late_start
+ user bluetooth
+ group bluetooth oem_2901 system
+ disabled
+
+service config_bluetooth /system/bin/sh /system/etc/init.qcom.bt.sh "onboot"
+ class core
+ user root
+ oneshot
+
+service hciattach /system/bin/sh /system/etc/init.qcom.bt.sh
+ class late_start
+ user bluetooth
+ group bluetooth net_bt_admin
+ disabled
+ oneshot
+
on property:bluetooth.hciattach=true
start hciattach
on property:bluetooth.hciattach=false
setprop bluetooth.status off
+service hciattach_ath3k /system/bin/sh /system/etc/init.ath3k.bt.sh
+ class late_start
+ user bluetooth
+ group system bluetooth net_bt_admin misc
+ disabled
+ oneshot
+
service bt-dun /system/bin/dun-server /dev/smd7 /dev/rfcomm0
class late_start
user bluetooth
@@ -849,27 +902,33 @@ service btsnoop /system/bin/btsnoop
service ftmd /system/bin/logwrapper /system/bin/ftmdaemon
class late_start
user root
- group bluetooth net_bt_admin misc net_bt_stack diag net_bt
+ group bluetooth net_bt_admin misc net_bt_stack oem_2901 net_bt
disabled
oneshot
+service bridgemgrd /system/bin/bridgemgrd
+ class late_start
+ user radio
+ group radio oem_2901
+ disabled
+
service port-bridge /system/bin/port-bridge
class main
- user radio system
+ user radio
group radio system inet
oneshot
service qmiproxy /system/bin/qmiproxy
class main
user radio
- group radio diag
+ group radio oem_2901
disabled
# QMUX must be in multiple groups to support external process connections
service qmuxd /system/bin/qmuxd
class main
user root
- group radio audio bluetooth gps nfc diag
+ group radio audio bluetooth gps nfc oem_2901 wakelock
writepid /dev/cpuset/system-background/tasks
service netmgrd /system/bin/netmgrd
@@ -879,22 +938,20 @@ service netmgrd /system/bin/netmgrd
service ipacm-diag /system/bin/ipacm-diag
class main
- user radio
- socket ipacm_log_file dgram 660 radio radio
- group radio diag
- disabled
+ user system
+ socket ipacm_log_file dgram 660 system net_admin
+ group net_admin oem_2901
service ipacm /system/vendor/bin/ipacm
class main
- user radio
- group radio inet
- disabled
+ user net_admin
+ group net_admin inet
writepid /dev/cpuset/system-background/tasks
service qti /system/vendor/bin/qti
class main
user radio
- group radio net_raw diag usb net_admin
+ group radio net_raw oem_2901 usb net_admin
writepid /dev/cpuset/system-background/tasks
service sensors /system/bin/sensors.qcom
@@ -915,6 +972,13 @@ on property:ro.data.large_tcp_window_size=true
on property:sys.sysctl.tcp_adv_win_scale=*
write /proc/sys/net/ipv4/tcp_adv_win_scale ${sys.sysctl.tcp_adv_win_scale}
+service btwlancoex /system/bin/sh /system/etc/init.qcom.coex.sh
+ class late_start
+ user bluetooth
+ group bluetooth net_bt_admin inet net_admin net_raw
+ disabled
+ oneshot
+
service amp_init /system/bin/amploader -i
class late_start
user root
@@ -984,9 +1048,16 @@ on property:sys.shutdown.requested=*
service loc_launcher /system/bin/loc_launcher
# loc_launcher will start as root and set its uid to gps
class late_start
- group gps inet diag wifi
+ group gps inet oem_2901 wifi
writepid /dev/cpuset/system-background/tasks
+service fm_dl /system/bin/sh /system/etc/init.qcom.fm.sh
+ class late_start
+ user system
+ group system
+ disabled
+ oneshot
+
service drmdiag /system/bin/drmdiagapp
class late_start
user root
@@ -998,6 +1069,12 @@ on property:drmdiag.load=1
on property:drmdiag.load=0
stop drmdiag
+service config-zram /system/bin/sh /system/etc/init.qcom.zram.sh
+ class late_start
+ user root
+ disabled
+ oneshot
+
on property:sys.boot_completed=1
start config-zram
@@ -1034,12 +1111,16 @@ service battery_monitor /system/bin/battery_monitor
service ril-daemon2 /vendor/bin/hw/rild -c 2
class main
- socket rild2 stream 660 root radio
- socket rild-debug2 stream 660 radio system
user radio
- group radio cache inet misc audio sdcard_r sdcard_rw diag oem_2901 log
+ group radio cache inet misc audio log oem_2901 net_raw wifi compass
capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
+service usb_uicc_enable /system/bin/sh /system/etc/init.qcom.uicc.sh
+ class late_start
+ user root
+ disabled
+ oneshot
+
service usb_uicc_daemon /system/bin/usb_uicc_client
class main
user system
@@ -1058,6 +1139,12 @@ service profiler_daemon /system/bin/profiler_daemon
group root
disabled
+service hcidump /system/bin/sh /system/etc/hcidump.sh
+ user bluetooth
+ group bluetooth system net_bt_admin net_admin
+ disabled
+ oneshot
+
service charger /charger
class charger
group system graphics
@@ -1096,17 +1183,17 @@ on property:sys.qbcharger.enable=true
on property:sys.qbcharger.enable=false
stop qbcharger
-service diag_mdlog_start /system/bin/diag_mdlog
+service diag_mdlog_start /system/bin/diag_mdlog -c
class late_start
user shell
- group system diag sdcard_rw sdcard_r media_rw
+ group system oem_2901 sdcard_rw sdcard_r media_rw
disabled
oneshot
service diag_mdlog_stop /system/bin/diag_mdlog -k
class late_start
user shell
- group system diag sdcard_rw sdcard_r media_rw
+ group system oem_2901 sdcard_rw sdcard_r media_rw
disabled
oneshot
@@ -1129,6 +1216,18 @@ service wfdservice /system/bin/wfdservice
# removed these because of limit of 12 groups
#graphics net_bt net_bt_admin bluetooth
+# Coresight early boot service
+service cs-early-boot /system/bin/sh /persist/coresight/qdss.agent.sh early-boot /system/etc/init.qcom.debug.sh
+ class core
+ user root
+ oneshot
+
+# Coresight post boot servive
+service cs-post-boot /system/bin/sh /persist/coresight/qdss.agent.sh
+ user root
+ disabled
+ oneshot
+
on property:sys.boot_completed=1
start cs-post-boot
diff --git a/rootdir/etc/init.qcom.usb.rc b/rootdir/etc/init.qcom.usb.rc
index 6a92054..da54d40 100755
--- a/rootdir/etc/init.qcom.usb.rc
+++ b/rootdir/etc/init.qcom.usb.rc
@@ -38,6 +38,11 @@ on fs
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
write /sys/class/android_usb/android0/f_ffs/aliases adb
+service qcom-usb-sh /system/bin/sh /init.qcom.usb.sh
+ class core
+ user root
+ oneshot
+
# Following are the parameters required for usb functionality. They provide configurable options like
# product_id/vendor id and allows specifying required functions:
#
diff --git a/rootdir/etc/init.qcom.usb.sh b/rootdir/etc/init.qcom.usb.sh
new file mode 100755
index 0000000..e0e6f1d
--- /dev/null
+++ b/rootdir/etc/init.qcom.usb.sh
@@ -0,0 +1,280 @@
+#!/system/bin/sh
+# Copyright (c) 2012, The Linux Foundation. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+# * Neither the name of The Linux Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+chown -h root.system /sys/devices/platform/msm_hsusb/gadget/wakeup
+chmod -h 220 /sys/devices/platform/msm_hsusb/gadget/wakeup
+
+# Set platform variables
+if [ -f /sys/devices/soc0/hw_platform ]; then
+ soc_hwplatform=`cat /sys/devices/soc0/hw_platform` 2> /dev/null
+else
+ soc_hwplatform=`cat /sys/devices/system/soc/soc0/hw_platform` 2> /dev/null
+fi
+
+# Get hardware revision
+if [ -f /sys/devices/soc0/revision ]; then
+ soc_revision=`cat /sys/devices/soc0/revision` 2> /dev/null
+else
+ soc_revision=`cat /sys/devices/system/soc/soc0/revision` 2> /dev/null
+fi
+
+#
+# Allow persistent usb charging disabling
+# User needs to set usb charging disabled in persist.usb.chgdisabled
+#
+target=`getprop ro.board.platform`
+usbchgdisabled=`getprop persist.usb.chgdisabled`
+case "$usbchgdisabled" in
+ "") ;; #Do nothing here
+ * )
+ case $target in
+ "msm8660")
+ echo "$usbchgdisabled" > /sys/module/pmic8058_charger/parameters/disabled
+ echo "$usbchgdisabled" > /sys/module/smb137b/parameters/disabled
+ ;;
+ "msm8960")
+ echo "$usbchgdisabled" > /sys/module/pm8921_charger/parameters/disabled
+ ;;
+ esac
+esac
+
+usbcurrentlimit=`getprop persist.usb.currentlimit`
+case "$usbcurrentlimit" in
+ "") ;; #Do nothing here
+ * )
+ case $target in
+ "msm8960")
+ echo "$usbcurrentlimit" > /sys/module/pm8921_charger/parameters/usb_max_current
+ ;;
+ esac
+esac
+
+#
+# Check ESOC for external MDM
+#
+# Note: currently only a single MDM is supported
+#
+if [ -d /sys/bus/esoc/devices ]; then
+for f in /sys/bus/esoc/devices/*; do
+ if [ -d $f ]; then
+ if [ `grep "^MDM" $f/esoc_name` ]; then
+ esoc_link=`cat $f/esoc_link`
+ break
+ fi
+ fi
+done
+fi
+
+target=`getprop ro.board.platform`
+
+#ifdef VENDOR_EDIT
+boot_mode=`getprop ro.boot.ftm_mode`
+echo "boot_mode: $boot_mode" > /dev/kmsg
+case "$boot_mode" in
+ "ftm_at" | "ftm_rf" | "ftm_wlan" | "ftm_mos")
+ usb_config=`getprop persist.sys.usb.config`
+ echo "BEFORE boot_mode: $usb_config" > /dev/kmsg
+ if [ "$usb_config" != "diag,adb" ] ; then
+ setprop persist.sys.usb.config diag,adb
+ fi
+ ;;
+esac
+usb_config=`getprop persist.sys.usb.config`
+echo "AFTER boot_mode: $usb_config" > /dev/kmsg
+#endif
+
+#
+# Allow USB enumeration with default PID/VID
+#
+baseband=`getprop ro.baseband`
+echo 1 > /sys/class/android_usb/f_mass_storage/lun/nofua
+usb_config=`getprop persist.sys.usb.config`
+echo "BEFORE: $usb_config" > /dev/kmsg
+case "$usb_config" in
+ "" | "adb" | "none") #USB persist config not set, select default configuration
+ case "$esoc_link" in
+ "PCIe")
+ setprop persist.sys.usb.config diag,diag_mdm,serial_cdev,rmnet_qti_ether,mass_storage,adb
+ ;;
+ *)
+ case "$soc_hwplatform" in
+ "Dragon")
+ setprop persist.sys.usb.config diag,adb
+ ;;
+ *)
+ case "$target" in
+ "msm8916")
+ setprop persist.sys.usb.config diag,serial_smd,rmnet_bam,adb
+ ;;
+ "msm8994" | "msm8992")
+ if [ "$soc_hwplatform" == "Dragon" ]; then
+ setprop persist.sys.usb.config diag,adb
+ else
+ setprop persist.sys.usb.config diag,serial_smd,serial_tty,rmnet_ipa,mass_storage,adb
+ fi
+ ;;
+ "msm8996")
+ if [ "$soc_revision" == "1.0" -o "$soc_hwplatform" == "Dragon" ]
+ then
+ setprop persist.sys.usb.config diag,adb
+ #[BSP-66]-Anderson-Disable_set_the_property.
+ #This will ause BSP-66 issue and cause all the port enable in default.
+ #else
+ #setprop persist.sys.usb.config diag,serial_cdev,serial_tty,rmnet_ipa,mass_storage,adb
+ fi
+ ;;
+ "msm8909" | "msm8937")
+ setprop persist.sys.usb.config diag,serial_smd,rmnet_qti_bam,adb
+ ;;
+ "msm8952" | "titanium")
+ setprop persist.sys.usb.config diag,serial_smd,rmnet_ipa,adb
+ ;;
+ *)
+ setprop persist.sys.usb.config diag,adb
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ * ) ;; #USB persist config exists, do nothing
+esac
+
+
+
+#
+# Do target specific things
+#
+case "$target" in
+ "msm8974")
+# Select USB BAM - 2.0 or 3.0
+ echo ssusb > /sys/bus/platform/devices/usb_bam/enable
+ ;;
+ "apq8084")
+ if [ "$baseband" == "apq" ]; then
+ echo "msm_hsic_host" > /sys/bus/platform/drivers/xhci_msm_hsic/unbind
+ fi
+ ;;
+ "msm8226")
+ if [ -e /sys/bus/platform/drivers/msm_hsic_host ]; then
+ if [ ! -L /sys/bus/usb/devices/1-1 ]; then
+ echo msm_hsic_host > /sys/bus/platform/drivers/msm_hsic_host/unbind
+ fi
+ fi
+ ;;
+ "msm8994" | "msm8992" | "msm8996" | "titanium")
+ echo BAM2BAM_IPA > /sys/class/android_usb/android0/f_rndis_qc/rndis_transports
+ echo 131072 > /sys/module/g_android/parameters/mtp_tx_req_len
+ echo 131072 > /sys/module/g_android/parameters/mtp_rx_req_len
+ ;;
+esac
+
+#
+# set module params for embedded rmnet devices
+#
+rmnetmux=`getprop persist.rmnet.mux`
+case "$baseband" in
+ "mdm" | "dsda" | "sglte2")
+ case "$rmnetmux" in
+ "enabled")
+ echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled
+ echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
+ echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
+ ;;
+ esac
+ echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init
+ # Allow QMUX daemon to assign port open wait time
+ chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
+ ;;
+ "dsda2")
+ echo 2 > /sys/module/rmnet_usb/parameters/no_rmnet_devs
+ echo hsicctl,hsusbctl > /sys/module/rmnet_usb/parameters/rmnet_dev_names
+ case "$rmnetmux" in
+ "enabled") #mux is neabled on both mdms
+ echo 3 > /sys/module/rmnet_usb/parameters/mux_enabled
+ echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
+ echo 17 > write /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
+ ;;
+ "enabled_hsic") #mux is enabled on hsic mdm
+ echo 1 > /sys/module/rmnet_usb/parameters/mux_enabled
+ echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
+ echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
+ ;;
+ "enabled_hsusb") #mux is enabled on hsusb mdm
+ echo 2 > /sys/module/rmnet_usb/parameters/mux_enabled
+ echo 8 > /sys/module/rmnet_usb/parameters/no_fwd_rmnet_links
+ echo 17 > /sys/module/rmnet_usb/parameters/no_rmnet_insts_per_dev
+ ;;
+ esac
+ echo 1 > /sys/module/rmnet_usb/parameters/rmnet_data_init
+ # Allow QMUX daemon to assign port open wait time
+ chown -h radio.radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
+ ;;
+esac
+
+#
+# Add support for exposing lun0 as cdrom in mass-storage
+#
+cdromname="/system/etc/cdrom_install.iso"
+platformver=`cat /sys/devices/soc0/hw_platform`
+case "$target" in
+ "msm8226" | "msm8610" | "msm8916")
+ case $platformver in
+ "QRD")
+ echo "mounting usbcdrom lun"
+ echo $cdromname > /sys/class/android_usb/android0/f_mass_storage/rom/file
+ chmod 0444 /sys/class/android_usb/android0/f_mass_storage/rom/file
+ ;;
+ esac
+ ;;
+esac
+
+#
+# Initialize RNDIS Diag option. If unset, set it to 'none'.
+#
+diag_extra=`getprop persist.sys.usb.config.extra`
+if [ "$diag_extra" == "" ]; then
+ setprop persist.sys.usb.config.extra none
+fi
+
+# soc_ids for 8937
+if [ -f /sys/devices/soc0/soc_id ]; then
+ soc_id=`cat /sys/devices/soc0/soc_id`
+else
+ soc_id=`cat /sys/devices/system/soc/soc0/id`
+fi
+
+# enable rps cpus on msm8937 target
+setprop sys.usb.rps_mask 0
+case "$soc_id" in
+ "294" | "295")
+ setprop sys.usb.rps_mask 10
+ ;;
+esac