init.qcom.usb.sh 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. #
  30. # Changes from Qualcomm Innovation Center are provided under the following license:
  31. # Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  32. #
  33. # Redistribution and use in source and binary forms, with or without
  34. # modification, are permitted provided that the following conditions are
  35. # met:
  36. # * Redistributions of source code must retain the above copyright
  37. # notice, this list of conditions and the following disclaimer.
  38. # * Redistributions in binary form must reproduce the above
  39. # copyright notice, this list of conditions and the following
  40. # disclaimer in the documentation and/or other materials provided
  41. # with the distribution.
  42. # * Neither the name of The Linux Foundation nor the names of its
  43. # contributors may be used to endorse or promote products derived
  44. # from this software without specific prior written permission.
  45. #
  46. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  47. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  48. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  49. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  50. # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  51. # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  52. # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  53. # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  54. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  55. # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  56. # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  57. #
  58. # Set platform variables
  59. soc_hwplatform=`cat /sys/devices/soc0/hw_platform 2> /dev/null`
  60. soc_machine=`cat /sys/devices/soc0/machine 2> /dev/null`
  61. soc_machine=${soc_machine:0:2}
  62. soc_id=`cat /sys/devices/soc0/soc_id 2> /dev/null`
  63. #
  64. # Check ESOC for external modem
  65. #
  66. # Note: currently only a single MDM/SDX is supported
  67. #
  68. esoc_name=`cat /sys/bus/esoc/devices/esoc0/esoc_name 2> /dev/null`
  69. target=`getprop ro.board.platform`
  70. #
  71. # Override USB default composition
  72. #
  73. # If USB persist config not set, set default configuration
  74. if [ "$(getprop persist.vendor.usb.config)" == "" -a "$(getprop ro.build.type)" != "user" ]; then
  75. if [ "$esoc_name" != "" ]; then
  76. setprop persist.vendor.usb.config diag,diag_mdm,qdss,qdss_mdm,serial_cdev,dpl,rmnet,adb
  77. else
  78. case "$(getprop ro.baseband)" in
  79. "apq")
  80. if [ "$target" == "neo" ] || [ "$target" == "anorak" ]; then
  81. setprop persist.vendor.usb.config diag,qdss,adb
  82. else
  83. setprop persist.vendor.usb.config diag,adb
  84. fi
  85. ;;
  86. *)
  87. case "$soc_hwplatform" in
  88. "Dragon" | "SBC")
  89. setprop persist.vendor.usb.config diag,adb
  90. ;;
  91. *)
  92. case "$soc_machine" in
  93. "SA")
  94. setprop persist.vendor.usb.config diag,adb
  95. ;;
  96. *)
  97. case "$target" in
  98. "msm8996")
  99. setprop persist.vendor.usb.config diag,serial_cdev,serial_tty,rmnet_ipa,mass_storage,adb
  100. ;;
  101. "msm8909")
  102. setprop persist.vendor.usb.config diag,serial_smd,rmnet_qti_bam,adb
  103. ;;
  104. "msm8937")
  105. if [ -d /config/usb_gadget ]; then
  106. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  107. else
  108. case "$soc_id" in
  109. "313" | "320")
  110. setprop persist.vendor.usb.config diag,serial_smd,rmnet_ipa,adb
  111. ;;
  112. *)
  113. setprop persist.vendor.usb.config diag,serial_smd,rmnet_qti_bam,adb
  114. ;;
  115. esac
  116. fi
  117. ;;
  118. "msm8953")
  119. if [ -d /config/usb_gadget ]; then
  120. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  121. else
  122. setprop persist.vendor.usb.config diag,serial_smd,rmnet_ipa,adb
  123. fi
  124. ;;
  125. "msm8998" | "sdm660" | "apq8098_latv")
  126. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,adb
  127. ;;
  128. "sdm845" | "sdm710")
  129. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  130. ;;
  131. "msmnile" | "sm6150" | "trinket" | "lito" | "atoll" | "bengal" | "lahaina" | "holi" | "taro" | "parrot" | "ravelin")
  132. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,qdss,adb
  133. ;;
  134. *)
  135. setprop persist.vendor.usb.config diag,adb
  136. ;;
  137. esac
  138. ;;
  139. esac
  140. ;;
  141. esac
  142. ;;
  143. esac
  144. fi
  145. fi
  146. # This check is needed for GKI 1.0 targets where QDSS is not available
  147. if [ "$(getprop persist.vendor.usb.config)" == "diag,serial_cdev,rmnet,dpl,qdss,adb" -a \
  148. ! -d /config/usb_gadget/g1/functions/qdss.qdss ]; then
  149. setprop persist.vendor.usb.config diag,serial_cdev,rmnet,dpl,adb
  150. fi
  151. # Start peripheral mode on primary USB controllers for Automotive platforms
  152. case "$soc_machine" in
  153. "SA")
  154. if [ -f /sys/bus/platform/devices/a600000.ssusb/mode ]; then
  155. default_mode=`cat /sys/bus/platform/devices/a600000.ssusb/mode`
  156. case "$default_mode" in
  157. "none")
  158. echo peripheral > /sys/bus/platform/devices/a600000.ssusb/mode
  159. ;;
  160. esac
  161. fi
  162. ;;
  163. esac
  164. # check configfs is mounted or not
  165. if [ -d /config/usb_gadget ]; then
  166. # Chip-serial is used for unique MSM identification in Product string
  167. msm_serial=`cat /sys/devices/soc0/serial_number`;
  168. # If MSM serial number is not available, then keep it blank instead of 0x00000000
  169. if [ "$msm_serial" != "" ]; then
  170. msm_serial_hex=`printf %08X $msm_serial`
  171. fi
  172. machine_type=`cat /sys/devices/soc0/machine`
  173. setprop vendor.usb.product_string "$machine_type-$soc_hwplatform _SN:$msm_serial_hex"
  174. # ADB requires valid iSerialNumber; if ro.serialno is missing, use dummy
  175. serialnumber=`cat /config/usb_gadget/g1/strings/0x409/serialnumber 2> /dev/null`
  176. if [ "$serialnumber" == "" ]; then
  177. serialno=1234567
  178. echo $serialno > /config/usb_gadget/g1/strings/0x409/serialnumber
  179. fi
  180. setprop vendor.usb.configfs 1
  181. fi
  182. # update product
  183. marketname=`getprop ro.product.marketname`
  184. if [ "$marketname" != "" ]; then
  185. setprop vendor.usb.product_string "$marketname"
  186. else
  187. setprop vendor.usb.product_string "$(getprop ro.product.model)"
  188. fi
  189. #
  190. # Initialize RNDIS Diag option. If unset, set it to 'none'.
  191. #
  192. diag_extra=`getprop persist.vendor.usb.config.extra`
  193. if [ "$diag_extra" == "" ]; then
  194. setprop persist.vendor.usb.config.extra none
  195. fi
  196. # enable rps cpus on msm8937 target
  197. setprop vendor.usb.rps_mask 0
  198. case "$soc_id" in
  199. "294" | "295" | "353" | "354")
  200. setprop vendor.usb.rps_mask 40
  201. ;;
  202. esac
  203. #
  204. # Initialize UVC conifguration.
  205. #
  206. if [ -d /config/usb_gadget/g1/functions/uvc.0 ]; then
  207. setprop vendor.usb.uvc.function.init 1
  208. fi
  209. # enable ncm
  210. case "$target" in
  211. "neo" | "anorak")
  212. if [ -d /config/usb_gadget/g1/functions/ncm.0 ]; then
  213. cd /config/usb_gadget/g1/functions/ncm.0
  214. echo WINNCM > os_desc/interface.ncm/compatible_id
  215. fi
  216. ;;
  217. esac