init.qcom.sh 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. #! /vendor/bin/sh
  2. # Copyright (c) 2009-2016, 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 met:
  6. # * Redistributions of source code must retain the above copyright
  7. # notice, this list of conditions and the following disclaimer.
  8. # * Redistributions in binary form must reproduce the above copyright
  9. # notice, this list of conditions and the following disclaimer in the
  10. # documentation and/or other materials provided with the distribution.
  11. # * Neither the name of The Linux Foundation nor
  12. # the names of its contributors may be used to endorse or promote
  13. # products derived from this software without specific prior written
  14. # permission.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  25. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  26. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. #
  28. target=`getprop ro.board.platform`
  29. low_ram=`getprop ro.config.low_ram`
  30. if [ -f /sys/devices/soc0/soc_id ]; then
  31. platformid=`cat /sys/devices/soc0/soc_id`
  32. else
  33. platformid=`cat /sys/devices/system/soc/soc0/id`
  34. fi
  35. start_battery_monitor()
  36. {
  37. if ls /sys/bus/spmi/devices/qpnp-bms-*/fcc_data ; then
  38. chown -h root.system /sys/module/pm8921_bms/parameters/*
  39. chown -h root.system /sys/module/qpnp_bms/parameters/*
  40. chown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_data
  41. chown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_temp
  42. chown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_chgcyl
  43. chmod 0660 /sys/module/qpnp_bms/parameters/*
  44. chmod 0660 /sys/module/pm8921_bms/parameters/*
  45. mkdir -p /data/bms
  46. chown -h root.system /data/bms
  47. chmod 0770 /data/bms
  48. start battery_monitor
  49. fi
  50. }
  51. start_charger_monitor()
  52. {
  53. if ls /sys/module/qpnp_charger/parameters/charger_monitor; then
  54. chown -h root.system /sys/module/qpnp_charger/parameters/*
  55. chown -h root.system /sys/class/power_supply/battery/input_current_max
  56. chown -h root.system /sys/class/power_supply/battery/input_current_trim
  57. chown -h root.system /sys/class/power_supply/battery/input_current_settled
  58. chown -h root.system /sys/class/power_supply/battery/voltage_min
  59. chmod 0664 /sys/class/power_supply/battery/input_current_max
  60. chmod 0664 /sys/class/power_supply/battery/input_current_trim
  61. chmod 0664 /sys/class/power_supply/battery/input_current_settled
  62. chmod 0664 /sys/class/power_supply/battery/voltage_min
  63. chmod 0664 /sys/module/qpnp_charger/parameters/charger_monitor
  64. start charger_monitor
  65. fi
  66. }
  67. start_vm_bms()
  68. {
  69. if [ -e /dev/vm_bms ]; then
  70. chown -h root.system /sys/class/power_supply/bms/current_now
  71. chown -h root.system /sys/class/power_supply/bms/voltage_ocv
  72. chmod 0664 /sys/class/power_supply/bms/current_now
  73. chmod 0664 /sys/class/power_supply/bms/voltage_ocv
  74. start vm_bms
  75. fi
  76. }
  77. start_msm_irqbalance_8939()
  78. {
  79. if [ -f /vendor/bin/msm_irqbalance ]; then
  80. case "$platformid" in
  81. "239" | "293" | "294" | "295" | "304" | "338" | "313" |"353")
  82. start vendor.msm_irqbalance;;
  83. "349" | "350" )
  84. start vendor.msm_irqbal_lb;;
  85. esac
  86. fi
  87. }
  88. start_msm_irqbalance_msmnile()
  89. {
  90. if [ -f /vendor/bin/msm_irqbalance ]; then
  91. start vendor.msm_irqbalance
  92. fi
  93. }
  94. start_msm_irqbalance660()
  95. {
  96. if [ -f /vendor/bin/msm_irqbalance ]; then
  97. case "$platformid" in
  98. "317" | "324" | "325" | "326" | "345" | "346")
  99. start vendor.msm_irqbalance;;
  100. "318" | "327" | "385")
  101. start vendor.msm_irqbl_sdm630;;
  102. esac
  103. fi
  104. }
  105. start_msm_irqbalance()
  106. {
  107. if [ -f /vendor/bin/msm_irqbalance ]; then
  108. start vendor.msm_irqbalance
  109. fi
  110. }
  111. baseband=`getprop ro.baseband`
  112. echo 1 > /proc/sys/net/ipv6/conf/default/accept_ra_defrtr
  113. case "$baseband" in
  114. "svlte2a")
  115. start bridgemgrd
  116. ;;
  117. esac
  118. case "$target" in
  119. "msm7630_surf" | "msm7630_1x" | "msm7630_fusion")
  120. if [ -f /sys/devices/soc0/hw_platform ]; then
  121. value=`cat /sys/devices/soc0/hw_platform`
  122. else
  123. value=`cat /sys/devices/system/soc/soc0/hw_platform`
  124. fi
  125. case "$value" in
  126. "Fluid")
  127. start profiler_daemon;;
  128. esac
  129. ;;
  130. "msm8660" )
  131. if [ -f /sys/devices/soc0/hw_platform ]; then
  132. platformvalue=`cat /sys/devices/soc0/hw_platform`
  133. else
  134. platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform`
  135. fi
  136. case "$platformvalue" in
  137. "Fluid")
  138. start profiler_daemon;;
  139. esac
  140. ;;
  141. "msm8960")
  142. case "$baseband" in
  143. "msm")
  144. start_battery_monitor;;
  145. esac
  146. if [ -f /sys/devices/soc0/hw_platform ]; then
  147. platformvalue=`cat /sys/devices/soc0/hw_platform`
  148. else
  149. platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform`
  150. fi
  151. case "$platformvalue" in
  152. "Fluid")
  153. start profiler_daemon;;
  154. "Liquid")
  155. start profiler_daemon;;
  156. esac
  157. ;;
  158. "msm8974")
  159. platformvalue=`cat /sys/devices/soc0/hw_platform`
  160. case "$platformvalue" in
  161. "Fluid")
  162. start profiler_daemon;;
  163. "Liquid")
  164. start profiler_daemon;;
  165. esac
  166. case "$baseband" in
  167. "msm")
  168. start_battery_monitor
  169. ;;
  170. esac
  171. start_charger_monitor
  172. ;;
  173. "sdm660")
  174. if [ -f /sys/devices/soc0/soc_id ]; then
  175. soc_id=`cat /sys/devices/soc0/soc_id`
  176. else
  177. soc_id=`cat /sys/devices/system/soc/soc0/id`
  178. fi
  179. if [ -f /sys/devices/soc0/hw_platform ]; then
  180. hw_platform=`cat /sys/devices/soc0/hw_platform`
  181. else
  182. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  183. fi
  184. case "$soc_id" in
  185. "317" | "324" | "325" | "326" | "318" | "327" | "385" )
  186. case "$hw_platform" in
  187. "Surf")
  188. setprop qemu.hw.mainkeys 0
  189. ;;
  190. "MTP")
  191. setprop qemu.hw.mainkeys 0
  192. ;;
  193. "RCM")
  194. setprop qemu.hw.mainkeys 0
  195. ;;
  196. "QRD")
  197. setprop qemu.hw.mainkeys 0
  198. ;;
  199. esac
  200. ;;
  201. esac
  202. start_msm_irqbalance660
  203. ;;
  204. "apq8084")
  205. platformvalue=`cat /sys/devices/soc0/hw_platform`
  206. case "$platformvalue" in
  207. "Fluid")
  208. start profiler_daemon;;
  209. "Liquid")
  210. start profiler_daemon;;
  211. esac
  212. ;;
  213. "msm8226")
  214. start_charger_monitor
  215. ;;
  216. "msm8610")
  217. start_charger_monitor
  218. ;;
  219. "msm8916")
  220. start_vm_bms
  221. start_msm_irqbalance_8939
  222. if [ -f /sys/devices/soc0/soc_id ]; then
  223. soc_id=`cat /sys/devices/soc0/soc_id`
  224. else
  225. soc_id=`cat /sys/devices/system/soc/soc0/id`
  226. fi
  227. if [ -f /sys/devices/soc0/platform_subtype_id ]; then
  228. platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id`
  229. fi
  230. if [ -f /sys/devices/soc0/hw_platform ]; then
  231. hw_platform=`cat /sys/devices/soc0/hw_platform`
  232. fi
  233. case "$soc_id" in
  234. "239")
  235. case "$hw_platform" in
  236. "Surf")
  237. case "$platform_subtype_id" in
  238. "1")
  239. setprop qemu.hw.mainkeys 0
  240. ;;
  241. esac
  242. ;;
  243. "MTP")
  244. case "$platform_subtype_id" in
  245. "3")
  246. setprop qemu.hw.mainkeys 0
  247. ;;
  248. esac
  249. ;;
  250. esac
  251. ;;
  252. esac
  253. ;;
  254. "msm8994" | "msm8992" | "msm8998" | "apq8098_latv" | "sdm845" | "sdm710" | "qcs605" | "sm6150" | "trinket")
  255. start_msm_irqbalance
  256. ;;
  257. "msm8996")
  258. if [ -f /sys/devices/soc0/hw_platform ]; then
  259. hw_platform=`cat /sys/devices/soc0/hw_platform`
  260. fi
  261. case "$hw_platform" in
  262. "MTP" | "CDP")
  263. #Loop through the sysfs nodes and determine the correct sysfs to change the permission and ownership.
  264. for count in 0 1 2 3 4 5 6 7 8 9 10
  265. do
  266. dir="/sys/devices/soc/75ba000.i2c/i2c-12/12-0020/input/input"$count
  267. if [ -d "$dir" ]; then
  268. chmod 0660 $dir/secure_touch_enable
  269. chmod 0440 $dir/secure_touch
  270. chown system.drmrpc $dir/secure_touch_enable
  271. chown system.drmrpc $dir/secure_touch
  272. break
  273. fi
  274. done
  275. ;;
  276. esac
  277. ;;
  278. "msm8909")
  279. start_vm_bms
  280. ;;
  281. "msmnile")
  282. start_msm_irqbalance_msmnile
  283. ;;
  284. "msm8937")
  285. start_msm_irqbalance_8939
  286. if [ -f /sys/devices/soc0/soc_id ]; then
  287. soc_id=`cat /sys/devices/soc0/soc_id`
  288. else
  289. soc_id=`cat /sys/devices/system/soc/soc0/id`
  290. fi
  291. if [ -f /sys/devices/soc0/hw_platform ]; then
  292. hw_platform=`cat /sys/devices/soc0/hw_platform`
  293. else
  294. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  295. fi
  296. if [ "$low_ram" != "true" ]; then
  297. case "$soc_id" in
  298. "294" | "295" | "303" | "307" | "308" | "309" | "313" | "320" | "353" | "354" | "363" | "364")
  299. case "$hw_platform" in
  300. "Surf")
  301. setprop qemu.hw.mainkeys 0
  302. ;;
  303. "MTP")
  304. setprop qemu.hw.mainkeys 0
  305. ;;
  306. "RCM")
  307. setprop qemu.hw.mainkeys 0
  308. ;;
  309. "QRD")
  310. setprop qemu.hw.mainkeys 0
  311. ;;
  312. esac
  313. ;;
  314. esac
  315. fi
  316. ;;
  317. "msm8953")
  318. start_msm_irqbalance_8939
  319. if [ -f /sys/devices/soc0/soc_id ]; then
  320. soc_id=`cat /sys/devices/soc0/soc_id`
  321. else
  322. soc_id=`cat /sys/devices/system/soc/soc0/id`
  323. fi
  324. if [ -f /sys/devices/soc0/hw_platform ]; then
  325. hw_platform=`cat /sys/devices/soc0/hw_platform`
  326. else
  327. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  328. fi
  329. case "$soc_id" in
  330. "293" | "304" | "338" | "351" | "349" | "350" )
  331. case "$hw_platform" in
  332. "Surf")
  333. setprop qemu.hw.mainkeys 0
  334. ;;
  335. "MTP")
  336. setprop qemu.hw.mainkeys 0
  337. ;;
  338. "RCM")
  339. setprop qemu.hw.mainkeys 0
  340. ;;
  341. "QRD")
  342. setprop qemu.hw.mainkeys 0
  343. ;;
  344. esac
  345. ;;
  346. esac
  347. ;;
  348. "sdm710")
  349. if [ -f /sys/devices/soc0/soc_id ]; then
  350. soc_id=`cat /sys/devices/soc0/soc_id`
  351. else
  352. soc_id=`cat /sys/devices/system/soc/soc0/id`
  353. fi
  354. if [ -f /sys/devices/soc0/hw_platform ]; then
  355. hw_platform=`cat /sys/devices/soc0/hw_platform`
  356. else
  357. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  358. fi
  359. case "$soc_id" in
  360. "336" | "337" | "347" | "360" | "393" )
  361. case "$hw_platform" in
  362. "Surf")
  363. setprop qemu.hw.mainkeys 0
  364. ;;
  365. "MTP")
  366. setprop qemu.hw.mainkeys 0
  367. ;;
  368. "RCM")
  369. setprop qemu.hw.mainkeys 0
  370. ;;
  371. "QRD")
  372. setprop qemu.hw.mainkeys 0
  373. ;;
  374. esac
  375. ;;
  376. esac
  377. ;;
  378. esac
  379. #
  380. # Make modem config folder and copy firmware config to that folder for RIL
  381. #
  382. if [ -f /data/vendor/modem_config/ver_info.txt ]; then
  383. prev_version_info=`cat /data/vendor/modem_config/ver_info.txt`
  384. else
  385. prev_version_info=""
  386. fi
  387. cur_version_info=`cat /vendor/firmware_mnt/verinfo/ver_info.txt`
  388. if [ ! -f /vendor/firmware_mnt/verinfo/ver_info.txt -o "$prev_version_info" != "$cur_version_info" ]; then
  389. # add W for group recursively before delete
  390. chmod g+w -R /data/vendor/modem_config/*
  391. rm -rf /data/vendor/modem_config/*
  392. # preserve the read only mode for all subdir and files
  393. cp --preserve=m -dr /vendor/firmware_mnt/image/modem_pr/mcfg/configs/* /data/vendor/modem_config
  394. cp --preserve=m -d /vendor/firmware_mnt/verinfo/ver_info.txt /data/vendor/modem_config/
  395. cp --preserve=m -d /vendor/firmware_mnt/image/modem_pr/mbn_ota.txt /data/vendor/modem_config/
  396. # the group must be root, otherwise this script could not add "W" for group recursively
  397. chown -hR radio.root /data/vendor/modem_config/*
  398. fi
  399. chmod g-w /data/vendor/modem_config
  400. setprop ro.vendor.ril.mbn_copy_completed 1
  401. #check build variant for printk logging
  402. #current default minimum boot-time-default
  403. buildvariant=`getprop ro.build.type`
  404. case "$buildvariant" in
  405. "userdebug" | "eng")
  406. #set default loglevel to KERN_INFO
  407. echo "6 6 1 7" > /proc/sys/kernel/printk
  408. ;;
  409. *)
  410. #set default loglevel to KERN_WARNING
  411. echo "4 4 1 4" > /proc/sys/kernel/printk
  412. ;;
  413. esac