init.qcom.usb.sh 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #!/vendor/bin/sh
  2. # Copyright (c) 2012-2018, 2020-2021 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. # Changes from Qualcomm Innovation Center are provided under the following license:
  30. # Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  31. # SPDX-License-Identifier: BSD-3-Clause-Clear
  32. #
  33. # Set platform variables
  34. soc_hwplatform=`cat /sys/devices/soc0/hw_platform 2> /dev/null`
  35. soc_machine=`cat /sys/devices/soc0/machine 2> /dev/null`
  36. soc_machine=${soc_machine:0:2}
  37. soc_id=`cat /sys/devices/soc0/soc_id 2> /dev/null`
  38. #
  39. # Check ESOC for external modem
  40. #
  41. # Note: currently only a single MDM/SDX is supported
  42. #
  43. esoc_name=`cat /sys/bus/esoc/devices/esoc0/esoc_name 2> /dev/null`
  44. target=`getprop ro.board.platform`
  45. #
  46. # Override USB default composition
  47. #
  48. if [ "$(getprop ro.build.type)" != "user" ]; then
  49. # If USB persist config not set, set default configuration
  50. if [ "$(getprop persist.vendor.usb.config)" == "" ]; then
  51. if [ "$esoc_name" != "" ]; then
  52. setprop persist.vendor.usb.config diag,diag_mdm,qdss,qdss_mdm,serial_cdev,dpl,rmnet,adb
  53. else
  54. case "$(getprop ro.baseband)" in
  55. "apq")
  56. setprop persist.vendor.usb.config diag,adb
  57. ;;
  58. *)
  59. case "$soc_hwplatform" in
  60. "Dragon" | "SBC")
  61. setprop persist.vendor.usb.config diag,adb
  62. ;;
  63. *)
  64. case "$soc_machine" in
  65. "SA")
  66. setprop persist.vendor.usb.config diag,adb
  67. ;;
  68. *)
  69. case "$target" in
  70. "msm8996")
  71. setprop persist.vendor.usb.config diag,serial_cdev,serial_tty,rmnet_ipa,mass_storage,adb
  72. ;;
  73. "msm8909")
  74. setprop persist.vendor.usb.config diag,serial_smd,rmnet_qti_bam,adb
  75. ;;
  76. "msm8937")
  77. if [ -d /config/usb_gadget ]; then
  78. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  79. else
  80. case "$soc_id" in
  81. "313" | "320")
  82. setprop persist.vendor.usb.config diag,serial_smd,rmnet_ipa,adb
  83. ;;
  84. *)
  85. setprop persist.vendor.usb.config diag,serial_smd,rmnet_qti_bam,adb
  86. ;;
  87. esac
  88. fi
  89. ;;
  90. "msm8953")
  91. if [ -d /config/usb_gadget ]; then
  92. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  93. else
  94. setprop persist.vendor.usb.config diag,serial_smd,rmnet_ipa,adb
  95. fi
  96. ;;
  97. "msm8998" | "sdm660" | "apq8098_latv")
  98. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,adb
  99. ;;
  100. "sdm845" | "sdm710")
  101. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  102. ;;
  103. "msmnile" | "sm6150" | "trinket" | "lito" | "atoll" | "bengal" | "lahaina" | "holi" | \
  104. "taro" | "kalama" | "pineapple" | "blair")
  105. setprop persist.vendor.usb.config diag,adb
  106. # setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,qdss,adb
  107. ;;
  108. "gen4")
  109. setprop persist.vendor.usb.config adb
  110. ;;
  111. *)
  112. setprop persist.vendor.usb.config diag,adb
  113. ;;
  114. esac
  115. ;;
  116. esac
  117. ;;
  118. esac
  119. ;;
  120. esac
  121. fi
  122. fi
  123. else # for user build let persist.sys.usb.config dictate the default composition
  124. setprop persist.vendor.usb.config ""
  125. fi
  126. # This check is needed for GKI 1.0 targets where QDSS is not available
  127. if [ "$(getprop persist.vendor.usb.config)" == "diag,serial_cdev,rmnet,dpl,qdss,adb" -a \
  128. ! -d /config/usb_gadget/g1/functions/qdss.qdss ]; then
  129. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  130. fi
  131. # Start peripheral mode on primary USB controllers for Automotive platforms
  132. case "$soc_machine" in
  133. "SA")
  134. if [ -f /sys/bus/platform/devices/a600000.ssusb/mode ]; then
  135. default_mode=`cat /sys/bus/platform/devices/a600000.ssusb/mode`
  136. case "$default_mode" in
  137. "none")
  138. echo peripheral > /sys/bus/platform/devices/a600000.ssusb/mode
  139. ;;
  140. esac
  141. fi
  142. ;;
  143. esac
  144. # check configfs is mounted or not
  145. if [ -d /config/usb_gadget ]; then
  146. machine_type=`cat /sys/devices/soc0/machine`
  147. # Chip ID & serial are used for unique MSM identification in Product String
  148. # If not present, then omit them instead of using 0x00000000
  149. msm_chipid=`cat /sys/devices/soc0/nproduct_id`;
  150. if [ "$msm_chipid" != "" ]; then
  151. msm_chipid_hex=`printf _CID:%04X $msm_chipid`
  152. fi
  153. msm_serial=`cat /sys/devices/soc0/serial_number`;
  154. if [ "$msm_serial" != "" ]; then
  155. msm_serial_hex=`printf _SN:%08X $msm_serial`
  156. fi
  157. setprop vendor.usb.product_string "$machine_type-$soc_hwplatform$msm_chipid_hex$msm_serial_hex"
  158. # ADB requires valid iSerialNumber; if ro.serialno is missing, use dummy
  159. serialnumber=`cat /config/usb_gadget/g1/strings/0x409/serialnumber 2> /dev/null`
  160. if [ "$serialnumber" == "" ]; then
  161. serialno=1234567
  162. echo $serialno > /config/usb_gadget/g1/strings/0x409/serialnumber
  163. fi
  164. setprop vendor.usb.configfs 1
  165. fi
  166. #
  167. # Initialize RNDIS Diag option. If unset, set it to 'none'.
  168. #
  169. diag_extra=`getprop persist.vendor.usb.config.extra`
  170. if [ "$diag_extra" == "" ]; then
  171. setprop persist.vendor.usb.config.extra none
  172. fi
  173. # enable rps cpus on msm8937 target
  174. setprop vendor.usb.rps_mask 0
  175. case "$soc_id" in
  176. "294" | "295" | "353" | "354")
  177. setprop vendor.usb.rps_mask 40
  178. ;;
  179. esac
  180. #
  181. # Initialize UVC conifguration.
  182. #
  183. if [ -d /config/usb_gadget/g1/functions/uvc.0 ]; then
  184. setprop vendor.usb.uvc.function.init 1
  185. fi