1#
2# Copyright 2015 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17import init.bullhead.usb.rc
18import init.bullhead.diag.rc
19import init.bullhead.fp.rc
20import init.bullhead.sensorhub.rc
21import init.bullhead.ramdump.rc
22import init.bullhead.misc.rc
23
24on early-init
25    mount debugfs debugfs /sys/kernel/debug
26    chown system system /sys/kernel/debug/kgsl/proc
27
28on charger
29    # disable FPS clk
30    write /sys/bus/spi/drivers/fpc1020/spi1.2/clk_enable 0
31
32    # low power governing
33    write /sys/devices/system/cpu/cpu1/online 0
34    write /sys/devices/system/cpu/cpu2/online 0
35    write /sys/devices/system/cpu/cpu3/online 0
36    write /sys/devices/system/cpu/cpu4/online 0
37    write /sys/devices/system/cpu/cpu5/online 0
38    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor powersave
39
40    # Disable CPU retention
41    write /sys/module/lpm_levels/system/a53/cpu0/retention/idle_enabled 0
42    write /sys/module/lpm_levels/system/a53/cpu1/retention/idle_enabled 0
43    write /sys/module/lpm_levels/system/a53/cpu2/retention/idle_enabled 0
44    write /sys/module/lpm_levels/system/a53/cpu3/retention/idle_enabled 0
45    write /sys/module/lpm_levels/system/a57/cpu4/retention/idle_enabled 0
46    write /sys/module/lpm_levels/system/a57/cpu5/retention/idle_enabled 0
47    # Disable L2 retention
48    write /sys/module/lpm_levels/system/a53/a53-l2-retention/idle_enabled 0
49    write /sys/module/lpm_levels/system/a57/a57-l2-retention/idle_enabled 0
50
51on property:sys.boot_completed=1
52    # allow CPUs to go in deeper idle state than C0
53    write /sys/module/lpm_levels/parameters/sleep_disabled 0
54    #end boot time fs tune
55    write /sys/block/mmcblk0/queue/scheduler noop
56    write /sys/block/mmcblk0/queue/rq_affinity 0
57    write /sys/block/mmcblk0/queue/read_ahead_kb 128
58    write /sys/block/dm-0/queue/read_ahead_kb 128
59    write /sys/block/dm-1/queue/read_ahead_kb 128
60    write /sys/block/dm-2/queue/read_ahead_kb 128
61    write /sys/block/mmcblk0/queue/iostats 1
62
63on init
64    # Load persistent dm-verity state
65    verity_load_state
66
67    # Set permissions for persist partition
68    mkdir /persist 0771 system system
69    mkdir /firmware 0771 system system
70
71    symlink /sdcard /storage/sdcard0
72
73    # NXP HAL expects /dev/pn54x
74    symlink /dev/pn548 /dev/pn54x
75
76    write /sys/block/zram0/comp_algorithm lz4
77    write /sys/block/zram0/max_comp_streams 4
78
79    write /proc/sys/vm/page-cluster 0
80
81on fs
82    mount_all ./fstab.bullhead
83    swapon_all ./fstab.bullhead
84
85    restorecon_recursive /persist
86
87on early-boot
88    # set RLIMIT_MEMLOCK to 64MB
89    setrlimit 8 67108864 67108864
90
91    # Allow subsystem (modem etc) debugging
92    write /sys/module/subsystem_restart/parameters/enable_debug ${persist.sys.ssr.enable_debug}
93    write /sys/module/pil_msa/parameters/pbl_mba_boot_timeout_ms ${persist.sys.mba_boot_timeout}
94    write /sys/module/pil_msa/parameters/modem_auth_timeout_ms ${persist.sys.modem_auth_timeout}
95    write /sys/module/peripheral_loader/parameters/proxy_timeout_ms ${persist.sys.pil_proxy_timeout}
96
97    # Update dm-verity state and set partition.*.verified properties
98    verity_update_state
99
100    # Busy loop to wait for devices booted by devstart_sh just in case device not ready
101    exec - root root system -- /system/bin/init.qcom.devwait.sh
102
103on boot
104    # execute script to set initial CPU settings
105    # don't run as a service to avoid race conditions
106    exec - root root system -- /system/bin/init.bullhead.power.sh
107
108    # update foreground cpuset now that processors are up
109    # foreground gets all CPUs except CPU 3
110    # CPU 3 is reserved for the top app
111    write /dev/cpuset/foreground/cpus 0-2,4-5
112    write /dev/cpuset/foreground/boost/cpus 4-5
113    write /dev/cpuset/background/cpus 0
114    write /dev/cpuset/system-background/cpus 0-2
115    write /dev/cpuset/top-app/cpus 0-5
116
117    # Bluetooth
118    chown bluetooth net_bt /sys/class/rfkill/rfkill0/type
119    chown bluetooth net_bt /sys/class/rfkill/rfkill0/state
120    chmod 0660 /sys/class/rfkill/rfkill0/state
121    chown bluetooth net_bt /dev/ttyHS0
122    chmod 0660 /dev/ttyHS0
123    chown bluetooth net_bt /sys/class/rfkill/rfkill0/device/extldo
124    chmod 0660 /sys/class/rfkill/rfkill0/device/extldo
125
126    # Fingerprint
127    chown system system /sys/bus/spi/drivers/fpc1020/spi1.2/clk_enable
128    chown system system /sys/bus/spi/drivers/fpc1020/spi1.2/wakeup_enable
129    chown system system /sys/bus/spi/drivers/fpc1020/spi1.2/irq
130
131    # create symlink for fb1 as HDMI
132    symlink /dev/graphics/fb1 /dev/graphics/hdmi
133
134    # setup permissions for fb1 related nodes
135    chown system graphics /sys/class/graphics/fb1/hpd
136    chown system graphics /sys/class/graphics/fb1/vendor_name
137    chown system graphics /sys/class/graphics/fb1/product_description
138    chmod 0664 /sys/devices/virtual/graphics/fb1/hpd
139    chmod 0664 /sys/devices/virtual/graphics/fb1/vendor_name
140    chmod 0664 /sys/devices/virtual/graphics/fb1/product_description
141
142    # Grant permission to modify the color_temp setting
143    chown system graphics /sys/class/graphics/fb0/color_temp
144    chmod 0664 /sys/class/graphics/fb0/color_temp
145
146    # Allow QMUX daemon to assign port open wait time
147    chown radio radio /sys/devices/virtual/hsicctl/hsicctl0/modem_wait
148
149    #Create QMUX deamon socket area
150    mkdir /dev/socket/qmux_radio 0770 radio radio
151    chmod 2770 /dev/socket/qmux_radio
152    mkdir /dev/socket/qmux_audio 0770 media audio
153    chmod 2770 /dev/socket/qmux_audio
154    mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth
155    chmod 2770 /dev/socket/qmux_bluetooth
156    mkdir /dev/socket/qmux_gps 0770 gps gps
157    chmod 2770 /dev/socket/qmux_gps
158
159    # Subsytem Restart
160    write /sys/bus/msm_subsys/devices/subsys0/restart_level "related"
161    write /sys/bus/msm_subsys/devices/subsys1/restart_level "related"
162    write /sys/bus/msm_subsys/devices/subsys2/restart_level "related"
163    write /sys/bus/msm_subsys/devices/subsys3/restart_level "related"
164
165    # Subsytem Ramdump collection
166    write /sys/module/subsystem_restart/parameters/enable_ramdumps 1
167    write /sys/module/msm_poweroff/parameters/download_mode 0
168
169    # Adjust socket buffer to enlarge TCP receive window for high bandwidth
170    write /proc/sys/net/ipv4/tcp_adv_win_scale 1
171
172    # Assign TCP buffer thresholds to be ceiling value of technology maximums
173    # Increased technology maximums should be reflected here.
174    write /proc/sys/net/core/rmem_max  8388608
175    write /proc/sys/net/core/wmem_max  8388608
176
177    # Leds
178    chown system system /sys/class/leds/red/on_off_ms
179    chown system system /sys/class/leds/green/on_off_ms
180    chown system system /sys/class/leds/blue/on_off_ms
181    chown system system /sys/class/leds/red/rgb_start
182
183    # Wifi firmware reload path
184    chown wifi wifi /sys/module/wlan/parameters/fwpath
185
186    # Wifi firmware reload path
187    chown wifi wifi /sys/module/wlan/parameters/fwpath
188
189on post-fs
190    symlink /dev/block/platform/soc.0/f9824900.sdhci /dev/block/bootdevice
191
192    mkdir /persist/data 0700 system system
193    mkdir /persist/data/sfs 0700 system system
194    mkdir /persist/data/tz 0700 system system
195    mkdir /persist/data/app_g 0700 system system
196    mkdir /persist/widevine 0770 drm system
197
198    start qseecomd
199    # Busy loop to wait for qseecomd started
200    exec - root root system -- /system/bin/init.bullhead.qseecomd.sh
201    # Start devices by sysfs trigger
202    start devstart_sh
203
204on post-fs-data
205    # boot time fs tune
206    write /sys/block/mmcblk0/queue/iostats 0
207    write /sys/block/mmcblk0/queue/scheduler cfq
208    write /sys/block/mmcblk0/queue/iosched/slice_idle 0
209    write /sys/block/mmcblk0/queue/read_ahead_kb 2048
210    write /sys/block/dm-0/queue/read_ahead_kb 2048
211    write /sys/block/dm-1/queue/read_ahead_kb 2048
212    write /sys/block/dm-2/queue/read_ahead_kb 2048
213
214    # Mark the copy complete flag to not completed
215    mkdir /data/misc/radio 0770 radio radio
216    write /data/misc/radio/copy_complete 0
217    chown radio radio /data/misc/radio/copy_complete
218    chmod 0660 /data/misc/radio/copy_complete
219
220    #Update touch firmware if required
221    write /sys/bus/i2c/devices/2-0020/check_fw 1
222    write /sys/devices/soc.0/f9924000.i2c/power/control on
223
224    # Create /data/time folder for time-services
225    mkdir /data/time/ 0700 system system
226
227    # Create the directories used by CnE subsystem
228    mkdir /data/connectivity 0771 system system
229
230    # NFC: create data/nfc for nv storage
231    mkdir /data/nfc 0770 nfc nfc
232    mkdir /data/vendor/nfc 0770 nfc nfc
233    mkdir /data/nfc/param 0770 nfc nfc
234
235    # use qcril.db to handle Ecc and load MBN
236    copy /system/etc/qcril.db /data/misc/radio/qcril.db
237    chown radio radio /data/misc/radio/qcril.db
238    chmod 0600 /data/misc/radio/qcril.db
239
240    # Create folder for mm-qcamera-daemon
241    mkdir /data/misc/camera 0770 camera camera
242
243    # change permission for ldaf
244    chown input system /persist/calibration
245    chmod 0650 /persist/calibration
246    chown input system /persist/calibration/offset
247    chmod 0640 /persist/calibration/offset
248    chown input system /persist/calibration/xtalk
249    chmod 0640 /persist/calibration/xtalk
250
251    #Create directories for Location services
252    mkdir /data/misc/location 0770 gps gps
253    mkdir /data/misc/location/mq 0770 gps gps
254    mkdir /data/misc/location/xtwifi 0770 gps gps
255    mkdir /data/misc/location/gpsone_d 0770 system gps
256
257    # Audio
258    mkdir /data/misc/audio 0770 audio audio
259
260    # perf daemon
261    mkdir /data/misc/perfd 0755 root system
262    chmod 2755 /data/misc/perfd
263    rm /data/misc/perfd/default_values
264
265    # Subsytem Ramdump collection
266    mkdir /data/ramdump 0700 root root
267
268    setprop vold.post_fs_data_done 1
269
270service irsc_util /system/bin/irsc_util "/etc/sec_config"
271    class main
272    user root
273    oneshot
274
275service rmt_storage /system/bin/rmt_storage
276    class core
277    user root
278    group system wakelock
279
280service start_hci_filter /vendor/bin/wcnss_filter
281    class late_start
282    user bluetooth
283    group bluetooth system
284    disabled
285
286on property:wc_transport.start_hci=true
287    start start_hci_filter
288
289on property:wc_transport.start_hci=false
290    stop start_hci_filter
291
292# QMUX must be in multiple groups to support external process connections
293service qmuxd /system/bin/qmuxd
294    class main
295    user radio
296    group radio audio bluetooth wakelock gps
297
298service perfd /system/bin/perfd
299    class main
300    user root
301    group system
302    writepid /dev/cpuset/system-background/tasks
303
304service qti /system/vendor/bin/qti
305    class main
306    user radio
307    group radio net_raw diag usb net_admin
308
309service netmgrd /system/bin/netmgrd
310    class main
311    group radio system wakelock
312
313service per_mgr /system/bin/pm-service
314    class core
315    user system
316    group system net_raw
317
318service per_proxy /system/bin/pm-proxy
319    class core
320    user system
321    group system net_raw
322    disabled
323
324on property:init.svc.per_mgr=running
325    start per_proxy
326
327on property:sys.shutdown.requested=*
328    stop per_proxy
329
330on property:ro.boot.hardware.sku=LGH790
331    setprop ro.boot.wificountrycode US
332
333on property:ro.boot.hardware.sku=LGH791
334    setprop ro.boot.wificountrycode 00
335
336on property:ro.boot.hardware.sku=LGH791F
337    setprop ro.boot.wificountrycode 00
338
339on property:ro.boot.hardware.sku=LGH798
340    setprop ro.boot.wificountrycode 00
341
342service thermal-engine /system/bin/thermal-engine
343    class main
344    user root
345    socket thermal-send-client stream 0666 system system
346    socket thermal-recv-client stream 0660 system system
347    socket thermal-recv-passive-client stream 0666 system system
348    group root
349
350service wpa_supplicant /vendor/bin/hw/wpa_supplicant \
351    -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
352    -I/system/etc/wifi/p2p_supplicant_overlay.conf -N \
353    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
354    -I/system/etc/wifi/wpa_supplicant_overlay.conf \
355    -puse_p2p_group_interface=1 \
356    -e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
357#   we will start as root and wpa_supplicant will switch to user wifi
358#   after setting up the capabilities required for WEXT
359#   user wifi
360#   group wifi inet keystore
361    class main
362    socket wpa_wlan0 dgram 660 wifi wifi
363    disabled
364    oneshot
365
366service loc_launcher /system/bin/loc_launcher
367    #loc_launcher will start as root and set its uid to gps
368    class late_start
369    group gps inet net_raw diag net_admin wifi
370
371service cnss-daemon /system/bin/cnss-daemon -n -l
372    class late_start
373
374service qseecomd /vendor/bin/qseecomd
375    class core
376    user root
377    group root
378
379service msm_irqbalance /system/bin/msm_irqbalance -f /vendor/etc/msm_irqbalance.conf
380    socket msm_irqbalance seqpacket 660 root system
381    class core
382    user root
383    group root
384    writepid /dev/cpuset/system-background/tasks
385
386service time_daemon /system/bin/time_daemon
387    class late_start
388    user root
389    group root
390
391service charger /charger
392    class charger
393    critical
394    seclabel u:r:charger:s0
395
396service qcamerasvr /vendor/bin/mm-qcamera-daemon
397    class late_start
398    user camera
399    group camera system inet input graphics
400    writepid /dev/cpuset/system-background/tasks
401
402on property:persist.radio.atfwd.start=false
403    stop atfwd
404
405service atfwd /system/bin/ATFWD-daemon
406    class late_start
407    user system
408    group system radio
409
410on property:ro.debuggable=1
411    start ss_ramdump
412
413service ss_ramdump /system/bin/subsystem_ramdump
414    class main
415    user root
416    group root system
417    disabled
418
419service cnd /system/bin/cnd
420    class late_start
421    socket cnd stream 660 root inet
422    group root wakelock
423
424service imsqmidaemon /system/bin/imsqmidaemon
425    class main
426    user system
427    socket ims_qmid stream 0660 system radio
428    group radio net_raw log diag
429
430service imsdatadaemon /system/bin/imsdatadaemon
431    class main
432    user system
433    socket ims_datad stream 0660 system radio
434    group system wifi radio inet net_raw log diag net_admin
435    disabled
436
437on property:sys.ims.QMI_DAEMON_STATUS=1
438    start imsdatadaemon
439
440service bullhead-sh /system/bin/init.bullhead.sh
441    class late_start
442    user radio
443    group system
444    oneshot
445
446# bugreport is triggered by holding down volume down, volume up and power
447service bugreport /system/bin/dumpstate -d -p -B -z \
448        -o /data/user_de/0/com.android.shell/files/bugreports/bugreport
449    class main
450    disabled
451    oneshot
452    keycodes 114 115 116
453
454service devstart_sh /system/bin/init.qcom.devstart.sh
455    class main
456    user root
457    group root system
458    disabled
459    oneshot
460