init.qcom.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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" | "354")
  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_irqbalance_kona()
  95. {
  96. if [ -f /vendor/bin/msm_irqbalance ]; then
  97. start vendor.msm_irqbalance
  98. fi
  99. }
  100. start_msm_irqbalance_lito()
  101. {
  102. if [ -f /vendor/bin/msm_irqbalance ]; then
  103. start vendor.msm_irqbalance
  104. fi
  105. }
  106. start_msm_irqbalance_atoll()
  107. {
  108. if [ -f /vendor/bin/msm_irqbalance ]; then
  109. start vendor.msm_irqbalance
  110. fi
  111. }
  112. start_msm_irqbalance660()
  113. {
  114. if [ -f /vendor/bin/msm_irqbalance ]; then
  115. case "$platformid" in
  116. "317" | "321" | "324" | "325" | "326" | "336" | "345" | "346" | "360" | "393")
  117. start vendor.msm_irqbalance;;
  118. "318" | "327" | "385")
  119. start vendor.msm_irqbl_sdm630;;
  120. esac
  121. fi
  122. }
  123. start_msm_irqbalance()
  124. {
  125. if [ -f /vendor/bin/msm_irqbalance ]; then
  126. start vendor.msm_irqbalance
  127. fi
  128. }
  129. baseband=`getprop ro.baseband`
  130. echo 1 > /proc/sys/net/ipv6/conf/default/accept_ra_defrtr
  131. case "$baseband" in
  132. "svlte2a")
  133. start bridgemgrd
  134. ;;
  135. esac
  136. case "$target" in
  137. "msm7630_surf" | "msm7630_1x" | "msm7630_fusion")
  138. if [ -f /sys/devices/soc0/hw_platform ]; then
  139. value=`cat /sys/devices/soc0/hw_platform`
  140. else
  141. value=`cat /sys/devices/system/soc/soc0/hw_platform`
  142. fi
  143. case "$value" in
  144. "Fluid")
  145. start profiler_daemon;;
  146. esac
  147. ;;
  148. "msm8660" )
  149. if [ -f /sys/devices/soc0/hw_platform ]; then
  150. platformvalue=`cat /sys/devices/soc0/hw_platform`
  151. else
  152. platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform`
  153. fi
  154. case "$platformvalue" in
  155. "Fluid")
  156. start profiler_daemon;;
  157. esac
  158. ;;
  159. "msm8960")
  160. case "$baseband" in
  161. "msm")
  162. start_battery_monitor;;
  163. esac
  164. if [ -f /sys/devices/soc0/hw_platform ]; then
  165. platformvalue=`cat /sys/devices/soc0/hw_platform`
  166. else
  167. platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform`
  168. fi
  169. case "$platformvalue" in
  170. "Fluid")
  171. start profiler_daemon;;
  172. "Liquid")
  173. start profiler_daemon;;
  174. esac
  175. ;;
  176. "msm8974")
  177. platformvalue=`cat /sys/devices/soc0/hw_platform`
  178. case "$platformvalue" in
  179. "Fluid")
  180. start profiler_daemon;;
  181. "Liquid")
  182. start profiler_daemon;;
  183. esac
  184. case "$baseband" in
  185. "msm")
  186. start_battery_monitor
  187. ;;
  188. esac
  189. start_charger_monitor
  190. ;;
  191. "sdm660")
  192. if [ -f /sys/devices/soc0/soc_id ]; then
  193. soc_id=`cat /sys/devices/soc0/soc_id`
  194. else
  195. soc_id=`cat /sys/devices/system/soc/soc0/id`
  196. fi
  197. if [ -f /sys/devices/soc0/hw_platform ]; then
  198. hw_platform=`cat /sys/devices/soc0/hw_platform`
  199. else
  200. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  201. fi
  202. case "$soc_id" in
  203. "317" | "324" | "325" | "326" | "318" | "327" )
  204. case "$hw_platform" in
  205. "Surf")
  206. setprop qemu.hw.mainkeys 0
  207. ;;
  208. "MTP")
  209. setprop qemu.hw.mainkeys 0
  210. ;;
  211. "RCM")
  212. setprop qemu.hw.mainkeys 0
  213. ;;
  214. "QRD")
  215. setprop qemu.hw.mainkeys 0
  216. ;;
  217. esac
  218. ;;
  219. esac
  220. start_msm_irqbalance660
  221. ;;
  222. "apq8084")
  223. platformvalue=`cat /sys/devices/soc0/hw_platform`
  224. case "$platformvalue" in
  225. "Fluid")
  226. start profiler_daemon;;
  227. "Liquid")
  228. start profiler_daemon;;
  229. esac
  230. ;;
  231. "msm8226")
  232. start_charger_monitor
  233. ;;
  234. "msm8610")
  235. start_charger_monitor
  236. ;;
  237. "msm8916")
  238. start_vm_bms
  239. start_msm_irqbalance_8939
  240. if [ -f /sys/devices/soc0/soc_id ]; then
  241. soc_id=`cat /sys/devices/soc0/soc_id`
  242. else
  243. soc_id=`cat /sys/devices/system/soc/soc0/id`
  244. fi
  245. if [ -f /sys/devices/soc0/platform_subtype_id ]; then
  246. platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id`
  247. fi
  248. if [ -f /sys/devices/soc0/hw_platform ]; then
  249. hw_platform=`cat /sys/devices/soc0/hw_platform`
  250. fi
  251. case "$soc_id" in
  252. "239")
  253. case "$hw_platform" in
  254. "Surf")
  255. case "$platform_subtype_id" in
  256. "1")
  257. setprop qemu.hw.mainkeys 0
  258. ;;
  259. esac
  260. ;;
  261. "MTP")
  262. case "$platform_subtype_id" in
  263. "3")
  264. setprop qemu.hw.mainkeys 0
  265. ;;
  266. esac
  267. ;;
  268. esac
  269. ;;
  270. esac
  271. ;;
  272. "msm8994" | "msm8992" | "msm8998" | "apq8098_latv" | "sdm845" | "sdm710" | "qcs605" | "sm6150" | "trinket" | "bengal")
  273. start_msm_irqbalance
  274. ;;
  275. "msm8996")
  276. if [ -f /sys/devices/soc0/hw_platform ]; then
  277. hw_platform=`cat /sys/devices/soc0/hw_platform`
  278. fi
  279. case "$hw_platform" in
  280. "MTP" | "CDP")
  281. #Loop through the sysfs nodes and determine the correct sysfs to change the permission and ownership.
  282. for count in 0 1 2 3 4 5 6 7 8 9 10
  283. do
  284. dir="/sys/devices/soc/75ba000.i2c/i2c-12/12-0020/input/input"$count
  285. if [ -d "$dir" ]; then
  286. chmod 0660 $dir/secure_touch_enable
  287. chmod 0440 $dir/secure_touch
  288. chown system.drmrpc $dir/secure_touch_enable
  289. chown system.drmrpc $dir/secure_touch
  290. break
  291. fi
  292. done
  293. ;;
  294. esac
  295. ;;
  296. "msm8909")
  297. start_vm_bms
  298. ;;
  299. "msmnile")
  300. start_msm_irqbalance_msmnile
  301. ;;
  302. "kona")
  303. start_msm_irqbalance_kona
  304. ;;
  305. "lito")
  306. start_msm_irqbalance_lito
  307. ;;
  308. "atoll")
  309. start_msm_irqbalance_atoll
  310. ;;
  311. "msm8937")
  312. start_msm_irqbalance_8939
  313. if [ -f /sys/devices/soc0/soc_id ]; then
  314. soc_id=`cat /sys/devices/soc0/soc_id`
  315. else
  316. soc_id=`cat /sys/devices/system/soc/soc0/id`
  317. fi
  318. if [ -f /sys/devices/soc0/hw_platform ]; then
  319. hw_platform=`cat /sys/devices/soc0/hw_platform`
  320. else
  321. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  322. fi
  323. if [ "$low_ram" != "true" ]; then
  324. case "$soc_id" in
  325. "294" | "295" | "303" | "307" | "308" | "309" | "313" | "320" | "353" | "354" | "363" | "364")
  326. case "$hw_platform" in
  327. "Surf")
  328. setprop qemu.hw.mainkeys 0
  329. ;;
  330. "MTP")
  331. setprop qemu.hw.mainkeys 0
  332. ;;
  333. "RCM")
  334. setprop qemu.hw.mainkeys 0
  335. ;;
  336. "QRD")
  337. setprop qemu.hw.mainkeys 0
  338. ;;
  339. esac
  340. ;;
  341. esac
  342. fi
  343. ;;
  344. "msm8953")
  345. start_msm_irqbalance_8939
  346. if [ -f /sys/devices/soc0/soc_id ]; then
  347. soc_id=`cat /sys/devices/soc0/soc_id`
  348. else
  349. soc_id=`cat /sys/devices/system/soc/soc0/id`
  350. fi
  351. if [ -f /sys/devices/soc0/hw_platform ]; then
  352. hw_platform=`cat /sys/devices/soc0/hw_platform`
  353. else
  354. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  355. fi
  356. case "$soc_id" in
  357. "293" | "304" | "338" | "351" | "349" | "350" )
  358. case "$hw_platform" in
  359. "Surf")
  360. setprop qemu.hw.mainkeys 0
  361. ;;
  362. "MTP")
  363. setprop qemu.hw.mainkeys 0
  364. ;;
  365. "RCM")
  366. setprop qemu.hw.mainkeys 0
  367. ;;
  368. "QRD")
  369. setprop qemu.hw.mainkeys 0
  370. ;;
  371. esac
  372. ;;
  373. esac
  374. ;;
  375. "sdm710")
  376. if [ -f /sys/devices/soc0/soc_id ]; then
  377. soc_id=`cat /sys/devices/soc0/soc_id`
  378. else
  379. soc_id=`cat /sys/devices/system/soc/soc0/id`
  380. fi
  381. if [ -f /sys/devices/soc0/hw_platform ]; then
  382. hw_platform=`cat /sys/devices/soc0/hw_platform`
  383. else
  384. hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform`
  385. fi
  386. case "$soc_id" in
  387. "336" | "337" | "347" | "360" | "393" )
  388. case "$hw_platform" in
  389. "Surf")
  390. setprop qemu.hw.mainkeys 0
  391. ;;
  392. "MTP")
  393. setprop qemu.hw.mainkeys 0
  394. ;;
  395. "RCM")
  396. setprop qemu.hw.mainkeys 0
  397. ;;
  398. "QRD")
  399. setprop qemu.hw.mainkeys 0
  400. ;;
  401. esac
  402. ;;
  403. esac
  404. ;;
  405. esac
  406. #
  407. # Make modem config folder and copy firmware config to that folder for RIL
  408. #
  409. if [ -f /data/vendor/modem_config/ver_info.txt ]; then
  410. prev_version_info=`cat /data/vendor/modem_config/ver_info.txt`
  411. else
  412. prev_version_info=""
  413. fi
  414. cur_version_info=`cat /vendor/firmware_mnt/verinfo/ver_info.txt`
  415. if [ ! -f /vendor/firmware_mnt/verinfo/ver_info.txt -o "$prev_version_info" != "$cur_version_info" ]; then
  416. # add W for group recursively before delete
  417. chmod g+w -R /data/vendor/modem_config/*
  418. rm -rf /data/vendor/modem_config/*
  419. # preserve the read only mode for all subdir and files
  420. cp --preserve=m -dr /vendor/firmware_mnt/image/modem_pr/mcfg/configs/* /data/vendor/modem_config
  421. cp --preserve=m -d /vendor/firmware_mnt/verinfo/ver_info.txt /data/vendor/modem_config/
  422. cp --preserve=m -d /vendor/firmware_mnt/image/modem_pr/mbn_ota.txt /data/vendor/modem_config/
  423. # the group must be root, otherwise this script could not add "W" for group recursively
  424. chown -hR radio.root /data/vendor/modem_config/*
  425. fi
  426. chmod g-w /data/vendor/modem_config
  427. setprop ro.vendor.ril.mbn_copy_completed 1
  428. #check build variant for printk logging
  429. #current default minimum boot-time-default
  430. buildvariant=`getprop ro.build.type`
  431. case "$buildvariant" in
  432. "userdebug" | "eng")
  433. #set default loglevel to KERN_INFO
  434. echo "6 6 1 7" > /proc/sys/kernel/printk
  435. ;;
  436. *)
  437. #set default loglevel to KERN_WARNING
  438. echo "4 4 1 4" > /proc/sys/kernel/printk
  439. ;;
  440. esac
  441. #add permission for block_size, mem_type, mem_size nodes to collect diag over QDSS by ODL
  442. #application by "oem_2902" group
  443. chown -h root.oem_2902 /sys/devices/platform/soc/10048000.tmc/coresight-tmc-etr/block_size
  444. chmod 660 /sys/devices/platform/soc/10048000.tmc/coresight-tmc-etr/block_size
  445. chown -h root.oem_2902 /sys/devices/platform/soc/10048000.tmc/coresight-tmc-etr/buffer_size
  446. chmod 660 /sys/devices/platform/soc/10048000.tmc/coresight-tmc-etr/buffer_size
  447. chmod 660 /sys/devices/platform/soc/10048000.tmc/coresight-tmc-etr/out_mode
  448. chown -h root.oem_2902 /sys/devices/platform/soc/1004f000.tmc/coresight-tmc-etr1/block_size
  449. chmod 660 /sys/devices/platform/soc/1004f000.tmc/coresight-tmc-etr1/block_size
  450. chown -h root.oem_2902 /sys/devices/platform/soc/1004f000.tmc/coresight-tmc-etr1/buffer_size
  451. chmod 660 /sys/devices/platform/soc/1004f000.tmc/coresight-tmc-etr1/buffer_size
  452. chmod 660 /sys/devices/platform/soc/1004f000.tmc/coresight-tmc-etr1/out_mode
  453. chmod 660 /sys/devices/platform/soc/1004f000.tmc/coresight-tmc-etr1/enable_sink
  454. chmod 660 /sys/devices/platform/soc/soc:modem_diag/coresight-modem-diag/enable_source
  455. chown -h root.oem_2902 /sys/bus/coresight/reset_source_sink
  456. chmod 660 /sys/bus/coresight/reset_source_sink
  457. # qcom case
  458. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etf/curr_sink
  459. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etf/enable_sink
  460. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etr/curr_sink
  461. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etr/enable_sink
  462. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etr/out_mode
  463. chown -h system.system /sys/bus/coresight/devices/coresight-tpiu/curr_sink
  464. chown -h system.system /sys/bus/coresight/devices/coresight-tpiu/out_mode
  465. chown -h system.system /sys/bus/coresight/devices/coresight-stm/enable
  466. chown -h system.system /sys/bus/coresight/devices/coresight-stm/enable_source
  467. chown -h system.system /sys/bus/coresight/devices/coresight-hwevent/enable
  468. chown -h system.system /sys/bus/coresight/devices/coresight-stm/hwevent_enable
  469. chown -h system.system /sys/bus/coresight/devices/coresight-hwevent/setreg
  470. chown -h system.system /sys/bus/coresight/devices/coresight-swao-csr/timestamp
  471. chown -h system.system /sys/bus/coresight/devices/coresight-modem-diag/enable_source
  472. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etr1/enable_sink
  473. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etr1/out_mode
  474. chown -h system.system /sys/bus/coresight/devices/coresight-tmc-etr1/curr_sink
  475. # qcom case 05386569
  476. mkdir /config/stp-policy/coresight-stm:p_ost.policy
  477. chmod 660 /config/stp-policy/coresight-stm:p_ost.policy
  478. mkdir /config/stp-policy/coresight-stm:p_ost.policy/default
  479. chmod 660 /config/stp-policy/coresight-stm:p_ost.policy/default
  480. echo 0x10 > /sys/bus/coresight/devices/coresight-stm/traceid
  481. # disable ftrace log on coresight stm buffer
  482. case "$buildvariant" in
  483. "eng")
  484. echo 0 > /sys/bus/coresight/devices/coresight-stm/port_enable
  485. echo 0x10000003 > /sys/bus/coresight/devices/coresight-stm/port_select
  486. echo 0xffffffff > /sys/bus/coresight/devices/coresight-stm/port_enable
  487. ;;
  488. esac