1#! /vendor/bin/sh
2
3################################################################################
4# helper functions to allow Android init like script
5
6function write() {
7    echo -n $2 > $1
8}
9
10function copy() {
11    cat $1 > $2
12}
13
14################################################################################
15
16# Enable bus-dcvs
17for cpubw in /sys/class/devfreq/*qcom,cpubw*
18do
19    write $cpubw/governor "bw_hwmon"
20    write $cpubw/polling_interval 50
21    write $cpubw/bw_hwmon/mbps_zones "3143 5859 11863 13763"
22    write $cpubw/bw_hwmon/sample_ms 4
23    write $cpubw/bw_hwmon/io_percent 34
24    write $cpubw/bw_hwmon/hist_memory 20
25    write $cpubw/bw_hwmon/hyst_length 10
26    write $cpubw/bw_hwmon/low_power_ceil_mbps 0
27    write $cpubw/bw_hwmon/low_power_io_percent 34
28    write $cpubw/bw_hwmon/low_power_delay 20
29    write $cpubw/bw_hwmon/guard_band_mbps 0
30    write $cpubw/bw_hwmon/up_scale 250
31    write $cpubw/bw_hwmon/idle_mbps 1600
32done
33
34write /sys/class/devfreq/soc:qcom,mincpubw/governor "cpufreq"
35
36# Enable memlat governor
37#for memlat in /sys/class/devfreq/*qcom,memlat-cpu*
38#do
39#    write $memlat/governor "mem_latency"
40#    write $memlat/polling_interval 10
41#    write $memlat/mem_latency/ratio_ceil 400
42#done
43
44# Signal perfd that boot has completed
45setprop sys.post_boot.parsed 1
46
47# On debuggable builds, enable console_suspend if uart is enabled to save power
48# Otherwise, disable console_suspend to get better logging for kernel crashes
49if [[ $(getprop ro.debuggable) == "1" && ! -e /sys/class/tty/ttyMSM0 ]]
50then
51    write /sys/module/printk/parameters/console_suspend N
52fi
53