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