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