diff --git a/bengal.mk b/bengal.mk index 01052cd..fd409eb 100644 --- a/bengal.mk +++ b/bengal.mk @@ -52,7 +52,30 @@ PRODUCT_USE_DYNAMIC_PARTITIONS := true # Rootdir PRODUCT_PACKAGES += \ - init.recovery.qcom.rc + hardware_revisions.sh \ + init.class_main.sh \ + init.mdm.sh \ + init.mmi.boot.sh \ + init.mmi.laser.sh \ + init.mmi.touch.sh \ + init.oem.fingerprint2.sh \ + init.oem.hw.sh \ + init.qcom.early_boot.sh \ + init.qcom.post_boot.sh \ + init.qcom.sh \ + init.qti.dcvs.sh \ + init.qti.early_init.sh \ + fstab.qcom \ + init.mmi.charge_only.rc \ + init.mmi.chipset.rc \ + init.mmi.debug.rc \ + init.mmi.overlay.rc \ + init.mmi.rc \ + init.qcom.factory.rc \ + init.qcom.rc \ + init.recovery.qcom.rc \ + init.target.rc \ + ueventd.qcom.rc \ # Shipping API level BOARD_API_LEVEL := 30 diff --git a/rootdir/Android.mk b/rootdir/Android.mk index 0ad2a9e..c2a6fa0 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -1,4 +1,173 @@ LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +include $(CLEAR_VARS) +LOCAL_MODULE := hardware_revisions.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/hardware_revisions.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.class_main.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.class_main.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mdm.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.mdm.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.boot.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.mmi.boot.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.laser.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.mmi.laser.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.touch.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.mmi.touch.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.oem.fingerprint2.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.oem.fingerprint2.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.oem.hw.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.oem.hw.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.qcom.early_boot.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.qcom.early_boot.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.qcom.post_boot.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.qcom.post_boot.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.qcom.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.qcom.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.qti.dcvs.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.qti.dcvs.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.qti.early_init.sh +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := bin/init.qti.early_init.sh +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := fstab.qcom +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/fstab.qcom +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC) +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.charge_only.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.mmi.charge_only.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.chipset.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.mmi.chipset.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.debug.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.mmi.debug.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.overlay.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.mmi.overlay.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.mmi.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.mmi.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.qcom.factory.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.qcom.factory.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.qcom.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.qcom.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) include $(CLEAR_VARS) LOCAL_MODULE := init.recovery.qcom.rc @@ -7,3 +176,20 @@ LOCAL_MODULE_CLASS := ETC LOCAL_SRC_FILES := etc/init.recovery.qcom.rc LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := init.target.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/init.target.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init/hw +include $(BUILD_PREBUILT) + +include $(CLEAR_VARS) +LOCAL_MODULE := ueventd.qcom.rc +LOCAL_MODULE_STEM := ueventd.rc +LOCAL_MODULE_TAGS := optional +LOCAL_MODULE_CLASS := ETC +LOCAL_SRC_FILES := etc/ueventd.qcom.rc +LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR) +include $(BUILD_PREBUILT) diff --git a/rootdir/bin/hardware_revisions.sh b/rootdir/bin/hardware_revisions.sh new file mode 100755 index 0000000..4258f2f --- /dev/null +++ b/rootdir/bin/hardware_revisions.sh @@ -0,0 +1,328 @@ +#!/vendor/bin/sh +# +# Copyright (c) 2013-2016, Motorola LLC All rights reserved. +# +# The purpose of this script is to compile information about the hardware +# versions of various devices on each unit. This is useful when searching +# through reported issues for correlations with certain hardware revisions. +# The information is collected from various locations in proc and sysfs (some +# of which are product-specific) and compiled into small, single-line text +# files in the userdata partition, one for each type of device. The format of +# these lines are as follows: +# +# MOTHREV-vX +# hw_name=XXXXX +# vendor_id=XXXXX +# hw_rev=XXXXX +# date=XXXXX +# lot_code=XXXXX +# fw_rev=XXXXX +# size=XXXXMB +# (components may also add additional fields to the ones above) +# +# The extact format of each field will be device-specific, but should be +# consistent across a particular hardware platform. Note that each revision +# data file is rewritten every time this script is called. This ensures that +# any future format changes to the revision files are picked up. +# +# While the method used to read the information should be consistent on a given +# platform, the specific path to a device's information may vary between +# products. The hardware_revisions.conf file provides a way to adjust those +# paths from the default. +# + +export PATH=/vendor/bin:$PATH + +# Output destination and permissions +OUT_PATH=/data/vendor/hardware_revisions +OUT_USR=system +OUT_GRP=system +OUT_PERM=0644 +OUT_PATH_PERM=0755 + +# Default paths to hardware information +PATH_RAM=/sys/ram +PATH_NVM=/sys/block/mmcblk0/device +PATH_STORAGE=/sys/storage +PATH_SDCARD=/sys/block/mmcblk1/device +PATH_TOUCH_CLASS="/sys/class/touchscreen/"`cd /sys/class/touchscreen && ls */ic_ver | sed 's/ic_ver//g'` +PATH_TOUCH="/sys/bus/i2c/drivers/"`cd /sys/bus/i2c/drivers && ls */?-*/ic_ver | sed 's/ic_ver//g'` +PATH_TOUCH_SPI="/sys/bus/spi/drivers/"`cd /sys/bus/spi/drivers && ls */*.?/ic_ver | sed 's/ic_ver//g'` +PATH_DISPLAY=/sys/class/graphics/fb0 +PATH_DISPLAY_DRM=/sys/class/drm/card0-DSI-1 +PATH_PMIC=/sys/hardware_revisions/pmic + +# Product-specific overrides +[ -e /vendor/etc/hardware_revisions.conf ] && . /vendor/etc/hardware_revisions.conf + +# +# Clear out all revision data in this directory. If in the future we decide +# to remove a component, we want to make sure any old files are not present. +rm /data/vendor/hardware_revisions/* + +# +# Append one piece of revision data to a given file. If a value is blank, +# then nothing will be written. +# +# $1 - tag +# $2 - value +# $3 - file to write +write_one_revision_data() +{ + if [ -n "${2}" ]; then + VALUE="${2}" + echo "${1}=${VALUE}" >> ${3} + fi +} + +# +# Generate the common data contained for +# all hardware peripherals +# +# $1 - file to write to +# $2 - name +# $3 - vendor ID +# $4 - hardware revision +# $5 - date +# $6 - lot code +# $7 - firmware revision +create_common_revision_data() +{ + FILE="${1}" + echo "MOTHREV-v2" > ${FILE} + + write_one_revision_data "hw_name" "${2}" ${FILE} + write_one_revision_data "vendor_id" "${3}" ${FILE} + write_one_revision_data "hw_rev" "${4}" ${FILE} + write_one_revision_data "date" "${5}" ${FILE} + write_one_revision_data "lot_code" "${6}" ${FILE} + write_one_revision_data "fw_rev" "${7}" ${FILE} + +} + +# +# Applies the appropriate file permissions to the +# hardware revision data file. +# +# $1 - file to write to +apply_revision_data_perms() +{ + chown ${OUT_USR}.${OUT_GRP} "${1}" + chmod ${OUT_PERM} "${1}" +} + +mkdir -p ${OUT_PATH} +chown ${OUT_USR}.${OUT_GRP} ${OUT_PATH} +chmod ${OUT_PATH_PERM} ${OUT_PATH} + + +# +# Compile ram +# +FILE="${OUT_PATH}/ram" +HNAME= +VEND= +HREV= +DATE= +FREV= +LOT_CODE= +INFO= +SIZE= +if [ -d "${PATH_RAM}" ] ; then + HNAME=`cat ${PATH_RAM}/type` + VEND=`cat ${PATH_RAM}/info` + VEND="${VEND%%:*:*}" + INFO="$(cat ${PATH_RAM}/mr5),$(cat ${PATH_RAM}/mr6),$(cat ${PATH_RAM}/mr7),\ +$(cat ${PATH_RAM}/mr8)" + SIZE=`cat ${PATH_RAM}/size` +fi +create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "" "" "" "" +write_one_revision_data "config_info" "${INFO}" "${FILE}" +write_one_revision_data "size" "${SIZE}" "${FILE}" +apply_revision_data_perms "${FILE}" + + +# +# Compile nvm +# +FILE="${OUT_PATH}/nvm" +HNAME= +VEND= +HREV= +DATE= +FREV= +LOT_CODE= +SIZE= +if [ -d "${PATH_NVM}" ] ; then + HNAME=`cat ${PATH_NVM}/type` + if [ -d "${PATH_STORAGE}" ] ; then + VEND=`cat ${PATH_STORAGE}/vendor` + SIZE=$((1024 * `cat ${PATH_STORAGE}/size | sed 's/[^0-9]//g'`)) + else + VEND=`cat ${PATH_NVM}/manfid` + SIZE=$((1024 * `getprop ro.boot.storage | sed 's/[^0-9]//g'`)) + fi + HREV=`cat ${PATH_NVM}/name` + DATE=`cat ${PATH_NVM}/date` + if [ -e ${PATH_NVM}/device_version -a -e ${PATH_NVM}/firmware_version ] ; then + FREV="$(cat ${PATH_NVM}/device_version),$(cat ${PATH_NVM}/firmware_version)" + else + FREV="$(cat ${PATH_NVM}/hwrev),$(cat ${PATH_NVM}/fwrev)" + fi + LOT_CODE="$(cat ${PATH_NVM}/csd)" +else + if [ -d "${PATH_STORAGE}" ] ; then + HNAME=`cat ${PATH_STORAGE}/type` + VEND=`cat ${PATH_STORAGE}/vendor` + HREV=`cat ${PATH_STORAGE}/model` + FREV=`cat ${PATH_STORAGE}/fw` + SIZE=$((1024 * `cat ${PATH_STORAGE}/size | sed 's/[^0-9]//g'`)) + fi +fi +create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}" +write_one_revision_data "size" "${SIZE}" "${FILE}" +apply_revision_data_perms "${FILE}" + + +# +# Compile ap +# +FILE="${OUT_PATH}/ap" +HNAME= +VEND= +HREV= +DATE= +FREV= +LOT_CODE= +if [ -e "/proc/cpuinfo" ]; then + PREVIFS="$IFS" + IFS=" +" + for CPU in `cat /proc/cpuinfo` ; do + KEY="${CPU%:*}" + VAL="${CPU#*: }" + case "${KEY}" in + Processor*) HNAME="${VAL}" ;; + *implementer*) VEND="${VAL}" ;; + *variant*) HREV="${VAL}" ;; + *part*) HREV="${HREV},${VAL}" ;; + *revision*) HREV="${HREV},${VAL}" ;; + esac + done + IFS="$PREVIFS" +fi +create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "" "" "" +apply_revision_data_perms "${FILE}" + + +# +# copy pmic data +# +if [ -e "/sys/hardware_revisions/pmic" ]; then + cat /sys/hardware_revisions/pmic > ${OUT_PATH}/pmic +else + create_common_revision_data "${OUT_PATH}/pmic" "" "" "" "" "" "" +fi +apply_revision_data_perms "${OUT_PATH}/pmic" + + +# +# copy display data +# PATH_DISPLAY_DRM is the sys file path name for DRM display driver +# PATH_DISPLAY is the path name for the old FB driver +# +FILE="${OUT_PATH}/display" +HNAME= +VEND= +HREV= +if [ -e ${PATH_DISPLAY_DRM}/panelName ] ; then + HNAME=`cat ${PATH_DISPLAY_DRM}/panelName` + VEND=`cat ${PATH_DISPLAY_DRM}/panelSupplier` + HREV=`cat ${PATH_DISPLAY_DRM}/panelVer` +else + HNAME=`cat ${PATH_DISPLAY}/panel_name` + VEND=`cat ${PATH_DISPLAY}/panel_supplier` + HREV=`cat ${PATH_DISPLAY}/panel_ver` +fi +create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "" "" "" +apply_revision_data_perms "${FILE}" + + +# +# Compile touchscreen +# +FILE="${OUT_PATH}/touchscreen" +HNAME= +VEND= +HREV= +DATE= +FREV= +LOT_CODE= + +# If there is the touchclass path, then access the nodes under the path to get the touch related +# information, otherwise access the path originally defined by the script. +if [ -e "${PATH_TOUCH_CLASS}/vendor" ]; then + HNAME=`cat ${PATH_TOUCH_CLASS}/vendor` + ICVER=`cat -e ${PATH_TOUCH_CLASS}/ic_ver` + if [ "$HNAME" ]; then + VEND="${ICVER##*'Product ID: '}" + VEND="${VEND%%\$*}" + FREV="${ICVER##*'Build ID: '}" + FREV="${FREV%%\$*}" + LOT_CODE="${ICVER##*'Config ID: '}" + LOT_CODE="${LOT_CODE%%\$*}" + fi +elif [ -e "${PATH_TOUCH_SPI}/name" ]; then + HNAME=`cat ${PATH_TOUCH_SPI}/name` + ICVER=`cat -e ${PATH_TOUCH_SPI}/ic_ver` + case "$HNAME" in + focaltech*) + VEND="${ICVER##*'Product ID: '}" + VEND="${VEND%%\$*}" + FREV="${ICVER##*'Build ID: '}" + FREV="${FREV%%\$*}" + ;; + esac +else + if [ -e "${PATH_TOUCH}/name" ]; then + HNAME=`cat ${PATH_TOUCH}/name` + ICVER=`cat -e ${PATH_TOUCH}/ic_ver` + case "${HNAME}" in + melfas*) + VEND="Melfas" + HREV="${ICVER##*'HW Revision:'}" + HREV="${HREV%%\$*}" + FREV="${ICVER##*'Core FW ver:'}" + FREV="${FREV%%\$*}" + ;; + cyttsp*) + VEND="${ICVER##*'Custom ID:'}" + VEND="${VEND%%\$*}" + VEND="Cypress,${VEND}" + HREV="${ICVER##*'TTSP Version:'}" + HREV="${HREV%%\$*}" + FREV="${ICVER##*'Application Version:'}" + FREV="${FREV%%\$*}" + ;; + atmxt*) + VEND="Atmel" + HREV="${ICVER##*'Family ID:'}" + HREV1="${ICVER##*'Variant ID:'}" + HREV="${HREV%%\$*},${HREV1%%\$*}" + FREV="${ICVER##*'Version:'}" + FREV1="${ICVER##*'Build:'}" + FREV="${FREV%%\$*},${FREV1%%\$*}" + ;; + synaptics*) + VEND="${ICVER##*'Product ID: '}" + VEND="${VEND%%\$*}" + FREV="${ICVER##*'Build ID: '}" + FREV="${FREV%%\$*}" + LOT_CODE="${ICVER##*'Config ID: '}" + LOT_CODE="${LOT_CODE%%\$*}" + ;; + esac + fi +fi +create_common_revision_data "${FILE}" "${HNAME}" "${VEND}" "${HREV}" "${DATE}" "${LOT_CODE}" "${FREV}" +apply_revision_data_perms "${FILE}" \ No newline at end of file diff --git a/rootdir/bin/init.class_main.sh b/rootdir/bin/init.class_main.sh new file mode 100755 index 0000000..05c3251 --- /dev/null +++ b/rootdir/bin/init.class_main.sh @@ -0,0 +1,155 @@ +#! /vendor/bin/sh + +# Copyright (c) 2013-2014, 2019 The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# +# start ril-daemon only for targets on which radio is present +# +baseband=`getprop ro.baseband` +sgltecsfb=`getprop persist.vendor.radio.sglte_csfb` +datamode=`getprop persist.vendor.data.mode` +low_ram=`getprop ro.config.low_ram` +qcrild_status=true + +case "$baseband" in + "apq" | "sda" | "qcs" ) + setprop ro.vendor.radio.noril yes + stop vendor.ril-daemon + stop vendor.qcrild +esac + +case "$baseband" in + "msm" | "csfb" | "svlte2a" | "mdm" | "mdm2" | "sglte" | "sglte2" | "dsda2" | "unknown" | "dsda3" | "sdm" | "sdx" | "sm6") + + # For older modem packages launch ril-daemon. + if [ -f /vendor/firmware_mnt/verinfo/ver_info.txt ]; then + modem=`cat /vendor/firmware_mnt/verinfo/ver_info.txt | + sed -n 's/^[^:]*modem[^:]*:[[:blank:]]*//p' | + sed 's/.*MPSS.\(.*\)/\1/g' | cut -d \. -f 1` + if [ "$modem" = "AT" ]; then + version=`cat /vendor/firmware_mnt/verinfo/ver_info.txt | + sed -n 's/^[^:]*modem[^:]*:[[:blank:]]*//p' | + sed 's/.*AT.\(.*\)/\1/g' | cut -d \- -f 1` + if [ ! -z $version ]; then + if [ "$version" \< "3.1" ]; then + qcrild_status=false + fi + fi + elif [ "$modem" = "TA" ]; then + version=`cat /vendor/firmware_mnt/verinfo/ver_info.txt | + sed -n 's/^[^:]*modem[^:]*:[[:blank:]]*//p' | + sed 's/.*TA.\(.*\)/\1/g' | cut -d \- -f 1` + if [ ! -z $version ]; then + if [ "$version" \< "3.0" ]; then + qcrild_status=false + fi + fi + elif [ "$modem" = "JO" ]; then + version=`cat /vendor/firmware_mnt/verinfo/ver_info.txt | + sed -n 's/^[^:]*modem[^:]*:[[:blank:]]*//p' | + sed 's/.*JO.\(.*\)/\1/g' | cut -d \- -f 1` + if [ ! -z $version ]; then + if [ "$version" \< "3.2" ]; then + qcrild_status=false + fi + fi + elif [ "$modem" = "TH" ]; then + qcrild_status=false + fi + fi + + if [ "$qcrild_status" = "true" ]; then + # Make sure both rild, qcrild are not running at same time. + # This is possible with vanilla aosp system image. + stop vendor.ril-daemon + + start vendor.qcrild + else + start vendor.ril-daemon + fi + + case "$baseband" in + "svlte2a" | "csfb") + start qmiproxy + ;; + "sglte" | "sglte2" ) + if [ "x$sgltecsfb" != "xtrue" ]; then + start qmiproxy + else + setprop persist.vendor.radio.voice.modem.index 0 + fi + ;; + esac + + multisim=`getprop persist.radio.multisim.config` + + if [ "$multisim" = "dsds" ] || [ "$multisim" = "dsda" ]; then + if [ "$qcrild_status" = "true" ]; then + start vendor.qcrild2 + else + start vendor.ril-daemon2 + fi + elif [ "$multisim" = "tsts" ]; then + if [ "$qcrild_status" = "true" ]; then + start vendor.qcrild2 + start vendor.qcrild3 + else + start vendor.ril-daemon2 + start vendor.ril-daemon3 + fi + fi + + case "$datamode" in + "tethered") + start vendor.dataqti + if [ "$low_ram" != "true" ]; then + start vendor.dataadpl + fi + ;; + "concurrent") + start vendor.dataqti + if [ "$low_ram" != "true" ]; then + start vendor.dataadpl + fi + ;; + *) + ;; + esac +esac + +# +# Allow persistent faking of bms +# User needs to set fake bms charge in persist.vendor.bms.fake_batt_capacity +# +fake_batt_capacity=`getprop persist.vendor.bms.fake_batt_capacity` +case "$fake_batt_capacity" in + "") ;; #Do nothing here + * ) + echo "$fake_batt_capacity" > /sys/class/power_supply/battery/capacity + ;; +esac diff --git a/rootdir/bin/init.mdm.sh b/rootdir/bin/init.mdm.sh new file mode 100755 index 0000000..3ed7ed5 --- /dev/null +++ b/rootdir/bin/init.mdm.sh @@ -0,0 +1,34 @@ +#! /vendor/bin/sh + +# Copyright (c) 2013, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +baseband=`getprop ro.baseband` +if [ "$baseband" = "mdm" ] || [ "$baseband" = "mdm2" ]; then + start vendor.mdm_helper +fi + diff --git a/rootdir/bin/init.mmi.boot.sh b/rootdir/bin/init.mmi.boot.sh new file mode 100755 index 0000000..0e11777 --- /dev/null +++ b/rootdir/bin/init.mmi.boot.sh @@ -0,0 +1,151 @@ +#!/vendor/bin/sh + +PATH=/sbin:/vendor/sbin:/vendor/bin:/vendor/xbin +export PATH + +scriptname=${0##*/} + +notice() +{ + echo "$*" + echo "$scriptname: $*" > /dev/kmsg +} + +# We take this from cpuinfo because hex "letters" are lowercase there +set -A cinfo `cat /proc/cpuinfo | sed -n "/Revision/p"` +hw=${cinfo[2]#?} + +# Now "cook" the value so it can be matched against devtree names +m2=${hw%?} +minor2=${hw#$m2} +m1=${m2%?} +minor1=${m2#$m1} +if [ "$minor2" == "0" ]; then + minor2="" + if [ "$minor1" == "0" ]; then + minor1="" + fi +fi +setprop ro.vendor.hw.revision p${hw%??}$minor1$minor2 +unset hw cinfo m1 m2 minor1 minor2 + +# reload UTAGS +utag_status=$(cat /proc/config/reload) +if [ "$utag_status" == "2" ]; then + notice "Utags are not ready, reloading" + echo 1 > /proc/config/reload + utag_status=$(cat /proc/config/reload) + [ "$utag_status" != "0" ] && notice "Utags failed to reload" +fi + +# Export these for factory validation purposes +iccid=$(cat /proc/config/iccid/ascii 2>/dev/null) +if [ ! -z "$iccid" ]; then + setprop ro.vendor.mot.iccid $iccid +fi +unset iccid +cust_md5=$(cat /proc/config/cust_md5/ascii 2>/dev/null) +if [ ! -z "$cust_md5" ]; then + setprop ro.vendor.mot.cust_md5 $cust_md5 +fi +unset cust_md5 + +# Get FTI data and catch old units with incorrect/missing UTAG_FTI +pds_fti=/mnt/vendor/persist/factory/fti +if [ -r $pds_fti ]; then + set -A fti $(od -A n -t x1 $pds_fti 2>/dev/null | tr '[A-F]' '[a-f]') +else + notice "Can not read FTI data in persist" +fi + +# If UTAG_FTI is readable, compare checksums +# and if they mismatch, assume PDS is valid and overwrite UTAG +utag_fti=/proc/config/fti +if [ -r $utag_fti/ascii ]; then + set -A fti_utag $(cat ${utag_fti}/raw | sed 's/../& /g' | tr '[A-F]' '[a-f]') + # Byte 128 is total cksum, if nothing there, PDS data is invalid/missing + if [ ! -z "${fti[127]}" ]; then + # Make sure fti in UTAG is the same as in persist. Checksum comparison + if [ "${fti[126]}" != "${fti_utag[126]}" -o "${fti[127]}" != "${fti_utag[127]}" ]; then + notice "Copying FTI data from persist" + cat $pds_fti > ${utag_fti}/raw + fi + else + # If PDS data is invalid, take UTAG and hope it is correct + notice "Will use FTI from UTAG" + set -A fti $(od -A n -t x1 ${utag_fti}/ascii 2>/dev/null) + fi +else + notice "Missing FTI UTAG; copying from persist" + echo fti > /proc/config/all/new + cat $pds_fti > ${utag_fti}/raw +fi + +# Read HW version from FTI data +hw_v1="\x${fti[35]}" +hw_v2="\x${fti[36]}" +hw_v3="\x${fti[37]}" +if [ "$hw_v3" == "\x30" ]; then + hw_v3="" +fi +hw_v4="\x${fti[38]}" +if [ "$hw_v4" == "\x30" ]; then + hw_v4="" +fi +setprop ro.vendor.hw.boardversion $(printf "$hw_v1$hw_v2$hw_v3$hw_v4") + +# Now we have set fti var either from PDS or UTAG +# Get Last Test Station stamp from FTI +# and convert to user-friendly date, US format +# Real offsets for year/month/day are 63/64/65 +# If the month/date look reasonable, data is probably OK. +mdate="Unknown" +y=0x${fti[63]} +m=0x${fti[64]} +d=0x${fti[65]} +let year=$y month=$m day=$d +# Invalid data will often have bogus month/date values +if [ $month -le 12 -a $day -le 31 -a $year -ge 12 ]; then + mdate=$month/$day/20$year +else + notice "Corrupt FTI data" +fi +setprop ro.vendor.manufacturedate $mdate +unset fti y m d year month day utag_fti pds_fti fti_utag mdate + +t=$(getprop ro.build.tags) +if [[ "$t" != *release* ]]; then + for p in $(cat /proc/cmdline); do + if [ ${p%%:*} = "@" ]; then + v=${p#@:}; a=${v%=*}; b=${v#*=} + ${a%%:*} ${a##*:} $b + fi + done +fi +unset p v a b t + +# Cleanup stale/incorrect programmed model value +# Real values will never contain substrings matching "internal" device name +product=$(getprop ro.vendor.hw.device) +model=$(cat /proc/config/model/ascii 2>/dev/null) +if [ $? -eq 0 ]; then + if [ "${model#*_}" == "$product" -o "${model%_*}" == "$product" ]; then + notice "Clearing stale model value" + echo "" > /proc/config/model/raw + fi +fi +unset model product + +# set ro.vendor.bootreason, which be used to indicate kpanic/wdt boot status. +# When ro.boot.last_powerup_reason is set, it denotes this is a 2nd reboot +# after kpanic/wdt, we set ro.bootreason as coldboot to copy logs. +# Otherwise, we would set ro.bootreason the same as ro.boot.bootreason. +# ro.boot.bootreason is restricted as of android p, so get it another way: +bootreason_kvp=$(cat /proc/bootinfo | grep "Last boot reason") +last_power_up=$(getprop ro.boot.last_powerup_reason) +if [ ! -z "$last_power_up" ] +then + setprop ro.vendor.bootreason "coldboot" +else + setprop ro.vendor.bootreason ${bootreason_kvp##* } +fi diff --git a/rootdir/bin/init.mmi.laser.sh b/rootdir/bin/init.mmi.laser.sh new file mode 100755 index 0000000..144d5a3 --- /dev/null +++ b/rootdir/bin/init.mmi.laser.sh @@ -0,0 +1,95 @@ +#!/vendor/bin/sh +scriptname=${0##*/} +dbg_on=1 +debug() +{ + [ $dbg_on ] && echo "Debug: $*" +} + +notice() +{ + echo "$*" + echo "$scriptname: $*" > /dev/kmsg +} + +error_and_leave() +{ + local err_msg + local err_code=$1 + case $err_code in + 1) err_msg="Error: No response";; + 2) err_msg="Error: Skip to overwrite xtalk and offset data in factory mode";; + 3) err_msg="Error: Calibration data file $2 does not exist";; + 4) err_msg="Error: Calibration sysfs path $2 does not show up";; + esac + notice "$err_msg" + exit $err_code +} + +# Change laser sysfs file ownership +laser_class_path=/sys/devices/virtual/laser +laser_product_string=$(ls $laser_class_path) +laser_product_path=$laser_class_path/$laser_product_string +for laser_file in $laser_product_path/*; do + if [ -f "$laser_file" ]; then + chown root:system $laser_file + fi +done + +if [ ! -d $laser_product_path ]; then + error_and_leave 4 "'$laser_product_path'" +fi + +# Change laser input sysfs file ownership +laser_input_root=/sys/devices/virtual/input +laser_input_list=$(ls $laser_input_root) +for laser_input_dir in $laser_input_list; do + if [ -f "$laser_input_root/$laser_input_dir/calibration_data" ]; then + laser_calib_file=$laser_input_root/$laser_input_dir/calibration_data + chown root:system $laser_calib_file + fi + if [ -f "$laser_input_root/$laser_input_dir/xtalk" ]; then + laser_xtalk_file=$laser_input_root/$laser_input_dir/xtalk + chown root:system $laser_xtalk_file + fi + if [ -f "$laser_input_root/$laser_input_dir/offset" ]; then + laser_offset_file=$laser_input_root/$laser_input_dir/offset + chown root:system $laser_offset_file + fi +done + +if [ -z "$laser_calib_file" ]; then + laser_calib_file=$laser_product_path/calibration_data +fi +if [ -z "$laser_xtalk_file" ]; then + laser_xtalk_file=$laser_product_path/xtalk +fi +if [ -z "$laser_offset_file" ]; then + laser_offset_file=$laser_product_path/offset +fi + +# Load calibration data +calib_data_file=/mnt/vendor/persist/camera/focus/cal_data +if [ -f $calib_data_file ]; then + chown root:vendor_tcmd $calib_data_file + chmod 660 $calib_data_file + if [ -z "$laser_calib_file" ]; then + error_and_leave 4 "'$laser_calib_file'" + else + cat $calib_data_file > $laser_calib_file + notice "laser calibration data updating complete" + fi +else + notice "laser calib_data_file '$calib_data_file' does not exist" +fi + +bootmode=$(getprop ro.bootmode 2> /dev/null) +if [ $bootmode != "mot-factory" ]; then + # Enable smudge mode + echo 1 > $laser_product_path/smudge_correction_mode + notice "laser smudge mode enabled" +else + # Disable smudge mode + echo 0 > $laser_product_path/smudge_correction_mode + notice "factory-mode boot, disable laser smudge mode" +fi diff --git a/rootdir/bin/init.mmi.touch.sh b/rootdir/bin/init.mmi.touch.sh new file mode 100755 index 0000000..5c36109 --- /dev/null +++ b/rootdir/bin/init.mmi.touch.sh @@ -0,0 +1,624 @@ +#!/vendor/bin/sh + +PATH=/sbin:/vendor/sbin:/vendor/bin:/vendor/xbin +export PATH + +while getopts cds op; +do + case $op in + c) cal_on=1;; + d) dbg_on=1;; + s) dump_statistics=1;; + esac +done +shift $(($OPTIND-1)) + +# Globals +scriptname=${0##*/} +touch_class_path=/sys/class/touchscreen +touch_status_prop= +touch_update_prop= +touch_calibration_done_version=persist.vendor.touch.calibration +touch_vendor= +touch_path= +panel_path=/sys/devices/virtual/graphics/fb0 +oem_panel_script=/vendor/bin/init.oem.panel.sh +dlkm_path=/vendor/lib/modules +device_property=ro.vendor.hw.device +hwrev_property=ro.vendor.hw.revision +firmware_path=/vendor/firmware +param_path=/data/vendor/param/touch +factory_property=ro.vendor.build.motfactory +bootmode_property=ro.bootmode +touch_firmware_property=ro.vendor.touch.fw_version +touch_vendor_property=ro.vendor.touch.supplier_vendor +let dec_cfg_id_boot=0 +let dec_cfg_id_latest=0 +# Whether to search for TP firmware in the parameter path +let search_in_param=0 +# Whether the matching TP firmware is found in the parameter path +let find_in_param=0 +typeset -l product_id +panel_ver= +supplier= +property= +config_id= +build_id= +hwrev_id= +str_cfg_id_new= +str_cfg_id_boot= +str_cfg_id_latest= +build_id_new= + +debug() +{ + [ $dbg_on ] && echo "Debug: $*" +} + +notice() +{ + echo "$*" + echo "$scriptname: $*" > /dev/kmsg +} + +sanity_check() +{ + read_touch_property flashprog || return 1 + [[ ( -z "$property" ) || ( "$property" == "1" ) ]] && return 2 + read_touch_property productinfo || return 1 + [[ ( -z "$property" ) || ( "$property" == "0" ) ]] && return 2 + read_touch_property buildid || return 1 + config_id=${property#*-} + [[ ( -z "$config_id" ) || ( "$config_id" == "0" ) ]] && return 2 + build_id=${property%-*} + [[ ( -z "$build_id" ) || ( "$build_id" == "0" ) ]] && return 2 + return 0 +} + +error_msg() +{ + local err_msg + local err_code=$1 + case $err_code in + 1) err_msg="Error: No response from touch IC";; + 2) err_msg="Error: Cannot read property $2";; + 3) err_msg="Error: No matching firmware file found";; + 4) err_msg="Error: Touch IC is in bootloader mode";; + 5) err_msg="Error: Touch provides no reflash interface";; + 6) err_msg="Error: Touch driver is not running";; + 7) err_msg="Warning: Touch firmware is not the latest";; + 8) err_msg="Info: Touch class does not exist";; + 9) err_msg="Error: Touch IC is not ready to flash";; + esac + notice "$err_msg" +} + +error_and_leave() +{ + local err_code=$1 + local touch_status="unknown" + error_msg $err_code + case $err_code in + 1|4) touch_status="dead";; + 5|6|8) touch_status="absent";; + esac + + # perform sanity check and declare touch ready if error is not fatal + if [ "$touch_status" == "unknown" ]; then + sanity_check + case "$?" in + 0) touch_status="ready";; + 2) touch_status="dead";; + 1) touch_status="absent";; + esac + fi + + # perform recovery if touch is declared dead + if [ "$touch_status" == "dead" ]; then + notice "Touch needs to go through recovery!!!" + reboot_cnt=$(getprop $touch_status_prop 2>/dev/null) + [ -z "$reboot_cnt" ] && reboot_cnt=0 + debug "current reboot counter [$reboot_cnt]" + fi + + setprop $touch_status_prop $touch_status + notice "property [$touch_status_prop] set to [`getprop $touch_status_prop`]" + + if [ "$touch_status" == "dead" ]; then + notice "Touch is not responding; no further action!!!" + #if [ $((reboot_cnt)) -lt 2 ]; then + # notice "Touch is not working; rebooting..." + # debug "sleep 3s to allow touch-dead-sh service to run" + # sleep 3 + # [ -z "$dbg_on" ] && setprop sys.powerctl reboot + #else + # notice "Although touch is not working, no more reboots" + #fi + fi + + exit $err_code +} + +prepend() +{ + local list="" + local prefix=$1 + shift + for name in $*; do + list="$list$prefix/$name " + done + echo $list +} + +dump_statistics() +{ + debug "dumping touch statistics" + cat $touch_path/ic_ver + [ -f $touch_path/stats ] && cat $touch_path/stats + return 0 +} + +wait_for_poweron() +{ + local wait_nomore + local readiness + local count + debug "wait until driver reports ..." + wait_nomore=60 + count=0 + while true; do + readiness=$(cat $touch_path/poweron) + if [ "$readiness" == "1" ]; then + debug "ready to flash!!!" + break; + fi + count=$((count+1)) + [ $count -eq $wait_nomore ] && break + sleep 1 + debug "not ready; keep waiting..." + done + if [ $count -eq $wait_nomore ]; then + error_msg 9 + return 1 + fi + return 0 +} + +setup_permissions() +{ + local bootmode=$(getprop $bootmode_property 2> /dev/null) + local selinux=$(getprop ro.boot.selinux 2> /dev/null) + local key_path + local key_files + local entry + if [[ ("$selinux" == "permissive") || ("$bootmode" == "mot-factory") ]]; then + debug "loosen permissions to $touch_vendor files" + case $touch_vendor in + samsung) key_path="/sys/devices/virtual/sec/sec_ts/" + key_files=$(ls $key_path 2>/dev/null) + # Set optional permissions to LSI touch tests + [ -f $touch_path/size ] && chown root:vendor_tcmd $touch_path/size + [ -f $touch_path/address ] && chown root:vendor_tcmd $touch_path/address + [ -f $touch_path/write ] && chown root:vendor_tcmd $touch_path/write + ;; + synaptics) key_path=$touch_path + key_files=$(prepend f54 `ls $touch_path/f54/ 2>/dev/null`) + key_files=$key_files"reporting query stats";; + focaltech) key_path="/proc/" + key_files="ftxxxx-debug";; + ilitek) key_path="/proc/ilitek" + key_files="ioctl";; + goodix) key_path="/proc/" + key_files="gmnode" + if [[ "$touch_instance" == "GTx5" ]] || [[ "$touch_instance" == "GTx8" ]]; then + key_path="/dev/" + key_files="gtp_tools" + fi + ;; + stmicro) key_path="/proc/fts/" + key_files="driver_test" + # Set optional permissions to LSI touch tests + [ -f $touch_path/calibrate ] && chown root:vendor_tcmd $touch_path/calibrate + ;; + esac + for entry in $key_files; do + chmod 0666 $key_path/$entry + debug "change permissions of $key_path/$entry" + done + fi + # Set permissions to enable factory touch tests + chown root:vendor_tcmd $touch_path/drv_irq + chown root:vendor_tcmd $touch_path/hw_irqstat + chown root:vendor_tcmd $touch_path/reset + + # Set permissions to allow Bug2Go access to touch statistics + chown root:log $touch_path/stats + # Erase is optional + [ -f $touch_path/erase_all ] && chown root:vendor_tcmd $touch_path/erase_all +} + +read_touch_property() +{ + property="" + debug "retrieving property: [$touch_path/$1]" + property=$(cat $touch_path/$1 2> /dev/null) + debug "touch property [$1] is: [$property]" + [ -z "$property" ] && return 1 + return 0 +} + +read_panel_property() +{ + property="" + debug "retrieving panel property: [$panel_path/$1]" + property=$(cat $panel_path/$1 2> /dev/null) + debug "panel property [$1] is: [$property]" + [ -z "$property" ] && return 1 + return 0 +} + +find_latest_config_id() +{ + local fw_mask=$1 + local skip_fields=$2 + local dec max z str_hex i + str_cfg_id_latest="" + debug "scanning dir for files matching [$fw_mask]" + let dec=0; max=0; + for file in $(ls $fw_mask 2>/dev/null); do + z=$file + i=0 + while [ ! $i -eq $skip_fields ]; do + z=${z#*-} + i=$((i+1)) + done + str_hex=${z%%-*}; + let dec=0x$str_hex + if [ $dec -gt $max ]; then + let max=$dec; dec_cfg_id_latest=$dec; + str_cfg_id_latest=$str_hex + fi + done + [ -z "$str_cfg_id_latest" ] && return 1 + return 0 +} + +find_best_match() +{ + local hw_mask=$1 + local panel_supplier=$2 + local skip_fields fw_mask + local match_best_cfg + local match_best_cfg_dec param_cfg_dec + let match_best_cfg_dec=0 + let param_cfg_dec=0 + + while [ ! -z "$hw_mask" ]; do + if [ "$hw_mask" == "-" ]; then + hw_mask="" + fi + if [ ! -z "$panel_supplier" ]; then + skip_fields=3 + fw_mask="$touch_vendor-$panel_supplier-$touch_product_id-*-$product_id$hw_mask.*" + else + skip_fields=2 + fw_mask="$touch_vendor-$touch_product_id-*-$product_id$hw_mask.*" + fi + find_latest_config_id "$fw_mask" "$skip_fields" + if [ "$?" == "0" ]; then + let match_best_cfg_dec=$dec_cfg_id_latest + match_best_cfg=$str_cfg_id_latest + fi + if [ "$search_in_param" == "1" ]; then + cd $param_path + find_latest_config_id "$fw_mask" "$skip_fields" + if [ "$?" == "0" ]; then + if [ $match_best_cfg_dec -lt $dec_cfg_id_latest ]; then + let match_best_cfg_dec=$dec_cfg_id_latest + match_best_cfg=$str_cfg_id_latest + let find_in_param=1 + else + cd $firmware_path + fi + else + cd $firmware_path + fi + fi + [ $match_best_cfg_dec != 0 ] && break + hw_mask=${hw_mask%?} + done + str_cfg_id_latest=$match_best_cfg + dec_cfg_id_latest=$match_best_cfg_dec + [ -z "$match_best_cfg" ] && return 1 + if [ -z "$panel_supplier" ]; then + firmware_file=$(ls $touch_vendor-$touch_product_id-$str_cfg_id_latest-*-$product_id$hw_mask.*) + else + firmware_file=$(ls $touch_vendor-$panel_supplier-$touch_product_id-$str_cfg_id_latest-*-$product_id$hw_mask.*) + fi + notice "Firmware file for upgrade $firmware_file" + return 0 +} + +query_touch_info() +{ + read_touch_property flashprog + bl_mode=$property + debug "bl mode: $bl_mode" + while true; do + read_touch_property productinfo + touch_product_id=$property + if [ "$touch_product_id" ]; then + # driver might not be ready yet, wait + debug "touch product id: $touch_product_id" + break + fi + sleep 1 + done + if [ "$touch_product_id" == "0" ]; then + debug "touch ic reports invalid product id" + error_msg 1 + return 1 + fi + read_touch_property buildid + str_cfg_id_boot=${property#*-} + let dec_cfg_id_boot=0x$str_cfg_id_boot + debug "touch config id: $str_cfg_id_boot" + build_id_boot=${property%-*} + debug "touch build id: $build_id_boot" + return 0 +} + +query_panel_info() +{ + supplier="" + read_touch_property "panel_supplier" + [ -z "$property" ] && read_panel_property "panel_supplier" + supplier=$property + if [ "$supplier" ]; then + read_panel_property "controller_drv_ver" + panel_ver=${property#${property%?}} + debug "panel supplier: $supplier, ver $panel_ver" + setprop $touch_vendor_property "$supplier-$touch_vendor" + notice "touch_vendor_property = $touch_vendor_property, $supplier-$touch_vendor" + else + debug "driver does not report panel supplier" + fi +} + +load_driver_modules() +{ + if [ "$supplier" ]; then + if [ -f $oem_panel_script ]; then + debug "load_driver_modules()" + $oem_panel_script -s $supplier + fi + fi +} + +search_firmware_file() +{ + local match_not_found + match_not_found=1 + if [ "$supplier" ]; then + for pattern in "$supplier$panel_ver" "$supplier"; do + debug "search for best hw revision match with supplier" + find_best_match "-$hwrev_id" "$pattern" + match_not_found=$? + [ "$match_not_found" == "0" ] && break + done + fi + if [ "$match_not_found" != "0" ]; then + debug "search for best hw revision match without supplier" + find_best_match "-$hwrev_id" + if [ "$?" != "0" ]; then + error_msg 3 + return 1 + fi + fi + return 0 +} + +reload_modules() +{ + local rc + local module + for module in $*; do + [ -f $dlkm_path/$module.ko ] || continue + notice "Reloading [$module.ko]..." + rmmod $module + rc=$? + [ $rc != 0 ] && notice "Unloading [$module] failed: $rc" + insmod $dlkm_path/$module.ko + rc=$? + [ $rc != 0 ] && notice "Loading [$module] failed: $rc" + done +} + +run_firmware_upgrade() +{ + local recovery + recovery=0 + if [ "$bl_mode" == "1" ] || [ "$build_id_boot" == "0" ]; then + recovery=1 + notice "Initiating touch firmware recovery" + notice " bl mode = $bl_mode" + notice " build id = $build_id_boot" + fi + if [ $dec_cfg_id_boot -ne $dec_cfg_id_latest ] || [ "$recovery" == "1" ]; then + wait_for_poweron + # wait for poweron time is limited, thus in ceratin cases + # it can time out. forfeiting firmware update in this case + # would be cleaner option, since script cannot indefinitely + # delay sysfs permissions setup and cause more troubles + if [ "$?" != "0" ]; then + notice "Touch firmware update forfeited!!!" + return 1 + fi + debug "forcing firmware upgrade" + echo 1 > $touch_path/forcereflash + debug "sending reflash command" + if [ "$find_in_param" == "1" ]; then + notice "Start touchUpg service, upgrade tp firmware parameters" + echo 1 > $touch_path/flash_mode + start vendor.touchUpg + else + echo 0 > $touch_path/flash_mode + fi + echo $firmware_file > $touch_path/doreflash + read_touch_property flashprog + if [ "$?" != "0" ]; then + error_msg 1 + return 1 + fi + bl_mode=$property + if [ "$bl_mode" == "1" ]; then + error_msg 4 + return 1 + fi + read_touch_property buildid + if [ "$?" != "0" ]; then + error_msg 1 + return 1 + fi + str_cfg_id_new=${property#*-} + build_id_new=${property%-*} + notice "Touch firmware config id at boot time $str_cfg_id_boot" + notice "Touch firmware config id in the file $str_cfg_id_latest" + notice "Touch firmware config id currently programmed $str_cfg_id_new" + [ "$str_cfg_id_latest" != "$str_cfg_id_new" ] && error_msg 7 && return 1 + # indicate that update has been completed + setprop $touch_update_prop "completed" + notice "property [$touch_update_prop] set to [`getprop $touch_update_prop`]" + if [ "$touch_vendor" == "synaptics" ]; then + notice "forcing F54 registers update" + echo 1 > $touch_path/f54/force_update + notice "need to reload F54" + reload_modules "synaptics_dsx_test_reporting" + fi + fi + return 0 +} + +do_sec_calibration() +{ + local __result=$1 + local info + local rc + + sleep 3 + echo run_force_calibration > /sys/devices/virtual/sec/tsp/cmd + rc=$(cat /sys/devices/virtual/sec/tsp/cmd_result) + [ "$rc" != "run_force_calibration:OK" ] && return 1 + info=$(cat $touch_class_path/$touch_instance/buildid) + if [ -f $touch_class_path/$touch_instance/mutual_range ]; then + info=$info";$(cat $touch_class_path/$touch_instance/mutual_range)" + else + notice "mutual range unavailable" + fi + info=$info";forced" + eval "$__result='$info'" + return 0 +} + +do_calibration() +{ + local rc + local cal_info + local factory_build + local cal_version + + factory_build=$(getprop $factory_property 2> /dev/null) + cal_info=$(getprop $touch_calibration_done_version 2> /dev/null) + # new calibration info comes with mutual range and probably was enforced + if [[ ("$cal_info" && "${cal_info%%;*}" != "$cal_info") || ("$cal_info" == "enable-autocalibration") ]]; then + cal_version=${cal_info%%;*} + cal_version=${cal_version#*-} + debug "cal_version is '$cal_version'" + fi + + if [[ ("$factory_build" != 1 || "$cal_version" != "autocalibration") ]]; then + debug "factory='$factory_build', cal_version='$cal_version', latest='$str_cfg_id_latest'" + return + fi + + notice "Force touch calibration" + case $touch_vendor in + samsung) do_sec_calibration cal_info + rc=$? + debug "cal_info='$cal_info'" + ;; + esac + notice "Touch calibration result $rc" + [ $rc == 0 ] && setprop $touch_calibration_done_version $cal_info +} + +process_touch_instance() +{ + touch_vendor=$(cat $touch_class_path/$touch_instance/vendor) + debug "touch vendor [$touch_vendor]" + touch_path=/sys$(cat $touch_class_path/$touch_instance/path) + debug "sysfs touch path: $touch_path" + touch_status_prop=vendor.hw.touch.$touch_instance.status + touch_update_prop=vendor.hw.touch.$touch_instance.update + if [ ! -f $touch_path/doreflash ] || + [ ! -f $touch_path/poweron ] || + [ ! -f $touch_path/flashprog ] || + [ ! -f $touch_path/productinfo ] || + [ ! -f $touch_path/buildid ]; then + error_msg 5 + return + fi + if [ $dump_statistics ]; then + dump_statistics + fi + if [ -f $touch_path/flash_mode ]; then + notice "Support parameter APK for FW upgrade" + let search_in_param=1 + fi + + notice "Checking touch ID [$touch_instance] FW upgrade" + touch_vendor=$(cat $touch_class_path/$touch_instance/vendor) + debug "touch vendor [$touch_vendor]" + touch_path=/sys$(cat $touch_class_path/$touch_instance/path) + debug "sysfs touch path: $touch_path" + query_touch_info + query_panel_info + search_firmware_file + [ "$?" == "0" ] && run_firmware_upgrade + if [ "$?" == "0" ]; then + do_calibration + notice "Touch firmware is up to date" + setprop $touch_status_prop "ready" + notice "property [$touch_status_prop] set to [`getprop $touch_status_prop`]" + notice "Handling touch ID [$touch_instance] permissions" + fi + read_touch_property buildid + setprop $touch_firmware_property ${property} + notice "Touch firmware property is $touch_firmware_property" + setup_permissions +} + +# Main starts here +query_panel_info +load_driver_modules +[ -d $touch_class_path ] || error_and_leave 8 +debug "sysfs panel path: $panel_path" +product_id=$(getprop $device_property 2> /dev/null) +[ -z "$product_id" ] && error_and_leave 2 $device_property +product_id=${product_id%-*} +product_id=${product_id%_*} +debug "product id: $product_id" +hwrev_id=$(getprop $hwrev_property 2> /dev/null) +[ -z "$hwrev_id" ] && notice "hw revision undefined" +debug "hw revision: $hwrev_id" +cd $firmware_path +# Run asynchronously for each instance +for touch_instance in $(ls $touch_class_path); do + process_touch_instance & +done + +# check if need to reload modules +wait +debug "all background processes completed" + +return 0 diff --git a/rootdir/bin/init.oem.fingerprint2.sh b/rootdir/bin/init.oem.fingerprint2.sh new file mode 100755 index 0000000..7fa1d36 --- /dev/null +++ b/rootdir/bin/init.oem.fingerprint2.sh @@ -0,0 +1,178 @@ +#!/vendor/bin/sh +# +# Start indicated fingerprint HAL service +# +# Copyright (c) 2019 Lenovo +# All rights reserved. +# +# April 15, 2019 chengql2@lenovo.com Initial version +# December 2, 2019 chengql2 Store fps_id into persist fs +# November 19, 2020 zengzm refactor the code, support more than 3 fingerprint sensors; support config. + +# get the filename, contains the file postfix +script_name=${0##*/} +# remove the file postfix +script_name=${script_name%.*} +function log { + echo "$script_name: $*" > /dev/kmsg +} + +PROP_GKI_PATH=ro.vendor.mot.gki.path +GKI_PATH=$(getprop $PROP_GKI_PATH) + +# for new projects, only need to config varible vendor_list,kernel_so_list,kernel_so_name_list,hal_list +# vendor_list: the array contains the sensor name, it will be used for system properties. +# kernel_so_list: the array contains the kernel so's absolute path. It will be used at insmod. +# kernel_so_name_list: the array contains the kernel so's name. It will be used at rmmod. +# hal_list: the array contains the hal service name. +# +# note: all arrays should have the same size. +vendor_list=('egis' 'chipone') +kernel_so_list=("/vendor/lib/modules/$GKI_PATH/rbs_fps_mmi.ko" "/vendor/lib/modules/$GKI_PATH/fpsensor_spi_tee.ko") +kernel_so_name_list=("rbs_fps_mmi.ko" "fpsensor_spi_tee.ko") +hal_list=('ets_hal' 'chipone_fp_hal') +last_vendor_index=`expr ${#vendor_list[@]} - 1` +vendor_list_size=${#vendor_list[@]} + +if [ $vendor_list_size != ${#kernel_so_list[@]} ]; then + log "error, vendor_list.size is not equal to kernel_so_list" + return 255 +fi + +if [ $vendor_list_size != ${#kernel_so_name_list[@]} ]; then + log "error, vendor_list.size is not equal to kernel_so_name_list" + return 255 +fi + +if [ $vendor_list_size != ${#hal_list[@]} ]; then + log "error, vendor_list.size is not equal to hal_list" + return 255 +fi + +# At the current boot, what is the fingerprint sensor +persist_fps_id=/mnt/vendor/persist/fps/vendor_id + +# what is the fingerprint sensor successfully installed before. +persist_fps_id2=/mnt/vendor/persist/fps/last_vendor_id + +FPS_VENDOR_NONE=none +MAX_TIMES=20 + +# this property store FPS_STATUS_NONE or FPS_STATUS_OK +# after start fingerprint hal service, the hal service will set this property. +prop_fps_status=vendor.hw.fingerprint.status + +# use this to trigger init.mmi.rc +prop_fps_ident=vendor.hw.fps.ident + +# if $prop_fps_status=$FPS_STATUS_OK, then will set prop_persist_fps to the specific vendor name. +prop_persist_fps=persist.vendor.hardware.fingerprint + +FPS_STATUS_NONE=none +FPS_STATUS_OK=ok + +function find_vendor_index() { + # param1: the specific vendor name + # return: the vendor index in vendor_list. the valid index is from 0; if not found,return 255 + for temp_vendor_index in $(seq 0 $last_vendor_index) + do + if [ "${vendor_list[temp_vendor_index]}" = "$1" ]; then + return $temp_vendor_index + fi + done + return 255 +} + +function start_hal_service(){ + # param1: the vendor index + # return: 0 means success, will setprop $prop_persist_fps + setprop $prop_fps_status $FPS_STATUS_NONE + setprop $prop_fps_ident $FPS_STATUS_NONE + + insmod ${kernel_so_list[$1]} + sleep 1 + setprop $prop_fps_ident ${vendor_list[$1]} + + log "start ${hal_list[$1]}" + start ${hal_list[$1]} + + for ii in $(seq 1 $MAX_TIMES) + do + sleep 0.1 + fps_status=$(getprop $prop_fps_status) + # log "check fps vendor status: $fps_status" + if [ $fps_status != $FPS_STATUS_NONE ]; then + break + fi + done + + log "fingerprint HAL status: $fps_status" + if [ $fps_status == $FPS_STATUS_OK ]; then + log "start ${hal_list[$1]} hal success" + setprop $prop_persist_fps ${vendor_list[$1]} + return 0 + fi + + log "start ${hal_list[$1]} hal failed, remove kernel so: ${kernel_so_name_list[$1]} " + setprop ctl.stop ${hal_list[$1]} + rmmod ${kernel_so_name_list[$1]} + sleep 0.1 + # if failed,return 255 + return 255 +} + +# set last fingerprint sensor +fps_vendor=$(cat $persist_fps_id) +if [ -n "$fps_vendor" ] && [ "$fps_vendor" != $FPS_STATUS_NONE ]; then + echo $fps_vendor > $persist_fps_id2 +fi + +# get the identified fingerprint sensor +fps_vendor2=$(cat $persist_fps_id2) +if [ -z $fps_vendor2 ]; then + fps_vendor2=$FPS_VENDOR_NONE +fi +log "FPS vendor (last): $fps_vendor2" + +fps_vendor=$(cat $persist_fps_id) +if [ -z $fps_vendor ]; then + fps_vendor=$FPS_VENDOR_NONE +fi +log "FPS vendor (current): $fps_vendor" + +vendor_index=255 +# try to start the most recent success launched sensor. +if [ $fps_vendor != $FPS_STATUS_NONE ]; then + find_vendor_index $fps_vendor + vendor_index=$? + if [ $vendor_index != 255 ]; then + log "start $fps_vendor hal service" + start_hal_service $vendor_index + if [ $? != 255 ]; then + return 0 + fi + fi +fi + +# try all the fingerprint sensors +for temp_vendor_index in $(seq 0 $last_vendor_index) +do + if [ $temp_vendor_index == $vendor_index ]; then + continue + fi + + if [ ! -e ${kernel_so_list[$temp_vendor_index]} ]; then + log "does not exist ${kernel_so_list[$temp_vendor_index]},ignore this fingerprint sensor" + continue + fi + + start_hal_service $temp_vendor_index + if [ $? != 255 ]; then + echo ${vendor_list[$temp_vendor_index]} > $persist_fps_id + return 0 + fi +done + +log "error, no fingerprint sensor found" +setprop $prop_persist_fps $FPS_VENDOR_NONE +echo $FPS_VENDOR_NONE > $persist_fps_id diff --git a/rootdir/bin/init.oem.hw.sh b/rootdir/bin/init.oem.hw.sh new file mode 100755 index 0000000..4973f47 --- /dev/null +++ b/rootdir/bin/init.oem.hw.sh @@ -0,0 +1,735 @@ +#!/vendor/bin/sh + +BASEDIR=vendor + +PATH=/sbin:/$BASEDIR/sbin:/$BASEDIR/bin:/$BASEDIR/xbin +export PATH + +while getopts dpfrM op; +do + case $op in + d) dbg_on=1;; + p) populate_only=1;; + f) dead_touch=1;; + r) reset_touch=1;; + M) mount_2nd_stage=1;; + esac +done +shift $(($OPTIND-1)) + +scriptname=${0##*/} +hw_mp=/proc/hw +config_mp=/proc/config +reboot_utag=$config_mp/.reboot +touch_status_prop=vendor.hw.touch.status +hw_cfg_file=hw_config.xml +vhw_file=/$BASEDIR/etc/vhw.xml +bp_file=/system/build.prop +oem_file=/oem/oem.prop +load_error=3 +need_to_reload=2 +reload_in_progress=1 +reload_done=0 +ver_utag=".version" +version_fs="unknown" +xml_version="unknown" +device_params="" +xml_file="" +utag_update_fail="false" +modem_ver_prop=ro.vendor.hw.modem_version +policy_prop=ro.vendor.super_image_policy + +super_image_detection() +{ + local subsys + local file2mount + local basefile + local version + local extention + local image_dir + local is_super_image + local super_image_prop + local file_mount_prop + local modem_version=$(getprop $modem_ver_prop) + local policy=$(getprop $policy_prop) + + debug "'$policy_prop' is '$policy'" + for subsys in modem fsg; do + debug "Processing [${subsys}]..." + is_super_image="" + case ${subsys} in + modem) image_dir=/vendor/firmware_mnt;; + fsg) image_dir=/vendor/fsg;; + esac + + [ -f $image_dir/super_modem ] && is_super_image="true" + debug "super image '$is_super_image'" + + if [ "$is_super_image" == "true" ]; then + file2mount="" + case ${subsys} in + modem) super_image_prop="ro.vendor.hw.modem_super_image" + file_mount_prop="ro.vendor.hw.modem_mount_file" + basefile="NON-HLOS.bin" + extention=".bin" + [ "$modem_version" ] && file2mount=$(printf "NON-HLOS%sbin" $modem_version) + ;; + fsg) super_image_prop="ro.vendor.hw.fsg_super_image" + file_mount_prop="ro.vendor.hw.fsg_mount_file" + basefile="fsg.mbn" + extention=".mbn" + [ "$modem_version" ] && file2mount=$(printf "fsg%smbn" $modem_version) + ;; + esac + if [ -z "$file2mount" ]; then + notice "'$modem_ver_prop' not set, but [$subsys] is super image!" + else + # modem_version matches existing file in super image + if [ -f $image_dir/$file2mount ]; then + notice "[$subsys] is super image. '$file2mount' will be mounted" + setprop $file_mount_prop $file2mount + setprop $super_image_prop yes + continue + fi + notice "[$subsys] is super image. '$file2mount' not found" + fi + else + notice "[$subsys] non-super image" + fi + + # check super image policy + if [ "$policy" == "enforce" ]; then + notice "[$subsys] strict super image policy! Rebooting to recovery..." + debug "'ro.vendor.hw.super_image_failure' -> 'yes'" + setprop ro.vendor.hw.super_image_failure yes + return + fi + notice "[$subsys] super image policy not enforced" + # proceed with non-super image if policy allows + if [ -z "$is_super_image" ]; then + notice "[$subsys] proceed with non-super image!" + continue + fi + + # retrieve default version if available + version=$(cat $image_dir/super_modem) + if [ "$version" ]; then + basefile=$version + notice "default file override '$basefile'" + else + notice "use default file: '$basefile' instead of '$file2mount'" + fi + + notice "Searching for '$basefile' in $image_dir..." + debug "checking file '$image_dir/$basefile'" + if [ -f $image_dir/$basefile ]; then + notice "[$subsys] is super image! '$basefile' will be mounted" + debug "'$file_mount_prop' -> '$basefile'" + setprop $file_mount_prop $basefile + debug "'$super_image_prop' -> 'yes'" + setprop $super_image_prop yes + continue + fi + + # set to fail + notice "Unable to mount '$basefile'! Rebooting to recovery..." + debug "'ro.vendor.hw.super_image_failure' -> 'yes'" + setprop ro.vendor.hw.super_image_failure yes + return + done +} + +set_reboot_counter() +{ + local value=$1 + local reboot_cnt=0 + local reboot_mp=${reboot_utag%.*} + local tag_name=${reboot_utag##*/} + if [ $((value)) -gt 0 ]; then + notice "increase reboot counter" + [ -d $reboot_utag ] && reboot_cnt=$(cat $reboot_utag/ascii) + value=$(($reboot_cnt + 1)) + fi + if [ ! -d $reboot_utag ]; then + echo ${reboot_utag##*/} > $reboot_mp/all/new + [ $? != 0 ] && notice "error creating UTAG $tag_name" + fi + echo "$value" > $reboot_utag/ascii + [ $? != 0 ] && notice "error updating UTAG $tag_name" + notice "UTAG $tag_name is [`cat $reboot_utag/ascii`]" +} + +set_reboot_counter_property() +{ + local reboot_cnt=0 + local tag_name=${reboot_utag##*/} + if [ -d $reboot_utag ]; then + reboot_cnt=$(cat $reboot_utag/ascii) + notice "UTAG $tag_name has value [$reboot_cnt]" + else + notice "UTAG $tag_name does not exist" + fi + setprop $touch_status_prop $reboot_cnt + notice "property [$touch_status_prop] is set to [`getprop $touch_status_prop`]" +} + +debug() +{ + [ $dbg_on ] && echo "Debug: $*" +} + +notice() +{ + echo "$*" + echo "$scriptname: $*" > /dev/kmsg +} + +add_device_params() +{ + device_params=$device_params" $@" + debug "add_device_params='$device_params'" +} + +drop_device_parameter() +{ + device_params=${device_params% *} + debug "drop_device_parameter='$device_params'" +} + +set_xml_file() +{ + xml_file=$@ + debug "working with XML file='$xml_file'" +} + +exec_parser() +{ + eval motobox expat -u -f $xml_file $device_params "$@" 2>/dev/null +} + +reload_utags() +{ + local mp=$1 + local value + echo "1" > $mp/reload + value=$(cat $mp/reload) + while [ "$value" == "$reload_in_progress" ]; do + notice "waiting for loading to complete" + sleep 1; + value=$(cat $mp/reload) + notice "'$mp' current status [$value]" + done +} + +procfs_wait_for_device() +{ + local __result=$1 + local status + local mpi + local IFS=' ' + local device_timeout_count=0 + while [ ! -f $hw_mp/reload ] || [ ! -f $config_mp/reload ]; do + notice "waiting for devices" + sleep 1; + if [ "$device_timeout_count" -eq "10" ];then + notice "waiting for devices timeout" + eval $__result="" + return + fi + device_timeout_count=$(($device_timeout_count + 1)) + done + for mpi in $hw_mp $config_mp; do + status=$(cat $mpi/reload) + notice "mount point '$mpi' status [$status]" + if [ "$status" == "$need_to_reload" ]; then + notice "force $mpi reloading" + reload_utags $mpi + fi + done + for mpi in $hw_mp $config_mp; do + status=$(cat $mpi/reload) + notice "$mpi reload is [$status]" + device_timeout_count=0 + while [ "$status" != "$reload_done" ]; do + notice "waiting for loading $mpi to complete" + sleep 1; + status=$(cat $mpi/reload) + if [ "$device_timeout_count" -eq "10" ]; then + notice "error: waiting for loading $mpi timeout" + break + fi + device_timeout_count=$(($device_timeout_count + 1)) + done + done + eval $__result=$status +} + +get_attr_data_by_name() +{ + local __result=$1 + local attr=$2 + shift 2 + local IFS=' ' + eval $__result="" + for arg in ${@}; do + [ "${arg%=*}" == "$attr" ] || continue + debug "attr_data='${arg#*=}'" + eval $__result="${arg#*=}" + break + done +} + +get_tag_data() +{ + local __name=$1 + local __value=$2 + shift 2 + local dataval + local IFS=' ' + eval $__name="" + eval $__value="" + for arg in ${@}; do + case $arg in + string-array | string) + debug "---/ skip keyword: '$arg'" + continue;; + esac + debug "---> arg='$arg'" + if [ "${arg%=*}" == "name" ]; then + eval $__name=${arg#*=} + continue + fi + # eval treats ';' as a separator, thus make it '\;' + dataval=$(echo ${arg#?} | sed 's/;/\\;/g') + debug "<--- dataval='$dataval'" + eval $__value=$dataval + done +} + +update_utag() +{ + local utag=$1 + local payload=$2 + local verify + local rc + if [ ! -d $hw_mp/$utag ]; then + notice "creating utag '$utag'" + echo $utag > $hw_mp/all/new + rc=$? + [ "$rc" != "0" ] && notice "'$utag' create dir failed rc=$rc" + fi + debug "writing '$payload' to '$hw_mp/$utag/ascii'" + echo "$payload" > $hw_mp/$utag/ascii + rc=$? + if [ "$rc" != "0" ]; then + utag_update_fail="true" + notice "'$utag' write file failed rc=$rc" + fi + verify=$(cat $hw_mp/$utag/ascii) + debug "read '$verify' from '$hw_mp/$utag/ascii'" + [ "$verify" != "$payload" ] && notice "'$utag' payload validation failed" +} + +populate_utags() +{ + local selection="$@" + local pline + local ptag + local pvalue + for pline in $(exec_parser $selection); do + get_tag_data ptag pvalue $pline + url_style_off pvalue $pvalue + debug "tag='$ptag' value='$pvalue'" + update_utag $ptag $pvalue + done +} + +set_ro_hw_properties_upgrade() +{ + local utag_path + local utag_name + local prop_prefix + local utag_value + local verify + for hwtag in $(find $hw_mp -name '.system'); do + debug "path $hwtag has '.system' in its name" + prop_prefix="ro.vendor.hw." + utag_path=${hwtag%/*} + utag_name=${utag_path##*/} + utag_value=$(cat $utag_path/ascii) + setprop $prop_prefix$utag_name "$utag_value" + notice "ro.vendor.hw.$utag_name='$utag_value'" + done +} + +set_ro_hw_properties() +{ + local utag_path + local utag_name + local prop_prefix + local utag_value + local verify + for hwtag in $(find $hw_mp -name '.system'); do + debug "path $hwtag has '.system' in its name" + prop_prefix=$(cat $hwtag/ascii) + verify=${prop_prefix%.} + # esure property ends with '.' + if [ "$prop_prefix" == "$verify" ]; then + prop_prefix="$prop_prefix." + debug "added '.' at the end of [$prop_prefix]" + + fi + utag_path=${hwtag%/*} + utag_name=${utag_path##*/} + utag_value=$(cat $utag_path/ascii) + setprop $prop_prefix$utag_name "$utag_value" + notice "$prop_prefix$utag_name='$utag_value'" + done +} + +set_ro_vendor_incremental() +{ + local vendor_incremental="ro.vendor.build.version.incremental" + local vendor_incremental_value + local fetch_prop="ro.build.version.incremental" + local fetch_value=$(getprop $fetch_prop) + + [ -z "$fetch_value" ] && prefetch_from_file $fetch_prop vendor_incremental_value + setprop $vendor_incremental "$vendor_incremental_value" + notice "$vendor_incremental='$vendor_incremental_value'" +} + +smart_value() +{ + local mtag=$1 + local __result=$2 + local value + eval $__result="" + local tmp=${mtag#?} + # absolute path to the file starts with '/' + if [ "${mtag%$tmp}" == "/" ]; then + value=$(cat $mtag) + # property likely to have '.' + elif [ "$mtag" != "${mtag%.*}" ]; then + value=$(getprop $mtag) + else # tag otherwise + value=$(cat $hw_mp/$mtag/ascii) + fi + eval $__result='$value' +} + +url_style_off() +{ + local __arg=$1 + local value=$2 + if [[ $value == *%* ]]; then + value=$(echo $value | sed 's/%20/ /g') + value=$(echo $value | sed 's/%28/\(/g') + value=$(echo $value | sed 's/%29/\)/g') + fi + eval $__arg='$value' +} + +match() +{ + local mapping + local mline + local mtag + local fs_value + local mvalue + local matched + url_style_off mapping $1 + debug "match mapping='$mapping'" + # put '\"' around $mapping to ensure XML + # parser takes it as a single argument + for mline in $(exec_parser \"$mapping\"); do + get_tag_data mtag mvalue $mline + url_style_off mvalue $mvalue + # obtain value based on data source: utag, property or file + smart_value $mtag fs_value + if [ "$fs_value" == "$mvalue" ]; then + matched="true"; + else + matched="false"; + fi + debug "cmp utag='$mtag' values '$mvalue' & '$fs_value' is \"$matched\"" + [ "$matched" == "false" ] && break + done + [ "$matched" == "true" ] && return 0 + return 1 +} + +find_match() +{ + local __retval=$1 + local tag_name + local fline + local line + local subsection + local matched="false" + eval $__retval="" + for fline in $(exec_parser); do + subsection=${fline%% *} + add_device_params $subsection + for line in $(exec_parser); do + get_attr_data_by_name tag_name "name" $line + debug "tag_name='$tag_name'" + match $tag_name + [ "$?" != "0" ] && continue + eval $__retval=$tag_name + matched="true" + break + done + drop_device_parameter + [ "$matched" == "true" ] && break + done +} + +prefetch_from_file() +{ + local pname=$1 + local __result=$2 + local value + local override + eval $__result="" + value=$(cat $bp_file 2>/dev/null | sed '/^$/d' | sed '/^#/d' | sed '/^import/d' | sed -n "/$pname=/p" | sed 's/.*=//') + debug "'$pname' from '$bp_file': '$value'" + if [ -f $oem_file ]; then + override=$(cat $oem_file 2>/dev/null | sed '/^$/d' | sed '/^#/d' | sed '/^import/d' | sed -n "/$pname=/p" | sed 's/.*=//') + [ "$override" ] && value=$override && debug "'$pname' from '$oem_file': '$value'" + fi + eval $__result=$value +} + +append_match() +{ + local prop_list=$1 + local suffix="$2" + local dest_prop + local fetched_prop + local prop_value + local IFS=',' + # properties list to put the result of appending hw suffix to + # example: appended="ro.vendor.product.name,ro.vendor.product.device" + for dest_prop in $prop_list; do + fetch_prop=${dest_prop} + # only alter property name that has "vendor" in it + if [ "${fetch_prop//.vendor}" != "$dest_prop" ]; then + fetch_prop=${fetch_prop//.vendor} + prop_value=$(getprop $fetch_prop) + [ -z "$prop_value" ] && prefetch_from_file $fetch_prop prop_value + # finally set destination property to appended value + setprop $dest_prop "$prop_value$suffix" + notice "$dest_prop='$prop_value$suffix'" + fi + done +} + +process_mappings() +{ + local pname="" + local pexport="" + local pdefault="" + local pappend="" + local putag="" + local subsection + local pline + local matched_val + local whitespace_val + local export_val + local utag_val + for pline in $(exec_parser); do + subsection=${pline%% *} + debug "subsection is '$subsection'" + get_attr_data_by_name pname "name" $pline + get_attr_data_by_name pexport "export" $pline + get_attr_data_by_name pdefault "default" $pline + get_attr_data_by_name pappend "append" $pline + get_attr_data_by_name putag "writeback" $pline + [ "$pname" ] && url_style_off pname $pname && debug "name='$pname'" + [ "$pexport" ] && url_style_off pexport $pexport && debug "export='$pexport'" + [ "$pdefault" ] && url_style_off pdefault $pdefault && debug "default='$pdefault'" + [ "$pappend" ] && url_style_off pappend $pappend && debug "append='$pappend'" + # add 'subsection' to permanent parameters + add_device_params $subsection + # call itself here to handle nonamed subsection, like quirks + [ -z "$pname" ] && [ -z "$pexport" ] && [ -z "$pdefault" ] && [ -z "$pappend" ] && [ -z "$putag" ] && process_mappings && continue + find_match matched_val + [ "$matched_val" ] && url_style_off matched_val $matched_val + # append_match handles OEM overrides, thus has to be called even with empty value + [ "$pappend" ] && append_match $pappend "$matched_val" + if [ "$matched_val" ]; then + if [ "$pexport" ]; then + setprop $pexport "$matched_val" + notice "exporting '$matched_val' into property $pexport" + fi + elif [ "$pexport" -a "$pdefault" ]; then + # if match is not found, proceed with default + setprop $pexport "$pdefault" + notice "defaulting '$pdefault' into property $pexport" + fi + + if [ "$putag" ] && [ -d $hw_mp/$putag ]; then + export_val=$(getprop $pexport) + utag_val=$(cat $hw_mp/$putag/ascii) + debug "writeback compare $utag_val,$export_val" + # if property is empty value, clear the utag. + # if property and writeback utag are empty value, don't update utag + if [ "$export_val" -o "$utag_val" != "(null)" ] && [ "$utag_val" != "$export_val" ]; then + update_utag $putag $export_val + notice "writeback '$export_val' into utag $putag" + fi + fi + # remove the last added parameter + drop_device_parameter + done +} + +# Main starts here +IFS=$'\n' + +if [ ! -z "$mount_2nd_stage" ]; then + notice "Super image detection" + super_image_detection + return 0 +fi + +if [ ! -z "$reset_touch" ]; then + notice "reset reboot counter" + set_reboot_counter 0 + return 0 +fi + +if [ ! -z "$dead_touch" ]; then + notice "property [$touch_status_prop] set to [dead]" + set_reboot_counter 1 + return 0 +fi + +if [ -f /vendor/lib/modules/utags.ko ]; then + notice "loading utag driver" + insmod /vendor/lib/modules/utags.ko + if [ $? -ne 0 ]; then + gki_modules_full_path=`find /vendor/lib/modules -name "*-gki"` + if [ -n "$gki_modules_full_path" ]; then + gki_modules_path=`basename $gki_modules_full_path` + notice "loading gki utag driver in /vendor/lib/modules/$gki_modules_path" + insmod /vendor/lib/modules/$gki_modules_path/utags.ko + if [ $? -ne 0 ]; then + notice "fail to load /vendor/lib/modules/$gki_modules_path/utags.ko" + setprop ro.vendor.mot.gki.path "." + else + notice "successfully load /vendor/lib/modules/$gki_modules_path/utags.ko" + setprop ro.vendor.mot.gki.path $gki_modules_path + fi + else + notice "fail to load utag driver" + setprop ro.vendor.mot.gki.path "." + fi + else + setprop ro.vendor.mot.gki.path "." + fi +fi + +notice "checking integrity" +# check necessary components exist and just proceed +# with RO properties setup otherwise +if [ ! -f /$BASEDIR/bin/expat ] || [ ! -f $vhw_file ]; then + notice "warning: missing expat or xml" + set_ro_hw_properties + return 0 +fi + +if [ ! -z "$populate_only" ]; then + # special handling for factory UTAGs provisioning + for path in /data/local/tmp /pds/factory; do + [ -f $path/$hw_cfg_file ] && break + done + notice "populating hw config from '$path/$hw_cfg_file'" + set_xml_file $path/$hw_cfg_file + populate_utags hardware + return 0 +fi + +notice "initializing procfs" +procfs_wait_for_device readiness +if [ "$readiness" != "0" ]; then + notice "no access to hw utags procfs" + return 1 +fi + +# populate touch status property with reboot counter +set_reboot_counter_property & + +# XML parsing starts here +set_xml_file $vhw_file + +get_attr_data_by_name boot_device_prop "match" $(exec_parser) +debug "attr='get' value='$boot_device_prop'" +if [ -z $boot_device_prop ]; then + notice "fatal: undefined boot device property" + return 1 +fi + +# ensure lower case +typeset -l boot_device=$(getprop $boot_device_prop) +# drop suffixes +boot_device=${boot_device%[_-]*} +notice "matching to boot device '$boot_device'" + +# add 'validation' to permanent parameters +add_device_params validation + +for line in $(exec_parser); do + get_attr_data_by_name product "name" $line + debug "attr='name' value='$product'" + if [ "$product" == "$boot_device" ]; then + get_attr_data_by_name xml_version "version" $line + [ "$xml_version" != "unknown" ] && notice "device '$boot_device' xml version='$xml_version'" + break + fi +done + +[ "$xml_version" == "unknown" ] && notice "no match found for device '$boot_device'" +# delete obsolete 'version' utag if exists +[ -d $hw_mp/${ver_utag#?} ] && $(echo ${ver_utag#?} > $hw_mp/all/delete) +# read procfs version +[ -d $hw_mp/$ver_utag ] && version_fs=$(cat $hw_mp/$ver_utag/ascii) +notice "procfs version='$version_fs'" +# add 'device' and '$boot_device' to permanent parameters +add_device_params device $boot_device +[ "$xml_version" == "$version_fs" ] && notice "hw descriptor is up to date" +for section in $(exec_parser); do + debug "section='$section'" + case $section in + mappings) + # add 'mappings' to permanent parameters + add_device_params $section + process_mappings & + ;; + *) + [ "$xml_version" == "$version_fs" ] && continue + populate_utags $section;; + esac +done + +if [ "$xml_version" != "$version_fs" ]; then + # create version utag if it's missing + [ ! -d $hw_mp/$ver_utag ] && $(echo "$ver_utag" > $hw_mp/all/new) + # update procfs version + [ -d $hw_mp/$ver_utag ] && $(echo "$xml_version" > $hw_mp/$ver_utag/ascii) +fi + +set_ro_vendor_incremental & + +set_ro_hw_properties + +if [ "$utag_update_fail" == "true" ]; then + set_ro_hw_properties_upgrade +fi + +wait + +notice "script init.oem.hw.sh finish " +return 0 + diff --git a/rootdir/bin/init.qcom.early_boot.sh b/rootdir/bin/init.qcom.early_boot.sh new file mode 100755 index 0000000..01d14b7 --- /dev/null +++ b/rootdir/bin/init.qcom.early_boot.sh @@ -0,0 +1,552 @@ +#! /vendor/bin/sh + +# Copyright (c) 2012-2013,2016,2018-2021 The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +export PATH=/vendor/bin + +# Set platform variables +if [ -f /sys/devices/soc0/hw_platform ]; then + soc_hwplatform=`cat /sys/devices/soc0/hw_platform` 2> /dev/null +else + soc_hwplatform=`cat /sys/devices/system/soc/soc0/hw_platform` 2> /dev/null +fi +if [ -f /sys/devices/soc0/soc_id ]; then + soc_hwid=`cat /sys/devices/soc0/soc_id` 2> /dev/null +else + soc_hwid=`cat /sys/devices/system/soc/soc0/id` 2> /dev/null +fi +if [ -f /sys/devices/soc0/platform_version ]; then + soc_hwver=`cat /sys/devices/soc0/platform_version` 2> /dev/null +else + soc_hwver=`cat /sys/devices/system/soc/soc0/platform_version` 2> /dev/null +fi + +if [ -f /sys/class/drm/card0-DSI-1/modes ]; then + echo "detect" > /sys/class/drm/card0-DSI-1/status + mode_file=/sys/class/drm/card0-DSI-1/modes + while read line; do + fb_width=${line%%x*}; + break; + done < $mode_file +elif [ -f /sys/class/graphics/fb0/virtual_size ]; then + res=`cat /sys/class/graphics/fb0/virtual_size` 2> /dev/null + fb_width=${res%,*} +fi + +log -t BOOT -p i "MSM target '$1', SoC '$soc_hwplatform', HwID '$soc_hwid', SoC ver '$soc_hwver'" + +#For drm based display driver +vbfile=/sys/module/drm/parameters/vblankoffdelay +if [ -w $vbfile ]; then + echo -1 > $vbfile +else + log -t DRM_BOOT -p w "file: '$vbfile' or perms doesn't exist" +fi + +function set_density_by_fb() { + #put default density based on width + if [ -z $fb_width ]; then + setprop vendor.display.lcd_density 320 + else + if [ $fb_width -ge 1600 ]; then + setprop vendor.display.lcd_density 640 + elif [ $fb_width -ge 1440 ]; then + setprop vendor.display.lcd_density 560 + elif [ $fb_width -ge 1080 ]; then + setprop vendor.display.lcd_density 480 + elif [ $fb_width -ge 720 ]; then + setprop vendor.display.lcd_density 320 #for 720X1280 resolution + elif [ $fb_width -ge 480 ]; then + setprop vendor.display.lcd_density 240 #for 480X854 QRD resolution + else + setprop vendor.display.lcd_density 160 + fi + fi +} + +target=`getprop ro.board.platform` +case "$target" in + "msm7630_surf" | "msm7630_1x" | "msm7630_fusion") + case "$soc_hwplatform" in + "FFA" | "SVLTE_FFA") + # linking to surf_keypad_qwerty.kcm.bin instead of surf_keypad_numeric.kcm.bin so that + # the UI keyboard works fine. + ln -s /system/usr/keychars/surf_keypad_qwerty.kcm.bin /system/usr/keychars/surf_keypad.kcm.bin + ;; + "Fluid") + setprop vendor.display.lcd_density 240 + setprop qcom.bt.dev_power_class 2 + ;; + *) + ln -s /system/usr/keychars/surf_keypad_qwerty.kcm.bin /system/usr/keychars/surf_keypad.kcm.bin + ;; + esac + ;; + "sm6150") + case "$soc_hwplatform" in + "ADP") + setprop vendor.display.lcd_density 160 + ;; + esac + case "$soc_hwid" in + 365|366) + sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null + setprop vendor.media.target.version 1 + if [ $sku_ver -eq 1 ]; then + setprop vendor.media.target.version 2 + fi + ;; + 355|369|377|384) + setprop vendor.chre.enabled 0 + ;; + *) + esac + ;; + "msm8660") + case "$soc_hwplatform" in + "Fluid") + setprop vendor.display.lcd_density 240 + ;; + "Dragon") + setprop ro.sound.alsa "WM8903" + ;; + esac + ;; + + "msm8960") + # lcd density is write-once. Hence the separate switch case + case "$soc_hwplatform" in + "Liquid") + if [ "$soc_hwver" == "196608" ]; then # version 0x30000 is 3D sku + setprop ro.sf.hwrotation 90 + fi + + setprop vendor.display.lcd_density 160 + ;; + "MTP") + setprop vendor.display.lcd_density 240 + ;; + *) + case "$soc_hwid" in + "109") + setprop vendor.display.lcd_density 160 + ;; + *) + setprop vendor.display.lcd_density 240 + ;; + esac + ;; + esac + + #Set up composition type based on the target + case "$soc_hwid" in + 87) + #8960 + setprop debug.composition.type dyn + ;; + 153|154|155|156|157|138) + #8064 V2 PRIME | 8930AB | 8630AB | 8230AB | 8030AB | 8960AB + setprop debug.composition.type c2d + ;; + *) + esac + ;; + + "msm8974") + case "$soc_hwplatform" in + "Liquid") + setprop vendor.display.lcd_density 160 + # Liquid do not have hardware navigation keys, so enable + # Android sw navigation bar + setprop ro.hw.nav_keys 0 + ;; + "Dragon") + setprop vendor.display.lcd_density 240 + ;; + *) + setprop vendor.display.lcd_density 320 + ;; + esac + ;; + + "msm8226") + case "$soc_hwplatform" in + *) + setprop vendor.display.lcd_density 320 + ;; + esac + ;; + + "msm8610" | "apq8084" | "mpq8092") + case "$soc_hwplatform" in + *) + setprop vendor.display.lcd_density 240 + ;; + esac + ;; + "apq8084") + case "$soc_hwplatform" in + "Liquid") + setprop vendor.display.lcd_density 320 + # Liquid do not have hardware navigation keys, so enable + # Android sw navigation bar + setprop ro.hw.nav_keys 0 + ;; + "SBC") + setprop vendor.display.lcd_density 200 + # SBC do not have hardware navigation keys, so enable + # Android sw navigation bar + setprop qemu.hw.mainkeys 0 + ;; + *) + setprop vendor.display.lcd_density 480 + ;; + esac + ;; + "msm8996") + case "$soc_hwplatform" in + "Dragon") + setprop vendor.display.lcd_density 240 + setprop qemu.hw.mainkeys 0 + ;; + "ADP") + setprop vendor.display.lcd_density 160 + setprop qemu.hw.mainkeys 0 + ;; + "SBC") + setprop vendor.display.lcd_density 240 + setprop qemu.hw.mainkeys 0 + ;; + *) + setprop vendor.display.lcd_density 560 + ;; + esac + ;; + "msm8937" | "msm8940") + # Set vendor.opengles.version based on chip id. + # MSM8937 and MSM8940 variants supports OpenGLES 3.1 + # 196608 is decimal for 0x30000 to report version 3.0 + # 196609 is decimal for 0x30001 to report version 3.1 + # 196610 is decimal for 0x30002 to report version 3.2 + case "$soc_hwid" in + 294|295|296|297|298|313|353|354|363|364) + # Disable adsprpcd_sensorspd daemon + setprop vendor.fastrpc.disable.adsprpcd_sensorspd.daemon 1 + + setprop vendor.opengles.version 196610 + if [ $soc_hwid = 354 ] + then + setprop vendor.media.target.version 1 + log -t BOOT -p i "SDM429 early_boot prop set for: HwID '$soc_hwid'" + fi + ;; + 303|307|308|309|320|386|436) + # Vulkan is not supported for 8917 variants + setprop vendor.opengles.version 196608 + setprop persist.graphics.vulkan.disable true + setprop vendor.gralloc.disable_ahardware_buffer 1 + # Disable adsprpcd_sensorspd daemon + setprop vendor.fastrpc.disable.adsprpcd_sensorspd.daemon 1 + ;; + *) + setprop vendor.opengles.version 196608 + ;; + esac + ;; + "msm8909") + case "$soc_hwplatform" in + *) + setprop persist.graphics.vulkan.disable true + ;; + esac + ;; + "msm8998" | "apq8098_latv") + case "$soc_hwplatform" in + *) + setprop vendor.display.lcd_density 560 + ;; + esac + ;; + "sdm845") + case "$soc_hwplatform" in + *) + if [ $fb_width -le 1600 ]; then + setprop vendor.display.lcd_density 560 + else + setprop vendor.display.lcd_density 640 + fi + ;; + esac + ;; + "msmnile") + case "$soc_hwplatform" in + *) + if [ $fb_width -le 1600 ]; then + setprop vendor.display.lcd_density 560 + else + setprop vendor.display.lcd_density 640 + fi + ;; + esac + ;; + "kona") + case "$soc_hwplatform" in + *) + setprop vendor.media.target_variant "_kona" + if [ $fb_width -le 1600 ]; then + setprop vendor.display.lcd_density 560 + else + setprop vendor.display.lcd_density 640 + fi + ;; + esac + ;; + "lito") + case "$soc_hwid" in + 400|440) + sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null + if [ $sku_ver -eq 1 ]; then + setprop vendor.media.target.version 1 + fi + ;; + 434|459) + sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null + setprop vendor.media.target.version 2 + if [ $sku_ver -eq 1 ]; then + setprop vendor.media.target.version 3 + fi + ;; + 476) + # Fraser soc_id 476 + setprop vendor.display.enable_qsync_idle 1 + ;; + esac + ;; + "bengal") + case "$soc_hwid" in + 441|473) + # 441 is for scuba and 473 for scuba iot qcm + setprop vendor.fastrpc.disable.cdsprpcd.daemon 1 + setprop vendor.media.target.version 2 + setprop vendor.gralloc.disable_ubwc 1 + setprop vendor.display.enhance_idle_time 1 + setprop vendor.netflix.bsp_rev "" + # 196609 is decimal for 0x30001 to report version 3.1 + setprop vendor.opengles.version 196609 + sku_ver=`cat /sys/devices/platform/soc/5a00000.qcom,vidc1/sku_version` 2> /dev/null + if [ $sku_ver -eq 1 ]; then + setprop vendor.media.target.version 3 + fi + ;; + 471|474) + # 471 is for scuba APQ and 474 for scuba iot qcs + setprop vendor.fastrpc.disable.cdsprpcd.daemon 1 + setprop vendor.gralloc.disable_ubwc 1 + setprop vendor.display.enhance_idle_time 1 + setprop vendor.netflix.bsp_rev "" + ;; + 518) + ;; + esac + ;; + "sdm710" | "msmpeafowl") + case "$soc_hwplatform" in + *) + if [ $fb_width -le 1600 ]; then + setprop vendor.display.lcd_density 560 + else + setprop vendor.display.lcd_density 640 + fi + + sku_ver=`cat /sys/devices/platform/soc/aa00000.qcom,vidc1/sku_version` 2> /dev/null + if [ $sku_ver -eq 1 ]; then + setprop vendor.media.target.version 1 + fi + ;; + esac + ;; + "msm8953") + cap_ver = 1 + if [ -e "/sys/devices/platform/soc/1d00000.qcom,vidc/capability_version" ]; then + cap_ver=`cat /sys/devices/platform/soc/1d00000.qcom,vidc/capability_version` 2> /dev/null + else + cap_ver=`cat /sys/devices/soc/1d00000.qcom,vidc/capability_version` 2> /dev/null + fi + + if [ $cap_ver -eq 1 ]; then + setprop vendor.media.target.version 1 + fi + ;; + #Set property to differentiate SDM660 & SDM455 + #SOC ID for SDM455 is 385 + "sdm660") + case "$soc_hwplatform" in + *) + if [ $fb_width -le 1600 ]; then + setprop vendor.display.lcd_density 560 + else + setprop vendor.display.lcd_density 640 + fi + + if [ $soc_hwid -eq 385 ]; then + setprop vendor.media.target.version 1 + fi + ;; + esac + ;; + "holi") + setprop vendor.media.target_variant "_holi" + ;; +esac +case "$target" in + "msm8937") + case "$soc_hwid" in + 386|354|353|303) + # enable qrtr-ns service for kernel 4.14 or above + KernelVersionStr=`cat /proc/sys/kernel/osrelease` + KernelVersionS=${KernelVersionStr:2:2} + KernelVersionA=${KernelVersionStr:0:1} + KernelVersionB=${KernelVersionS%.*} + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 14 ]; then + setprop init.svc.vendor.qrtrns.enable 1 + fi + ;; + esac + ;; + esac + +baseband=`getprop ro.baseband` +#enable atfwd daemon all targets except sda, apq, qcs +case "$baseband" in + "apq" | "sda" | "qcs" ) + setprop persist.vendor.radio.atfwd.start false;; + *) + setprop persist.vendor.radio.atfwd.start true;; +esac + +#set default lcd density +#Since lcd density has read only +#property, it will not overwrite previous set +#property if any target is setting forcefully. +set_density_by_fb + + +# set Lilliput LCD density for ADP +product=`getprop ro.build.product` + +case "$product" in + "msmnile_au") + setprop vendor.display.lcd_density 160 + echo 902400000 > /sys/class/devfreq/soc:qcom,cpu0-cpu-l3-lat/min_freq + echo 1612800000 > /sys/class/devfreq/soc:qcom,cpu0-cpu-l3-lat/max_freq + echo 902400000 > /sys/class/devfreq/soc:qcom,cpu4-cpu-l3-lat/min_freq + echo 1612800000 > /sys/class/devfreq/soc:qcom,cpu4-cpu-l3-lat/max_freq + ;; + *) + ;; +esac +case "$product" in + "sm6150_au") + setprop vendor.display.lcd_density 160 + ;; + *) + ;; +esac +case "$product" in + "sdmshrike_au") + setprop vendor.display.lcd_density 160 + ;; + *) + ;; +esac + +case "$product" in + "msmnile_gvmq") + setprop vendor.display.lcd_density 160 + ;; + *) + ;; +esac + +case "$product" in + "msmnile_gvmgh") + setprop vendor.display.lcd_density 160 + ;; + *) + ;; +esac +# Setup display nodes & permissions +# HDMI can be fb1 or fb2 +# Loop through the sysfs nodes and determine +# the HDMI(dtv panel) + +function set_perms() { + #Usage set_perms + chown -h $2 $1 + chmod $3 $1 +} + +# check for the type of driver FB or DRM +fb_driver=/sys/class/graphics/fb0 +if [ -e "$fb_driver" ] +then + # check for mdp caps + file=/sys/class/graphics/fb0/mdp/caps + if [ -f "$file" ] + then + setprop vendor.gralloc.disable_ubwc 1 + cat $file | while read line; do + case "$line" in + *"ubwc"*) + setprop vendor.gralloc.enable_fb_ubwc 1 + setprop vendor.gralloc.disable_ubwc 0 + esac + done + fi +else + set_perms /sys/devices/virtual/hdcp/msm_hdcp/min_level_change system.graphics 0660 +fi + +# allow system_graphics group to access pmic secure_mode node +set_perms /sys/class/lcd_bias/secure_mode system.graphics 0660 +set_perms /sys/class/leds/wled/secure_mode system.graphics 0660 + +boot_reason=`cat /proc/sys/kernel/boot_reason` +reboot_reason=`getprop ro.boot.alarmboot` +if [ "$boot_reason" = "3" ] || [ "$reboot_reason" = "true" ]; then + setprop ro.vendor.alarm_boot true +else + setprop ro.vendor.alarm_boot false +fi + +# copy GPU frequencies to vendor property +if [ -f /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies ]; then + gpu_freq=`cat /sys/class/kgsl/kgsl-3d0/gpu_available_frequencies` 2> /dev/null + setprop vendor.gpu.available_frequencies "$gpu_freq" +fi diff --git a/rootdir/bin/init.qcom.post_boot.sh b/rootdir/bin/init.qcom.post_boot.sh new file mode 100755 index 0000000..b0bff43 --- /dev/null +++ b/rootdir/bin/init.qcom.post_boot.sh @@ -0,0 +1,6272 @@ +#! /vendor/bin/sh + +# Copyright (c) 2012-2013, 2016-2020, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +function 8953_sched_dcvs_eas() +{ + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + #governor settings + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + #set the hispeed_freq + echo 1401600 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8953 and sdm450 it should be 85 + echo 85 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_load + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + + echo 652800 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + + #input boost params + echo 1401600 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 34 > $cpubw/bw_hwmon/io_percent + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 10 > $cpubw/bw_hwmon/hyst_length + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 20 > $cpubw/bw_hwmon/low_power_delay + echo 34 > $cpubw/bw_hwmon/low_power_io_percent + echo "1611 3221 5859 6445 7104" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1611 > $cpubw/min_freq + done + done + else + #governor settings + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/schedutil/down_rate_limit_us + #set the hispeed_freq + echo 1401600 > /sys/devices/system/cpu/cpufreq/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8953 and sdm450 it should be 85 + echo 85 > /sys/devices/system/cpu/cpufreq/schedutil/hispeed_load + + echo 652800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + fi +} + +function 8917_sched_dcvs_eas() +{ + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + #governor settings + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + #set the hispeed_freq + echo 1094400 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8917 it should be 85 + echo 85 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_load + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + + echo 960000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + + #input boost params + echo 1094400 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 20 > $cpubw/bw_hwmon/io_percent + echo 30 > $cpubw/bw_hwmon/guard_band_mbps + done + done + else + #governor settings + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/schedutil/down_rate_limit_us + #set the hispeed_freq + echo 1094400 > /sys/devices/system/cpu/cpufreq/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8917 it should be 85 + echo 85 > /sys/devices/system/cpu/cpufreq/schedutil/hispeed_load + + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + fi + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + fi +} + +function 8937_sched_dcvs_eas() +{ + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + # enable governor for perf cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + #set the hispeed_freq + echo 1094400 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8937 it should be 85 + echo 85 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_load + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + + echo 960000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + + ## enable governor for power cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor + #set the hispeed_freq + echo 768000 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8937 it should be 85 + echo 85 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_load + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/pl + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/rtg_boost_freq + + echo 768000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq + + #input boost params + echo 109440 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 20 > $cpubw/bw_hwmon/io_percent + echo 30 > $cpubw/bw_hwmon/guard_band_mbps + done + done + else + # enable governor for perf cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + #set the hispeed_freq + echo 1094400 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8937 it should be 85 + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + ## enable governor for power cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/down_rate_limit_us + #set the hispeed_freq + echo 768000 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + #default value for hispeed_load is 90, for 8937 it should be 85 + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_load + + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 768000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + fi + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + fi +} + +function configure_automotive_sku_parameters() { + + echo 1036800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 1056000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 1171200 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq + echo 1785600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + echo 902400000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/min_freq + echo 902400000 > /sys/class/devfreq/18321110.qcom,cpu4-cpu-l3-lat/min_freq + echo 902400000 > /sys/class/devfreq/18321110.qcom,cpu7-cpu-l3-lat/min_freq + echo 1612800000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/max_freq + echo 1612800000 > /sys/class/devfreq/18321110.qcom,cpu4-cpu-l3-lat/max_freq + echo 1612800000 > /sys/class/devfreq/18321110.qcom,cpu7-cpu-l3-lat/max_freq + echo 902400000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/min_freq + echo 902400000 > /sys/class/devfreq/soc\:qcom,cpu4-cpu-l3-lat/min_freq + echo 902400000 > /sys/class/devfreq/soc\:qcom,cpu7-cpu-l3-lat/min_freq + echo 1612800000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/max_freq + echo 1612800000 > /sys/class/devfreq/soc\:qcom,cpu4-cpu-l3-lat/max_freq + echo 1612800000 > /sys/class/devfreq/soc\:qcom,cpu7-cpu-l3-lat/max_freq + +#read feature id from nvram +reg_val=`cat /sys/devices/platform/soc/780130.qfprom/qfprom0/nvmem | od -An -t d4` +feature_id=$(((reg_val >> 20) & 0xFF)) +log -t BOOT -p i "feature id '$feature_id'" +if [ $feature_id == 0 ]; then + echo " SKU Configured : SA8155P" + echo 2131200 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + echo 2419200 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq + echo 0 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel +elif [ $feature_id == 1 ]; then + echo "SKU Configured : SA8150P" + echo 1920000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + echo 2227200 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq + echo 3 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel +else + echo "unknown feature_id value" $feature_id +fi +} + +function configure_automotive_sku_parameters_sa8195() { + + #Setting the min supported frequencies + echo 1113600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 1171200 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/min_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu4-cpu-l3-lat/min_freq + echo 1651200000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/max_freq + echo 1651200000 > /sys/class/devfreq/18321110.qcom,cpu4-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/min_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu4-cpu-l3-lat/min_freq + echo 1651200000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/max_freq + echo 1651200000 > /sys/class/devfreq/soc\:qcom,cpu4-cpu-l3-lat/max_freq + + #read feature id + reg_val=`cat /sys/devices/platform/soc/780130.qfprom/qfprom0/nvmem | od -An -t d4` + feature_id=$(((reg_val >> 20) & 0xFF)) + + #setting min gpu freq to 392 MHz + echo 4 > /sys/class/kgsl/kgsl-3d0/min_pwrlevel + if [ $feature_id == 0 ]; then + echo "feature_id is 0 for SA8195AA" + + #setting max cpu freq to 2.496GHz + echo 2496000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + #setting max gpu freq to 530 MHz + echo 3 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 1804 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + elif [ $feature_id == 1 ] || [ $feature_id == 2 ]; then + echo "feature_id is 1 for external SA8195AB" + echo "feature_id is 2 for internal SA8195AB" + + #setting max cpu freq to 2.496GHz + echo 2496000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + #setting max gpu freq to 670 MHz + echo 0 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 2092 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + elif [ $feature_id == 3 ]; then + echo "feature_id is 3 for external SA8195AC" + else + echo "unknown feature_id value" $feature_id + fi +} + +function configure_sku_parameters() { + +#read feature id from nvram +reg_val=`cat /sys/devices/platform/soc/780130.qfprom/qfprom0/nvmem | od -An -t d4` +feature_id=$(((reg_val >> 20) & 0xFF)) +log -t BOOT -p i "feature id '$feature_id'" +if [ $feature_id == 6 ]; then + echo " SKU Configured : SA6145" + echo 748800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + echo 748800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq + echo 748800 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq + echo 748800 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq + echo 748800 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + echo 748800 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq + echo 1017600 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq + echo 1017600 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/min_freq + echo 1017600000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/min_freq + echo 1017600000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/min_freq + echo 1017600000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/min_freq + echo 1017600000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/max_freq + echo 3 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 1016 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + setprop vendor.sku_identified 1 + setprop vendor.sku_name "SA6145" +elif [ $feature_id == 5 ]; then + echo "SKU Configured : SA6150" + echo 748800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq + echo 998400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + echo 998400 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq + echo 998400 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq + echo 998400 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq + echo 998400 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + echo 998400 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq + echo 1708800 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq + echo 1708800 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/max_freq + echo 2 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 1333 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + setprop vendor.sku_identified 1 + setprop vendor.sku_name "SA6150" +elif [ $feature_id == 4 ] || [ $feature_id == 3 ]; then + echo "SKU Configured : SA6155" + echo 748800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq + echo 1593600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq + echo 1900800 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq + echo 1900800 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/max_freq + echo 0 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 1555 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + setprop vendor.sku_identified 1 + setprop vendor.sku_name "SA6155" +else + echo "SKU Configured : SA6155" + echo 748800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 748800 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + echo 1017600 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq + echo 1593600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + echo 1593600 > /sys/devices/system/cpu/cpu5/cpufreq/scaling_max_freq + echo 1900800 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_max_freq + echo 1900800 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/18321110.qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/18321110.qcom,cpu6-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/max_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/min_freq + echo 1363200000 > /sys/class/devfreq/soc\:qcom,cpu6-cpu-l3-lat/max_freq + echo 0 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 1555 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + setprop vendor.sku_identified 1 + setprop vendor.sku_name "SA6155" +fi +} + +function 8953_sched_dcvs_hmp() +{ + #scheduler settings + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + #task packing settings + echo 0 > /sys/devices/system/cpu/cpu0/sched_static_cpu_pwr_cost + echo 0 > /sys/devices/system/cpu/cpu1/sched_static_cpu_pwr_cost + echo 0 > /sys/devices/system/cpu/cpu2/sched_static_cpu_pwr_cost + echo 0 > /sys/devices/system/cpu/cpu3/sched_static_cpu_pwr_cost + echo 0 > /sys/devices/system/cpu/cpu4/sched_static_cpu_pwr_cost + echo 0 > /sys/devices/system/cpu/cpu5/sched_static_cpu_pwr_cost + echo 0 > /sys/devices/system/cpu/cpu6/sched_static_cpu_pwr_cost + echo 0 > /sys/devices/system/cpu/cpu7/sched_static_cpu_pwr_cost + # spill load is set to 100% by default in the kernel + echo 3 > /proc/sys/kernel/sched_spill_nr_run + # Apply inter-cluster load balancer restrictions + echo 1 > /proc/sys/kernel/sched_restrict_cluster_spill + # set sync wakee policy tunable + echo 1 > /proc/sys/kernel/sched_prefer_sync_wakee_to_waker + + #governor settings + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "19000 1401600:39000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate + echo 1401600 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + echo "85 1401600:80" > /sys/devices/system/cpu/cpufreq/interactive/target_loads + echo 39000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor + echo 19 > /proc/sys/kernel/sched_upmigrate_min_nice + # Enable sched guided freq control + echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_migration_notif + echo 200000 > /proc/sys/kernel/sched_freq_inc_notify + echo 200000 > /proc/sys/kernel/sched_freq_dec_notify + +} + +function 8917_sched_dcvs_hmp() +{ + # HMP scheduler settings + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + echo 1 > /proc/sys/kernel/sched_restrict_tasks_spread + # HMP Task packing settings + echo 20 > /proc/sys/kernel/sched_small_task + echo 30 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_load + + echo 3 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_nr_run + + echo 0 > /sys/devices/system/cpu/cpu0/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu1/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu2/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu3/sched_prefer_idle + + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "19000 1094400:39000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate + echo 1094400 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + echo "1 960000:85 1094400:90" > /sys/devices/system/cpu/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor + + # Enable sched guided freq control + echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpufreq/interactive/use_migration_notif + echo 50000 > /proc/sys/kernel/sched_freq_inc_notify + echo 50000 > /proc/sys/kernel/sched_freq_dec_notify +} + +function 8937_sched_dcvs_hmp() +{ + # HMP scheduler settings + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + # HMP Task packing settings + echo 20 > /proc/sys/kernel/sched_small_task + echo 30 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_load + + echo 3 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_nr_run + + echo 0 > /sys/devices/system/cpu/cpu0/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu1/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu2/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu3/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu4/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu5/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu6/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu7/sched_prefer_idle + # enable governor for perf cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "19000 1094400:39000" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 1094400 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo "1 960000:85 1094400:90 1344000:80" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/sampling_down_factor + + # enable governor for power cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 39000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 768000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "1 768000:90" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/sampling_down_factor + + # Enable sched guided freq control + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo 50000 > /proc/sys/kernel/sched_freq_inc_notify + echo 50000 > /proc/sys/kernel/sched_freq_dec_notify + +} + +function sdm660_sched_interactive_dcvs() { + + echo 0 > /proc/sys/kernel/sched_select_prev_cpu_us + echo 400000 > /proc/sys/kernel/sched_freq_inc_notify + echo 400000 > /proc/sys/kernel/sched_freq_dec_notify + echo 5 > /proc/sys/kernel/sched_spill_nr_run + echo 1 > /proc/sys/kernel/sched_restrict_cluster_spill + echo 100000 > /proc/sys/kernel/sched_short_burst_ns + echo 1 > /proc/sys/kernel/sched_prefer_sync_wakee_to_waker + echo 20 > /proc/sys/kernel/sched_small_wakee_task_load + + # disable thermal bcl hotplug to switch governor + echo 0 > /sys/module/msm_thermal/core_control/enabled + + # online CPU0 + echo 1 > /sys/devices/system/cpu/cpu0/online + # configure governor settings for little cluster + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo "19000 1401600:39000" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 1401600 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo "85 1747200:95" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 39000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis + echo 633600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/ignore_hispeed_on_notif + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/fast_ramp_down + # online CPU4 + echo 1 > /sys/devices/system/cpu/cpu4/online + # configure governor settings for big cluster + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo "19000 1401600:39000" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 1401600 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "85 1401600:90 2150400:95" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 39000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 59000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/max_freq_hysteresis + echo 1113600 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/ignore_hispeed_on_notif + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/fast_ramp_down + + # bring all cores online + echo 1 > /sys/devices/system/cpu/cpu0/online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # configure LPM + echo N > /sys/module/lpm_levels/system/pwr/cpu0/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu1/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu2/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu3/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu4/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu5/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu6/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu7/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-dynret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-dynret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-ret/idle_enabled + + # re-enable thermal and BCL hotplug + echo 1 > /sys/module/msm_thermal/core_control/enabled + + # Enable bus-dcvs + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 762 > $cpubw/min_freq + echo "1525 3143 5859 7759 9887 10327 11863 13763" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 85 > $cpubw/bw_hwmon/io_percent + echo 100 > $cpubw/bw_hwmon/decay_rate + echo 50 > $cpubw/bw_hwmon/bw_step + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/low_power_ceil_mbps + echo 34 > $cpubw/bw_hwmon/low_power_io_percent + echo 20 > $cpubw/bw_hwmon/low_power_delay + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + for memlat in /sys/class/devfreq/*qcom,memlat-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + echo "cpufreq" > /sys/class/devfreq/soc:qcom,mincpubw/governor +} + +function sdm660_sched_schedutil_dcvs() { + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + echo 1401600 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + echo 633600 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + echo 902400 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/down_rate_limit_us + echo 1401600 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/pl + echo 1113600 > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/rtg_boost_freq + else + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1401600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/down_rate_limit_us + echo 1401600 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + fi + + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + #if the kernel version >=4.19,set input_boost_freq accordingly + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + echo "0:1401600" > /sys/devices/system/cpu/cpu_boost/input_boost_freq + echo 40 > /sys/devices/system/cpu/cpu_boost/input_boost_ms + else + echo "0:1401600" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + fi + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_load + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 762 > $cpubw/min_freq + echo "1525 3143 5859 7759 9887 10327 11863 13763" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 85 > $cpubw/bw_hwmon/io_percent + echo 100 > $cpubw/bw_hwmon/decay_rate + echo 50 > $cpubw/bw_hwmon/bw_step + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -le 14 ]; then + for memlat in $device/*cpu*-lat/devfreq/*cpu*-lat + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + for latfloor in $device/*cpu*-ddr-latfloor*/devfreq/*cpu-ddr-latfloor* + do + echo "compute" > $latfloor/governor + echo 10 > $latfloor/polling_interval + done + fi + done + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + fi + +} + +target=`getprop ro.board.platform` + +KernelVersionStr=`cat /proc/sys/kernel/osrelease` +KernelVersionS=${KernelVersionStr:2:2} +KernelVersionA=${KernelVersionStr:0:1} +KernelVersionB=${KernelVersionS%.*} + +function configure_zram_parameters() { + # Moto lulei1: Skip this if we are using zram from fstab. + using_zram_from_fstab=`getprop ro.boot.using_zram_from_fstab` + if [ "$using_zram_from_fstab" == "true" ]; then + return + fi + MemTotalStr=`cat /proc/meminfo | grep MemTotal` + MemTotal=${MemTotalStr:16:8} + + low_ram=`getprop ro.config.low_ram` + + # Zram disk - 75% for Go devices. + # For 512MB Go device, size = 384MB, set same for Non-Go. + # For 1GB Go device, size = 768MB, set same for Non-Go. + # For 2GB Go device, size = 1536MB, set same for Non-Go. + # For >2GB Non-Go devices, size = 50% of RAM size. Limit the size to 4GB. + # And enable lz4 zram compression for Go targets. + + let RamSizeGB="( $MemTotal / 1048576 ) + 1" + diskSizeUnit=M + if [ $RamSizeGB -le 2 ]; then + let zRamSizeMB="( $RamSizeGB * 1024 ) * 3 / 4" + else + let zRamSizeMB="( $RamSizeGB * 1024 ) / 2" + fi + + # use MB avoid 32 bit overflow + if [ $zRamSizeMB -gt 4096 ]; then + let zRamSizeMB=4096 + fi + + if [ "$low_ram" == "true" ]; then + echo lz4 > /sys/block/zram0/comp_algorithm + fi + + if [ -f /sys/block/zram0/disksize ]; then + if [ -f /sys/block/zram0/use_dedup ]; then + echo 1 > /sys/block/zram0/use_dedup + fi + echo "$zRamSizeMB""$diskSizeUnit" > /sys/block/zram0/disksize + + # ZRAM may use more memory than it saves if SLAB_STORE_USER + # debug option is enabled. + if [ -e /sys/kernel/slab/zs_handle ]; then + echo 0 > /sys/kernel/slab/zs_handle/store_user + fi + if [ -e /sys/kernel/slab/zspage ]; then + echo 0 > /sys/kernel/slab/zspage/store_user + fi + + mkswap /dev/block/zram0 + swapon /dev/block/zram0 -p 32758 + fi +} + +function configure_read_ahead_kb_values() { + MemTotalStr=`cat /proc/meminfo | grep MemTotal` + MemTotal=${MemTotalStr:16:8} + + dmpts=$(ls /sys/block/*/queue/read_ahead_kb | grep -e dm -e mmc) + + # Set 128 for <= 3GB & + # set 512 for >= 4GB targets. + if [ $MemTotal -le 3145728 ]; then + echo 128 > /sys/block/mmcblk0/bdi/read_ahead_kb + echo 128 > /sys/block/mmcblk0rpmb/bdi/read_ahead_kb + for dm in $dmpts; do + echo 128 > $dm + done + else + echo 512 > /sys/block/mmcblk0/bdi/read_ahead_kb + echo 512 > /sys/block/mmcblk0rpmb/bdi/read_ahead_kb + for dm in $dmpts; do + echo 512 > $dm + done + fi +} + +function disable_core_ctl() { + if [ -f /sys/devices/system/cpu/cpu0/core_ctl/enable ]; then + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + else + echo 1 > /sys/devices/system/cpu/cpu0/core_ctl/disable + fi +} + +function enable_swap() { + MemTotalStr=`cat /proc/meminfo | grep MemTotal` + MemTotal=${MemTotalStr:16:8} + + SWAP_ENABLE_THRESHOLD=1048576 + swap_enable=`getprop ro.vendor.qti.config.swap` + + # Enable swap initially only for 1 GB targets + if [ "$MemTotal" -le "$SWAP_ENABLE_THRESHOLD" ] && [ "$swap_enable" == "true" ]; then + # Static swiftness + echo 1 > /proc/sys/vm/swap_ratio_enable + echo 70 > /proc/sys/vm/swap_ratio + + # Swap disk - 200MB size + if [ ! -f /data/vendor/swap/swapfile ]; then + dd if=/dev/zero of=/data/vendor/swap/swapfile bs=1m count=200 + fi + mkswap /data/vendor/swap/swapfile + swapon /data/vendor/swap/swapfile -p 32758 + fi +} + +function disable_ppr() +{ + if [ -f /sys/module/process_reclaim/parameters/enable_process_reclaim ]; then + echo 0 > /sys/module/process_reclaim/parameters/enable_process_reclaim + fi +} + +function configure_memory_parameters() { + # Set Memory parameters. + # + # Set per_process_reclaim tuning parameters + # All targets will use vmpressure range 50-70, + # All targets will use 512 pages swap size. + # + # Set Low memory killer minfree parameters + # 32 bit Non-Go, all memory configurations will use 15K series + # 32 bit Go, all memory configurations will use uLMK + Memcg + # 64 bit will use Google default LMK series. + # + # Set ALMK parameters (usually above the highest minfree values) + # vmpressure_file_min threshold is always set slightly higher + # than LMK minfree's last bin value for all targets. It is calculated as + # vmpressure_file_min = (last bin - second last bin ) + last bin + # + # Set allocstall_threshold to 0 for all targets. + # + +ProductName=`getprop ro.board.platform` +low_ram=`getprop ro.config.low_ram` + +if [ "$ProductName" == "msmnile" ] || [ "$ProductName" == "kona" ] || [ "$ProductName" == "sdmshrike_au" ] || [ "$ProductName" == "lito" ] ; then + # Enable ZRAM + configure_zram_parameters + configure_read_ahead_kb_values + echo 0 > /proc/sys/vm/page-cluster + echo 100 > /proc/sys/vm/swappiness +else + arch_type=`uname -m` + + # Set parameters for 32-bit Go targets. + if [ "$low_ram" == "true" ]; then + # Disable KLMK, ALMK, PPR & Core Control for Go devices + echo 0 > /sys/module/lowmemorykiller/parameters/enable_lmk + echo 0 > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk + echo 0 > /sys/module/process_reclaim/parameters/enable_process_reclaim + disable_core_ctl + # Enable oom_reaper for Go devices + if [ -f /proc/sys/vm/reap_mem_on_sigkill ]; then + echo 1 > /proc/sys/vm/reap_mem_on_sigkill + fi + else + + # Read adj series and set adj threshold for PPR and ALMK. + # This is required since adj values change from framework to framework. + adj_series=`cat /sys/module/lowmemorykiller/parameters/adj` + adj_1="${adj_series#*,}" + set_almk_ppr_adj="${adj_1%%,*}" + + # PPR and ALMK should not act on HOME adj and below. + # Normalized ADJ for HOME is 6. Hence multiply by 6 + # ADJ score represented as INT in LMK params, actual score can be in decimal + # Hence add 6 considering a worst case of 0.9 conversion to INT (0.9*6). + # For uLMK + Memcg, this will be set as 6 since adj is zero. + set_almk_ppr_adj=$(((set_almk_ppr_adj * 6) + 6)) + echo $set_almk_ppr_adj > /sys/module/lowmemorykiller/parameters/adj_max_shift + + # Calculate vmpressure_file_min as below & set for 64 bit: + # vmpressure_file_min = last_lmk_bin + (last_lmk_bin - last_but_one_lmk_bin) + if [ "$arch_type" == "aarch64" ]; then + minfree_series=`cat /sys/module/lowmemorykiller/parameters/minfree` + minfree_1="${minfree_series#*,}" ; rem_minfree_1="${minfree_1%%,*}" + minfree_2="${minfree_1#*,}" ; rem_minfree_2="${minfree_2%%,*}" + minfree_3="${minfree_2#*,}" ; rem_minfree_3="${minfree_3%%,*}" + minfree_4="${minfree_3#*,}" ; rem_minfree_4="${minfree_4%%,*}" + minfree_5="${minfree_4#*,}" + + vmpres_file_min=$((minfree_5 + (minfree_5 - rem_minfree_4))) + echo $vmpres_file_min > /sys/module/lowmemorykiller/parameters/vmpressure_file_min + else + # Set LMK series, vmpressure_file_min for 32 bit non-go targets. + # Disable Core Control, enable KLMK for non-go 8909. + if [ "$ProductName" == "msm8909" ]; then + disable_core_ctl + echo 1 > /sys/module/lowmemorykiller/parameters/enable_lmk + fi + echo "15360,19200,23040,26880,34415,43737" > /sys/module/lowmemorykiller/parameters/minfree + echo 53059 > /sys/module/lowmemorykiller/parameters/vmpressure_file_min + fi + + # Enable adaptive LMK for all targets & + # use Google default LMK series for all 64-bit targets >=2GB. + echo 1 > /sys/module/lowmemorykiller/parameters/enable_adaptive_lmk + + # Enable oom_reaper + if [ -f /sys/module/lowmemorykiller/parameters/oom_reaper ]; then + echo 1 > /sys/module/lowmemorykiller/parameters/oom_reaper + fi + + if [[ "$ProductName" != "bengal"* ]]; then + #bengal has appcompaction enabled. So not needed + # Set PPR parameters for other targets + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + case "$soc_id" in + # Do not set PPR parameters for premium targets + # sdm845 - 321, 341 + # msm8998 - 292, 319 + # msm8996 - 246, 291, 305, 312 + "321" | "341" | "292" | "319" | "246" | "291" | "305" | "312") + ;; + *) + #Set PPR parameters for all other targets. + echo $set_almk_ppr_adj > /sys/module/process_reclaim/parameters/min_score_adj + echo 1 > /sys/module/process_reclaim/parameters/enable_process_reclaim + echo 50 > /sys/module/process_reclaim/parameters/pressure_min + echo 70 > /sys/module/process_reclaim/parameters/pressure_max + echo 30 > /sys/module/process_reclaim/parameters/swap_opt_eff + echo 512 > /sys/module/process_reclaim/parameters/per_swap_size + ;; + esac + fi + fi + + if [[ "$ProductName" == "bengal"* ]]; then + DeviceName=`getprop ro.product.name` + #Do not set PPR parameters for the followimg targets: + #Guam NA + case "$DeviceName" in + "guamna"*) ;; + *) + #Set PPR nomap parameters for all other bengal targets + echo 1 > /sys/module/process_reclaim/parameters/enable_process_reclaim + echo 50 > /sys/module/process_reclaim/parameters/pressure_min + echo 70 > /sys/module/process_reclaim/parameters/pressure_max + echo 30 > /sys/module/process_reclaim/parameters/swap_opt_eff + echo 0 > /sys/module/process_reclaim/parameters/per_swap_size + echo 7680 > /sys/module/process_reclaim/parameters/tsk_nomap_swap_sz + ;; + esac + fi + + # Set allocstall_threshold to 0 for all targets. + # Set swappiness to 100 for all targets + echo 0 > /sys/module/vmpressure/parameters/allocstall_threshold + echo 100 > /proc/sys/vm/swappiness + + # Disable wsf for all targets beacause we are using efk. + # wsf Range : 1..1000 So set to bare minimum value 1. + echo 1 > /proc/sys/vm/watermark_scale_factor + + configure_zram_parameters + + configure_read_ahead_kb_values + + enable_swap +fi +} + +function enable_memory_features() +{ + MemTotalStr=`cat /proc/meminfo | grep MemTotal` + MemTotal=${MemTotalStr:16:8} + + if [ $MemTotal -le 2097152 ]; then + #Enable B service adj transition for 2GB or less memory + setprop ro.vendor.qti.sys.fw.bservice_enable true + setprop ro.vendor.qti.sys.fw.bservice_limit 5 + setprop ro.vendor.qti.sys.fw.bservice_age 5000 + + #Enable Delay Service Restart + setprop ro.vendor.qti.am.reschedule_service true + fi +} + +function start_hbtp() +{ + # Start the Host based Touch processing but not in the power off mode. + bootmode=`getprop ro.bootmode` + if [ "charger" != $bootmode ]; then + start vendor.hbtp + fi +} + +case "$target" in + "msm7201a_ffa" | "msm7201a_surf" | "msm7627_ffa" | "msm7627_6x" | "msm7627a" | "msm7627_surf" | \ + "qsd8250_surf" | "qsd8250_ffa" | "msm7630_surf" | "msm7630_1x" | "msm7630_fusion" | "qsd8650a_st1x") + echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + ;; +esac + +case "$target" in + "msm7201a_ffa" | "msm7201a_surf") + echo 500000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + ;; +esac + +case "$target" in + "msm7630_surf" | "msm7630_1x" | "msm7630_fusion") + echo 75000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 1 > /sys/module/pm2/parameters/idle_sleep_mode + ;; +esac + +case "$target" in + "msm7201a_ffa" | "msm7201a_surf" | "msm7627_ffa" | "msm7627_6x" | "msm7627_surf" | "msm7630_surf" | "msm7630_1x" | "msm7630_fusion" | "msm7627a" ) + echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + ;; +esac + +case "$target" in + "msm8660") + echo 1 > /sys/module/rpm_resources/enable_low_power/L2_cache + echo 1 > /sys/module/rpm_resources/enable_low_power/pxo + echo 2 > /sys/module/rpm_resources/enable_low_power/vdd_dig + echo 2 > /sys/module/rpm_resources/enable_low_power/vdd_mem + echo 1 > /sys/module/rpm_resources/enable_low_power/rpm_cpu + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled + echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor + echo 50000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + echo 4 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + echo 384000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 384000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + chown -h root.system /sys/devices/system/cpu/mfreq + chmod -h 220 /sys/devices/system/cpu/mfreq + chown -h root.system /sys/devices/system/cpu/cpu1/online + chmod -h 664 /sys/devices/system/cpu/cpu1/online + ;; +esac + +case "$target" in + "msm8960") + echo 1 > /sys/module/rpm_resources/enable_low_power/L2_cache + echo 1 > /sys/module/rpm_resources/enable_low_power/pxo + echo 1 > /sys/module/rpm_resources/enable_low_power/vdd_dig + echo 1 > /sys/module/rpm_resources/enable_low_power/vdd_mem + echo 1 > /sys/module/msm_pm/modes/cpu0/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor + echo 50000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + echo 4 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential + echo 70 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core + echo 3 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core + echo 918000 > /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq + echo 1026000 > /sys/devices/system/cpu/cpufreq/ondemand/sync_freq + echo 80 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load + chown -h system /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + chown -h system /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + chown -h system /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + echo 384000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 384000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 384000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 384000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + echo 1 > /sys/module/msm_thermal/core_control/enabled + chown -h root.system /sys/devices/system/cpu/mfreq + chmod -h 220 /sys/devices/system/cpu/mfreq + chown -h root.system /sys/devices/system/cpu/cpu1/online + chown -h root.system /sys/devices/system/cpu/cpu2/online + chown -h root.system /sys/devices/system/cpu/cpu3/online + chmod -h 664 /sys/devices/system/cpu/cpu1/online + chmod -h 664 /sys/devices/system/cpu/cpu2/online + chmod -h 664 /sys/devices/system/cpu/cpu3/online + # set DCVS parameters for CPU + echo 40000 > /sys/module/msm_dcvs/cores/cpu0/slack_time_max_us + echo 40000 > /sys/module/msm_dcvs/cores/cpu0/slack_time_min_us + echo 100000 > /sys/module/msm_dcvs/cores/cpu0/em_win_size_min_us + echo 500000 > /sys/module/msm_dcvs/cores/cpu0/em_win_size_max_us + echo 0 > /sys/module/msm_dcvs/cores/cpu0/slack_mode_dynamic + echo 1000000 > /sys/module/msm_dcvs/cores/cpu0/disable_pc_threshold + echo 25000 > /sys/module/msm_dcvs/cores/cpu1/slack_time_max_us + echo 25000 > /sys/module/msm_dcvs/cores/cpu1/slack_time_min_us + echo 100000 > /sys/module/msm_dcvs/cores/cpu1/em_win_size_min_us + echo 500000 > /sys/module/msm_dcvs/cores/cpu1/em_win_size_max_us + echo 0 > /sys/module/msm_dcvs/cores/cpu1/slack_mode_dynamic + echo 1000000 > /sys/module/msm_dcvs/cores/cpu1/disable_pc_threshold + echo 25000 > /sys/module/msm_dcvs/cores/cpu2/slack_time_max_us + echo 25000 > /sys/module/msm_dcvs/cores/cpu2/slack_time_min_us + echo 100000 > /sys/module/msm_dcvs/cores/cpu2/em_win_size_min_us + echo 500000 > /sys/module/msm_dcvs/cores/cpu2/em_win_size_max_us + echo 0 > /sys/module/msm_dcvs/cores/cpu2/slack_mode_dynamic + echo 1000000 > /sys/module/msm_dcvs/cores/cpu2/disable_pc_threshold + echo 25000 > /sys/module/msm_dcvs/cores/cpu3/slack_time_max_us + echo 25000 > /sys/module/msm_dcvs/cores/cpu3/slack_time_min_us + echo 100000 > /sys/module/msm_dcvs/cores/cpu3/em_win_size_min_us + echo 500000 > /sys/module/msm_dcvs/cores/cpu3/em_win_size_max_us + echo 0 > /sys/module/msm_dcvs/cores/cpu3/slack_mode_dynamic + echo 1000000 > /sys/module/msm_dcvs/cores/cpu3/disable_pc_threshold + # set DCVS parameters for GPU + echo 20000 > /sys/module/msm_dcvs/cores/gpu0/slack_time_max_us + echo 20000 > /sys/module/msm_dcvs/cores/gpu0/slack_time_min_us + echo 0 > /sys/module/msm_dcvs/cores/gpu0/slack_mode_dynamic + # set msm_mpdecision parameters + echo 45000 > /sys/module/msm_mpdecision/slack_time_max_us + echo 15000 > /sys/module/msm_mpdecision/slack_time_min_us + echo 100000 > /sys/module/msm_mpdecision/em_win_size_min_us + echo 1000000 > /sys/module/msm_mpdecision/em_win_size_max_us + echo 3 > /sys/module/msm_mpdecision/online_util_pct_min + echo 25 > /sys/module/msm_mpdecision/online_util_pct_max + echo 97 > /sys/module/msm_mpdecision/em_max_util_pct + echo 2 > /sys/module/msm_mpdecision/rq_avg_poll_ms + echo 10 > /sys/module/msm_mpdecision/mp_em_rounding_point_min + echo 85 > /sys/module/msm_mpdecision/mp_em_rounding_point_max + echo 50 > /sys/module/msm_mpdecision/iowait_threshold_pct + #set permissions for the nodes needed by display on/off hook + chown -h system /sys/module/msm_dcvs/cores/cpu0/slack_time_max_us + chown -h system /sys/module/msm_dcvs/cores/cpu0/slack_time_min_us + chown -h system /sys/module/msm_mpdecision/slack_time_max_us + chown -h system /sys/module/msm_mpdecision/slack_time_min_us + chmod -h 664 /sys/module/msm_dcvs/cores/cpu0/slack_time_max_us + chmod -h 664 /sys/module/msm_dcvs/cores/cpu0/slack_time_min_us + chmod -h 664 /sys/module/msm_mpdecision/slack_time_max_us + chmod -h 664 /sys/module/msm_mpdecision/slack_time_min_us + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + case "$soc_id" in + "130") + echo 230 > /sys/class/gpio/export + echo 228 > /sys/class/gpio/export + echo 229 > /sys/class/gpio/export + echo "in" > /sys/class/gpio/gpio230/direction + echo "rising" > /sys/class/gpio/gpio230/edge + echo "in" > /sys/class/gpio/gpio228/direction + echo "rising" > /sys/class/gpio/gpio228/edge + echo "in" > /sys/class/gpio/gpio229/direction + echo "rising" > /sys/class/gpio/gpio229/edge + echo 253 > /sys/class/gpio/export + echo 254 > /sys/class/gpio/export + echo 257 > /sys/class/gpio/export + echo 258 > /sys/class/gpio/export + echo 259 > /sys/class/gpio/export + echo "out" > /sys/class/gpio/gpio253/direction + echo "out" > /sys/class/gpio/gpio254/direction + echo "out" > /sys/class/gpio/gpio257/direction + echo "out" > /sys/class/gpio/gpio258/direction + echo "out" > /sys/class/gpio/gpio259/direction + chown -h media /sys/class/gpio/gpio253/value + chown -h media /sys/class/gpio/gpio254/value + chown -h media /sys/class/gpio/gpio257/value + chown -h media /sys/class/gpio/gpio258/value + chown -h media /sys/class/gpio/gpio259/value + chown -h media /sys/class/gpio/gpio253/direction + chown -h media /sys/class/gpio/gpio254/direction + chown -h media /sys/class/gpio/gpio257/direction + chown -h media /sys/class/gpio/gpio258/direction + chown -h media /sys/class/gpio/gpio259/direction + echo 0 > /sys/module/rpm_resources/enable_low_power/vdd_dig + echo 0 > /sys/module/rpm_resources/enable_low_power/vdd_mem + ;; + esac + ;; +esac + +case "$target" in + "msm8974") + echo 4 > /sys/module/lpm_levels/enable_low_power/l2 + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/retention/idle_enabled + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + case "$soc_id" in + "208" | "211" | "214" | "217" | "209" | "212" | "215" | "218" | "194" | "210" | "213" | "216") + for devfreq_gov in /sys/class/devfreq/qcom,cpubw*/governor + do + echo "cpubw_hwmon" > $devfreq_gov + done + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "interactive" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor + echo "interactive" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor + echo "interactive" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor + echo "20000 1400000:40000 1700000:20000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + echo 1190400 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + echo "85 1500000:90 1800000:70" > /sys/devices/system/cpu/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + echo 20 > /sys/module/cpu_boost/parameters/boost_ms + echo 1728000 > /sys/module/cpu_boost/parameters/sync_threshold + echo 100000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor + echo 1497600 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + ;; + *) + echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor + echo 50000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + echo 2 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential + echo 70 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core + echo 3 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core + echo 960000 > /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq + echo 960000 > /sys/devices/system/cpu/cpufreq/ondemand/sync_freq + echo 1190400 > /sys/devices/system/cpu/cpufreq/ondemand/input_boost + echo 80 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load + ;; + esac + echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 1 > /sys/module/msm_thermal/core_control/enabled + chown -h root.system /sys/devices/system/cpu/mfreq + chmod -h 220 /sys/devices/system/cpu/mfreq + chown -h root.system /sys/devices/system/cpu/cpu1/online + chown -h root.system /sys/devices/system/cpu/cpu2/online + chown -h root.system /sys/devices/system/cpu/cpu3/online + chmod -h 664 /sys/devices/system/cpu/cpu1/online + chmod -h 664 /sys/devices/system/cpu/cpu2/online + chmod -h 664 /sys/devices/system/cpu/cpu3/online + echo 1 > /dev/cpuctl/apps/cpu.notify_on_migrate + ;; +esac + +case "$target" in + "msm8916") + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + case "$soc_id" in + "206") + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 2 > /sys/class/net/rmnet0/queues/rx-0/rps_cpus + ;; + "247" | "248" | "249" | "250") + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + ;; + "239" | "241" | "263") + if [ -f /sys/devices/soc0/revision ]; then + revision=`cat /sys/devices/soc0/revision` + else + revision=`cat /sys/devices/system/soc/soc0/revision` + fi + echo 10 > /sys/class/net/rmnet0/queues/rx-0/rps_cpus + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + fi + case "$soc_id" in + "239") + case "$hw_platform" in + "Surf") + case "$platform_subtype_id" in + "1" | "2") + start_hbtp + ;; + esac + ;; + "MTP") + case "$platform_subtype_id" in + "3") + start_hbtp + ;; + esac + ;; + esac + ;; + esac + ;; + "268" | "269" | "270" | "271") + echo 10 > /sys/class/net/rmnet0/queues/rx-0/rps_cpus + ;; + "233" | "240" | "242") + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + ;; + esac + ;; +esac + +case "$target" in + "msm8226") + echo 4 > /sys/module/lpm_levels/enable_low_power/l2 + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 50000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + echo 2 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential + echo 70 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core + echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core + echo 787200 > /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq + echo 300000 > /sys/devices/system/cpu/cpufreq/ondemand/sync_freq + echo 80 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load + echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + chown -h root.system /sys/devices/system/cpu/cpu1/online + chown -h root.system /sys/devices/system/cpu/cpu2/online + chown -h root.system /sys/devices/system/cpu/cpu3/online + chmod -h 664 /sys/devices/system/cpu/cpu1/online + chmod -h 664 /sys/devices/system/cpu/cpu2/online + chmod -h 664 /sys/devices/system/cpu/cpu3/online + ;; +esac + +case "$target" in + "msm8610") + echo 4 > /sys/module/lpm_levels/enable_low_power/l2 + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 50000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + echo 2 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential + echo 70 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_multi_core + echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/down_differential_multi_core + echo 787200 > /sys/devices/system/cpu/cpufreq/ondemand/optimal_freq + echo 300000 > /sys/devices/system/cpu/cpufreq/ondemand/sync_freq + echo 80 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold_any_cpu_load + echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + setprop ro.qualcomm.perf.min_freq 7 + echo 1 > /sys/kernel/mm/ksm/deferred_timer + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + chown -h root.system /sys/devices/system/cpu/cpu1/online + chown -h root.system /sys/devices/system/cpu/cpu2/online + chown -h root.system /sys/devices/system/cpu/cpu3/online + chmod -h 664 /sys/devices/system/cpu/cpu1/online + chmod -h 664 /sys/devices/system/cpu/cpu2/online + chmod -h 664 /sys/devices/system/cpu/cpu3/online + ;; +esac + +case "$target" in + "msm8916") + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + # HMP scheduler settings for 8916, 8936, 8939, 8929 + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + + # Apply governor settings for 8916 + case "$soc_id" in + "206" | "247" | "248" | "249" | "250") + + # HMP scheduler load tracking settings + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + + # HMP Task packing settings for 8916 + echo 20 > /proc/sys/kernel/sched_small_task + echo 30 > /proc/sys/kernel/sched_mostly_idle_load + echo 3 > /proc/sys/kernel/sched_mostly_idle_nr_run + + # disable thermal core_control to update scaling_min_freq + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + # enable thermal core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + + echo "25000 1094400:50000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + echo 30000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate + echo 998400 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + echo "1 800000:85 998400:90 1094400:80" > /sys/devices/system/cpu/cpufreq/interactive/target_loads + echo 50000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + echo 50000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + ;; + esac + + # Apply governor settings for 8936 + case "$soc_id" in + "233" | "240" | "242") + + # HMP scheduler load tracking settings + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + + # HMP Task packing settings for 8936 + echo 50 > /proc/sys/kernel/sched_small_task + echo 50 > /proc/sys/kernel/sched_mostly_idle_load + echo 10 > /proc/sys/kernel/sched_mostly_idle_nr_run + + # disable thermal core_control to update scaling_min_freq, interactive gov + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + # enable thermal core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + + echo "25000 1113600:50000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + echo 30000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate + echo 960000 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + echo "1 800000:85 1113600:90 1267200:80" > /sys/devices/system/cpu/cpufreq/interactive/target_loads + echo 50000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + echo 50000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + for gpu_bimc_io_percent in /sys/class/devfreq/*qcom,gpubw*/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + ;; + esac + + # Apply governor settings for 8939 + case "$soc_id" in + "239" | "241" | "263" | "268" | "269" | "270" | "271") + + if [ `cat /sys/devices/soc0/revision` != "3.0" ]; then + # Apply 1.0 and 2.0 specific Sched & Governor settings + + # HMP scheduler load tracking settings + echo 5 > /proc/sys/kernel/sched_ravg_hist_size + + # HMP Task packing settings for 8939, 8929 + echo 20 > /proc/sys/kernel/sched_small_task + + for devfreq_gov in /sys/class/devfreq/*qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + + for devfreq_gov in /sys/class/devfreq/*qcom,cpubw*/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_io_percent in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/io_percent + do + echo 20 > $cpu_io_percent + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/*qcom,gpubw*/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + # disable thermal core_control to update interactive gov settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + + # enable governor for perf cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "20000 1113600:50000" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 1113600 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo "1 960000:85 1113600:90 1344000:80" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 50000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 50000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/sampling_down_factor + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # enable governor for power cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo "25000 800000:50000" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 998400 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "1 800000:90" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/sampling_down_factor + echo 800000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + + # enable thermal core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # HMP scheduler (big.Little cluster related) settings + echo 75 > /proc/sys/kernel/sched_upmigrate + echo 60 > /proc/sys/kernel/sched_downmigrate + + # cpu idle load threshold + echo 30 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_load + + # cpu idle nr run threshold + echo 3 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_nr_run + + else + # Apply 3.0 specific Sched & Governor settings + # HMP scheduler settings for 8939 V3.0 + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + echo 20000000 > /proc/sys/kernel/sched_ravg_window + + # HMP Task packing settings for 8939 V3.0 + echo 20 > /proc/sys/kernel/sched_small_task + echo 30 > /proc/sys/kernel/sched_mostly_idle_load + echo 3 > /proc/sys/kernel/sched_mostly_idle_nr_run + + echo 0 > /sys/devices/system/cpu/cpu0/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu1/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu2/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu3/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu4/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu5/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu6/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu7/sched_prefer_idle + + for devfreq_gov in /sys/class/devfreq/*qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + + for devfreq_gov in /sys/class/devfreq/*qcom,cpubw*/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_io_percent in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/io_percent + do + echo 20 > $cpu_io_percent + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/*qcom,gpubw*/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + # disable thermal core_control to update interactive gov settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + + # enable governor for perf cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "19000 1113600:39000" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 1113600 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo "1 960000:85 1113600:90 1344000:80" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/sampling_down_factor + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # enable governor for power cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 39000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 800000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "1 800000:90" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/sampling_down_factor + echo 800000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + + # enable thermal core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # HMP scheduler (big.Little cluster related) settings + echo 93 > /proc/sys/kernel/sched_upmigrate + echo 83 > /proc/sys/kernel/sched_downmigrate + + # Enable sched guided freq control + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo 50000 > /proc/sys/kernel/sched_freq_inc_notify + echo 50000 > /proc/sys/kernel/sched_freq_dec_notify + + # Enable core control +# insmod /system/lib/modules/core_ctl.ko + echo 2 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + echo 68 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + case "$revision" in + "3.0") + # Enable dynamic clock gatin + echo 1 > /sys/module/lpm_levels/lpm_workarounds/dynamic_clock_gating + ;; + esac + fi + ;; + esac + # Set Memory parameters + configure_memory_parameters + ;; +esac + +case "$target" in + "msm8952") + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + case "$soc_id" in + "264" | "289") + # Apply Scheduler and Governor settings for 8952 + + # HMP scheduler settings + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + echo 20000000 > /proc/sys/kernel/sched_ravg_window + + # HMP Task packing settings + echo 20 > /proc/sys/kernel/sched_small_task + echo 30 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_load + + echo 3 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_nr_run + + echo 0 > /sys/devices/system/cpu/cpu0/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu1/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu2/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu3/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu4/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu5/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu6/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu7/sched_prefer_idle + + echo 0 > /proc/sys/kernel/sched_boost + + for devfreq_gov in /sys/class/devfreq/*qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + + for devfreq_gov in /sys/class/devfreq/*qcom,cpubw*/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_io_percent in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/io_percent + do + echo 20 > $cpu_io_percent + done + for cpu_guard_band in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/guard_band_mbps + do + echo 30 > $cpu_guard_band + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/qcom,gpubw*/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + # disable thermal & BCL core_control to update interactive gov settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + bcl_hotplug_mask=`cat $hotplug_mask` + echo 0 > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + bcl_soc_hotplug_mask=`cat $hotplug_soc_mask` + echo 0 > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # enable governor for perf cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "19000 1113600:39000" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 1113600 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo "1 960000:85 1113600:90 1344000:80" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/sampling_down_factor + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # enable governor for power cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 39000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 806400 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "1 806400:90" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/sampling_down_factor + echo 806400 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # Enable Low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # HMP scheduler (big.Little cluster related) settings + echo 93 > /proc/sys/kernel/sched_upmigrate + echo 83 > /proc/sys/kernel/sched_downmigrate + + # Enable sched guided freq control + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo 50000 > /proc/sys/kernel/sched_freq_inc_notify + echo 50000 > /proc/sys/kernel/sched_freq_dec_notify + + # Enable core control + echo 2 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + echo 68 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu0/core_ctl/is_big_cluster + + # re-enable thermal & BCL core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + echo $bcl_hotplug_mask > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + echo $bcl_soc_hotplug_mask > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # Enable dynamic clock gating + echo 1 > /sys/module/lpm_levels/lpm_workarounds/dynamic_clock_gating + # Enable timer migration to little cluster + echo 1 > /proc/sys/kernel/power_aware_timer_migration + + # Set Memory parameters + configure_memory_parameters + + ;; + *) + panel=`cat /sys/class/graphics/fb0/modes` + if [ "${panel:5:1}" == "x" ]; then + panel=${panel:2:3} + else + panel=${panel:2:4} + fi + + # Apply Scheduler and Governor settings for 8976 + # SoC IDs are 266, 274, 277, 278 + + # HMP scheduler (big.Little cluster related) settings + echo 95 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_downmigrate + + echo 2 > /proc/sys/kernel/sched_window_stats_policy + echo 5 > /proc/sys/kernel/sched_ravg_hist_size + + echo 3 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_nr_run + + for devfreq_gov in /sys/class/devfreq/*qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + + for devfreq_gov in /sys/class/devfreq/*qcom,cpubw*/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_io_percent in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/io_percent + do + echo 20 > $cpu_io_percent + done + for cpu_guard_band in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/guard_band_mbps + do + echo 30 > $cpu_guard_band + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/qcom,gpubw*/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + # disable thermal & BCL core_control to update interactive gov settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + bcl_hotplug_mask=`cat $hotplug_mask` + echo 0 > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + bcl_soc_hotplug_mask=`cat $hotplug_soc_mask` + echo 0 > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # enable governor for power cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 691200 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # enable governor for perf cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/sampling_down_factor + echo 883200 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 60000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/max_freq_hysteresis + + if [ $panel -gt 1080 ]; then + #set texture cache size for resolution greater than 1080p + setprop ro.hwui.texture_cache_size 72 + fi + + echo 59000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 1305600 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo "1 691200:80" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 1382400 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo "19000 1382400:39000" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo "85 1382400:90 1747200:80" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + # HMP Task packing settings for 8976 + echo 30 > /proc/sys/kernel/sched_small_task + echo 20 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_load + echo 20 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_load + echo 20 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_load + echo 20 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_load + echo 20 > /sys/devices/system/cpu/cpu4/sched_mostly_idle_load + echo 20 > /sys/devices/system/cpu/cpu5/sched_mostly_idle_load + echo 20 > /sys/devices/system/cpu/cpu6/sched_mostly_idle_load + echo 20 > /sys/devices/system/cpu/cpu7/sched_mostly_idle_load + + echo 0 > /proc/sys/kernel/sched_boost + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + #Disable CPU retention modes for 32bit builds + ProductName=`getprop ro.product.name` + if [ "$ProductName" == "msm8952_32" ] || [ "$ProductName" == "msm8952_32_LMT" ]; then + echo N > /sys/module/lpm_levels/system/a72/cpu4/retention/idle_enabled + echo N > /sys/module/lpm_levels/system/a72/cpu5/retention/idle_enabled + echo N > /sys/module/lpm_levels/system/a72/cpu6/retention/idle_enabled + echo N > /sys/module/lpm_levels/system/a72/cpu7/retention/idle_enabled + fi + + if [ `cat /sys/devices/soc0/revision` == "1.0" ]; then + # Disable l2-pc and l2-gdhs low power modes + echo N > /sys/module/lpm_levels/system/a53/a53-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/a72/a72-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/a53/a53-l2-pc/idle_enabled + echo N > /sys/module/lpm_levels/system/a72/a72-l2-pc/idle_enabled + fi + + # Enable LPM Prediction + echo 1 > /sys/module/lpm_levels/parameters/lpm_prediction + + # Enable Low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + # Disable L2 GDHS on 8976 + echo N > /sys/module/lpm_levels/system/a53/a53-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/a72/a72-l2-gdhs/idle_enabled + + # Enable sched guided freq control + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo 50000 > /proc/sys/kernel/sched_freq_inc_notify + echo 50000 > /proc/sys/kernel/sched_freq_dec_notify + + # Enable core control + #for 8976 + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 4 > /sys/devices/system/cpu/cpu4/core_ctl/max_cpus + echo 68 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu4/core_ctl/is_big_cluster + + # re-enable thermal & BCL core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + echo $bcl_hotplug_mask > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + echo $bcl_soc_hotplug_mask > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # Enable timer migration to little cluster + echo 1 > /proc/sys/kernel/power_aware_timer_migration + + case "$soc_id" in + "277" | "278") + # Start energy-awareness for 8976 + start energy-awareness + ;; + esac + + #enable sched colocation and colocation inheritance + echo 130 > /proc/sys/kernel/sched_grp_upmigrate + echo 110 > /proc/sys/kernel/sched_grp_downmigrate + echo 1 > /proc/sys/kernel/sched_enable_thread_grouping + + # Set Memory parameters + configure_memory_parameters + + ;; + esac + #Enable Memory Features + enable_memory_features + restorecon -R /sys/devices/system/cpu + ;; +esac + +case "$target" in + "msm8953") + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + + echo 0 > /proc/sys/kernel/sched_boost + + case "$soc_id" in + "293" | "304" | "338" | "351") + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" | "Surf" | "RCM" ) + #if this directory is present, it means that a + #1200p panel is connected to the device. + dir="/sys/bus/i2c/devices/3-0038" + if [ ! -d "$dir" ]; then + start_hbtp + fi + ;; + esac + + if [ $soc_id -eq "338" ]; then + case "$hw_platform" in + "QRD" ) + if [ $platform_subtype_id -eq "1" ]; then + start_hbtp + fi + ;; + esac + fi + + #init task load, restrict wakeups to preferred cluster + echo 15 > /proc/sys/kernel/sched_init_task_load + + for devfreq_gov in /sys/class/devfreq/qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + + for devfreq_gov in /sys/class/devfreq/soc:qcom,cpubw/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_io_percent in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/io_percent + do + echo 34 > $cpu_io_percent + done + for cpu_guard_band in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/guard_band_mbps + do + echo 0 > $cpu_guard_band + done + for cpu_hist_memory in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/hist_memory + do + echo 20 > $cpu_hist_memory + done + for cpu_hyst_length in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/hyst_length + do + echo 10 > $cpu_hyst_length + done + for cpu_idle_mbps in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/idle_mbps + do + echo 1600 > $cpu_idle_mbps + done + for cpu_low_power_delay in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/low_power_delay + do + echo 20 > $cpu_low_power_delay + done + for cpu_low_power_io_percent in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/low_power_io_percent + do + echo 34 > $cpu_low_power_io_percent + done + for cpu_mbps_zones in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/mbps_zones + do + echo "1611 3221 5859 6445 7104" > $cpu_mbps_zones + done + for cpu_sample_ms in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/sample_ms + do + echo 4 > $cpu_sample_ms + done + for cpu_up_scale in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/up_scale + do + echo 250 > $cpu_up_scale + done + for cpu_min_freq in /sys/class/devfreq/soc:qcom,cpubw/min_freq + do + echo 1611 > $cpu_min_freq + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/soc:qcom,gpubw/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + + # disable thermal & BCL core_control to update interactive gov settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + bcl_hotplug_mask=`cat $hotplug_mask` + echo 0 > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + bcl_soc_hotplug_mask=`cat $hotplug_soc_mask` + echo 0 > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + #if the kernel version >=4.9,use the schedutil governor + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 9 ]; then + 8953_sched_dcvs_eas + else + 8953_sched_dcvs_hmp + echo 652800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + fi + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # re-enable thermal & BCL core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + echo $bcl_hotplug_mask > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + echo $bcl_soc_hotplug_mask > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # SMP scheduler + echo 85 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_downmigrate + + # Set Memory parameters + configure_memory_parameters + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + disable_ppr + fi + ;; + esac + case "$soc_id" in + "349" | "350") + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" | "Surf" | "RCM" | "QRD" ) + start_hbtp + ;; + esac + + for devfreq_gov in /sys/class/devfreq/qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo "1611 3221 5859 6445 7104" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 34 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + # Configure DCC module to capture critical register contents when device crashes + for DCC_PATH in /sys/bus/platform/devices/*.dcc* + do + echo 0 > $DCC_PATH/enable + echo cap > $DCC_PATH/func_type + echo sram > $DCC_PATH/data_sink + echo 1 > $DCC_PATH/config_reset + + # Register specifies APC CPR closed-loop settled voltage for current voltage corner + echo 0xb1d2c18 1 > $DCC_PATH/config + + # Register specifies SW programmed open-loop voltage for current voltage corner + echo 0xb1d2900 1 > $DCC_PATH/config + + # Register specifies APM switch settings and APM FSM state + echo 0xb1112b0 1 > $DCC_PATH/config + + # Register specifies CPR mode change state and also #online cores input to CPR HW + echo 0xb018798 1 > $DCC_PATH/config + + echo 1 > $DCC_PATH/enable + done + + # disable thermal & BCL core_control to update interactive gov settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + bcl_hotplug_mask=`cat $hotplug_mask` + echo 0 > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + bcl_soc_hotplug_mask=`cat $hotplug_soc_mask` + echo 0 > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # configure governor settings for little cluster + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1363200 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + #default value for hispeed_load is 90, for sdm632 it should be 85 + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + # sched_load_boost as -6 is equivalent to target load as 85. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + + # configure governor settings for big cluster + echo 1 > /sys/devices/system/cpu/cpu4/online + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/down_rate_limit_us + echo 1401600 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + #default value for hispeed_load is 90, for sdm632 it should be 85 + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_load + # sched_load_boost as -6 is equivalent to target load as 85. + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + + echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 633600 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + + # cpuset settings + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + # choose idle CPU for top app tasks + echo 1 > /dev/stune/top-app/schedtune.prefer_idle + + # re-enable thermal & BCL core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + echo $bcl_hotplug_mask > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + echo $bcl_soc_hotplug_mask > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # Disable Core control + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + echo 0 > /sys/devices/system/cpu/cpu4/core_ctl/enable + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # Set Memory parameters + configure_memory_parameters + + # Setting b.L scheduler parameters + echo 76 > /proc/sys/kernel/sched_downmigrate + echo 86 > /proc/sys/kernel/sched_upmigrate + echo 80 > /proc/sys/kernel/sched_group_downmigrate + echo 90 > /proc/sys/kernel/sched_group_upmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # Enable min frequency adjustment for big cluster + if [ -f /sys/module/big_cluster_min_freq_adjust/parameters/min_freq_cluster ]; then + echo "4-7" > /sys/module/big_cluster_min_freq_adjust/parameters/min_freq_cluster + fi + echo 1 > /sys/module/big_cluster_min_freq_adjust/parameters/min_freq_adjust + + ;; + esac + ;; +esac + +case "$target" in + "msm8937") + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + + # Socid 386 = Pukeena + case "$soc_id" in + "303" | "307" | "308" | "309" | "320" | "386" | "436") + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" ) + start_hbtp + ;; + esac + + case "$hw_platform" in + "Surf" | "RCM" ) + if [ $platform_subtype_id -ne "4" ]; then + start_hbtp + fi + ;; + esac + # Apply Scheduler and Governor settings for 8917 / 8920 + + echo 20000000 > /proc/sys/kernel/sched_ravg_window + + #disable sched_boost in 8917 + echo 0 > /proc/sys/kernel/sched_boost + + # core_ctl is not needed for 8917. Disable it. + disable_core_ctl + + if [ $KernelVersionA -le 4 ] && [ $KernelVersionB -le 9 ]; then + for devfreq_gov in /sys/class/devfreq/qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + + for devfreq_gov in /sys/class/devfreq/soc:qcom,cpubw/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_io_percent in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/io_percent + do + echo 20 > $cpu_io_percent + done + for cpu_guard_band in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/guard_band_mbps + do + echo 30 > $cpu_guard_band + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/soc:qcom,gpubw/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + fi + + # disable thermal core_control to update interactive gov settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 9 ]; then + 8917_sched_dcvs_eas + else + 8917_sched_dcvs_hmp + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + fi + + # re-enable thermal core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + + # Disable L2-GDHS low power modes + echo N > /sys/module/lpm_levels/perf/perf-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/perf/perf-l2-gdhs/suspend_enabled + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # Set rps mask + echo 2 > /sys/class/net/rmnet0/queues/rx-0/rps_cpus + + # Enable dynamic clock gating + echo 1 > /sys/module/lpm_levels/lpm_workarounds/dynamic_clock_gating + # Enable timer migration to little cluster + echo 1 > /proc/sys/kernel/power_aware_timer_migration + # Set Memory parameters + configure_memory_parameters + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + disable_ppr + fi + ;; + *) + ;; + esac + + case "$soc_id" in + "294" | "295" | "313" ) + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" | "Surf" | "RCM" ) + start_hbtp + ;; + esac + + # Apply Scheduler and Governor settings for 8937/8940 + + # HMP scheduler settings + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + echo 20000000 > /proc/sys/kernel/sched_ravg_window + + #disable sched_boost in 8937 + echo 0 > /proc/sys/kernel/sched_boost + + if [ $KernelVersionA -le 4 ] && [ $KernelVersionB -le 9 ]; then + for devfreq_gov in /sys/class/devfreq/qcom,mincpubw*/governor + do + echo "cpufreq" > $devfreq_gov + done + + for devfreq_gov in /sys/class/devfreq/soc:qcom,cpubw/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_io_percent in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/io_percent + do + echo 20 > $cpu_io_percent + done + for cpu_guard_band in /sys/class/devfreq/soc:qcom,cpubw/bw_hwmon/guard_band_mbps + do + echo 30 > $cpu_guard_band + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/soc:qcom,gpubw/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + fi + + # disable thermal core_control to update interactive gov and core_ctl settings + echo 0 > /sys/module/msm_thermal/core_control/enabled + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 9 ]; then + 8937_sched_dcvs_eas + else + 8937_sched_dcvs_hmp + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 768000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + fi + # Disable L2-GDHS low power modes + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-gdhs/suspend_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-gdhs/suspend_enabled + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # HMP scheduler (big.Little cluster related) settings + echo 93 > /proc/sys/kernel/sched_upmigrate + echo 83 > /proc/sys/kernel/sched_downmigrate + + # Enable core control + echo 2 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + echo 68 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu0/core_ctl/is_big_cluster + + # re-enable thermal core_control + echo 1 > /sys/module/msm_thermal/core_control/enabled + + # Enable dynamic clock gating + echo 1 > /sys/module/lpm_levels/lpm_workarounds/dynamic_clock_gating + # Enable timer migration to little cluster + echo 1 > /proc/sys/kernel/power_aware_timer_migration + # Set Memory parameters + configure_memory_parameters + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + disable_ppr + fi + ;; + *) + + ;; + esac + + case "$soc_id" in + "354" | "364" | "353" | "363" ) + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" | "Surf" | "RCM" | "QRD" ) + start_hbtp + ;; + esac + + # Apply settings for sdm429/sda429/sdm439/sda439 + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 20 > $cpubw/bw_hwmon/io_percent + echo 30 > $cpubw/bw_hwmon/guard_band_mbps + done + done + else + for cpubw in /sys/class/devfreq/*qcom,mincpubw* + do + echo "cpufreq" > $cpubw/governor + done + + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 20 > $cpubw/bw_hwmon/io_percent + echo 30 > $cpubw/bw_hwmon/guard_band_mbps + done + + for gpu_bimc_io_percent in /sys/class/devfreq/soc:qcom,gpubw/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + fi + + case "$soc_id" in + "353" | "363" ) + # Apply settings for sdm439/sda439 + echo 1 > /sys/devices/system/cpu/cpu0/online + echo 1 > /sys/devices/system/cpu/cpu4/online + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # configure schedutil governor settings + # enable governor for perf cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + + #set the hispeed_freq + echo 1497600 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + echo 80 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_load + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + echo 960000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + + #input boost params + echo 1497600 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + ## enable governor for power cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/down_rate_limit_us + + #set the hispeed_freq + echo 998400 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_freq + echo 85 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_load + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/pl + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/rtg_boost_freq + echo 768000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq + else + # configure schedutil governor settings + # enable governor for perf cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + + #set the hispeed_freq + echo 1497600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + ## enable governor for power cluster + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/down_rate_limit_us + + #set the hispeed_freq + echo 998400 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_load + echo 768000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + fi + + # sched_load_boost as -6 is equivalent to target load as 85. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + + # EAS scheduler (big.Little cluster related) settings + echo 93 > /proc/sys/kernel/sched_upmigrate + echo 83 > /proc/sys/kernel/sched_downmigrate + echo 140 > /proc/sys/kernel/sched_group_upmigrate + echo 120 > /proc/sys/kernel/sched_group_downmigrate + + # cpuset settings + #echo 0-3 > /dev/cpuset/background/cpus + #echo 0-3 > /dev/cpuset/system-background/cpus + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # Enable core control + echo 2 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/max_cpus + echo 68 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu0/core_ctl/is_big_cluster + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + + # Big cluster min frequency adjust settings + if [ -f /sys/module/big_cluster_min_freq_adjust/parameters/min_freq_cluster ]; then + echo "0-3" > /sys/module/big_cluster_min_freq_adjust/parameters/min_freq_cluster + fi + echo 1305600 > /sys/module/big_cluster_min_freq_adjust/parameters/min_freq_floor + ;; + *) + # Apply settings for sdm429/sda429 + # configure schedutil governor settings + echo 1 > /sys/devices/system/cpu/cpu0/online + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + + #set the hispeed_freq + echo 1305600 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + echo 80 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_load + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + echo 960000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + #input boost params + + echo 1305600 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + else + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + + #set the hispeed_freq + echo 1305600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + fi + + # sched_load_boost as -6 is equivalent to target load as 85. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + ;; + esac + + # Set Memory parameters + configure_memory_parameters + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 19 ]; then + disable_ppr + fi + + #disable sched_boost + echo 0 > /proc/sys/kernel/sched_boost + + # Disable L2-GDHS low power modes + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-gdhs/suspend_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-gdhs/suspend_enabled + + # Enable low power modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + case "$soc_id" in + "353" | "363" ) + echo 1 > /sys/module/big_cluster_min_freq_adjust/parameters/min_freq_adjust + ;; + esac + ;; + esac + + case "$soc_id" in + "386" | "436") + + # Start Host based Touch processing + case "$hw_platform" in + "QRD" ) + start_hbtp + ;; + esac + ;; + esac + ;; +esac + +case "$target" in + "sdm660") + + # Set the default IRQ affinity to the primary cluster. When a + # CPU is isolated/hotplugged, the IRQ affinity is adjusted + # to one of the CPU from the default IRQ affinity mask. + echo f > /proc/irq/default_smp_affinity + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + panel=`cat /sys/class/graphics/fb0/modes` + if [ "${panel:5:1}" == "x" ]; then + panel=${panel:2:3} + else + panel=${panel:2:4} + fi + + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -le 14 ]; then + if [ $panel -gt 1080 ]; then + echo 2 > /proc/sys/kernel/sched_window_stats_policy + echo 5 > /proc/sys/kernel/sched_ravg_hist_size + else + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + fi + fi + #Apply settings for sdm660, sdm636,sda636 + case "$soc_id" in + "317" | "324" | "325" | "326" | "345" | "346" ) + + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu4/core_ctl/is_big_cluster + echo 4 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 96 > /proc/sys/kernel/sched_upmigrate + echo 90 > /proc/sys/kernel/sched_downmigrate + echo 140 > /proc/sys/kernel/sched_group_upmigrate + echo 120 > /proc/sys/kernel/sched_group_downmigrate + + # cpuset settings + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + #if the kernel version >=4.14,use the schedutil governor + if [ $KernelVersionA -ge 4 ] && [ $KernelVersionB -ge 14 ]; then + sdm660_sched_schedutil_dcvs + else + sdm660_sched_interactive_dcvs + fi + + # Set Memory parameters + configure_memory_parameters + + # enable LPM + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # Start cdsprpcd only for sdm660 and disable for sdm630 + start vendor.cdsprpcd + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" | "Surf" | "RCM" | "QRD" ) + start_hbtp + ;; + esac + ;; + esac + #Apply settings for sdm630 and Tahaa + case "$soc_id" in + "318" | "327" | "385" ) + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" | "Surf" | "RCM" | "QRD" ) + start_hbtp + ;; + esac + + # Disable cdsprpcd daemon for sdm630 + setprop vendor.fastrpc.disable.cdsprpcd.daemon 1 + + # Setting b.L scheduler parameters + echo 85 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_downmigrate + echo 900 > /proc/sys/kernel/sched_group_upmigrate + echo 900 > /proc/sys/kernel/sched_group_downmigrate + echo 0 > /proc/sys/kernel/sched_select_prev_cpu_us + echo 400000 > /proc/sys/kernel/sched_freq_inc_notify + echo 400000 > /proc/sys/kernel/sched_freq_dec_notify + echo 3 > /proc/sys/kernel/sched_spill_nr_run + + #init task load, restrict wakeups to preferred cluster + echo 15 > /proc/sys/kernel/sched_init_task_load + echo 1 > /proc/sys/kernel/sched_restrict_cluster_spill + echo 50000 > /proc/sys/kernel/sched_short_burst_ns + + # cpuset settings + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + # disable thermal bcl hotplug to switch governor + echo 0 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + bcl_hotplug_mask=`cat $hotplug_mask` + echo 0 > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + bcl_soc_hotplug_mask=`cat $hotplug_soc_mask` + echo 0 > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # online CPU0 + echo 1 > /sys/devices/system/cpu/cpu0/online + # configure governor settings for Big cluster(CPU0 to CPU3) + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo "19000 1344000:39000" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 1344000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo "85 1344000:80" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 39000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis + echo 787200 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/ignore_hispeed_on_notif + + # online CPU4 + echo 1 > /sys/devices/system/cpu/cpu4/online + # configure governor settings for Little cluster(CPU4 to CPU7) + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo "19000 1094400:39000" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 1094400 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "85 1094400:80" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 39000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/max_freq_hysteresis + echo 614400 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/ignore_hispeed_on_notif + + # bring all cores online + echo 1 > /sys/devices/system/cpu/cpu0/online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 1 > /sys/devices/system/cpu/cpu4/online + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + + # configure LPM + echo N > /sys/module/lpm_levels/system/perf/cpu0/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu1/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu2/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu3/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu4/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu5/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu6/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu7/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-dynret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-dynret/idle_enabled + # enable LPM + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # re-enable thermal and BCL hotplug + echo 1 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + echo $bcl_hotplug_mask > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + echo $bcl_soc_hotplug_mask > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 762 > $cpubw/min_freq + echo "1525 3143 4173 5195 5859 7759 9887 10327" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 85 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 100 > $cpubw/bw_hwmon/decay_rate + echo 50 > $cpubw/bw_hwmon/bw_step + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/low_power_ceil_mbps + echo 50 > $cpubw/bw_hwmon/low_power_io_percent + echo 20 > $cpubw/bw_hwmon/low_power_delay + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + for memlat in /sys/class/devfreq/*qcom,memlat-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + echo "cpufreq" > /sys/class/devfreq/soc:qcom,mincpubw/governor + ;; + esac + ;; +esac + +case "$target" in + "sdm710") + + #Apply settings for sdm710 + # Set the default IRQ affinity to the silver cluster. When a + # CPU is isolated/hotplugged, the IRQ affinity is adjusted + # to one of the CPU from the default IRQ affinity mask. + echo 3f > /proc/irq/default_smp_affinity + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + case "$soc_id" in + "336" | "337" | "347" | "360" | "393" ) + + # Start Host based Touch processing + case "$hw_platform" in + "MTP" | "Surf" | "RCM" | "QRD" ) + start_hbtp + ;; + esac + + # Core control parameters on silver + echo 0 0 0 0 1 1 > /sys/devices/system/cpu/cpu0/core_ctl/not_preferred + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/is_big_cluster + echo 8 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 96 > /proc/sys/kernel/sched_upmigrate + echo 90 > /proc/sys/kernel/sched_downmigrate + echo 140 > /proc/sys/kernel/sched_group_upmigrate + echo 120 > /proc/sys/kernel/sched_group_downmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/rate_limit_us + echo 1209600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/rate_limit_us + echo 1344000 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_freq + echo 652800 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_load + + echo "0:1209600" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo "1144 1720 2086 2929 3879 5931 6881" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 68 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + #Enable mem_latency governor for DDR scaling + for memlat in /sys/class/devfreq/*qcom,memlat-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + #Enable mem_latency governor for L3 scaling + for memlat in /sys/class/devfreq/*qcom,l3-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + #Enable userspace governor for L3 cdsp nodes + for l3cdsp in /sys/class/devfreq/*qcom,l3-cdsp* + do + echo "userspace" > $l3cdsp/governor + chown -h system $l3cdsp/userspace/set_freq + done + + echo "cpufreq" > /sys/class/devfreq/soc:qcom,mincpubw/governor + + # Disable CPU Retention + echo N > /sys/module/lpm_levels/L3/cpu0/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu1/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu2/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu3/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu4/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu5/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu6/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu7/ret/idle_enabled + + # cpuset parameters + echo 0-5 > /dev/cpuset/background/cpus + echo 0-5 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes. + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + ;; + esac + ;; +esac + +case "$target" in + "trinket") + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + case "$soc_id" in + "394" | "467" | "468" ) + + # Core control parameters on big + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 40 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu4/core_ctl/is_big_cluster + echo 4 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 67 > /proc/sys/kernel/sched_downmigrate + echo 77 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + + # cpuset settings + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1305600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1401600 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + echo 1056000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_load + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + ddr_type=`od -An -tx /proc/device-tree/memory/ddr_device_type` + ddr_type4="07" + ddr_type3="05" + + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 762 > $cpubw/min_freq + if [ ${ddr_type:4:2} == $ddr_type4 ]; then + # LPDDR4 + echo "2288 3440 4173 5195 5859 7759 10322 11863 13763" > $cpubw/bw_hwmon/mbps_zones + echo 85 > $cpubw/bw_hwmon/io_percent + fi + if [ ${ddr_type:4:2} == $ddr_type3 ]; then + # LPDDR3 + echo "1525 3440 5195 5859 7102" > $cpubw/bw_hwmon/mbps_zones + echo 34 > $cpubw/bw_hwmon/io_percent + fi + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 90 > $cpubw/bw_hwmon/decay_rate + echo 190 > $cpubw/bw_hwmon/bw_step + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 50 > $cpubw/polling_interval + done + + done + + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # colcoation v3 disabled + echo 0 > /proc/sys/kernel/sched_min_task_util_for_boost + echo 0 > /proc/sys/kernel/sched_min_task_util_for_colocation + echo 0 > /proc/sys/kernel/sched_little_cluster_coloc_fmin_khz + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes. + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + ;; + esac + ;; +esac + +case "$target" in + "sm6150") + + #Apply settings for sm6150 + # Set the default IRQ affinity to the silver cluster. When a + # CPU is isolated/hotplugged, the IRQ affinity is adjusted + # to one of the CPU from the default IRQ affinity mask. + echo 3f > /proc/irq/default_smp_affinity + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + case "$soc_id" in + "355" | "369" | "377" | "380" | "384" ) + target_type=`getprop ro.hardware.type` + if [ "$target_type" == "automotive" ]; then + # update frequencies + configure_sku_parameters + sku_identified=`getprop vendor.sku_identified` + else + sku_identified=0 + fi + + # Core control parameters on silver + echo 0 0 0 0 1 1 > /sys/devices/system/cpu/cpu0/core_ctl/not_preferred + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/is_big_cluster + echo 8 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + echo 0 > /sys/devices/system/cpu/cpu6/core_ctl/enable + + + # Setting b.L scheduler parameters + # default sched up and down migrate values are 90 and 85 + echo 65 > /proc/sys/kernel/sched_downmigrate + echo 71 > /proc/sys/kernel/sched_upmigrate + # default sched up and down migrate values are 100 and 95 + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # colocation v3 settings + echo 740000 > /proc/sys/kernel/sched_little_cluster_coloc_fmin_khz + + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1209600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + if [ $sku_identified != 1 ]; then + echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + fi + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/down_rate_limit_us + echo 1209600 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_freq + if [ $sku_identified != 1 ]; then + echo 768000 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + fi + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_load + + echo "0:1209600" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo "2288 4577 7110 9155 12298 14236" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 68 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 50 > $cpubw/polling_interval + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + echo "1144 1720 2086 2929 3879 5931 6881" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 68 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 0 > $llccbw/bw_hwmon/hyst_length + echo 80 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 40 > $llccbw/polling_interval + done + done + + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # cpuset parameters + echo 0-5 > /dev/cpuset/background/cpus + echo 0-5 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes. + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + ;; + esac + + #Apply settings for moorea + case "$soc_id" in + "365" | "366" ) + + # Core control parameters on silver + echo 0 0 0 0 1 1 > /sys/devices/system/cpu/cpu0/core_ctl/not_preferred + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/is_big_cluster + echo 8 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + echo 0 > /sys/devices/system/cpu/cpu6/core_ctl/enable + + # Setting b.L scheduler parameters + # default sched up and down migrate values are 71 and 65 + echo 65 > /proc/sys/kernel/sched_downmigrate + echo 71 > /proc/sys/kernel/sched_upmigrate + # default sched up and down migrate values are 100 and 95 + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + #colocation v3 settings + echo 740000 > /proc/sys/kernel/sched_little_cluster_coloc_fmin_khz + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/down_rate_limit_us + echo 1324600 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_freq + echo 652800 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_load + + echo "0:1248000" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo "2288 4577 7110 9155 12298 14236" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 68 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 50 > $cpubw/polling_interval + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + echo "1144 1720 2086 2929 3879 5931 6881" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 68 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 0 > $llccbw/bw_hwmon/hyst_length + echo 80 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 40 > $llccbw/polling_interval + done + + for npubw in $device/*npu-npu-ddr-bw/devfreq/*npu-npu-ddr-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npubw/governor + echo "1144 1720 2086 2929 3879 5931 6881" > $npubw/bw_hwmon/mbps_zones + echo 4 > $npubw/bw_hwmon/sample_ms + echo 80 > $npubw/bw_hwmon/io_percent + echo 20 > $npubw/bw_hwmon/hist_memory + echo 10 > $npubw/bw_hwmon/hyst_length + echo 30 > $npubw/bw_hwmon/down_thres + echo 0 > $npubw/bw_hwmon/guard_band_mbps + echo 250 > $npubw/bw_hwmon/up_scale + echo 0 > $npubw/bw_hwmon/idle_mbps + echo 40 > $npubw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + done + + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # cpuset parameters + echo 0-5 > /dev/cpuset/background/cpus + echo 0-5 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes. + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + ;; + esac + + ;; +esac + + +case "$target" in + "lito") + + #Apply settings for lito + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + fi + + case "$soc_id" in + "400" | "440" | "476" ) + # Core control parameters on silver + echo 0 0 0 0 0 0 > /sys/devices/system/cpu/cpu0/core_ctl/not_preferred + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 8 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + + # Disable Core control on gold, prime + echo 0 > /sys/devices/system/cpu/cpu6/core_ctl/enable + echo 0 > /sys/devices/system/cpu/cpu7/core_ctl/enable + + # Setting b.L scheduler parameters + echo 65 85 > /proc/sys/kernel/sched_downmigrate + echo 71 95 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + echo 0 > /proc/sys/kernel/sched_coloc_busy_hyst_ns + echo 0 > /proc/sys/kernel/sched_coloc_busy_hysteresis_enable_cpus + echo 0 > /proc/sys/kernel/sched_coloc_busy_hyst_max_ms + + # disable unfiltering + echo 20000000 > /proc/sys/kernel/sched_task_unfilter_period + echo 1 > /proc/sys/kernel/sched_task_unfilter_nr_windows + + # configure governor settings for silver cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + echo 1228800 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + echo 576000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + echo 650000 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + + # configure governor settings for gold cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/down_rate_limit_us + echo 1228800 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/hispeed_freq + echo 85 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_load + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo 0 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/pl + echo 672000 > /sys/devices/system/cpu/cpufreq/policy6/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/rtg_boost_freq + + # configure governor settings for gold+ cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy7/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/down_rate_limit_us + echo 1228800 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/hispeed_freq + echo 85 > /sys/devices/system/cpu/cpu7/cpufreq/schedutil/hispeed_load + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/pl + echo 672000 > /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/rtg_boost_freq + + # colocation v3 settings + echo 51 > /proc/sys/kernel/sched_min_task_util_for_boost + echo 35 > /proc/sys/kernel/sched_min_task_util_for_colocation + + # Enable conservative pl + echo 1 > /proc/sys/kernel/sched_conservative_pl + + echo "0:1228800" > /sys/devices/system/cpu/cpu_boost/input_boost_freq + echo 120 > /sys/devices/system/cpu/cpu_boost/input_boost_ms + + # Set Memory parameters + configure_memory_parameters + + if [ `cat /sys/devices/soc0/revision` == "2.0" ]; then + # r2.0 related changes + echo "0:1075200" > /sys/devices/system/cpu/cpu_boost/input_boost_freq + echo 610000 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + echo 1075200 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + echo 1152000 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/hispeed_freq + echo 1401600 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/hispeed_freq + echo 614400 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + echo 652800 > /sys/devices/system/cpu/cpufreq/policy6/scaling_min_freq + echo 806400 > /sys/devices/system/cpu/cpufreq/policy7/scaling_min_freq + echo 83 > /proc/sys/kernel/sched_asym_cap_sibling_freq_match_pct + fi + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo "2288 4577 7110 9155 12298 14236 16265" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 68 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 50 > $cpubw/polling_interval + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + echo "1144 1720 2086 2929 3879 5931 6881 7980" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 68 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 0 > $llccbw/bw_hwmon/hyst_length + echo 80 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 50 > $llccbw/polling_interval + done + + for npubw in $device/*npu*-ddr-bw/devfreq/*npu*-ddr-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npubw/governor + echo "1144 1720 2086 2929 3879 5931 6881 7980" > $npubw/bw_hwmon/mbps_zones + echo 4 > $npubw/bw_hwmon/sample_ms + echo 80 > $npubw/bw_hwmon/io_percent + echo 20 > $npubw/bw_hwmon/hist_memory + echo 10 > $npubw/bw_hwmon/hyst_length + echo 30 > $npubw/bw_hwmon/down_thres + echo 0 > $npubw/bw_hwmon/guard_band_mbps + echo 250 > $npubw/bw_hwmon/up_scale + echo 0 > $npubw/bw_hwmon/idle_mbps + echo 40 > $npubw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + + for npullccbw in $device/*npu*-llcc-bw/devfreq/*npu*-llcc-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npullccbw/governor + echo "2288 4577 7110 9155 12298 14236 16265" > $npullccbw/bw_hwmon/mbps_zones + echo 4 > $npullccbw/bw_hwmon/sample_ms + echo 100 > $npullccbw/bw_hwmon/io_percent + echo 20 > $npullccbw/bw_hwmon/hist_memory + echo 10 > $npullccbw/bw_hwmon/hyst_length + echo 30 > $npullccbw/bw_hwmon/down_thres + echo 0 > $npullccbw/bw_hwmon/guard_band_mbps + echo 250 > $npullccbw/bw_hwmon/up_scale + echo 40 > $npullccbw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + done + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 0 + setprop vendor.dcvs.prop 1 + + # cpuset parameters + echo 0-5 > /dev/cpuset/background/cpus + echo 0-5 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + ;; + esac + + #Apply settings for lagoon + case "$soc_id" in + "434" | "459" ) + + # Core control parameters on silver + echo 0 0 0 0 1 1 > /sys/devices/system/cpu/cpu0/core_ctl/not_preferred + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 8 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + + # Disable Core control on gold + echo 0 > /sys/devices/system/cpu/cpu6/core_ctl/enable + + + # disable unfiltering + echo 20000000 > /proc/sys/kernel/sched_task_unfilter_period + + # Setting b.L scheduler parameters + # default sched up and down migrate values are 95 and 85 + echo 65 > /proc/sys/kernel/sched_downmigrate + echo 71 > /proc/sys/kernel/sched_upmigrate + + # default sched up and down migrate values are 100 and 95 + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + echo 0 > /proc/sys/kernel/sched_coloc_busy_hyst_ns + echo 0 > /proc/sys/kernel/sched_coloc_busy_hysteresis_enable_cpus + echo 0 > /proc/sys/kernel/sched_coloc_busy_hyst_max_ms + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/down_rate_limit_us + echo 1248000 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_freq + echo 652800 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + + #colocation v3 settings + echo 740000 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/rtg_boost_freq + echo 0 > /sys/devices/system/cpu/cpufreq/policy6/schedutil/rtg_boost_freq + echo 51 > /proc/sys/kernel/sched_min_task_util_for_boost + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_load + + # Enable conservative pl + echo 1 > /proc/sys/kernel/sched_conservative_pl + + echo "0:1248000" > /sys/devices/system/cpu/cpu_boost/input_boost_freq + echo 120 > /sys/devices/system/cpu/cpu_boost/input_boost_ms + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo "2288 4577 7110 9155 12298 14236" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 68 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 50 > $cpubw/polling_interval + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + echo "1144 1720 2086 2929 3879 5931 6881 8137" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 68 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 0 > $llccbw/bw_hwmon/hyst_length + echo 80 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 40 > $llccbw/polling_interval + done + + for npubw in $device/*npu*-ddr-bw/devfreq/*npu*-ddr-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npubw/governor + echo "1144 1720 2086 2929 3879 5931 6881 7980" > $npubw/bw_hwmon/mbps_zones + echo 4 > $npubw/bw_hwmon/sample_ms + echo 80 > $npubw/bw_hwmon/io_percent + echo 20 > $npubw/bw_hwmon/hist_memory + echo 10 > $npubw/bw_hwmon/hyst_length + echo 30 > $npubw/bw_hwmon/down_thres + echo 0 > $npubw/bw_hwmon/guard_band_mbps + echo 250 > $npubw/bw_hwmon/up_scale + echo 0 > $npubw/bw_hwmon/idle_mbps + echo 40 > $npubw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + + for npullccbw in $device/*npu*-llcc-bw/devfreq/*npu*-llcc-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npullccbw/governor + echo "2288 4577 7110 9155 12298 14236 16265" > $npullccbw/bw_hwmon/mbps_zones + echo 4 > $npullccbw/bw_hwmon/sample_ms + echo 100 > $npullccbw/bw_hwmon/io_percent + echo 20 > $npullccbw/bw_hwmon/hist_memory + echo 10 > $npullccbw/bw_hwmon/hyst_length + echo 30 > $npullccbw/bw_hwmon/down_thres + echo 0 > $npullccbw/bw_hwmon/guard_band_mbps + echo 250 > $npullccbw/bw_hwmon/up_scale + echo 40 > $npullccbw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + done + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # moto add by yangbq2, set wsf value as 1 + # Disable wsf for all targets beacause we are using efk. + # wsf Range : 1..1000 So set to bare minimum value 1. + echo 1 > /proc/sys/vm/watermark_scale_factor + # moto end + + # cpuset parameters + echo 0-5 > /dev/cpuset/background/cpus + echo 0-5 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn off sleep modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # Log kernel wake-up source + echo 1 > /sys/module/msm_show_resume_irq/parameters/debug_mask + + # Log kernel enabled clock before suspend + if [ -f /sys/kernel/debug/clk/debug_suspend ]; then + echo 1 > /sys/kernel/debug/clk/debug_suspend + fi + ;; + esac +esac + +case "$target" in + "bengal") + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + case "$soc_id" in + "417" | "420" | "444" | "445" | "469" | "470" ) + + # Core control is temporarily disabled till bring up + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + # Core control parameters on big + echo 40 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 4 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 67 > /proc/sys/kernel/sched_downmigrate + echo 77 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + + # cpuset settings + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1305600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/rtg_boost_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/down_rate_limit_us + echo 1401600 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + echo 1056000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/rtg_boost_freq + + echo "0:1017600" > /sys/devices/system/cpu/cpu_boost/input_boost_freq + echo 80 > /sys/devices/system/cpu/cpu_boost/input_boost_ms + + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_load + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + ddr_type=`od -An -tx /proc/device-tree/memory/ddr_device_type` + ddr_type4="07" + ddr_type3="05" + + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 762 > $cpubw/min_freq + if [ ${ddr_type:4:2} == $ddr_type4 ]; then + # LPDDR4 + echo "2288 3440 4173 5195 5859 7759 10322 11863 13763" > $cpubw/bw_hwmon/mbps_zones + echo 85 > $cpubw/bw_hwmon/io_percent + fi + if [ ${ddr_type:4:2} == $ddr_type3 ]; then + # LPDDR3 + echo "1525 3440 5195 5859 7102" > $cpubw/bw_hwmon/mbps_zones + echo 34 > $cpubw/bw_hwmon/io_percent + fi + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 90 > $cpubw/bw_hwmon/decay_rate + echo 190 > $cpubw/bw_hwmon/bw_step + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + done + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # colcoation v3 disabled + echo 0 > /proc/sys/kernel/sched_min_task_util_for_boost + echo 0 > /proc/sys/kernel/sched_min_task_util_for_colocation + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + # Log kernel wake-up source + echo 1 > /sys/module/msm_show_resume_irq/parameters/debug_mask + + ;; + esac + + #power/perf tunings for khaje + case "$soc_id" in + "518" ) + + # Core control parameters on big + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 40 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 4 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 65 > /proc/sys/kernel/sched_downmigrate + echo 71 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + + # cpuset settings + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1516800 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 691200 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/rtg_boost_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/down_rate_limit_us + echo 1344000 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + echo 1056000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/rtg_boost_freq + + echo "0:1190000" > /sys/devices/system/cpu/cpu_boost/input_boost_freq + echo 80 > /sys/devices/system/cpu/cpu_boost/input_boost_ms + + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu4/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu5/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_load + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 762 > $cpubw/min_freq + echo "2288 3440 4173 5195 5859 7759 10322 11863 13763 15960" > $cpubw/bw_hwmon/mbps_zones + echo 85 > $cpubw/bw_hwmon/io_percent + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 90 > $cpubw/bw_hwmon/decay_rate + echo 190 > $cpubw/bw_hwmon/bw_step + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + done + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # colcoation v3 disabled + echo 0 > /proc/sys/kernel/sched_min_task_util_for_boost + echo 0 > /proc/sys/kernel/sched_min_task_util_for_colocation + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-gdhs/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-gdhs/suspend_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-gdhs/suspend_enabled + # Turn on sleep modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + ;; + esac + + # Scuba perf/power tunings + case "$soc_id" in + "441" | "471" | "473" | "474" ) + + # Quad-core device. disable core_ctl + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + + # Configure schedutil governor settings + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1305600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 614400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/rtg_boost_freq + + # sched_load_boost as -6 is equivalent to target load as 85. + echo 0 > /proc/sys/kernel/sched_boost + echo -6 > /sys/devices/system/cpu/cpu0/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu1/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu2/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu3/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_load + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + ddr_type=`od -An -tx /proc/device-tree/memory/ddr_device_type` + ddr_type4="07" + ddr_type3="05" + + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-ddr-bw/devfreq/*cpu-cpu-ddr-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 762 > $cpubw/min_freq + if [ ${ddr_type:4:2} == $ddr_type4 ]; then + # LPDDR4 + echo "2288 3440 4173 5195 5859 7759 10322 11863 13763" > $cpubw/bw_hwmon/mbps_zones + echo 85 > $cpubw/bw_hwmon/io_percent + fi + if [ ${ddr_type:4:2} == $ddr_type3 ]; then + # LPDDR3 + echo "1525 3440 5195 5859 7102" > $cpubw/bw_hwmon/mbps_zones + echo 34 > $cpubw/bw_hwmon/io_percent + fi + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 90 > $cpubw/bw_hwmon/decay_rate + echo 190 > $cpubw/bw_hwmon/bw_step + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + done + + # Disable low power modes. Enable it after LPM stable + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + # Log kernel wake-up source + echo 1 > /sys/module/msm_show_resume_irq/parameters/debug_mask + + ;; + esac + + ;; +esac + + +#Apply settings for atoll +case "$target" in + "atoll") + + # Core control parameters on silver + echo 0 0 0 0 1 1 > /sys/devices/system/cpu/cpu0/core_ctl/not_preferred + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 8 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + echo 0 > /sys/devices/system/cpu/cpu6/core_ctl/enable + + # Setting b.L scheduler parameters + # default sched up and down migrate values are 95 and 85 + echo 65 > /proc/sys/kernel/sched_downmigrate + echo 71 > /proc/sys/kernel/sched_upmigrate + # default sched up and down migrate values are 100 and 95 + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + #colocation v3 settings + echo 740000 > /proc/sys/kernel/sched_little_cluster_coloc_fmin_khz + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us + echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/down_rate_limit_us + echo 1267200 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_freq + echo 652800 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + + # sched_load_boost as -6 is equivalent to target load as 85. It is per cpu tunable. + echo -6 > /sys/devices/system/cpu/cpu6/sched_load_boost + echo -6 > /sys/devices/system/cpu/cpu7/sched_load_boost + echo 85 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_load + + echo "0:1248000" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # Set Memory parameters + configure_memory_parameters + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo "2288 4577 7110 9155 12298 14236" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 68 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 50 > $cpubw/polling_interval + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + echo "1144 1720 2086 2929 3879 5931 6881 8137" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 68 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 0 > $llccbw/bw_hwmon/hyst_length + echo 80 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 40 > $llccbw/polling_interval + done + + for npubw in $device/*npu*-npu-ddr-bw/devfreq/*npu*-npu-ddr-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npubw/governor + echo "1144 1720 2086 2929 3879 5931 6881 8137" > $npubw/bw_hwmon/mbps_zones + echo 4 > $npubw/bw_hwmon/sample_ms + echo 80 > $npubw/bw_hwmon/io_percent + echo 20 > $npubw/bw_hwmon/hist_memory + echo 10 > $npubw/bw_hwmon/hyst_length + echo 30 > $npubw/bw_hwmon/down_thres + echo 0 > $npubw/bw_hwmon/guard_band_mbps + echo 250 > $npubw/bw_hwmon/up_scale + echo 0 > $npubw/bw_hwmon/idle_mbps + echo 40 > $npubw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + + done + + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + # cpuset parameters + echo 0-5 > /dev/cpuset/background/cpus + echo 0-5 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + ;; +esac + + +case "$target" in + "qcs605") + + #Apply settings for qcs605 + # Set the default IRQ affinity to the silver cluster. When a + # CPU is isolated/hotplugged, the IRQ affinity is adjusted + # to one of the CPU from the default IRQ affinity mask. + echo 3f > /proc/irq/default_smp_affinity + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + + case "$soc_id" in + "347" ) + + # Start Host based Touch processing + case "$hw_platform" in + "Surf" | "RCM" | "QRD" ) + start_hbtp + ;; + "MTP" ) + if [ $platform_subtype_id != 5 ]; then + start_hbtp + fi + ;; + esac + + # Core control parameters on silver + echo 4 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres + echo 40 > /sys/devices/system/cpu/cpu0/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/is_big_cluster + echo 8 > /sys/devices/system/cpu/cpu0/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 96 > /proc/sys/kernel/sched_upmigrate + echo 90 > /proc/sys/kernel/sched_downmigrate + echo 140 > /proc/sys/kernel/sched_group_upmigrate + echo 120 > /proc/sys/kernel/sched_group_downmigrate + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/rate_limit_us + echo 1209600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/rate_limit_us + echo 1344000 > /sys/devices/system/cpu/cpu6/cpufreq/schedutil/hispeed_freq + echo 825600 > /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq + + echo "0:1209600" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + + # Enable bus-dcvs + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo "1144 1720 2086 2929 3879 5931 6881" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 68 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 0 > $cpubw/bw_hwmon/hyst_length + echo 80 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/low_power_ceil_mbps + echo 68 > $cpubw/bw_hwmon/low_power_io_percent + echo 20 > $cpubw/bw_hwmon/low_power_delay + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + #Enable mem_latency governor for DDR scaling + for memlat in /sys/class/devfreq/*qcom,memlat-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + #Enable mem_latency governor for L3 scaling + for memlat in /sys/class/devfreq/*qcom,l3-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + echo "cpufreq" > /sys/class/devfreq/soc:qcom,mincpubw/governor + + # cpuset parameters + echo 0-5 > /dev/cpuset/background/cpus + echo 0-5 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # Turn on sleep modes. + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + echo 100 > /proc/sys/vm/swappiness + ;; + esac + ;; +esac + +case "$target" in + "apq8084") + echo 4 > /sys/module/lpm_levels/enable_low_power/l2 + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/retention/idle_enabled + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + for devfreq_gov in /sys/class/devfreq/qcom,cpubw*/governor + do + echo "cpubw_hwmon" > $devfreq_gov + done + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "interactive" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor + echo "interactive" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor + echo "interactive" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor + echo "20000 1400000:40000 1700000:20000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + echo 1497600 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + echo "85 1500000:90 1800000:70" > /sys/devices/system/cpu/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + echo 20 > /sys/module/cpu_boost/parameters/boost_ms + echo 1728000 > /sys/module/cpu_boost/parameters/sync_threshold + echo 100000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor + echo 1497600 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + echo 1 > /dev/cpuctl/apps/cpu.notify_on_migrate + echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + echo 1 > /sys/module/msm_thermal/core_control/enabled + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + chown -h root.system /sys/devices/system/cpu/mfreq + chmod -h 220 /sys/devices/system/cpu/mfreq + chown -h root.system /sys/devices/system/cpu/cpu1/online + chown -h root.system /sys/devices/system/cpu/cpu2/online + chown -h root.system /sys/devices/system/cpu/cpu3/online + chmod -h 664 /sys/devices/system/cpu/cpu1/online + chmod -h 664 /sys/devices/system/cpu/cpu2/online + chmod -h 664 /sys/devices/system/cpu/cpu3/online + ;; +esac + +case "$target" in + "mpq8092") + echo 4 > /sys/module/lpm_levels/enable_low_power/l2 + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu0/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu1/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu2/retention/idle_enabled + echo 1 > /sys/module/msm_pm/modes/cpu3/retention/idle_enabled + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor + echo "ondemand" > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor + echo 50000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo 90 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 300000 > /sys/devices/system/cpu/cpu3/cpufreq/scaling_min_freq + echo 1 > /sys/module/msm_thermal/core_control/enabled + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq + chown -h system /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + chown -h root.system /sys/devices/system/cpu/mfreq + chmod -h 220 /sys/devices/system/cpu/mfreq + chown -h root.system /sys/devices/system/cpu/cpu1/online + chown -h root.system /sys/devices/system/cpu/cpu2/online + chown -h root.system /sys/devices/system/cpu/cpu3/online + chmod -h 664 /sys/devices/system/cpu/cpu1/online + chmod -h 664 /sys/devices/system/cpu/cpu2/online + chmod -h 664 /sys/devices/system/cpu/cpu3/online + ;; +esac + +case "$target" in + "msm8992") + # disable thermal bcl hotplug to switch governor + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo -n disable > /sys/devices/soc.*/qcom,bcl.*/mode + bcl_hotplug_mask=`cat /sys/devices/soc.*/qcom,bcl.*/hotplug_mask` + echo 0 > /sys/devices/soc.*/qcom,bcl.*/hotplug_mask + echo -n enable > /sys/devices/soc.*/qcom,bcl.*/mode + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + # configure governor settings for little cluster + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 19000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 80000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis + echo 384000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + # online CPU4 + echo 1 > /sys/devices/system/cpu/cpu4/online + # configure governor settings for big cluster + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo 19000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 1536000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo 85 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 80000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/max_freq_hysteresis + echo 384000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + # re-enable thermal and BCL hotplug + echo 1 > /sys/module/msm_thermal/core_control/enabled + echo -n disable > /sys/devices/soc.*/qcom,bcl.*/mode + echo $bcl_hotplug_mask > /sys/devices/soc.*/qcom,bcl.*/hotplug_mask + echo $bcl_soc_hotplug_mask > /sys/devices/soc.*/qcom,bcl.*/hotplug_soc_mask + echo -n enable > /sys/devices/soc.*/qcom,bcl.*/mode + # plugin remaining A57s + echo 1 > /sys/devices/system/cpu/cpu5/online + # input boost configuration + echo 0:1248000 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + # Enable task migration fixups in the scheduler + echo 1 > /proc/sys/kernel/sched_migration_fixup + for devfreq_gov in /sys/class/devfreq/qcom,cpubw*/governor + do + echo "bw_hwmon" > $devfreq_gov + done + #enable rps static configuration + echo 8 > /sys/class/net/rmnet_ipa0/queues/rx-0/rps_cpus + echo 30 > /proc/sys/kernel/sched_small_task + ;; +esac + +case "$target" in + "msm8994") + # ensure at most one A57 is online when thermal hotplug is disabled + echo 0 > /sys/devices/system/cpu/cpu5/online + echo 0 > /sys/devices/system/cpu/cpu6/online + echo 0 > /sys/devices/system/cpu/cpu7/online + # in case CPU4 is online, limit its frequency + echo 960000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + # Limit A57 max freq from msm_perf module in case CPU 4 is offline + echo "4:960000 5:960000 6:960000 7:960000" > /sys/module/msm_performance/parameters/cpu_max_freq + # disable thermal bcl hotplug to switch governor + echo 0 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + bcl_hotplug_mask=`cat $hotplug_mask` + echo 0 > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + bcl_soc_hotplug_mask=`cat $hotplug_soc_mask` + echo 0 > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + # configure governor settings for little cluster + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 19000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 80000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis + echo 384000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + # online CPU4 + echo 1 > /sys/devices/system/cpu/cpu4/online + # Best effort limiting for first time boot if msm_performance module is absent + echo 960000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + # configure governor settings for big cluster + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo "19000 1400000:39000 1700000:19000" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 1248000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "85 1500000:90 1800000:70" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 40000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 80000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/max_freq_hysteresis + echo 384000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + # restore A57's max + cat /sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_max_freq > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + # re-enable thermal and BCL hotplug + echo 1 > /sys/module/msm_thermal/core_control/enabled + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n disable > $mode + done + for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask + do + echo $bcl_hotplug_mask > $hotplug_mask + done + for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask + do + echo $bcl_soc_hotplug_mask > $hotplug_soc_mask + done + for mode in /sys/devices/soc.0/qcom,bcl.*/mode + do + echo -n enable > $mode + done + # plugin remaining A57s + echo 1 > /sys/devices/system/cpu/cpu5/online + echo 1 > /sys/devices/system/cpu/cpu6/online + echo 1 > /sys/devices/system/cpu/cpu7/online + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + # Restore CPU 4 max freq from msm_performance + echo "4:4294967295 5:4294967295 6:4294967295 7:4294967295" > /sys/module/msm_performance/parameters/cpu_max_freq + # input boost configuration + echo 0:1344000 > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + # Setting b.L scheduler parameters + echo 1 > /proc/sys/kernel/sched_migration_fixup + echo 30 > /proc/sys/kernel/sched_small_task + echo 20 > /proc/sys/kernel/sched_mostly_idle_load + echo 3 > /proc/sys/kernel/sched_mostly_idle_nr_run + echo 99 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_downmigrate + echo 400000 > /proc/sys/kernel/sched_freq_inc_notify + echo 400000 > /proc/sys/kernel/sched_freq_dec_notify + #enable rps static configuration + echo 8 > /sys/class/net/rmnet_ipa0/queues/rx-0/rps_cpus + for devfreq_gov in /sys/class/devfreq/qcom,cpubw*/governor + do + echo "bw_hwmon" > $devfreq_gov + done + ;; +esac + +case "$target" in + "msm8996") + # disable thermal bcl hotplug to switch governor + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo -n disable > /sys/devices/soc/soc:qcom,bcl/mode + bcl_hotplug_mask=`cat /sys/devices/soc/soc:qcom,bcl/hotplug_mask` + echo 0 > /sys/devices/soc/soc:qcom,bcl/hotplug_mask + bcl_soc_hotplug_mask=`cat /sys/devices/soc/soc:qcom,bcl/hotplug_soc_mask` + echo 0 > /sys/devices/soc/soc:qcom,bcl/hotplug_soc_mask + echo -n enable > /sys/devices/soc/soc:qcom,bcl/mode + # set sync wakee policy tunable + echo 1 > /proc/sys/kernel/sched_prefer_sync_wakee_to_waker + # configure governor settings for little cluster + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 19000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 960000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo 80 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 19000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 79000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis + echo 300000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/ignore_hispeed_on_notif + # online CPU2 + echo 1 > /sys/devices/system/cpu/cpu2/online + # configure governor settings for big cluster + echo "interactive" > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/use_migration_notif + echo "19000 1400000:39000 1700000:19000 2100000:79000" > /sys/devices/system/cpu/cpu2/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/timer_rate + echo 1248000 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/io_is_busy + echo "85 1500000:90 1800000:70 2100000:95" > /sys/devices/system/cpu/cpu2/cpufreq/interactive/target_loads + echo 19000 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/min_sample_time + echo 79000 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/max_freq_hysteresis + echo 300000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpu2/cpufreq/interactive/ignore_hispeed_on_notif + # re-enable thermal and BCL hotplug + echo 1 > /sys/module/msm_thermal/core_control/enabled + echo -n disable > /sys/devices/soc/soc:qcom,bcl/mode + echo $bcl_hotplug_mask > /sys/devices/soc/soc:qcom,bcl/hotplug_mask + echo $bcl_soc_hotplug_mask > /sys/devices/soc/soc:qcom,bcl/hotplug_soc_mask + echo -n enable > /sys/devices/soc/soc:qcom,bcl/mode + # input boost configuration + echo "0:1324800 2:1324800" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + # Setting b.L scheduler parameters + echo 0 > /proc/sys/kernel/sched_boost + echo 1 > /proc/sys/kernel/sched_migration_fixup + echo 45 > /proc/sys/kernel/sched_downmigrate + echo 45 > /proc/sys/kernel/sched_upmigrate + echo 400000 > /proc/sys/kernel/sched_freq_inc_notify + echo 400000 > /proc/sys/kernel/sched_freq_dec_notify + echo 3 > /proc/sys/kernel/sched_spill_nr_run + echo 100 > /proc/sys/kernel/sched_init_task_load + # Enable bus-dcvs + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 1525 > $cpubw/min_freq + echo "1525 5195 11863 13763" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 34 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 10 > $cpubw/bw_hwmon/hyst_length + echo 0 > $cpubw/bw_hwmon/low_power_ceil_mbps + echo 34 > $cpubw/bw_hwmon/low_power_io_percent + echo 20 > $cpubw/bw_hwmon/low_power_delay + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + for memlat in /sys/class/devfreq/*qcom,memlat-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + done + echo "cpufreq" > /sys/class/devfreq/soc:qcom,mincpubw/governor + + soc_revision=`cat /sys/devices/soc0/revision` + if [ "$soc_revision" == "2.0" ]; then + #Disable suspend for v2.0 + echo pwr_dbg > /sys/power/wake_lock + elif [ "$soc_revision" == "2.1" ]; then + # Enable C4.D4.E4.M3 LPM modes + # Disable D3 state + echo 0 > /sys/module/lpm_levels/system/pwr/pwr-l2-gdhs/idle_enabled + echo 0 > /sys/module/lpm_levels/system/perf/perf-l2-gdhs/idle_enabled + # Disable DEF-FPC mode + echo N > /sys/module/lpm_levels/system/pwr/cpu0/fpc-def/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu1/fpc-def/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu2/fpc-def/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu3/fpc-def/idle_enabled + else + # Enable all LPMs by default + # This will enable C4, D4, D3, E4 and M3 LPMs + echo N > /sys/module/lpm_levels/parameters/sleep_disabled + fi + echo N > /sys/module/lpm_levels/parameters/sleep_disabled + # Starting io prefetcher service + start iop + + # Set Memory parameters + configure_memory_parameters + ;; +esac + +case "$target" in + "sdm845") + + # Set the default IRQ affinity to the silver cluster. When a + # CPU is isolated/hotplugged, the IRQ affinity is adjusted + # to one of the CPU from the default IRQ affinity mask. + echo f > /proc/irq/default_smp_affinity + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + fi + + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + + case "$soc_id" in + "321" | "341") + # Start Host based Touch processing + case "$hw_platform" in + "QRD" ) + case "$platform_subtype_id" in + "32") #QVR845 do nothing + ;; + *) + start_hbtp + ;; + esac + ;; + *) + start_hbtp + ;; + esac + ;; + esac + # Core control parameters + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu4/core_ctl/is_big_cluster + echo 4 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 95 > /proc/sys/kernel/sched_upmigrate + echo 85 > /proc/sys/kernel/sched_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 95 > /proc/sys/kernel/sched_group_downmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # configure governor settings for little cluster + echo "schedutil" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/rate_limit_us + echo 1209600 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/schedutil/pl + echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + + # configure governor settings for big cluster + echo "schedutil" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 0 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/rate_limit_us + echo 1574400 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/schedutil/pl + echo "0:1324800" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 120 > /sys/module/cpu_boost/parameters/input_boost_ms + # Limit the min frequency to 825MHz + echo 825000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + + # Enable oom_reaper + echo 1 > /sys/module/lowmemorykiller/parameters/oom_reaper + + # Enable bus-dcvs + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo "2288 4577 6500 8132 9155 10681" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 50 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 10 > $cpubw/bw_hwmon/hyst_length + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + for llccbw in /sys/class/devfreq/*qcom,llccbw* + do + echo "bw_hwmon" > $llccbw/governor + echo 50 > $llccbw/polling_interval + echo "1720 2929 3879 5931 6881" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 80 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 10 > $llccbw/bw_hwmon/hyst_length + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + done + + #Enable mem_latency governor for DDR scaling + for memlat in /sys/class/devfreq/*qcom,memlat-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + #Enable mem_latency governor for L3 scaling + for memlat in /sys/class/devfreq/*qcom,l3-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + #Enable userspace governor for L3 cdsp nodes + for l3cdsp in /sys/class/devfreq/*qcom,l3-cdsp* + do + echo "userspace" > $l3cdsp/governor + chown -h system $l3cdsp/userspace/set_freq + done + + #Gold L3 ratio ceil + echo 4000 > /sys/class/devfreq/soc:qcom,l3-cpu4/mem_latency/ratio_ceil + + echo "compute" > /sys/class/devfreq/soc:qcom,mincpubw/governor + echo 10 > /sys/class/devfreq/soc:qcom,mincpubw/polling_interval + + # cpuset parameters + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + # Disable CPU Retention + echo N > /sys/module/lpm_levels/L3/cpu0/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu1/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu2/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu3/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu4/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu5/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu6/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/cpu7/ret/idle_enabled + echo N > /sys/module/lpm_levels/L3/l3-dyn-ret/idle_enabled + # Turn on sleep modes. + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + echo 100 > /proc/sys/vm/swappiness + echo 120 > /proc/sys/vm/watermark_scale_factor + ;; +esac + +case "$target" in + "msmnile") + # cpuset parameters + target_varient=`getprop ro.build.product` + if [ "$target_varient" == "msmnile_gvmq" ]; then + echo 4-7 > /dev/cpuset/background/cpus + echo 4-7 > /dev/cpuset/system-background/cpus + + # Enable oom_reaper + if [ -f /sys/module/lowmemorykiller/parameters/oom_reaper ]; then + echo 1 > /sys/module/lowmemorykiller/parameters/oom_reaper + else + echo 1 > /proc/sys/vm/reap_mem_on_sigkill + fi + # Disable wsf, beacause we are using efk. + # wsf Range : 1..1000 So set to bare minimum value 1. + echo 1 > /proc/sys/vm/watermark_scale_factor + + # Disable wsf, beacause we are using efk. + # wsf Range : 1..1000 So set to bare minimum value 1. + echo 1 > /proc/sys/vm/watermark_scale_factor + # Enable oom_reaper + echo 1 > /proc/sys/vm/reap_mem_on_sigkill + + else + # Core control parameters for gold + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 3 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Core control parameters for gold+ + echo 0 > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu7/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu7/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu7/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/task_thres + # Controls how many more tasks should be eligible to run on gold CPUs + # w.r.t number of gold CPUs available to trigger assist (max number of + # tasks eligible to run on previous cluster minus number of CPUs in + # the previous cluster). + # + # Setting to 1 by default which means there should be at least + # 4 tasks eligible to run on gold cluster (tasks running on gold cores + # plus misfit tasks on silver cores) to trigger assitance from gold+. + echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/nr_prev_assist_thresh + + # Disable Core control on silver + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + + # Setting b.L scheduler parameters + echo 95 95 > /proc/sys/kernel/sched_upmigrate + echo 85 85 > /proc/sys/kernel/sched_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 10 > /proc/sys/kernel/sched_group_downmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # configure governor settings for silver cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + echo 1209600 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + echo 576000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + + # configure governor settings for gold cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + echo 1612800 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/pl + + # configure governor settings for gold+ cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy7/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + echo 1612800 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/pl + + # configure input boost settings + echo "0:1324800" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 120 > /sys/module/cpu_boost/parameters/input_boost_ms + + # Disable wsf, beacause we are using efk. + # wsf Range : 1..1000 So set to bare minimum value 1. + echo 1 > /proc/sys/vm/watermark_scale_factor + + # Enable oom_reaper + if [ -f /sys/module/lowmemorykiller/parameters/oom_reaper ]; then + echo 1 > /sys/module/lowmemorykiller/parameters/oom_reaper + else + echo 1 > /proc/sys/vm/reap_mem_on_sigkill + fi + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo "2288 4577 7110 9155 12298 14236 15258" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 50 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 10 > $cpubw/bw_hwmon/hyst_length + echo 30 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 14236 > $cpubw/max_freq + echo 40 > $cpubw/polling_interval + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + echo "1720 2929 3879 5931 6881 7980" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 80 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 10 > $llccbw/bw_hwmon/hyst_length + echo 30 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 6881 > $llccbw/max_freq + echo 40 > $llccbw/polling_interval + done + + for npubw in $device/*npu-npu-ddr-bw/devfreq/*npu-npu-ddr-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npubw/governor + echo "1720 2929 3879 5931 6881 7980" > $npubw/bw_hwmon/mbps_zones + echo 4 > $npubw/bw_hwmon/sample_ms + echo 80 > $npubw/bw_hwmon/io_percent + echo 20 > $npubw/bw_hwmon/hist_memory + echo 6 > $npubw/bw_hwmon/hyst_length + echo 30 > $npubw/bw_hwmon/down_thres + echo 0 > $npubw/bw_hwmon/guard_band_mbps + echo 250 > $npubw/bw_hwmon/up_scale + echo 0 > $npubw/bw_hwmon/idle_mbps + echo 40 > $npubw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + done + fi + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 1 + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + + case "$hw_platform" in + "MTP" | "Surf" | "RCM" ) + # Start Host based Touch processing + case "$platform_subtype_id" in + "0" | "1" | "2" | "3" | "4") + start_hbtp + ;; + esac + ;; + "HDK" ) + if [ -d /sys/kernel/hbtpsensor ] ; then + start_hbtp + fi + ;; + esac + + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + configure_memory_parameters + target_type=`getprop ro.hardware.type` + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + if [ "$target_type" == "automotive" ]; then + # update frequencies + if [ "$soc_id" == "340" ] | [ "$soc_id" == "405" ]; then #sa8195 + configure_automotive_sku_parameters_sa8195 + else #sa8155 + configure_automotive_sku_parameters + fi + fi + ;; +esac + +case "$target" in + "sdmshrike") + # Core control parameters for gold + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 3 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Core control parameters for gold+ + echo 0 > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu7/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu7/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu7/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/task_thres + # Controls how many more tasks should be eligible to run on gold CPUs + # w.r.t number of gold CPUs available to trigger assist (max number of + # tasks eligible to run on previous cluster minus number of CPUs in + # the previous cluster). + # + # Setting to 1 by default which means there should be at least + # 4 tasks eligible to run on gold cluster (tasks running on gold cores + # plus misfit tasks on silver cores) to trigger assitance from gold+. + echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/nr_prev_assist_thresh + + # Disable Core control on silver + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + + # Setting b.L scheduler parameters + echo 95 95 > /proc/sys/kernel/sched_upmigrate + echo 85 85 > /proc/sys/kernel/sched_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 10 > /proc/sys/kernel/sched_group_downmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + + # cpuset parameters + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # configure governor settings for silver cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + echo 1209600 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + echo 576000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + + # configure governor settings for gold cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/down_rate_limit_us + echo 1612800 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/pl + + # configure governor settings for gold+ cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy7/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/up_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/down_rate_limit_us + echo 1612800 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/pl + + # configure input boost settings + echo "0:1324800" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 120 > /sys/module/cpu_boost/parameters/input_boost_ms + + # Disable wsf, beacause we are using efk. + # wsf Range : 1..1000 So set to bare minimum value 1. + echo 1 > /proc/sys/vm/watermark_scale_factor + + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + # Enable oom_reaper + if [ -f /sys/module/lowmemorykiller/parameters/oom_reaper ]; then + echo 1 > /sys/module/lowmemorykiller/parameters/oom_reaper + else + echo 1 > /proc/sys/vm/reap_mem_on_sigkill + fi + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo 40 > $cpubw/polling_interval + echo "2288 4577 7110 9155 12298 14236 15258" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 50 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 10 > $cpubw/bw_hwmon/hyst_length + echo 30 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 14236 > $cpubw/max_freq + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + echo 40 > $llccbw/polling_interval + echo "1720 2929 3879 5931 6881 7980" > $llccbw/bw_hwmon/mbps_zones + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 80 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 10 > $llccbw/bw_hwmon/hyst_length + echo 30 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 6881 > $llccbw/max_freq + done + + for npubw in $device/*npu-npu-ddr-bw/devfreq/*npu-npu-ddr-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npubw/governor + echo 40 > $npubw/polling_interval + echo "1720 2929 3879 5931 6881 7980" > $npubw/bw_hwmon/mbps_zones + echo 4 > $npubw/bw_hwmon/sample_ms + echo 80 > $npubw/bw_hwmon/io_percent + echo 20 > $npubw/bw_hwmon/hist_memory + echo 6 > $npubw/bw_hwmon/hyst_length + echo 30 > $npubw/bw_hwmon/down_thres + echo 0 > $npubw/bw_hwmon/guard_band_mbps + echo 250 > $npubw/bw_hwmon/up_scale + echo 0 > $npubw/bw_hwmon/idle_mbps + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + + #Enable mem_latency governor for L3, LLCC, and DDR scaling + for memlat in $device/*cpu*-lat/devfreq/*cpu*-lat + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + #Enable userspace governor for L3 cdsp nodes + for l3cdsp in $device/*cdsp-cdsp-l3-lat/devfreq/*cdsp-cdsp-l3-lat + do + echo "cdspl3" > $l3cdsp/governor + done + + #Enable compute governor for gold latfloor + for latfloor in $device/*cpu-ddr-latfloor*/devfreq/*cpu-ddr-latfloor* + do + echo "compute" > $latfloor/governor + echo 10 > $latfloor/polling_interval + done + + #Gold L3 ratio ceil + for l3gold in $device/*cpu4-cpu-l3-lat/devfreq/*cpu4-cpu-l3-lat + do + echo 4000 > $l3gold/mem_latency/ratio_ceil + done + + #Prime L3 ratio ceil + for l3prime in $device/*cpu7-cpu-l3-lat/devfreq/*cpu7-cpu-l3-lat + do + echo 20000 > $l3prime/mem_latency/ratio_ceil + done + done + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + + case "$hw_platform" in + "MTP" | "Surf" | "RCM" ) + # Start Host based Touch processing + case "$platform_subtype_id" in + "0" | "1") + start_hbtp + ;; + esac + ;; + "HDK" ) + if [ -d /sys/kernel/hbtpsensor ] ; then + start_hbtp + fi + ;; + esac + + #Setting the min and max supported frequencies + reg_val=`cat /sys/devices/platform/soc/780130.qfprom/qfprom0/nvmem | od -An -t d4` + feature_id=$(((reg_val >> 20) & 0xFF)) + + #Setting the min supported frequencies + echo 1113600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 1171200 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/min_freq + echo 940800000 > /sys/class/devfreq/soc\:qcom,cpu4-cpu-l3-lat/min_freq + echo 1651200000 > /sys/class/devfreq/soc\:qcom,cpu0-cpu-l3-lat/max_freq + echo 1651200000 > /sys/class/devfreq/soc\:qcom,cpu4-cpu-l3-lat/max_freq + #setting min gpu freq to 392 MHz + echo 4 > /sys/class/kgsl/kgsl-3d0/min_pwrlevel + if [ $feature_id == 0 ]; then + echo "feature_id is 0 for SA8195AA" + + #setting max cpu freq to 2.496GHz + echo 2496000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + #setting max gpu freq to 530 MHz + echo 3 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 1804 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + elif [ $feature_id == 1 ] || [ $feature_id == 2 ]; then + echo "feature_id is 1 for external SA8195AB" + echo "feature_id is 2 for internal SA8195AB" + + #setting max cpu freq to 2.496GHz + echo 2496000 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_max_freq + #setting max gpu freq to 670 MHz + echo 0 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel + echo 2092 > /sys/devices/platform/soc/soc:aop-set-ddr-freq/set_ddr_capped_freq + elif [ $feature_id == 3 ]; then + echo "feature_id is 3 for external SA8195AC" + else + echo "unknown feature_id value" $feature_id + fi + + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + configure_memory_parameters + ;; +esac + +case "$target" in + "kona") + rev=`cat /sys/devices/soc0/revision` + ddr_type=`od -An -tx /proc/device-tree/memory/ddr_device_type` + ddr_type4="07" + ddr_type5="08" + + # Core control parameters for gold + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 3 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Core control parameters for gold+ + echo 0 > /sys/devices/system/cpu/cpu7/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu7/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu7/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu7/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/task_thres + # Controls how many more tasks should be eligible to run on gold CPUs + # w.r.t number of gold CPUs available to trigger assist (max number of + # tasks eligible to run on previous cluster minus number of CPUs in + # the previous cluster). + # + # Setting to 1 by default which means there should be at least + # 4 tasks eligible to run on gold cluster (tasks running on gold cores + # plus misfit tasks on silver cores) to trigger assitance from gold+. + echo 1 > /sys/devices/system/cpu/cpu7/core_ctl/nr_prev_assist_thresh + + # Disable Core control on silver + echo 0 > /sys/devices/system/cpu/cpu0/core_ctl/enable + + # Setting b.L scheduler parameters + echo 95 95 > /proc/sys/kernel/sched_upmigrate + echo 85 85 > /proc/sys/kernel/sched_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 85 > /proc/sys/kernel/sched_group_downmigrate + echo 1 > /proc/sys/kernel/sched_walt_rotate_big_tasks + echo 400000000 > /proc/sys/kernel/sched_coloc_downmigrate_ns + + # cpuset parameters + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + + # Turn off scheduler boost at the end + echo 0 > /proc/sys/kernel/sched_boost + + # configure governor settings for silver cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/down_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/up_rate_limit_us + if [ $rev == "2.0" ] || [ $rev == "2.1" ]; then + echo 1248000 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + else + echo 1228800 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/hispeed_freq + fi + echo 691200 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy0/schedutil/pl + + # configure input boost settings + echo "0:1324800" > /sys/devices/system/cpu/cpu_boost/input_boost_freq + echo 120 > /sys/devices/system/cpu/cpu_boost/input_boost_ms + + # configure governor settings for gold cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy4/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/down_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/up_rate_limit_us + echo 1574400 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpufreq/policy4/schedutil/pl + + # configure governor settings for gold+ cluster + echo "schedutil" > /sys/devices/system/cpu/cpufreq/policy7/scaling_governor + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/down_rate_limit_us + echo 0 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/up_rate_limit_us + if [ $rev == "2.0" ] || [ $rev == "2.1" ]; then + echo 1632000 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/hispeed_freq + else + echo 1612800 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/hispeed_freq + fi + echo 1 > /sys/devices/system/cpu/cpufreq/policy7/schedutil/pl + + # Enable bus-dcvs + for device in /sys/devices/platform/soc + do + for cpubw in $device/*cpu-cpu-llcc-bw/devfreq/*cpu-cpu-llcc-bw + do + echo "bw_hwmon" > $cpubw/governor + echo "4577 7110 9155 12298 14236 15258" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 50 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 10 > $cpubw/bw_hwmon/hyst_length + echo 30 > $cpubw/bw_hwmon/down_thres + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + echo 14236 > $cpubw/max_freq + echo 40 > $cpubw/polling_interval + done + + for llccbw in $device/*cpu-llcc-ddr-bw/devfreq/*cpu-llcc-ddr-bw + do + echo "bw_hwmon" > $llccbw/governor + if [ ${ddr_type:4:2} == $ddr_type4 ]; then + echo "1720 2086 2929 3879 5161 5931 6881 7980" > $llccbw/bw_hwmon/mbps_zones + elif [ ${ddr_type:4:2} == $ddr_type5 ]; then + echo "1720 2086 2929 3879 5931 6881 7980 10437" > $llccbw/bw_hwmon/mbps_zones + fi + echo 4 > $llccbw/bw_hwmon/sample_ms + echo 80 > $llccbw/bw_hwmon/io_percent + echo 20 > $llccbw/bw_hwmon/hist_memory + echo 10 > $llccbw/bw_hwmon/hyst_length + echo 30 > $llccbw/bw_hwmon/down_thres + echo 0 > $llccbw/bw_hwmon/guard_band_mbps + echo 250 > $llccbw/bw_hwmon/up_scale + echo 1600 > $llccbw/bw_hwmon/idle_mbps + echo 6881 > $llccbw/max_freq + echo 40 > $llccbw/polling_interval + done + + for npubw in $device/*npu*-ddr-bw/devfreq/*npu*-ddr-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npubw/governor + if [ ${ddr_type:4:2} == $ddr_type4 ]; then + echo "1720 2086 2929 3879 5931 6881 7980" > $npubw/bw_hwmon/mbps_zones + elif [ ${ddr_type:4:2} == $ddr_type5 ]; then + echo "1720 2086 2929 3879 5931 6881 7980 10437" > $npubw/bw_hwmon/mbps_zones + fi + echo 4 > $npubw/bw_hwmon/sample_ms + echo 160 > $npubw/bw_hwmon/io_percent + echo 20 > $npubw/bw_hwmon/hist_memory + echo 10 > $npubw/bw_hwmon/hyst_length + echo 30 > $npubw/bw_hwmon/down_thres + echo 0 > $npubw/bw_hwmon/guard_band_mbps + echo 250 > $npubw/bw_hwmon/up_scale + echo 1600 > $npubw/bw_hwmon/idle_mbps + echo 40 > $npubw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + + for npullccbw in $device/*npu*-llcc-bw/devfreq/*npu*-llcc-bw + do + echo 1 > /sys/devices/virtual/npu/msm_npu/pwr + echo "bw_hwmon" > $npullccbw/governor + echo "4577 7110 9155 12298 14236 15258" > $npullccbw/bw_hwmon/mbps_zones + echo 4 > $npullccbw/bw_hwmon/sample_ms + echo 160 > $npullccbw/bw_hwmon/io_percent + echo 20 > $npullccbw/bw_hwmon/hist_memory + echo 10 > $npullccbw/bw_hwmon/hyst_length + echo 30 > $npullccbw/bw_hwmon/down_thres + echo 0 > $npullccbw/bw_hwmon/guard_band_mbps + echo 250 > $npullccbw/bw_hwmon/up_scale + echo 1600 > $npullccbw/bw_hwmon/idle_mbps + echo 40 > $npullccbw/polling_interval + echo 0 > /sys/devices/virtual/npu/msm_npu/pwr + done + done + # memlat specific settings are moved to seperate file under + # device/target specific folder + setprop vendor.dcvs.prop 0 + setprop vendor.dcvs.prop 1 + echo N > /sys/module/lpm_levels/parameters/sleep_disabled + configure_memory_parameters + ;; +esac + +case "$target" in + "msm8998" | "apq8098_latv") + + echo 2 > /sys/devices/system/cpu/cpu4/core_ctl/min_cpus + echo 60 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres + echo 30 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres + echo 100 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms + echo 1 > /sys/devices/system/cpu/cpu4/core_ctl/is_big_cluster + echo 4 > /sys/devices/system/cpu/cpu4/core_ctl/task_thres + + # Setting b.L scheduler parameters + echo 1 > /proc/sys/kernel/sched_migration_fixup + echo 95 > /proc/sys/kernel/sched_upmigrate + echo 90 > /proc/sys/kernel/sched_downmigrate + echo 100 > /proc/sys/kernel/sched_group_upmigrate + echo 95 > /proc/sys/kernel/sched_group_downmigrate + echo 0 > /proc/sys/kernel/sched_select_prev_cpu_us + echo 400000 > /proc/sys/kernel/sched_freq_inc_notify + echo 400000 > /proc/sys/kernel/sched_freq_dec_notify + echo 5 > /proc/sys/kernel/sched_spill_nr_run + echo 1 > /proc/sys/kernel/sched_restrict_cluster_spill + echo 1 > /proc/sys/kernel/sched_prefer_sync_wakee_to_waker + start iop + + # disable thermal bcl hotplug to switch governor + echo 0 > /sys/module/msm_thermal/core_control/enabled + + # online CPU0 + echo 1 > /sys/devices/system/cpu/cpu0/online + # configure governor settings for little cluster + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/use_migration_notif + echo 19000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/timer_rate + echo 1248000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/io_is_busy + echo "83 1804800:95" > /sys/devices/system/cpu/cpu0/cpufreq/interactive/target_loads + echo 19000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/min_sample_time + echo 79000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/max_freq_hysteresis + echo 518400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/ignore_hispeed_on_notif + # online CPU4 + echo 1 > /sys/devices/system/cpu/cpu4/online + # configure governor settings for big cluster + echo "interactive" > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_sched_load + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/use_migration_notif + echo 19000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/go_hispeed_load + echo 20000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/timer_rate + echo 1574400 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/hispeed_freq + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/io_is_busy + echo "83 1939200:90 2016000:95" > /sys/devices/system/cpu/cpu4/cpufreq/interactive/target_loads + echo 19000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/min_sample_time + echo 79000 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/max_freq_hysteresis + echo 806400 > /sys/devices/system/cpu/cpu4/cpufreq/scaling_min_freq + echo 1 > /sys/devices/system/cpu/cpu4/cpufreq/interactive/ignore_hispeed_on_notif + + # re-enable thermal and BCL hotplug + echo 1 > /sys/module/msm_thermal/core_control/enabled + + # Enable input boost configuration + echo "0:1324800" > /sys/module/cpu_boost/parameters/input_boost_freq + echo 40 > /sys/module/cpu_boost/parameters/input_boost_ms + # Enable bus-dcvs + for cpubw in /sys/class/devfreq/*qcom,cpubw* + do + echo "bw_hwmon" > $cpubw/governor + echo 50 > $cpubw/polling_interval + echo 1525 > $cpubw/min_freq + echo "3143 5859 11863 13763" > $cpubw/bw_hwmon/mbps_zones + echo 4 > $cpubw/bw_hwmon/sample_ms + echo 34 > $cpubw/bw_hwmon/io_percent + echo 20 > $cpubw/bw_hwmon/hist_memory + echo 10 > $cpubw/bw_hwmon/hyst_length + echo 0 > $cpubw/bw_hwmon/low_power_ceil_mbps + echo 34 > $cpubw/bw_hwmon/low_power_io_percent + echo 20 > $cpubw/bw_hwmon/low_power_delay + echo 0 > $cpubw/bw_hwmon/guard_band_mbps + echo 250 > $cpubw/bw_hwmon/up_scale + echo 1600 > $cpubw/bw_hwmon/idle_mbps + done + + for memlat in /sys/class/devfreq/*qcom,memlat-cpu* + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + echo "cpufreq" > /sys/class/devfreq/soc:qcom,mincpubw/governor + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + if [ -f /sys/devices/soc0/platform_version ]; then + platform_version=`cat /sys/devices/soc0/platform_version` + platform_major_version=$((10#${platform_version}>>16)) + fi + + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + + case "$soc_id" in + "292") #msm8998 apq8098_latv + # Start Host based Touch processing + case "$hw_platform" in + "QRD") + case "$platform_subtype_id" in + "0") + start_hbtp + ;; + "16") + if [ $platform_major_version -lt 6 ]; then + start_hbtp + fi + ;; + esac + + ;; + esac + ;; + esac + + echo N > /sys/module/lpm_levels/system/pwr/cpu0/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu1/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu2/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/cpu3/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu4/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu5/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu6/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/cpu7/ret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-dynret/idle_enabled + echo N > /sys/module/lpm_levels/system/pwr/pwr-l2-ret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-dynret/idle_enabled + echo N > /sys/module/lpm_levels/system/perf/perf-l2-ret/idle_enabled + echo N > /sys/module/lpm_levels/parameters/sleep_disabled + + echo 0-3 > /dev/cpuset/background/cpus + echo 0-3 > /dev/cpuset/system-background/cpus + echo 0 > /proc/sys/kernel/sched_boost + + # Set Memory parameters + configure_memory_parameters + ;; +esac + +case "$target" in + "msm8909") + + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + # HMP scheduler settings for 8909 similiar to 8917 + echo 3 > /proc/sys/kernel/sched_window_stats_policy + echo 3 > /proc/sys/kernel/sched_ravg_hist_size + + echo 1 > /proc/sys/kernel/sched_restrict_tasks_spread + + echo 20 > /proc/sys/kernel/sched_small_task + echo 30 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_load + echo 30 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_load + + echo 3 > /sys/devices/system/cpu/cpu0/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu1/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu2/sched_mostly_idle_nr_run + echo 3 > /sys/devices/system/cpu/cpu3/sched_mostly_idle_nr_run + + echo 0 > /sys/devices/system/cpu/cpu0/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu1/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu2/sched_prefer_idle + echo 0 > /sys/devices/system/cpu/cpu3/sched_prefer_idle + + # Apply governor settings for 8909 + + # disable thermal core_control to update scaling_min_freq + echo 0 > /sys/module/msm_thermal/core_control/enabled + echo 1 > /sys/devices/system/cpu/cpu0/online + echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + echo 800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq + # enable thermal core_control now + echo 1 > /sys/module/msm_thermal/core_control/enabled + + echo "29000 1094400:49000" > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay + echo 90 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load + echo 30000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate + echo 998400 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq + echo 0 > /sys/devices/system/cpu/cpufreq/interactive/io_is_busy + echo "1 800000:85 998400:90 1094400:80" > /sys/devices/system/cpu/cpufreq/interactive/target_loads + echo 50000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time + echo 50000 > /sys/devices/system/cpu/cpufreq/interactive/sampling_down_factor + + # Bring up all cores online + echo 1 > /sys/devices/system/cpu/cpu1/online + echo 1 > /sys/devices/system/cpu/cpu2/online + echo 1 > /sys/devices/system/cpu/cpu3/online + echo 0 > /sys/module/lpm_levels/parameters/sleep_disabled + + for devfreq_gov in /sys/class/devfreq/*qcom,cpubw*/governor + do + echo "bw_hwmon" > $devfreq_gov + for cpu_bimc_bw_step in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/bw_step + do + echo 60 > $cpu_bimc_bw_step + done + for cpu_guard_band_mbps in /sys/class/devfreq/*qcom,cpubw*/bw_hwmon/guard_band_mbps + do + echo 30 > $cpu_guard_band_mbps + done + done + + for gpu_bimc_io_percent in /sys/class/devfreq/*qcom,gpubw*/bw_hwmon/io_percent + do + echo 40 > $gpu_bimc_io_percent + done + for gpu_bimc_bw_step in /sys/class/devfreq/*qcom,gpubw*/bw_hwmon/bw_step + do + echo 60 > $gpu_bimc_bw_step + done + for gpu_bimc_guard_band_mbps in /sys/class/devfreq/*qcom,gpubw*/bw_hwmon/guard_band_mbps + do + echo 30 > $gpu_bimc_guard_band_mbps + done + + # Set Memory parameters + configure_memory_parameters + restorecon -R /sys/devices/system/cpu + ;; +esac + +case "$target" in + "msm7627_ffa" | "msm7627_surf" | "msm7627_6x") + echo 25000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + ;; +esac + +case "$target" in + "qsd8250_surf" | "qsd8250_ffa" | "qsd8650a_st1x") + echo 50000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + ;; +esac + +case "$target" in + "qsd8650a_st1x") + mount -t debugfs none /sys/kernel/debug + ;; +esac + +chown -h system /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate +chown -h system /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor +chown -h system /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + +emmc_boot=`getprop vendor.boot.emmc` +case "$emmc_boot" + in "true") + chown -h system /sys/devices/platform/rs300000a7.65536/force_sync + chown -h system /sys/devices/platform/rs300000a7.65536/sync_sts + chown -h system /sys/devices/platform/rs300100a7.65536/force_sync + chown -h system /sys/devices/platform/rs300100a7.65536/sync_sts + ;; +esac + +case "$target" in + "msm8960" | "msm8660" | "msm7630_surf") + echo 10 > /sys/devices/platform/msm_sdcc.3/idle_timeout + ;; + "msm7627a") + echo 10 > /sys/devices/platform/msm_sdcc.1/idle_timeout + ;; +esac + +# Post-setup services +case "$target" in + "msm8660" | "msm8960" | "msm8226" | "msm8610" | "mpq8092" ) + start mpdecision + ;; + "msm8974") + start mpdecision + echo 512 > /sys/block/mmcblk0/bdi/read_ahead_kb + ;; + "msm8909" | "msm8916" | "msm8937" | "msm8952" | "msm8953" | "msm8994" | "msm8992" | "msm8996" | "msm8998" | "sdm660" | "apq8098_latv" | "sdm845" | "sdm710" | "msmnile" | "msmsteppe" | "sm6150" | "kona" | "lito" | "trinket" | "atoll" | "bengal" | "sdmshrike") + setprop vendor.post_boot.parsed 1 + ;; + "apq8084") + rm /data/system/perfd/default_values + start mpdecision + echo 512 > /sys/block/mmcblk0/bdi/read_ahead_kb + echo 512 > /sys/block/sda/bdi/read_ahead_kb + echo 512 > /sys/block/sdb/bdi/read_ahead_kb + echo 512 > /sys/block/sdc/bdi/read_ahead_kb + echo 512 > /sys/block/sdd/bdi/read_ahead_kb + echo 512 > /sys/block/sde/bdi/read_ahead_kb + echo 512 > /sys/block/sdf/bdi/read_ahead_kb + echo 512 > /sys/block/sdg/bdi/read_ahead_kb + echo 512 > /sys/block/sdh/bdi/read_ahead_kb + ;; + "msm7627a") + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + case "$soc_id" in + "127" | "128" | "129") + start mpdecision + ;; + esac + ;; +esac + +# Enable Power modes and set the CPU Freq Sampling rates +case "$target" in + "msm7627a") + start qosmgrd + echo 1 > /sys/module/pm2/modes/cpu0/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/pm2/modes/cpu1/standalone_power_collapse/idle_enabled + echo 1 > /sys/module/pm2/modes/cpu0/standalone_power_collapse/suspend_enabled + echo 1 > /sys/module/pm2/modes/cpu1/standalone_power_collapse/suspend_enabled + #SuspendPC: + echo 1 > /sys/module/pm2/modes/cpu0/power_collapse/suspend_enabled + #IdlePC: + echo 1 > /sys/module/pm2/modes/cpu0/power_collapse/idle_enabled + echo 25000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + ;; +esac + +# Change adj level and min_free_kbytes setting for lowmemory killer to kick in +case "$target" in + "msm7627a") + echo 0,1,2,4,9,12 > /sys/module/lowmemorykiller/parameters/adj + echo 5120 > /proc/sys/vm/min_free_kbytes + ;; +esac + +# Install AdrenoTest.apk if not already installed +if [ -f /data/prebuilt/AdrenoTest.apk ]; then + if [ ! -d /data/data/com.qualcomm.adrenotest ]; then + pm install /data/prebuilt/AdrenoTest.apk + fi +fi + +# Install SWE_Browser.apk if not already installed +if [ -f /data/prebuilt/SWE_AndroidBrowser.apk ]; then + if [ ! -d /data/data/com.android.swe.browser ]; then + pm install /data/prebuilt/SWE_AndroidBrowser.apk + fi +fi + +# Change adj level and min_free_kbytes setting for lowmemory killer to kick in +case "$target" in + "msm8660") + start qosmgrd + echo 0,1,2,4,9,12 > /sys/module/lowmemorykiller/parameters/adj + echo 5120 > /proc/sys/vm/min_free_kbytes + ;; +esac +# Let kernel know our image version/variant/crm_version +if [ -f /sys/devices/soc0/select_image ]; then + image_version="10:" + image_version+=`getprop ro.build.id` + image_version+=":" + image_version+=`getprop ro.build.version.incremental` + image_variant=`getprop ro.product.name` + image_variant+="-" + image_variant+=`getprop ro.build.type` + oem_version=`getprop ro.build.version.codename` + echo 10 > /sys/devices/soc0/select_image + echo $image_version > /sys/devices/soc0/image_version + echo $image_variant > /sys/devices/soc0/image_variant + echo $oem_version > /sys/devices/soc0/image_crm_version +fi + +# Change console log level as per console config property +console_config=`getprop persist.vendor.console.silent.config` +case "$console_config" in + "1") + echo "Enable console config to $console_config" + echo 0 > /proc/sys/kernel/printk + ;; + *) + echo "Enable console config to $console_config" + ;; +esac + +# Parse misc partition path and set property +misc_link=$(ls -l /dev/block/bootdevice/by-name/misc) +real_path=${misc_link##*>} +setprop persist.vendor.mmi.misc_dev_path $real_path diff --git a/rootdir/bin/init.qcom.sh b/rootdir/bin/init.qcom.sh new file mode 100755 index 0000000..9fe153f --- /dev/null +++ b/rootdir/bin/init.qcom.sh @@ -0,0 +1,465 @@ +#! /vendor/bin/sh + +# Copyright (c) 2009-2016, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +target=`getprop ro.board.platform` +low_ram=`getprop ro.config.low_ram` +if [ -f /sys/devices/soc0/soc_id ]; then + platformid=`cat /sys/devices/soc0/soc_id` +else + platformid=`cat /sys/devices/system/soc/soc0/id` +fi + +start_battery_monitor() +{ + if ls /sys/bus/spmi/devices/qpnp-bms-*/fcc_data ; then + chown -h root.system /sys/module/pm8921_bms/parameters/* + chown -h root.system /sys/module/qpnp_bms/parameters/* + chown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_data + chown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_temp + chown -h root.system /sys/bus/spmi/devices/qpnp-bms-*/fcc_chgcyl + chmod 0660 /sys/module/qpnp_bms/parameters/* + chmod 0660 /sys/module/pm8921_bms/parameters/* + mkdir -p /data/bms + chown -h root.system /data/bms + chmod 0770 /data/bms + start battery_monitor + fi +} + +start_charger_monitor() +{ + if ls /sys/module/qpnp_charger/parameters/charger_monitor; then + chown -h root.system /sys/module/qpnp_charger/parameters/* + chown -h root.system /sys/class/power_supply/battery/input_current_max + chown -h root.system /sys/class/power_supply/battery/input_current_trim + chown -h root.system /sys/class/power_supply/battery/input_current_settled + chown -h root.system /sys/class/power_supply/battery/voltage_min + chmod 0664 /sys/class/power_supply/battery/input_current_max + chmod 0664 /sys/class/power_supply/battery/input_current_trim + chmod 0664 /sys/class/power_supply/battery/input_current_settled + chmod 0664 /sys/class/power_supply/battery/voltage_min + chmod 0664 /sys/module/qpnp_charger/parameters/charger_monitor + start charger_monitor + fi +} + +start_vm_bms() +{ + if [ -e /dev/vm_bms ]; then + chown -h root.system /sys/class/power_supply/bms/current_now + chown -h root.system /sys/class/power_supply/bms/voltage_ocv + chmod 0664 /sys/class/power_supply/bms/current_now + chmod 0664 /sys/class/power_supply/bms/voltage_ocv + start vm_bms + fi +} + +start_msm_irqbalance_8939() +{ + if [ -f /vendor/bin/msm_irqbalance ]; then + case "$platformid" in + "239" | "293" | "294" | "295" | "304" | "338" | "313" | "353" | "354") + start vendor.msm_irqbalance;; + "349" | "350" ) + start vendor.msm_irqbal_lb;; + esac + fi +} + +start_msm_irqbalance_msmnile() +{ + if [ -f /vendor/bin/msm_irqbalance ]; then + start vendor.msm_irqbalance + fi +} + +start_msm_irqbalance_kona() +{ + if [ -f /vendor/bin/msm_irqbalance ]; then + start vendor.msm_irqbalance + fi +} + +start_msm_irqbalance_lito() +{ + if [ -f /vendor/bin/msm_irqbalance ]; then + start vendor.msm_irqbalance + fi +} + +start_msm_irqbalance_atoll() +{ + if [ -f /vendor/bin/msm_irqbalance ]; then + start vendor.msm_irqbalance + fi +} + +start_msm_irqbalance660() +{ + if [ -f /vendor/bin/msm_irqbalance ]; then + case "$platformid" in + "317" | "321" | "324" | "325" | "326" | "336" | "345" | "346" | "360" | "393") + start vendor.msm_irqbalance;; + "318" | "327" | "385") + start vendor.msm_irqbl_sdm630;; + esac + fi +} + +start_msm_irqbalance() +{ + if [ -f /vendor/bin/msm_irqbalance ]; then + start vendor.msm_irqbalance + fi +} + +baseband=`getprop ro.baseband` +echo 1 > /proc/sys/net/ipv6/conf/default/accept_ra_defrtr + +case "$baseband" in + "svlte2a") + start bridgemgrd + ;; +esac + +case "$target" in + "msm7630_surf" | "msm7630_1x" | "msm7630_fusion") + if [ -f /sys/devices/soc0/hw_platform ]; then + value=`cat /sys/devices/soc0/hw_platform` + else + value=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + case "$value" in + "Fluid") + start profiler_daemon;; + esac + ;; + "msm8660" ) + if [ -f /sys/devices/soc0/hw_platform ]; then + platformvalue=`cat /sys/devices/soc0/hw_platform` + else + platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + case "$platformvalue" in + "Fluid") + start profiler_daemon;; + esac + ;; + "msm8960") + case "$baseband" in + "msm") + start_battery_monitor;; + esac + + if [ -f /sys/devices/soc0/hw_platform ]; then + platformvalue=`cat /sys/devices/soc0/hw_platform` + else + platformvalue=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + case "$platformvalue" in + "Fluid") + start profiler_daemon;; + "Liquid") + start profiler_daemon;; + esac + ;; + "msm8974") + platformvalue=`cat /sys/devices/soc0/hw_platform` + case "$platformvalue" in + "Fluid") + start profiler_daemon;; + "Liquid") + start profiler_daemon;; + esac + case "$baseband" in + "msm") + start_battery_monitor + ;; + esac + start_charger_monitor + ;; + "sdm660") + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + + case "$soc_id" in + "317" | "324" | "325" | "326" | "318" | "327" ) + case "$hw_platform" in + "Surf") + setprop qemu.hw.mainkeys 0 + ;; + "MTP") + setprop qemu.hw.mainkeys 0 + ;; + "RCM") + setprop qemu.hw.mainkeys 0 + ;; + "QRD") + setprop qemu.hw.mainkeys 0 + ;; + esac + ;; + esac + start_msm_irqbalance660 + ;; + "apq8084") + platformvalue=`cat /sys/devices/soc0/hw_platform` + case "$platformvalue" in + "Fluid") + start profiler_daemon;; + "Liquid") + start profiler_daemon;; + esac + ;; + "msm8226") + start_charger_monitor + ;; + "msm8610") + start_charger_monitor + ;; + "msm8916") + start_vm_bms + start_msm_irqbalance_8939 + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/platform_subtype_id ]; then + platform_subtype_id=`cat /sys/devices/soc0/platform_subtype_id` + fi + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + fi + case "$soc_id" in + "239") + case "$hw_platform" in + "Surf") + case "$platform_subtype_id" in + "1") + setprop qemu.hw.mainkeys 0 + ;; + esac + ;; + "MTP") + case "$platform_subtype_id" in + "3") + setprop qemu.hw.mainkeys 0 + ;; + esac + ;; + esac + ;; + esac + ;; + "msm8994" | "msm8992" | "msm8998" | "apq8098_latv" | "sdm845" | "sdm710" | "qcs605" | "sm6150" | "trinket" | "bengal") + start_msm_irqbalance + ;; + "msm8996") + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + fi + case "$hw_platform" in + "MTP" | "CDP") + #Loop through the sysfs nodes and determine the correct sysfs to change the permission and ownership. + for count in 0 1 2 3 4 5 6 7 8 9 10 + do + dir="/sys/devices/soc/75ba000.i2c/i2c-12/12-0020/input/input"$count + if [ -d "$dir" ]; then + chmod 0660 $dir/secure_touch_enable + chmod 0440 $dir/secure_touch + chown system.drmrpc $dir/secure_touch_enable + chown system.drmrpc $dir/secure_touch + break + fi + done + ;; + esac + ;; + "msm8909") + start_vm_bms + ;; + "msmnile") + start_msm_irqbalance_msmnile + ;; + "kona") + start_msm_irqbalance_kona + ;; + "lito") + start_msm_irqbalance_lito + ;; + "atoll") + start_msm_irqbalance_atoll + ;; + "msm8937") + start_msm_irqbalance_8939 + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + if [ "$low_ram" != "true" ]; then + case "$soc_id" in + "294" | "295" | "303" | "307" | "308" | "309" | "313" | "320" | "353" | "354" | "363" | "364") + case "$hw_platform" in + "Surf") + setprop qemu.hw.mainkeys 0 + ;; + "MTP") + setprop qemu.hw.mainkeys 0 + ;; + "RCM") + setprop qemu.hw.mainkeys 0 + ;; + "QRD") + setprop qemu.hw.mainkeys 0 + ;; + esac + ;; + esac + fi + ;; + "msm8953") + start_msm_irqbalance_8939 + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + case "$soc_id" in + "293" | "304" | "338" | "351" | "349" | "350" ) + case "$hw_platform" in + "Surf") + setprop qemu.hw.mainkeys 0 + ;; + "MTP") + setprop qemu.hw.mainkeys 0 + ;; + "RCM") + setprop qemu.hw.mainkeys 0 + ;; + "QRD") + setprop qemu.hw.mainkeys 0 + ;; + esac + ;; + esac + ;; + "sdm710") + if [ -f /sys/devices/soc0/soc_id ]; then + soc_id=`cat /sys/devices/soc0/soc_id` + else + soc_id=`cat /sys/devices/system/soc/soc0/id` + fi + + if [ -f /sys/devices/soc0/hw_platform ]; then + hw_platform=`cat /sys/devices/soc0/hw_platform` + else + hw_platform=`cat /sys/devices/system/soc/soc0/hw_platform` + fi + case "$soc_id" in + "336" | "337" | "347" | "360" | "393" ) + case "$hw_platform" in + "Surf") + setprop qemu.hw.mainkeys 0 + ;; + "MTP") + setprop qemu.hw.mainkeys 0 + ;; + "RCM") + setprop qemu.hw.mainkeys 0 + ;; + "QRD") + setprop qemu.hw.mainkeys 0 + ;; + esac + ;; + esac + ;; +esac + +# +# Make modem config folder and copy firmware config to that folder for RIL +# +if [ -f /data/vendor/modem_config/ver_info.txt ]; then + prev_version_info=`cat /data/vendor/modem_config/ver_info.txt` +else + prev_version_info="" +fi + +cur_version_info=`cat /vendor/firmware_mnt/verinfo/ver_info.txt` +if [ ! -f /vendor/firmware_mnt/verinfo/ver_info.txt -o "$prev_version_info" != "$cur_version_info" ]; then + # add W for group recursively before delete + chmod g+w -R /data/vendor/modem_config/* + rm -rf /data/vendor/modem_config/* + # preserve the read only mode for all subdir and files + cp --preserve=m -dr /vendor/firmware_mnt/image/modem_pr/mcfg/configs/* /data/vendor/modem_config + cp --preserve=m -d /vendor/firmware_mnt/verinfo/ver_info.txt /data/vendor/modem_config/ + cp --preserve=m -d /vendor/firmware_mnt/image/modem_pr/mbn_ota.txt /data/vendor/modem_config/ + # the group must be root, otherwise this script could not add "W" for group recursively + chown -hR radio.root /data/vendor/modem_config/* +fi +chmod g-w /data/vendor/modem_config +setprop ro.vendor.ril.mbn_copy_completed 1 + +#check build variant for printk logging +#current default minimum boot-time-default +buildvariant=`getprop ro.build.type` +case "$buildvariant" in + "userdebug" | "eng") + #set default loglevel to KERN_INFO + echo "7 6 1 7" > /proc/sys/kernel/printk + ;; + *) + #set default loglevel to KERN_WARNING + echo "4 4 1 4" > /proc/sys/kernel/printk + ;; +esac diff --git a/rootdir/bin/init.qti.dcvs.sh b/rootdir/bin/init.qti.dcvs.sh new file mode 100755 index 0000000..f2ff0d1 --- /dev/null +++ b/rootdir/bin/init.qti.dcvs.sh @@ -0,0 +1,44 @@ +#! /vendor/bin/sh +# +# Copyright (c) 2020, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of The Linux Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + for device in /sys/devices/platform/soc + do + for memlat in $device/*cpu*-lat/devfreq/*cpu*-lat + do + echo "mem_latency" > $memlat/governor + echo 10 > $memlat/polling_interval + echo 400 > $memlat/mem_latency/ratio_ceil + done + + for latfloor in $device/*cpu*-ddr-latfloor*/devfreq/*cpu-ddr-latfloor* + do + echo "compute" > $latfloor/governor + echo 10 > $latfloor/polling_interval + done + done; diff --git a/rootdir/bin/init.qti.early_init.sh b/rootdir/bin/init.qti.early_init.sh new file mode 100755 index 0000000..62c9186 --- /dev/null +++ b/rootdir/bin/init.qti.early_init.sh @@ -0,0 +1,56 @@ +#! /vendor/bin/sh +# +# Copyright (c) 2021 The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of The Linux Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +soc_id=`cat /sys/devices/soc0/soc_id` 2> /dev/null + +# Store soc_id in ro.vendor.qti.soc_id +setprop ro.vendor.qti.soc_id $soc_id + +if [ "$soc_id" -eq 444 ]; then + setprop ro.vendor.qti.soc_model SM6115 +elif [ "$soc_id" -eq 417 ]; then + setprop ro.vendor.qti.soc_model SM4250 +elif [ "$soc_id" -eq 441 ]; then + setprop ro.vendor.qti.soc_model SM4125 +elif [ "$soc_id" -eq 518 ]; then + setprop ro.vendor.qti.soc_model SM6225 +elif [ "$soc_id" -eq 469 ]; then + setprop ro.vendor.qti.soc_model QCM4290 +elif [ "$soc_id" -eq 470 ]; then + setprop ro.vendor.qti.soc_model QCS4290 +elif [ "$soc_id" -eq 473 ]; then + setprop ro.vendor.qti.soc_model QCM2290 +elif [ "$soc_id" -eq 474 ]; then + setprop ro.vendor.qti.soc_model QCS2290 +elif [ "$soc_id" -eq 497 ]; then + setprop ro.vendor.qti.soc_model QCM6490 +elif [ "$soc_id" -eq 498 ]; then + setprop ro.vendor.qti.soc_model QCS6490 +fi diff --git a/rootdir/etc/init.mmi.charge_only.rc b/rootdir/etc/init.mmi.charge_only.rc new file mode 100644 index 0000000..3afbae1 --- /dev/null +++ b/rootdir/etc/init.mmi.charge_only.rc @@ -0,0 +1,27 @@ +# Wait for the USB init shell script to finish, to prevent enumeration issues +on property:init.svc.vendor.mmi-usb-sh=stopped && property:ro.boot.mode=charger + setprop sys.usb.configfs 1 + setprop sys.usb.config charging + +on moto-charger + stop vendor.sensors + chown radio wakelock /sys/power/wake_lock + chmod 0660 /sys/power/wake_lock + chown radio wakelock /sys/power/wake_unlock + chmod 0660 /sys/power/wake_unlock + trigger firmware_mounts_complete + start vendor.charge_only_mode + start vendor.batt_health + start vendor.thermal-com + start system_suspend + + # Enable only CPU core 0 to keep current drain to a minimum + write /sys/devices/system/cpu/cpu0/online 1 + write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "interactive" + write /sys/devices/system/cpu/cpu1/online 0 + write /sys/devices/system/cpu/cpu2/online 0 + write /sys/devices/system/cpu/cpu3/online 0 + write /sys/devices/system/cpu/cpu4/online 0 + write /sys/devices/system/cpu/cpu5/online 0 + write /sys/devices/system/cpu/cpu6/online 0 + write /sys/devices/system/cpu/cpu7/online 0 diff --git a/rootdir/etc/init.mmi.chipset.rc b/rootdir/etc/init.mmi.chipset.rc new file mode 100644 index 0000000..973563b --- /dev/null +++ b/rootdir/etc/init.mmi.chipset.rc @@ -0,0 +1,13 @@ +# Charge only mode configuration +import /vendor/etc/init/hw/init.mmi.charge_only.rc + +on early-init + exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules exfat + +on property:ro.vendor.build.motfactory=1 + write /sys/class/power_supply/battery/device/factory_image_mode 1 + wait /sys/class/power_supply/battery/device/force_charger_suspend + chown system system /sys/class/power_supply/battery/device/force_charger_suspend + +on property:ro.build.type=userdebug + setprop persist.vendor.qg.log_level 1 diff --git a/rootdir/etc/init.mmi.debug.rc b/rootdir/etc/init.mmi.debug.rc new file mode 100644 index 0000000..33a7074 --- /dev/null +++ b/rootdir/etc/init.mmi.debug.rc @@ -0,0 +1,5 @@ +on boot && property:ro.boot.adb_early=1 + start vendor.mmi-usb-sh + +on post-fs && property:ro.boot.force_aplogd_enable=1 + setprop persist.vendor.log.aplogd.enable 1 diff --git a/rootdir/etc/init.mmi.overlay.rc b/rootdir/etc/init.mmi.overlay.rc new file mode 100644 index 0000000..8ca11fb --- /dev/null +++ b/rootdir/etc/init.mmi.overlay.rc @@ -0,0 +1,125 @@ + +on early-init && property:ro.bootmode=mot-factory + insmod /vendor/lib/modules/moto_f_usbnet.ko + +on mmi-priority + # Only high priority MMI DLKMs loaded here + # For instance, sensor_class referenced from several DLKMs + # and needs to load first. Touchscreen might need extra time + # to perform firmware update if necessary + setprop vendor.mmi_init.stage priority + exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules tzlog_dump watchdog_cpu_ctx wl2864c.ko mmi_sys_temp + +on post-fs + # "Tap to wake" gesture + chown root input /sys/class/sensors/dt-gesture/enable + chmod 0660 /sys/class/sensors/dt-gesture/enable + chown root input /sys/class/sensors/dt-gesture/poll_delay + chmod 0660 /sys/class/sensors/dt-gesture/poll_delay + +on fs + # Majority of MMI DLKMs should be in this group + setprop vendor.mmi_init.stage common + insmod /vendor/lib/modules/sensors_class.ko + #zram wb + mount_all /vendor/etc/fstab.qcom.zram --early + exec_background u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules adapter_class mmi_relay touchscreen_mmi focaltech_v2_mmi regulator_vibrator_mmi leds-indicator-pwm audio_snd_soc_aw882xx aw9610x + +on charger + insmod /vendor/lib/modules/cw2217b_fg_mmi.ko + insmod /vendor/lib/modules/sm5602_fg_mmi.ko + insmod /vendor/lib/modules/mmi_charger.ko + insmod /vendor/lib/modules/adapter_class.ko + insmod /vendor/lib/modules/mmi_discrete_charger_class.ko + insmod /vendor/lib/modules/mmi_discrete_charger.ko + insmod /vendor/lib/modules/sgm4154x_charger.ko + insmod /vendor/lib/modules/bq2589x_charger.ko + insmod /vendor/lib/modules/tcpc_class.ko + insmod /vendor/lib/modules/tcpc_sgm7220.ko + + +on post-fs-data + # Load DLKM that can afford being loaded later + setprop vendor.mmi_init.stage late + start vendor.mmi_modules + #wait_for_prop init.svc.vendor.mmi_modules stopped + setprop vendor.mmi_init.stage complete + +on early-boot + # Goodix fingerprint + chown system system /dev/goodix_fp + chmod 0664 /dev/goodix_fp + chmod 0777 /proc/android_touch/debug + mkdir /data/vendor/gf_data 0770 system system + mkdir /mnt/vendor/persist/goodix 0770 system system + +on boot + # Change ownership for capsensor + chown root input /sys/class/sensors/Moto\ CapSense\ Ch0/enable + chown root input /sys/class/sensors/Moto\ CapSense\ Ch0/poll_delay + chown root input /sys/class/sensors/Moto\ CapSense\ Ch1/enable + chown root input /sys/class/sensors/Moto\ CapSense\ Ch1/poll_delay + chown root input /sys/class/sensors/Moto\ CapSense\ Ch2/enable + chown root input /sys/class/sensors/Moto\ CapSense\ Ch2/poll_delay + chown root input /sys/class/sensors/Moto\ CapSense\ Ch3/enable + chown root input /sys/class/sensors/Moto\ CapSense\ Ch3/poll_delay + chown root input /sys/class/sensors/Moto\ CapSense\ Ch4/enable + chown root input /sys/class/sensors/Moto\ CapSense\ Ch4/poll_delay + chown system system /sys/class/capsense/reset + chown system system /sys/class/capsense/int_state + + # change permission for adaptive charging + chown system system /sys/module/qpnp_adaptive_charge/parameters/upper_limit + chown system system /sys/module/qpnp_adaptive_charge/parameters/lower_limit + # change ownership of display early suspend node + chown root system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_early_power + chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_early_power + +#on post-fs-data +# mkdir /data/vendor/focaltech 0770 system system +#service vendor.mmi_modules /vendor/bin/init.mmi.modules.sh +# user root +# oneshot +# disabled + +service capsense_reset /system/vendor/bin/capsense_reset + class core + user system + group system input + disabled + +on property:sys.boot_completed=1 + start capsense_reset + +service vendor.motpsd /vendor/bin/motpsd + class late_start + user root + +service vendor.vl53l1_daemon /vendor/bin/vl53l1_daemon + class late_start + user root + group root + socket vl53l1_daemon stream 660 root system + +service vendor.mmi-laser-sh /vendor/bin/init.mmi.laser.sh + class core + user root + oneshot + +# Turn on led to indicate device on in factory mode +on property:ro.bootmode=mot-factory + write /sys/class/leds/charging/brightness 255 + +# on property:ro.build.type=userdebug +# start vendor.touchRec + +on property:sys.boot_completed=1 + write /sys/devices/platform/soc/soc:mmi,charger/state_sync 1 + +on post-fs && property:ro.vendor.build.motfactory=1 + write /sys/devices/platform/soc/soc:mmi,charger/state_sync 1 + wait /sys/class/power_supply/battery/device/factory_image_mode + write /sys/class/power_supply/battery/device/factory_image_mode 1 + +on property:sys.boot_completed=1 && property:ro.build.type=userdebug + stop llkd-${ro.debuggable:-0} diff --git a/rootdir/etc/init.mmi.rc b/rootdir/etc/init.mmi.rc new file mode 100644 index 0000000..7eaa0f0 --- /dev/null +++ b/rootdir/etc/init.mmi.rc @@ -0,0 +1,653 @@ +# Chipset-specific file +import /vendor/etc/init/hw/init.mmi.chipset.rc + +# Target-specific file +import /vendor/etc/init/hw/init.mmi.overlay.rc + +# Moto USB configuration +# import /vendor/etc/init/hw/init.mmi.usb.rc +# Moto debugging +import /vendor/etc/init/hw/init.mmi.debug.rc + +#import /vendor/etc/init/hw/init.oem.rc +#import /vendor/etc/init/hw/init.mmi.common.rc +#import /vendor/etc/init/hw/init.mmi.nonab.rc + +#Moto wlan configuration +#import /vendor/etc/init/hw/init.mmi.wlan.rc + +# Moto verified boot extension +#import /vendor/etc/init/hw/init.mmi.hab.rc + +# Test commands +#import /vendor/etc/init/hw/init.mmi.tcmd.rc + +# Carrier specific script +import /vendor/etc/init/carrier/init.${ro.boot.carrier}.rc +import /vendor/etc/init/carrier/init.default.rc + +on early-boot + write /sys/module/subsystem_restart/parameters/disable_restart_work 0x0 + +on init + chown system log /sys/fs/pstore/console-ramoops-0 + chmod 0440 /sys/fs/pstore/console-ramoops-0 + chown system log /sys/fs/pstore/annotate-ramoops-0 + chmod 0640 /sys/fs/pstore/annotate-ramoops-0 + chown system log /sys/fs/pstore/dmesg-ramoops-0 + chmod 0640 /sys/fs/pstore/dmesg-ramoops-0 + chown system log /proc/driver/mmi_annotate + chmod 0640 /proc/driver/mmi_annotate + +on early-init && property:ro.bootmode=mot-factory + setprop ro.vendor.mot.factory true + +on early-init && property:ro.vendor.build.motfactory=1 + setprop ro.vendor.mot.factory true + +on early-init + # Need to wait for platform path for UTAGs driver to succeed + wait /dev/block/platform/soc/${ro.boot.bootdevice}/by-name/hw + + # initialize ro.vendor.mot.factory with default value when it is not set + setprop ro.vendor.mot.factory false + + # If utags driver is DLKM, script will load it, + # otherwise it has to be already loaded + exec_start vendor.oem-hw-sh + + # Map oem properties, this must follow + # execution of vendor.oem-hw-sh to set + # required properties. + setprop ro.carrier ${ro.boot.carrier} + setprop ro.sf.lcd_density ${ro.boot.lcd_density} + setprop ro.vendor.fsg-id ${ro.boot.fsg-id} + setprop ro.vendor.hw.device ${ro.boot.device} + setprop ro.vendor.hw.hwrev ${ro.boot.hwrev} + setprop ro.vendor.hw.modelno ${ro.boot.modelno} + setprop ro.vendor.hw.revision ${ro.boot.revision} + setprop ro.vendor.hw.nav_keys ${ro.boot.nav_keys} + setprop ro.product.vendor.device ${ro.vendor.product.device} + setprop ro.product.vendor.name ${ro.vendor.product.name} + setprop ro.product.vendor.model ${ro.vendor.product.model} + setprop ro.vendor.boot.cid ${ro.boot.cid} + setprop ro.vendor.boot.powerup_reason ${ro.boot.powerup_reason} + setprop ro.vendor.boot.bl_state ${ro.boot.bl_state} + setprop ro.vendor.boot.serialno ${ro.boot.serialno} + setprop ro.vendor.zygote ${ro.zygote} + + # Make sure ro.boot.product.hardware.sku is set before hwservicemanager startup. + setprop ro.boot.product.hardware.sku ${ro.vendor.product.hardware.sku.variant} + + # Trigger priority stage of MMI init + trigger mmi-priority + + # Log kernel wake-up source + write /sys/module/msm_show_resume_irq/parameters/debug_mask 1 + +on fs + insmod /vendor/lib/modules/cci_intf.ko + mkdir /mnt/vendor/persist/fps 0770 system system + exec_start vendor.ident-fps-sh + +on fs && property:ro.vendor.hw.modem_version=* + # Super modem detection + exec_start vendor.oem-super-image-detector-sh + +on property:ro.vendor.hw.super_image_failure=yes + setprop sys.powerctl reboot,recovery + +on post-fs && property:ro.vendor.hw.modem_super_image=yes + umount /vendor/firmware_mnt + mount ext4 /dev/block/bootdevice/by-name/modem${ro.boot.slot_suffix} /vendor/super_modem ro nosuid nodev context=u:object_r:firmware_file:s0 + mount ext4 loop@/vendor/super_modem/${ro.vendor.hw.modem_mount_file} /vendor/firmware_mnt ro nosuid nodev context=u:object_r:firmware_file:s0 + +on post-fs && property:ro.vendor.hw.fsg_super_image=yes + umount /vendor/fsg + mount ext4 /dev/block/bootdevice/by-name/fsg${ro.boot.slot_suffix} /vendor/super_fsg ro nosuid nodev context=u:object_r:fsg_file:s0 + mount ext4 loop@/vendor/super_fsg/${ro.vendor.hw.fsg_mount_file} /vendor/fsg ro nosuid nodev context=u:object_r:fsg_file:s0 + +on post-fs + mkdir /mnt/vendor/persist/camera 0755 vendor_tcmd vendor_tcmd + mkdir /mnt/vendor/persist/camera/dualcal 0775 camera vendor_tcmd + mkdir /mnt/vendor/persist/camera/focus 0775 camera vendor_tcmd + mkdir /mnt/vendor/persist/camera/ledcal 0775 camera vendor_tcmd + mkdir /mnt/vendor/persist/camera/mot_ledcal 0775 camera camera + mkdir /mnt/vendor/persist/camera/mot_gyrocal 0775 camera camera + mkdir /mnt/vendor/persist/batt_health 0775 vendor_pwric vendor_pwric + mkdir /mnt/vendor/persist/mdm 0770 radio radio + mkdir /mnt/vendor/persist/factory 0755 vendor_tcmd vendor_tcmd + mkdir /mnt/vendor/persist/factory/audio 0755 vendor_tcmd system + mkdir /mnt/vendor/persist/factory/wlan 0755 vendor_tcmd vendor_tcmd + mkdir /mnt/vendor/persist/factory/regulatory 0755 vendor_tcmd system + mkdir /mnt/vendor/persist/public 0755 vendor_tcmd vendor_tcmd + mkdir /mnt/vendor/persist/public/att_dm 0775 radio vendor_tcmd + mkdir /mnt/vendor/persist/public/hiddenmenu 0775 radio vendor_tcmd + mkdir /mnt/vendor/persist/public/hiddenmenu/data 0775 system vendor_tcmd + mkdir /persist/public/locale 0700 system system + mkdir /persist/public/omadm 0700 radio radio + mkdir /persist/public/svcs 0770 system system + mkdir /mnt/vendor/persist/wifi 0755 vendor_tcmd vendor_tcmd + mkdir /mnt/vendor/persist/bt 0755 vendor_tcmd bluetooth + mkdir /persist/public/usc_dm 0775 radio radio + mkdir /mnt/vendor/persist/rfs/msm/mpss/mot_rfs 0771 vendor_rfs system + mkdir /mnt/vendor/persist/rfs/mdm/mpss/mot_rfs 0771 vendor_rfs system + + # This dir is used to store any OMA(both DM and CP) files in persist partition + # Any app with radio UID or vendor_tcmd GID can read/write/execute files in this dir. + mkdir /mnt/vendor/persist/public/oma 0775 radio vendor_tcmd + + chown vendor_tcmd vendor_tcmd /mnt/vendor/persist/factory/fti + chmod 0664 /mnt/vendor/persist/factory/fti + chown vendor_tcmd vendor_tcmd /mnt/vendor/persist/factory/byte + chmod 0660 /mnt/vendor/persist/factory/byte + chmod 0660 /mnt/vendor/persist/wifi/wlan_mac.bin + chown vendor_tcmd vendor_tcmd /mnt/vendor/persist/bt/bt_bdaddr + chmod 0664 /mnt/vendor/persist/bt/bt_bdaddr + + # Set life_calls and life_timer file permissions + chown radio vendor_tcmd /mnt/vendor/persist/public/hiddenmenu/life_calls + chmod 0775 /mnt/vendor/persist/public/hiddenmenu/life_calls + chown radio vendor_tcmd /mnt/vendor/persist/public/hiddenmenu/life_timer + chmod 0775 /mnt/vendor/persist/public/hiddenmenu/life_timer + + chmod 0711 /mnt/vendor/persist/rfs + chmod 0711 /mnt/vendor/persist/rfs/msm + chmod 0711 /mnt/vendor/persist/rfs/msm/mpss + chmod 0771 /mnt/vendor/persist/rfs/msm/mpss/mot_rfs + chmod 0711 /mnt/vendor/persist/rfs/mdm + chmod 0711 /mnt/vendor/persist/rfs/mdm/mpss + chmod 0771 /mnt/vendor/persist/rfs/mdm/mpss/mot_rfs + + # Set dm-verity property for system partition + verity_update_state + + # Set capsensor calibration sysfs for MDMCTBK + chown radio radio /sys/class/capsense/calibrate + chmod 0660 /sys/class/capsense/calibrate + +on post-fs-data + setprop ro.vendor.build.fingerprint ${ro.product.vendor.brand}/${ro.product.vendor.name}/${ro.product.vendor.device}:${ro.vendor.build.version.release}/${ro.vendor.build.id}/${ro.vendor.build.version.incremental}:${ro.vendor.build.type}/${ro.vendor.build.tags} + + # Setup folders for security + mkdir /mnt/vendor/persist/security 02770 drmrpc drmrpc + mkdir /data/vendor/dbvc 0750 vendor_tcmd shell + chown drmrpc vendor_tcmd /mnt/vendor/persist/security + + # Setup folder for Pre-Activation Kill Switch app (PAKS) + mkdir /mnt/vendor/persist/paks 02770 vendor_tcmd vendor_tcmd + + # Create directory used by power_supply_logger + mkdir /data/vendor/power_supply_logger 0750 vendor_pwric log + # Create directory power_supply_logger used by memtest and batt_health + mkdir /data/vendor_de/power_supply_logger 0770 root log + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/cycle_count + chmod 0664 /sys/class/power_supply/battery/cycle_count + chmod 0664 /sys/class/power_supply/battery/charge_control_limit + + # Permissions for Factory Test of Charging Paths + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_auto_enable + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_ibatt + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_itrick + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_iusb + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_idc + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_usb_suspend + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_fail_clear + chown vendor_pwric vendor_pwric /sys/class/power_supply/battery/device/force_chg_usb_otg_ctl + + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_auto_enable + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_ibatt + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_itrick + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_iusb + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_idc + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_usb_suspend + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_fail_clear + chown vendor_pwric vendor_pwric /sys/class/power_supply/mmi_battery/device/force_chg_usb_otg_ctl + + chown vendor_pwric vendor_pwric /sys/class/power_supply/wireless/device/chip_id + chown vendor_pwric vendor_pwric /sys/class/power_supply/wireless/current_now + chown vendor_pwric vendor_pwric /sys/class/power_supply/wireless/voltage_now + chown vendor_pwric vendor_pwric /sys/class/power_supply/wireless/voltage_max + chmod 0664 /sys/class/power_supply/wireless/voltage_max + chown vendor_pwric vendor_pwric /sys/kernel/debug/pmic-votable/CHG_DISABLE/force_val + chmod 0664 /sys/kernel/debug/pmic-votable/CHG_DISABLE/force_val + chown vendor_pwric vendor_pwric /sys/kernel/debug/pmic-votable/CHG_DISABLE/force_active + chmod 0664 /sys/kernel/debug/pmic-votable/CHG_DISABLE/force_active + chown vendor_pwric vendor_pwric /sys/kernel/debug/regulator/smb5-vconn/enable + chmod 0664 /sys/kernel/debug/regulator/smb5-vconn/enable + + chown root vendor_mod /sys/module/qpnp_smbcharger_mmi/parameters/eb_rechrg_start_soc + chown root vendor_mod /sys/module/qpnp_smbcharger_mmi/parameters/eb_rechrg_stop_soc + chown root vendor_mod /sys/module/qpnp_smbcharger_mmi/parameters/eb_attach_start_soc + chown root vendor_mod /sys/module/qpnp_smbcharger_mmi/parameters/eb_attach_stop_soc + chown root vendor_mod /sys/module/qpnp_smbcharger_mmi/parameters/eb_low_start_soc + chown root vendor_mod /sys/module/qpnp_smbcharger_mmi/parameters/eb_low_stop_soc + chown root vendor_mod /sys/module/qpnp_smbcharger_mmi/parameters/eb_on_sw + + chmod 0664 /sys/module/qpnp_smbcharger_mmi/parameters/eb_rechrg_start_soc + chmod 0664 /sys/module/qpnp_smbcharger_mmi/parameters/eb_rechrg_stop_soc + chmod 0664 /sys/module/qpnp_smbcharger_mmi/parameters/eb_attach_start_soc + chmod 0664 /sys/module/qpnp_smbcharger_mmi/parameters/eb_attach_stop_soc + chmod 0664 /sys/module/qpnp_smbcharger_mmi/parameters/eb_low_start_soc + chmod 0664 /sys/module/qpnp_smbcharger_mmi/parameters/eb_low_stop_soc + chmod 0664 /sys/module/qpnp_smbcharger_mmi/parameters/eb_on_sw + + chown root vendor_mod /sys/class/power_supply/usb/usb_priority + chmod 0660 /sys/class/power_supply/usb/usb_priority + chown root vendor_mod /sys/module/dwc3_msm/parameters/usb_priority + chmod 0660 /sys/module/dwc3_msm/parameters/usb_priority + chown root vendor_mod /sys/module/usbnet/parameters/force_on + chmod 0666 /sys/module/usbnet/parameters/force_on + + # Setup folder for native to transfer data to NativeDropBoxAgent + mkdir /data/vendor/dropbox-add 0730 log diag + + # Create panic dump dir. + mkdir /data/vendor/dontpanic 0750 root log + + # Create directory for cutback + mkdir /data/vendor/misc/cutback 0770 radio wifi + + # Create bug2go folder + mkdir /data/vendor/bug2go 0770 log log + + # Setup folder for aplogd + mkdir /data/vendor/aplogd 0770 log log + + # Create directory used by chargeonlymode + mkdir /data/vendor/chargeonly 0750 root log + + # Subsystem RAM-dumps + mkdir /data/vendor/ss-ram-dumps 0750 system log + mkdir /data/vendor/ss-ram-dumps/bp-dumps 0750 system log + mkdir /data/vendor/ss-ram-dumps/riva-dumps 0750 system log + + # folder for Blueooth ramdump + mkdir /data/vendor/bt-ram-dumps 0750 bluetooth log + + # folder for ssrdumps + mkdir /data/vendor/ssrdump 0775 root system + + #Folder for hardware properties + mkdir /data/vendor/hardware_revisions 0755 system system + + # Imager tuning data for camera subsystem + mkdir /data/vendor/misc/imager 0771 camera camera + + # NFC vendor data + mkdir /data/vendor/nfc 0770 nfc nfc + + # Required by FingerPrint Cards (FPC) via init so we don't need to give qseecomd or fingerprintd permissions to create them + mkdir /data/vendor/fpc 0700 system system + mkdir /data/vendor/.fps 0770 system vendor_fingerp + + # Required by touchRec for write the touch data + mkdir /data/vendor/touchrec 0770 input input + chown input input /data/vendor/touchrec/bootindex + chown input input /data/vendor/touchrec/lastbootuuid + chown input input /data/vendor/touchrec/touch_data.txt + chmod 0664 /data/vendor/touchrec/touch_data.txt + +on boot + # restore default console_loglevel to KERN_DEBUG + # restore default_message_loglevel to KERN_WARNING + write /proc/sys/kernel/printk "7 4 1 7" + + # MOTO, NJH348, IKHALFMWK-1864, change system max tcp buffer sizes based on RAT changes + # Define system changable TCP buffer max values + chown system system /proc/sys/net/core/rmem_max + chown system system /proc/sys/net/core/wmem_max + + # Change ownership and permission for leds backlight + chmod 0664 /sys/class/leds/lcd-backlight/brightness + chown system system /sys/class/leds/charging/brightness + chmod 0664 /sys/class/leds/charging/brightness + + # change permission of red leds + chown system system /sys/class/leds/red/brightness + chmod 0664 /sys/class/leds/red/brightness + + # Change ownership and permission for vibrator + chown system system /sys/class/timed_output/vibrator/enable + chmod 0660 /sys/class/timed_output/vibrator/enable + chown system system /sys/class/leds/vibrator/state + chmod 0660 /sys/class/leds/vibrator/state + chown system system /sys/class/leds/vibrator/activate + chmod 0660 /sys/class/leds/vibrator/activate + chown system system /sys/class/leds/vibrator/duration + chmod 0660 /sys/class/leds/vibrator/duration + chown system system /sys/class/leds/vibrator/seq + chmod 0660 /sys/class/leds/vibrator/seq + chown system system /sys/class/leds/vibrator/extra + chmod 0660 /sys/class/leds/vibrator/extra + chown root vendor_mod /sys/bus/i2c/devices/2-005a/reduce + + # Change ownership of aov related sysfs entries + chown audio audio /sys/kernel/aov/trigger + chown audio audio /sys/kernel/aov/register + chown audio audio /sys/kernel/aov/event + + # Quiet binder logs + write /sys/module/binder/parameters/debug_mask 0x5 + + # Clear cooldown state + mkdir /mnt/vendor/persist/chargeonly 0770 system system + write /mnt/vendor/persist/chargeonly/cooldown n + chown system system /mnt/vendor/persist/chargeonly/cooldown + chmod 0660 /mnt/vendor/persist/chargeonly/cooldown + + # Change owner ship of l5 laser calibration + chown camera vendor_tcmd /mnt/vendor/persist/camera/focus/offset_cal + chmod 0660 /mnt/vendor/persist/camera/focus/offset_cal + + # change ownership of capsensor related sysfs node + chown system system /sys/class/capsense/reset + chown system system /sys/class/capsense/int_state + +#service vendor.mmi-block-perm /vendor/bin/init.mmi.block_perm.sh +# class main +# user root +# oneshot + +#service vendor.pstore_annotate /vendor/bin/pstore_annotate.sh build +# class main +# user system +# group log +# oneshot + +#service vendor.apanic_copy /vendor/bin/apanic_copy.sh +# class late_start +# group log +# oneshot +# disabled + +#service vendor.bl_logs_copy /vendor/bin/apanic_copy.sh -i +# class late_start +# group log + # oneshot + # disabled + +on charger + trigger early-fs + trigger fs + trigger post-fs + trigger late-fs + trigger post-fs-data + trigger moto-charger + class_stop main + class_stop late_start + +#service vendor.apanic_annotate /vendor/bin/apanic_save.sh build +# class late_start +# group log +# oneshot +# disabled + +service vendor.batt_health /vendor/bin/batt_health + class late_start + user vendor_pwric + group vendor_pwric cache net_admin log + disabled + +on property:sys.boot_completed=1 + start vendor.batt_health + +on property:sys.boot_completed=1 && property:ro.vendor.zram.product_swapon="" + write /proc/sys/vm/page-cluster 0 + swapon_all /vendor/etc/fstab.qcom + write /proc/sys/vm/swappiness 100 + setprop sys.sysctl.swappiness 100 + +on property:sys.boot_completed=1 && property:ro.vendor.bootreason=coldboot + start vendor.apanic_copy + +on property:ro.vendor.bootreason=watchdog + stop surfaceflinger + stop zygote + stop zygote_secondary + stop sensors + start vendor.apanic_annotate + +on property:ro.vendor.bootreason=pmic_watchdog + stop surfaceflinger + stop zygote + stop zygote_secondary + stop sensors + start vendor.apanic_annotate + +on property:ro.vendor.bootreason=kernel_panic + stop surfaceflinger + stop zygote + stop zygote_secondary + stop sensors + start vendor.apanic_annotate + +on property:ro.vendor.bootreason=hw_warmreset + stop surfaceflinger + stop zygote + stop zygote_secondary + stop sensors + start vendor.apanic_annotate + +on property:persist.vendor.log.aplogd.enable=1 + start vendor.aplogd + +on property:persist.vendor.log.aplogd.enable=0 + stop vendor.aplogd + +service vendor.aplogd /vendor/bin/aplogd + class late_start + #user log + #group log system sdcard_rw sdcard_r media_rw mount + # The user and group definitions above are intentionally disabled and left + # only as documentation. It actually starts as root and immediately drops + # to log plus those groups after preserving CAP_SYS_ADMIN, which is required + # for kernel logging. + disabled + +# from P onwards aplogd cannot read vold.post_fs_data_done so a new property +# shall be used to allow aplogd checking if FBE has finished /data decryption +on property:vold.post_fs_data_done=* + setprop vendor.vold.post_fs_data_done ${vold.post_fs_data_done} + +service vendor.mmi-boot-sh /vendor/bin/init.mmi.boot.sh + class core + user root + oneshot + +#service vendor.mmi-shutdown-sh /vendor/bin/init.mmi.shutdown.sh +# class core +## oneshot +# disabled + +# translate to qcom property name in order to keep the consistent with +# our legacy property +on property:persist.vendor.qc.sub.rdump.on=* + setprop persist.vendor.ssr.enable_ramdumps ${persist.vendor.qc.sub.rdump.on} + +# translate MMI property in order to keep the consistent with QCOM +on property:ro.vendor.hw.dualsim=true + setprop persist.radio.multisim.config dsds + +on property:persist.vendor.qc.sub.rdump.on=* + setprop persist.vendor.ssr.enable_ramdumps ${persist.vendor.qc.sub.rdump.on} + +on property:ro.vendor.hw.dualsim=false + setprop persist.radio.multisim.config "" + +on property:sys.sysctl.swappiness=* + write /proc/sys/vm/swappiness ${sys.sysctl.swappiness} + +service vendor.mbm_spy /vendor/bin/mbm_spy + class late_start + user system + group system + oneshot + disabled + +on property:sys.boot_completed=1 + start vendor.mbm_spy + +service vendor.hw_revs /vendor/bin/hardware_revisions.sh + class late_start + user system + group system + oneshot + +service vendor.mmi-touch-sh /vendor/bin/init.mmi.touch.sh + class core + user root + oneshot + +service vendor.touchUpg /vendor/bin/touchUpg + class core + user root + oneshot + disabled + +service vendor.oem-hw-sh /vendor/bin/init.oem.hw.sh + class core + user root + oneshot + disabled + +service vendor.oem-super-image-detector-sh /vendor/bin/init.oem.hw.sh -M + class core + user root + oneshot + disabled + +service vendor.ident-fps-sh /vendor/bin/init.oem.fingerprint.sh + class core + user root + group drmrpc system + oneshot + disabled + +service vendor.hal-fps-sh /vendor/bin/init.oem.fingerprint2.sh + class late_start + user root + group system + oneshot + +service fpc_ident /vendor/bin/hw/fpc_ident + class late_start + user system + group system + oneshot + disabled + +service egis_ident /vendor/bin/hw/egis_ident + class late_start + user system + group system + oneshot + disabled + +service vendor.touch-dead-sh /vendor/bin/init.oem.hw.sh -f + class main + user root + oneshot + disabled + +service vendor.touch-ready-sh /vendor/bin/init.oem.hw.sh -r + class main + user root + oneshot + disabled + +service vendor.oem-hw-config-sh /vendor/bin/init.oem.hw.sh -p + class main + user root + oneshot + disabled + +on property:vendor.hw.touch.status="dead" + start vendor.touch-dead-sh + +on property:vendor.hw.touch.status="ready" + start vendor.touch-ready-sh + +service vendor.charge_only_mode /vendor/bin/charge_only_mode + user root + group graphics system input + disabled + +service vendor.thermal-com /vendor/bin/thermal-engine --minimode + class main + user root + group root system oem_2907 + socket thermal-send-client stream 0666 system oem_2907 + socket thermal-recv-client stream 0660 system oem_2907 + socket thermal-recv-passive-client stream 0666 system oem_2907 + socket thermal-send-rule stream 0660 system oem_2907 + disabled + +# bugreport is triggered by holding down volume down, volume up and power +service bugreport /system/bin/dumpstate -d -p -B -z \ + -o /data/user_de/0/com.android.shell/files/bugreports/bugreport + class main + disabled + oneshot + keycodes 114 115 116 + +# touchRec +service vendor.touchRec /vendor/bin/touchRec + class late_start + user input + group input + oneshot + disabled + +on property:vendor.wifi.tethering=false + write /sys/module/wlan/parameters/sar_mhs disabled + +on property:vendor.wifi.tethering=true + write /sys/module/wlan/parameters/sar_mhs enabled + +# Override the AOSP sensor HAL service definition +# from hardware/interfaces/sensors/2.0/multihal +# to add input and uhid group access +service vendor.sensors-hal-2-0-multihal /vendor/bin/hw/android.hardware.sensors@2.0-service.multihal + class hal + user system + group system wakelock context_hub input uhid + writepid /dev/cpuset/system-background/tasks + capabilities BLOCK_SUSPEND + rlimit rtprio 10 10 + +# from hardware/interfaces/sensors/2.1/multihal +# to add input and uhid group access +service vendor.sensors-hal-2-1-multihal /vendor/bin/hw/android.hardware.sensors@2.1-service.multihal + class hal + user system + group system wakelock context_hub input uhid + writepid /dev/cpuset/system-background/tasks + capabilities BLOCK_SUSPEND + rlimit rtprio 10 10 + +#Override fwpath string when wpa_supplicant server was killed +on property:vendor.wifi.station=true + write /sys/module/wlan/parameters/sar_sta enabled + +on property:vendor.wifi.station=false + write /sys/module/wlan/parameters/sar_sta disabled + +on shutdown + exec_start vendor.mmi-shutdown-sh + +on property:persist.sys.locale=* + mkdir /mnt/vendor/persist/chargeonly 0770 system system + write /mnt/vendor/persist/chargeonly/locale ${persist.sys.locale} + chown system system /mnt/vendor/persist/chargeonly/locale + chmod 0660 /mnt/vendor/persist/chargeonly/locale + +# IKSWQ-149109: Force shutter tone on Japan softbank carrier +on property:ro.carrier=softbank + setprop audio.camerasound.force true + +on property:ro.sys.force_max_chrg_temp=* + write /sys/class/power_supply/battery/device/force_max_chrg_temp ${ro.sys.force_max_chrg_temp} + +on property:ro.sys.force_demo_mode=* + write /sys/class/power_supply/battery/device/force_demo_mode ${ro.sys.force_demo_mode} diff --git a/rootdir/etc/init.qcom.factory.rc b/rootdir/etc/init.qcom.factory.rc new file mode 100644 index 0000000..1edaa99 --- /dev/null +++ b/rootdir/etc/init.qcom.factory.rc @@ -0,0 +1,258 @@ +# +# Copyright (c) 2009-2016, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Define fastmmi +service fastmmi /system_ext/bin/mmi + user root + group root + disabled + +service vendor.mmid /vendor/bin/mmid + user root + group root + disabled + +service mmi_diag /system_ext/bin/mmi_diag + class main + user root + group root oem_2901 + disabled + +on property:vendor.sys.boot_mode=ffbm + write ${persist.vendor.mmi.misc_dev_path} "ffbm-01" + +on property:vendor.sys.boot_mode=qmmi + write ${persist.vendor.mmi.misc_dev_path} "qmmi" + +on property:vendor.sys.boot_mode=normal + write ${persist.vendor.mmi.misc_dev_path} "normal" + +# Creating a scratch storage on /data for factory testing. +on factory-fs && property:ro.bootmode=ffbm-00 + mount tmpfs tmpfs /data + +on factory-fs && property:ro.bootmode=ffbm-01 + mount tmpfs tmpfs /data + +# aligned the usb port with system standard, otherwise if only diag be added +# Then in QMMI mode, the whole Andoid be booted, but due to the ro.bootmode is +# not normal/unknow, then when it apply the default funcs, it will turn to MTP +# which cause the diag/Wwan/modem port all be lost in qmmi mode. Details: +# UsbDeviceManager.java---->getDefaultFunctions and trySetEnabledFunctions +on property:persist.vendor.usb.config=* + setprop persist.sys.usb.qmmi.func ${persist.vendor.usb.config} + +on mmi && property:ro.bootmode=ffbm-00 + # ======================================================== + # This is FFBM only settings. + # ======================================================== + #mkdir for factory data files. + mkdir /mnt/vendor/persist/FTM_AP 0750 system system + + start fastmmi + # start qcom-post-boot to set the misc partition path property value + start qcom-post-boot + start mmi_diag + +on mmi && property:ro.bootmode=ffbm-01 + # ======================================================== + # This is FFBM only settings. + # ======================================================== + #mkdir for factory data files. + mkdir /mnt/vendor/persist/FTM_AP 0750 system system + + start fastmmi + ## start qcom-post-boot to set the misc partition path property value + start qcom-post-boot + start mmi_diag + +on property:persist.vendor.usb.config=* && property:ro.bootmode=ffbm-00 + setprop sys.usb.config ${persist.vendor.usb.config} + +on property:persist.vendor.usb.config=* && property:ro.bootmode=ffbm-01 + setprop sys.usb.config ${persist.vendor.usb.config} + +on property:persist.vendor.usb.config=* && property:ro.bootmode=ffbm-02 + setprop sys.usb.config ${persist.vendor.usb.config} + +on property:persist.vendor.usb.config=* && property:ro.bootmode=qmmi + setprop sys.usb.config ${persist.vendor.usb.config} + +on ffbm + trigger early-fs + trigger factory-fs + trigger fs + trigger post-fs + + # Mount fstab in init.{$device}.rc by mount_all with '--late' parameter + # to only mount entries with 'latemount'. This is needed if '--early' is + # specified in the previous mount_all command on the fs stage. + # With /system mounted and properties form /system + /factory available, + # some services can be started. + trigger late-fs + + # Now we can mount /data. File encryption requires keymaster to decrypt + # /data, which in turn can only be loaded when system properties are present. + trigger post-fs-data + + # Now we can start zygote for devices with file based encryption + trigger zygote-start + + # Load persist properties and override properties (if enabled) from /data. + trigger load_persist_props_action + + # Remove a file to wake up anything waiting for firmware. + trigger firmware_mounts_complete + + trigger early-boot + trigger boot + trigger mmi + + +# ======================================================== +# Start for audio TC +# ======================================================== + +service vendor.audio_tc53 /vendor/bin/mm-audio-ftm -tc 53 + user audio + group audio + disabled + oneshot + + +service vendor.audio_tc51 /vendor/bin/mm-audio-ftm -tc 51 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc56 /vendor/bin/mm-audio-ftm -tc 56 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc222 /vendor/bin/mm-audio-ftm -tc 222 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc228 /vendor/bin/mm-audio-ftm -tc 228 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc229 /vendor/bin/mm-audio-ftm -tc 229 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc230 /vendor/bin/mm-audio-ftm -tc 230 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc225 /vendor/bin/mm-audio-ftm -tc 225 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc246 /vendor/bin/mm-audio-ftm -tc 246 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc247 /vendor/bin/mm-audio-ftm -tc 247 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc250 /vendor/bin/mm-audio-ftm -tc 250 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc251 /vendor/bin/mm-audio-ftm -tc 251 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc252 /vendor/bin/mm-audio-ftm -tc 252 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc253 /vendor/bin/mm-audio-ftm -tc 253 + user audio + group audio + disabled + oneshot + +service vendor.audio_tc11 /vendor/bin/mm-audio-ftm -tc 11 -file /data/vendor/audio/ftm_headset_mic_record.wav + user audio + group audio + disabled + oneshot + +service vendor.audio_tc101 /vendor/bin/mm-audio-ftm -tc 101 -file /data/vendor/audio/ftm_mic1_record.wav + user audio + group audio + disabled + oneshot + +service vendor.audio_tc102 /vendor/bin/mm-audio-ftm -tc 102 -file /data/vendor/audio/ftm_mic2_record.wav + user audio + group audio + disabled + oneshot + +service vendor.audio_tc103 /vendor/bin/mm-audio-ftm -tc 103 -file /data/vendor/audio/ftm_mic3_record.wav + user audio + group audio + disabled + oneshot + +service vendor.audio_tc104 /vendor/bin/mm-audio-ftm -tc 104 -file /data/vendor/audio/ftm_mic4_record.wav + user audio + group audio + disabled + oneshot + +# ======================================================== +# End for audio TC +# ======================================================== diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc new file mode 100755 index 0000000..6488cbb --- /dev/null +++ b/rootdir/etc/init.qcom.rc @@ -0,0 +1,942 @@ +# Copyright (c) 2009-2012, 2014-2020, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +#import /vendor/etc/init/hw/init.qti.ufs.rc +#import /vendor/etc/init/hw/init.qcom.usb.rc +#import /vendor/etc/init/hw/init.qcom.test.rc +import /vendor/etc/init/hw/init.target.rc +import /vendor/etc/init/hw/init.qcom.factory.rc + +on early-init + mount debugfs debugfs /sys/kernel/debug + chmod 0755 /sys/kernel/debug + mount tracefs tracefs /sys/kernel/tracing + chmod 0755 /sys/kernel/tracing + + # create symlink for vendor mount points + symlink /vendor/firmware_mnt /firmware + symlink /vendor/bt_firmware /bt_firmware + symlink /vendor/dsp /dsp + + # Change ownership of hw_recovery related nodes + chown system graphics /sys/kernel/debug/dri/0/debug/dump + chown system graphics /sys/kernel/debug/dri/0/debug/recovery_reg + chown system graphics /sys/kernel/debug/dri/0/debug/recovery_dbgbus + chown system graphics /sys/kernel/debug/dri/0/debug/recovery_vbif_dbgbus + chown system graphics /sys/kernel/debug/dri/0/debug/recovery_dsi_dbgbus + + # Change ownership of sysfs power control node + chown system graphics /sys/class/drm/card0/device/power/control + + # Change ownership of sw_sync node + chown system graphics /sys/kernel/debug/sync/sw_sync + chmod 0666 /sys/kernel/debug/sync/sw_sync + + #Disable UFS clock scaling + write /sys/bus/platform/devices/${ro.boot.bootdevice}/clkscale_enable 0 + + chown root system /dev/kmsg + chmod 0620 /dev/kmsg + # Load WIGIG platform driver + # exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules msm_11ad_proxy + +on init + + # Support legacy paths + symlink /sdcard /mnt/sdcard + symlink /sdcard /storage/sdcard0 + + # Create cgroup mount point for memory + mkdir /sys/fs/cgroup/memory/bg 0750 root system + write /sys/fs/cgroup/memory/bg/memory.swappiness 140 + write /sys/fs/cgroup/memory/bg/memory.move_charge_at_immigrate 1 + chown root system /sys/fs/cgroup/memory/bg/tasks + chmod 0660 /sys/fs/cgroup/memory/bg/tasks + +on post-fs + chmod 0755 /sys/kernel/debug/tracing + +on early-boot + # set RLIMIT_MEMLOCK to 64MB + setrlimit 8 67108864 67108864 + # Allow subsystem (modem etc) debugging + write /sys/kernel/boot_adsp/boot 1 + write /sys/kernel/boot_cdsp/boot 1 + write /sys/devices/virtual/npu/msm_npu/boot 1 + write /sys/devices/virtual/cvp/cvp/boot 1 + exec u:r:vendor_qti_init_shell:s0 -- /vendor/bin/init.qcom.early_boot.sh + exec u:r:vendor_qti_init_shell:s0 -- /vendor/bin/init.qti.can.sh + setprop ro.sf.lcd_density ${vendor.display.lcd_density} + + chown system system /mnt/vendor/persist/data/pfm/licenses + chmod 0775 /mnt/vendor/persist/data/pfm/licenses + chown system system /mnt/vendor/persist/data/pfm/licenses/store_0 + chmod 0664 /mnt/vendor/persist/data/pfm/licenses/store_0 + chown system system /mnt/vendor/persist/data/pfm/licenses/store_1 + chmod 0664 /mnt/vendor/persist/data/pfm/licenses/store_1 + chown system system /mnt/vendor/persist/data/pfm/licenses/store_2 + chmod 0664 /mnt/vendor/persist/data/pfm/licenses/store_2 + chown system system /mnt/vendor/persist/data/pfm/licenses/store_3 + chmod 0664 /mnt/vendor/persist/data/pfm/licenses/store_3 + chown system system /mnt/vendor/persist/data/pfm/licenses/store_4 + chmod 0664 /mnt/vendor/persist/data/pfm/licenses/store_4 + +on boot + chown bluetooth bluetooth /sys/module/bluetooth_power/parameters/power + chown bluetooth net_bt /sys/class/rfkill/rfkill0/type + chown bluetooth net_bt /sys/class/rfkill/rfkill0/state + chown bluetooth bluetooth /proc/bluetooth/sleep/proto + chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_lpm + chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_btwrite + chown system system /sys/module/sco/parameters/disable_esco + chown bluetooth bluetooth /sys/module/hci_smd/parameters/hcismd_set + chown system system /sys/module/msm_core/parameters/polling_interval + chown system system /sys/module/msm_core/parameters/disabled + chown system system /sys/kernel/debug/msm_core/enable + chown system system /sys/kernel/debug/msm_core/ptable + chown system system /sys/kernel/boot_slpi/ssr + chown system system /sys/module/radio_iris_transport/parameters/fmsmd_set + chmod 0660 /sys/module/bluetooth_power/parameters/power + chmod 0660 /sys/module/hci_smd/parameters/hcismd_set + chmod 0660 /sys/module/radio_iris_transport/parameters/fmsmd_set + chmod 0660 /sys/class/rfkill/rfkill0/state + chmod 0660 /proc/bluetooth/sleep/proto + chown bluetooth net_bt /dev/ttyHS0 + chmod 0660 /sys/module/hci_uart/parameters/ath_lpm + chmod 0660 /sys/module/hci_uart/parameters/ath_btwrite + chmod 0660 /dev/ttyHS0 + chown bluetooth bluetooth /sys/devices/platform/msm_serial_hs.0/clock + chmod 0660 /sys/devices/platform/msm_serial_hs.0/clock + + chmod 0660 /dev/ttyHS2 + chown bluetooth bluetooth /dev/ttyHS2 + + chown bluetooth net_bt /sys/class/rfkill/rfkill0/device/extldo + chmod 0660 /sys/class/rfkill/rfkill0/device/extldo + + # This location is used by QCRIL to host UNIX domain + # socket files used for internal IPC within QCRIL + # modules + mkdir /dev/socket/qmux_radio 0770 radio radio + chmod 2770 /dev/socket/qmux_radio + + mkdir /persist/drm 0770 system system + mkdir /persist/bluetooth 0770 bluetooth bluetooth + mkdir /persist/misc 0770 system system + mkdir /persist/alarm 0770 system system + mkdir /mnt/vendor/persist/time 0770 system system + mkdir /mnt/vendor/persist/secnvm 0770 system system + mkdir /mnt/vendor/persist/iar_db 0770 system system + mkdir /mnt/vendor/spunvm 0770 system system + + #Create WIGIG socket area + mkdir /dev/socket/wigig 0770 wifi wifi + + setprop wifi.interface wlan0 + + setprop ro.telephony.call_ring.multiple false + + #Remove SUID bit for iproute2 ip tool + chmod 0755 /system/bin/ip + + + chmod 0444 /sys/devices/platform/msm_hsusb/gadget/usb_state + + setprop net.tcp.2g_init_rwnd 10 + + # To prevent out of order acknowledgements from making + # connection tracking to treat them as not belonging to + # the connection they belong to. + # Otherwise, a weird issue happens in which some long + # connections on high-throughput links get dropped when + # an ack packet comes out of order + write /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal 1 + + # Set the console loglevel to < KERN_WARN + # Set the default message loglevel to KERN_INFO + write /proc/sys/kernel/printk "4 6 1 7" + + # Allow access for CCID command/response timeout configuration + chown system system /sys/module/ccid_bridge/parameters/bulk_msg_timeout + + # bond0 used by FST Manager + chown wifi wifi /sys/class/net/bond0/bonding/queue_id + + # Allow access to emmc rawdump block partition and dload sysfs node + chown root system /dev/block/bootdevice/by-name/rawdump + chmod 0660 /dev/block/bootdevice/by-name/rawdump + chown root system /sys/kernel/dload/emmc_dload + chmod 0660 /sys/kernel/dload/emmc_dload + chown root system /dev/block/bootdevice/by-name/ramdump + chmod 0660 /dev/block/bootdevice/by-name/ramdump + chown root system /sys/kernel/dload/dload_mode + chmod 0660 /sys/kernel/dload/dload_mode + + chown system system /sys/class/backlight/panel0-backlight/brightness + chown system system /sys/class/backlight/panel0-backlight/max_brightness + chown system system /sys/class/backlight/panel1-backlight/brightness + chown system system /sys/class/backlight/panel1-backlight/max_brightness + + # Allow access to sensors device attributes + chown system system /sys/class/sensors/MPU6050-accel/enable + chown system system /sys/class/sensors/MPU6050-accel/poll_delay + chown system system /sys/class/sensors/MPU6050-gyro/enable + chown system system /sys/class/sensors/MPU6050-gyro/poll_delay + chown system system /sys/class/sensors/apds9930-light/enable + chown system system /sys/class/sensors/apds9930-light/poll_delay + chown system system /sys/class/sensors/apds9930-proximity/enable + chown system system /sys/class/sensors/apds9930-proximity/poll_delay + + # Create directory used for display + # for backward compatibility + mkdir /persist/display 0770 system graphics + mkdir /mnt/vendor/persist/display 0770 system graphics + + # Create vpp directory + mkdir /mnt/vendor/persist/vpp 0770 media media + + + # Create hvdcp_opti directory + mkdir /mnt/vendor/persist/hvdcp_opti 0770 root system + + # limit discard size to 128MB in order to avoid long IO latency + write /sys/block/sda/queue/discard_max_bytes 134217728 + +# msm specific files that need to be created on /data +on post-fs-data + mkdir /data/vendor/misc 01771 system system + + # Create directory used for dump collection + mkdir /data/vendor/ssrdump 0770 root system + + # Create directory used by display clients + mkdir /data/vendor/display 0770 system graphics + + # Change lm related dirs + mkdir /data/vendor/lm 0700 root root + + # Create directory used by powermodule + mkdir /data/vendor/pwr 0700 root root + + # Create directory used by media clients + mkdir /data/vendor/media 0770 mediacodec media + + # Create /data/vendor/tzstorage directory for SFS listener + mkdir /data/vendor/tzstorage 0770 system system + + # Create directory for apps access via QTEEConnector + mkdir /data/vendor/qtee 0770 system system + + #Create folder of camera + mkdir /data/vendor/camera 0770 camera camera + + + #Create directory for tftp + mkdir /data/vendor/tombstones 0771 system system + mkdir /data/vendor/tombstones/rfs 0771 system system + + mkdir /data/vendor/ramdump 0771 root system + mkdir /data/vendor/bluetooth 0770 bluetooth bluetooth + mkdir /data/vendor/ramdump/bluetooth 0770 bluetooth bluetooth + + # Create the directories used by the Wireless subsystem + mkdir /data/vendor/wifi 0770 wifi wifi + mkdir /data/vendor/wifi/sockets 0770 wifi wifi + mkdir /data/vendor/wifi/hostapd 0770 wifi wifi + mkdir /data/vendor/wifi/hostapd/ctrl 0770 wifi wifi + mkdir /data/vendor/wifi/wpa_supplicant 0770 wifi wifi + mkdir /data/vendor/wifi/wigig_hostapd 0770 wifi wifi + mkdir /data/vendor/wifi/wpa 0770 wifi wifi + mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi + + # Create the directories used by WiGig Sensing + mkdir /data/vendor/sensing 0770 system wifi + + # Create the directories used by CnE subsystem + mkdir /data/vendor/connectivity 0771 radio radio + chown radio radio /data/vendor/connectivity + + # Create directory used by audio subsystem + mkdir /data/vendor/audio 0770 audio audio + + # Create directory for audio delta files + mkdir /data/vendor/audio/acdbdata 0770 media audio + mkdir /data/vendor/audio/acdbdata/delta 0770 media audio + + # Create directory for radio + mkdir /data/vendor/radio 0770 system radio + rm /data/vendor/radio/shmbus + + # Create directory for modem_config + mkdir /data/vendor/modem_config 0570 radio root + + # Mounting of persist is moved to 'on emmc-fs' and 'on fs' sections + # We chown/chmod /persist again so because mount is run as root + defaults + chown root system /persist + chmod 0771 /persist + chown system system /persist/WCNSS_qcom_wlan_nv.bin + chmod 0664 /sys/devices/platform/msm_sdcc.1/polling + chmod 0664 /sys/devices/platform/msm_sdcc.2/polling + chmod 0664 /sys/devices/platform/msm_sdcc.3/polling + chmod 0664 /sys/devices/platform/msm_sdcc.4/polling + + # Chown polling nodes as needed from UI running on system server + chown system system /sys/devices/platform/msm_sdcc.1/polling + chown system system /sys/devices/platform/msm_sdcc.2/polling + chown system system /sys/devices/platform/msm_sdcc.3/polling + chown system system /sys/devices/platform/msm_sdcc.4/polling + + #Create the symlink to qcn wpa_supplicant folder for ar6000 wpa_supplicant + #symlink /data/misc/wifi/wpa_supplicant /data/system/wpa_supplicant + + #Create directories for Location services + mkdir /data/vendor/location 0770 gps gps + mkdir /data/vendor/location/mq 0770 gps gps + mkdir /data/vendor/location/xtwifi 0770 gps gps + mkdir /dev/socket/location 0770 gps gps + mkdir /dev/socket/location/mq 0770 gps gps + mkdir /dev/socket/location/xtra 0770 gps gps + mkdir /dev/socket/location/dgnss 0770 gps gps + + #Create directories for wifihal services + mkdir /dev/socket/wifihal 0770 wifi wifi + chmod 2770 /dev/socket/wifihal + + # Create /data/time folder for time-services + mkdir /data/vendor/time/ 0700 system system + + setprop vold.post_fs_data_done 1 + + #Create a folder for SRS to be able to create a usercfg file + #mkdir /data/data/media 0770 media media + + #Create FM dir for patchdownloader + mkdir /data/vendor/fm 0770 system system + chmod 0770 /data/vendor/fm + + #Create PERFD deamon related dirs + mkdir /data/vendor/perfd 0770 root system + chmod 2770 /data/vendor/perfd + rm /data/vendor/perfd/default_values + + mkdir /data/vendor/secure_element 0777 system system + + #Create IOP deamon related dirs + mkdir /data/vendor/iop 0700 root system + + # Mark the copy complete flag to not completed + write /data/vendor/radio/copy_complete 0 + chown radio radio /data/vendor/radio/copy_complete + chmod 0660 /data/vendor/radio/copy_complete + + # copy prebuilt qcril.db files always + copy /vendor/radio/qcril_database/qcril.db /data/vendor/radio/qcril_prebuilt.db + chown radio radio /data/vendor/radio/qcril_prebuilt.db + chmod 0660 /data/vendor/radio/qcril_prebuilt.db + copy /vendor/radio/qcril_database/qcrilNr.db /data/vendor/radio/qcrilNr_prebuilt.db + copy /vendor/etc/qcril_database/qcrilNr.db /data/vendor/radio/qcrilNr_prebuilt.db + chown radio radio /data/vendor/radio/qcrilNr_prebuilt.db + chmod 0660 /data/vendor/radio/qcrilNr_prebuilt.db + + # File flags for prebuilt ril db file + write /data/vendor/radio/prebuilt_db_support 1 + chown radio radio /data/vendor/radio/prebuilt_db_support + chmod 0400 /data/vendor/radio/prebuilt_db_support + write /data/vendor/radio/db_check_done 0 + chown radio radio /data/vendor/radio/db_check_done + chmod 0660 /data/vendor/radio/db_check_done + + # qti-logkit data + mkdir /data/vendor/qti-logkit/ 0771 system system + mkdir /data/vendor/qti-logkit/shared-privileged/ 2770 system system + mkdir /data/vendor/qti-logkit/shared-public/ 2770 system diag + mkdir /data/vendor/qti-logkit/socket-privileged/ 2770 system system + mkdir /data/vendor/qti-logkit/socket-public/ 2750 system diag + mkdir /data/vendor/qti-logkit/logdata/ 2750 system shell + + #Create SWAP related dirs + mkdir /data/vendor/swap 0770 root system + chmod 2770 /data/vendor/swap + + # set aggressive read ahead for dm-0 and dm-1 during boot up + write /sys/block/dm-0/queue/read_ahead_kb 2048 + write /sys/block/dm-1/queue/read_ahead_kb 2048 + write /sys/block/dm-2/queue/read_ahead_kb 2048 + + # Create vpp directory + mkdir /data/vendor/vpp 0770 media media + + #Create dir for TUI + mkdir /data/vendor/tui 0700 system drmrpc + +service nqnfcinfo /system/vendor/bin/nqnfcinfo + class late_start + group nfc + user system + oneshot + +service iop /system/vendor/bin/iop + class main + user root + group root + disabled + socket iop seqpacket 0666 root system + +on property:ro.vendor.hw.dualsim=true + setprop persist.vendor.radio.multisim.config dsds + +on property:ro.vendor.hw.dualsim=false + setprop persist.vendor.radio.multisim.config "" + +#service qcomsysd /system/vendor/bin/qcom-system-daemon +# class main +# user root +# group root diag oem_2901 +# disabled + +#on property:persist.vendor.qcomsysd.enabled=1 +# enable qcomsysd + +#on property:persist.vendor.qcomsysd.enabled=0 +# stop qcomsysd + +service vendor.ssr_setup /system/vendor/bin/ssr_setup + oneshot + disabled + +service vendor.ss_ramdump /system/vendor/bin/subsystem_ramdump + class main + user system + group log sdcard_rw sdcard_r diag + ioprio rt 4 + disabled + +on property:ro.vendor.iocgrp.config=1 + mkdir /dev/blkio + mount cgroup none /dev/blkio blkio + chown system system /dev/blkio + chown system system /dev/blkio/tasks + chmod 0664 /dev/blkio/tasks + mkdir /dev/blkio/bg 0755 system system + chown system system /dev/blkio/bg/tasks + chmod 0664 /dev/blkio/bg/tasks + write /dev/blkio/blkio.weight 1000 + write /dev/blkio/bg/blkio.weight 100 + +on property:persist.sys.ssr.enable_debug=* + write /sys/module/subsystem_restart/parameters/enable_debug ${persist.sys.ssr.enable_debug} + +on property:persist.sys.mba_boot_timeout=* + write /sys/module/pil_msa/parameters/pbl_mba_boot_timeout_ms ${persist.sys.mba_boot_timeout} + +on property:persist.sys.modem_auth_timeout=* + write /sys/module/pil_msa/parameters/modem_auth_timeout_ms ${persist.sys.modem_auth_timeout} + +on property:persist.sys.pil_proxy_timeout=* + write /sys/module/peripheral_loader/parameters/proxy_timeout_ms ${persist.sys.pil_proxy_timeout} + +on property:persist.vendor.ssr.restart_level=* + start vendor.ssr_setup + +on property:persist.vendor.ssr.enable_ramdumps=1 + write /sys/module/subsystem_restart/parameters/enable_ramdumps 1 + mkdir /data/vendor/ramdump_ssr 770 system system + start vendor.ss_ramdump + +on property:persist.vendor.ssr.enable_ramdumps=0 + write /sys/module/subsystem_restart/parameters/enable_ramdumps 0 + +on property:persist.vendor.sys.rawdump_copy=1 + write /sys/kernel/dload/emmc_dload 1 + +on property:persist.vendor.sys.rawdump_copy=0 + write /sys/kernel/dload/emmc_dload 0 + +on charger + #Enable UFS clock scaling back + write /sys/bus/platform/devices/${ro.boot.bootdevice}/clkscale_enable 1 + +on property:sys.boot_completed=1 + write /dev/kmsg "Boot completed " + #Enable UFS clock scaling back + write /sys/bus/platform/devices/${ro.boot.bootdevice}/clkscale_enable 1 + #Reset read ahead for dm-0 and dm-1 to 512kb + write /sys/block/dm-0/queue/read_ahead_kb 512 + write /sys/block/dm-1/queue/read_ahead_kb 512 + #WDSP FW boot sysfs node used by STHAL + chown media audio /sys/kernel/wdsp0/boot + chown media audio /sys/kernel/wcd_cpe0/fw_name + #Reinit lmkd to reconfigure lmkd properties + setprop lmkd.reinit 1 + +on property:persist.vendor.radio.atfwd.start=false + stop vendor.atfwd + +on property:vendor.radio.atfwd.start=false + stop vendor.atfwd + +# corefile limit +on property:persist.debug.trace=1 + mkdir /data/core 0777 root root + write /proc/sys/kernel/core_pattern "/data/core/%E.%p.%e" + +on property:vendor.media.target.version=* + setprop vendor.sys.media.target.version ${vendor.media.target.version} + +on property:vendor.netflix.bsp_rev=* + setprop ro.netflix.bsp_rev ${vendor.netflix.bsp_rev} + +on property:vendor.media.target_variant=* + setprop ro.media.xml_variant.codecs ${vendor.media.target_variant} + setprop ro.media.xml_variant.codecs_performance ${vendor.media.target_variant} + +service qcom-c_core-sh /vendor/bin/init.qcom.class_core.sh + class core + user root + oneshot + +service qcom-c_main-sh /vendor/bin/init.class_main.sh + class main + user root + group root system + oneshot + +on property:vold.decrypt=trigger_restart_framework + start qcom-c_main-sh + start wcnss-service + +service vendor.qrtr-ns /vendor/bin/qrtr-ns -f + class core + user vendor_qrtr + group vendor_qrtr + capabilities NET_BIND_SERVICE + +service irsc_util /vendor/bin/irsc_util "/vendor/etc/sec_config" + class core + user root + oneshot + +service qmiproxy /system/bin/qmiproxy + class main + user radio + group radio diag + disabled + +service wpa_supplicant /vendor/bin/hw/wpa_supplicant \ + -O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 -dd \ + -g@android:vendor_wpa_wlan0 +# we will start as root and wpa_supplicant will switch to user wifi +# after setting up the capabilities required for WEXT +# user wifi +# group wifi inet keystore + interface android.hardware.wifi.supplicant@1.0::ISupplicant default + interface android.hardware.wifi.supplicant@1.1::ISupplicant default + interface android.hardware.wifi.supplicant@1.2::ISupplicant default + interface android.hardware.wifi.supplicant@1.3::ISupplicant default + interface vendor.qti.hardware.wifi.supplicant@2.0::ISupplicantVendor default + interface vendor.qti.hardware.wifi.supplicant@2.1::ISupplicantVendor default + interface vendor.qti.hardware.wifi.supplicant@2.2::ISupplicantVendor default + class main + socket vendor_wpa_wlan0 dgram 660 wifi wifi + disabled + oneshot + +service vendor.wigig_supplicant /vendor/bin/hw/wpa_supplicant \ + -iwigig0 -Dnl80211 -c/data/vendor/wifi/wigig_supplicant.conf \ + -m/data/vendor/wifi/wigig_p2p_supplicant.conf \ + -O/data/vendor/wifi/wigig_sockets -dd \ + -e/data/vendor/wifi/wigig_entropy.bin -g@android:wigig/wpa_wigig0 \ + -S wigigsvc + # we will start as root and wpa_supplicant will switch to user wifi + # after setting up the capabilities required for WEXT + # user wifi + # group wifi inet keystore + class main + socket wigig/wpa_wigig0 dgram 660 wifi wifi + disabled + oneshot + +# Data Migration +service vendor.move_wifi_data /system/bin/move_wifi_data.sh + class main + user wifi + group wifi + disabled + oneshot + +service wigignpt /vendor/bin/wigignpt + interface vendor.qti.hardware.wigig.netperftuner@1.0::INetPerfTuner default + class hal + socket wigig/wigignpt stream 660 system wifi + user system + group wifi + capabilities NET_ADMIN + disabled + +on property:persist.vendor.wigig.npt.enable=1 + start wigignpt + +service vendor.sensingdaemon /vendor/bin/sensingdaemon + class hal + socket wigig/sensingdaemon stream 660 system wifi + user system + group wifi + disabled + +service dhcpcd_wlan0 /system/bin/dhcpcd -ABKLG + class late_start + disabled + oneshot + +service dhcpcd_bond0 /system/bin/dhcpcd -ABKLG + class late_start + disabled + oneshot + +service dhcpcd_p2p /system/bin/dhcpcd -ABKLG + class late_start + disabled + oneshot + +service dhcpcd_wigig0 /system/bin/dhcpcd -ABKLG + class late_start + disabled + oneshot + +service iprenew_wlan0 /system/bin/dhcpcd -n + class late_start + disabled + oneshot + +service iprenew_bond0 /system/bin/dhcpcd -n + class late_start + disabled + oneshot + +service iprenew_p2p /system/bin/dhcpcd -n + class late_start + disabled + oneshot + +service iprenew_wigig0 /system/bin/dhcpcd -n + class late_start + disabled + oneshot + +service ptt_socket_app /system/vendor/bin/ptt_socket_app -d + class main + user wifi + group wifi system inet net_admin + capabilities NET_ADMIN + oneshot + +service ptt_ffbm /system/vendor/bin/ptt_socket_app -f -d + user root + group root + disabled + oneshot + +service wifi_ftmd /system/vendor/bin/wifi_ftmd + user system + group system inet net_admin + socket wififtmd_server dgram 0660 system system + disabled + oneshot + +on property:vendor.wifi.ftmd.load=true + insmod /system/lib/modules/pronto/pronto_wlan.ko con_mode=5 + +service cnss-daemon /system/vendor/bin/cnss-daemon -n -l + class late_start + user system + group system inet net_admin wifi + capabilities NET_ADMIN + +on property:sys.shutdown.requested=* + write /sys/kernel/shutdown_wlan/shutdown 1 + stop cnss-daemon + +service dhcpcd_bt-pan /system/bin/dhcpcd -BKLG + class late_start + disabled + oneshot + +service iprenew_bt-pan /system/bin/dhcpcd -n + class late_start + disabled + oneshot + +#service ssgqmigd /vendor/bin/ssgqmigd +# class late_start +# user radio +# group radio gps system +# socket ssgqmig seqpacket 0660 radio inet + +service mlid /vendor/bin/mlid + class late_start + user gps + group gps + socket mlid stream 0666 gps gps + +service loc_launcher /system/vendor/bin/loc_launcher + class late_start + user gps + group gps + +service qcom-sh /vendor/bin/init.qcom.sh + class late_start + user root + group root system radio + oneshot +# Remove since is deprecated but throws AVC denial. +# service crashdata-sh /vendor/bin/init.qcom.crashdata.sh +# class late_start +# user root +# oneshot + +service qcom-post-boot /vendor/bin/init.qcom.post_boot.sh + class late_start + user root + group root system wakelock graphics + disabled + oneshot + +service qti-testscripts /system/bin/sh /product/etc/init.qcom.testscripts.sh + class late_start + user root + disabled + oneshot + seclabel u:r:qti-testscripts:s0 + +service wifi-sdio-on /vendor/bin/init.qcom.sdio.sh + class late_start + group wifi inet + disabled + oneshot + +service wifi-crda /vendor/bin/init.crda.sh + class late_start + user root + disabled + oneshot + +on property:sys.boot_completed=1 + start qcom-post-boot + start qti-testscripts + +on property:ro.vendor.ril.mbn_copy_completed=1 + write /data/vendor/radio/copy_complete 1 + +service qvop-daemon /vendor/bin/qvop-daemon + class late_start + user system + group system drmrpc + +service vendor.atfwd /vendor/bin/ATFWD-daemon + class late_start + user system + group system radio + +service hostapd_fst /vendor/bin/hw/hostapd -dd -g /data/vendor/wifi/hostapd/global + class main + capabilities NET_ADMIN NET_RAW + user wifi + group wifi + disabled + oneshot + +service battery_monitor /system/bin/battery_monitor + user system + group system + disabled + +service vendor.ril-daemon2 /vendor/bin/hw/rild -c 2 + class main + user radio + disabled + group radio cache inet misc audio sdcard_r sdcard_rw diag oem_2901 log + capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW + +service vendor.ril-daemon3 /vendor/bin/hw/rild -c 3 + class main + user radio + disabled + group radio cache inet misc audio sdcard_r sdcard_rw diag oem_2901 log + capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW + +service profiler_daemon /system/bin/profiler_daemon + class late_start + user root + group root + disabled + +service vendor.ssr_diag /system/vendor/bin/ssr_diag + class late_start + user system + group system + disabled + +#service diag_mdlog_start /system/vendor/bin/diag_mdlog +# class late_start +# user shell +# group system oem_2901 sdcard_rw sdcard_r media_rw +# disabled +# oneshot + +#service diag_mdlog_stop /system/vendor/bin/diag_mdlog -k +# class late_start +# user shell +# group system oem_2901 sdcard_rw sdcard_r media_rw +# disabled +# oneshot + +service qlogd /system/xbin/qlogd + socket qlogd stream 0662 system system + class main + disabled +on property:persist.sys.qlogd=1 + start qlogd +on property:persist.sys.qlogd=0 + stop qlogd + +service vm_bms /vendor/bin/vm_bms + user root + group root + disabled + +service vendor.msm_irqbalance /vendor/bin/msm_irqbalance -f /system/vendor/etc/msm_irqbalance.conf + class core + user root + group root + disabled + +service vendor.msm_irqbal_lb /vendor/bin/msm_irqbalance -f /system/vendor/etc/msm_irqbalance_little_big.conf + class core + user root + group root + disabled + +service vendor.msm_irqbl_sdm630 /vendor/bin/msm_irqbalance -f /system/vendor/etc/msm_irqbalance_sdm630.conf + class core + user root + group root + disabled + +# service for USERDEBUG +service vendor.LKCore-dbg /vendor/bin/LKCore + class late_start + oneshot + disabled + user root + group root system log diag net_raw + +# service for USER +service vendor.LKCore-rel /vendor/bin/LKCore + class late_start + oneshot + disabled + user system + group system log diag + +service qseeproxydaemon /system/vendor/bin/qseeproxydaemon + class late_start + user system + group system + +service esepmdaemon /system/vendor/bin/esepmdaemon + class core + user system + group nfc + +#add poweroffhandler +service poweroffhandler /system/vendor/bin/poweroffhandler + class core + user media + group graphics audio + disabled + oneshot + +service time_daemon /vendor/bin/time_daemon + class main + user system + group system + capabilities SYS_TIME + +# Set vendor-ril lib path based on Meta version +on property:vendor.rild.libpath=* + setprop rild.libpath ${vendor.rild.libpath} + +on property:ro.vendor.radio.noril=* + setprop ro.radio.noril ${ro.vendor.radio.noril} + +service vendor.power_off_alarm /vendor/bin/power_off_alarm + class core + group system + disabled + oneshot + +service vendor.hbtp /vendor/bin/hbtp_daemon + class main + user system + group system + capabilities SYS_NICE + disabled + +#service chre /vendor/bin/chre +# class late_start +# user system +# group system +# socket chre seqpacket 0660 root system +# shutdown critical + +on property:vendor.chre.enabled=0 + stop chre + +service bugreport /system/bin/dumpstate -d -p -B -z -o /data/user_de/0/com.android.shell/files/bugreports/bugreport + class main + disabled + oneshot + keycodes 114 115 116 + +#Set GPU Opengles version +on property:vendor.opengles.version=* + setprop ro.opengles.version ${vendor.opengles.version} + +#Set gpu available frequencies property +on property:vendor.gpu.available_frequencies=* + setprop ro.vendor.gpu.available_frequencies ${vendor.gpu.available_frequencies} + +service vendor.audio-hal /vendor/bin/hw/android.hardware.audio.service + override + class hal + user audioserver + # media gid needed for /dev/fm (radio) and for /data/misc/media (tee) + group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct oem_2901 wakelock + capabilities BLOCK_SUSPEND + ioprio rt 4 + writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks + onrestart restart audioserver diff --git a/rootdir/etc/init.target.rc b/rootdir/etc/init.target.rc new file mode 100755 index 0000000..173109c --- /dev/null +++ b/rootdir/etc/init.target.rc @@ -0,0 +1,157 @@ +# Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of The Linux Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# +import /vendor/etc/init/hw/init.mmi.rc + +on early-init + exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules audio_q6_pdr audio_q6_notifier audio_snd_event audio_apr audio_adsp_loader audio_q6 audio_native audio_usf audio_pinctrl_lpi audio_swr audio_swr_ctrl audio_platform audio_stub audio_wcd_core audio_wcd9xxx audio_wsa881x_analog audio_bolero_cdc audio_va_macro audio_rx_macro audio_tx_macro audio_mbhc audio_wcd937x audio_wcd937x_slave audio_pm2250_spmi audio_rouleur audio_rouleur_slave audio_machine_bengal + write /proc/sys/kernel/sched_boost 1 + exec u:r:vendor_qti_init_shell:s0 -- /vendor/bin/init.qti.early_init.sh + setprop ro.soc.model ${ro.vendor.qti.soc_model} + +on init + write /dev/stune/foreground/schedtune.sched_boost_no_override 1 + write /dev/stune/top-app/schedtune.sched_boost_no_override 1 + write /dev/stune/schedtune.colocate 0 + write /dev/stune/background/schedtune.colocate 0 + write /dev/stune/system-background/schedtune.colocate 0 + write /dev/stune/foreground/schedtune.colocate 0 + write /dev/stune/top-app/schedtune.colocate 1 + #Moving to init as this is needed for qseecomd + wait /dev/block/platform/soc/${ro.boot.bootdevice} + symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice + start vendor.qseecomd + start keymaster-4-0 + +on early-fs + start vold + +on fs + start hwservicemanager + mount_all --early + chown root system /mnt/vendor/persist + chmod 0771 /mnt/vendor/persist + restorecon_recursive /mnt/vendor/persist + mkdir /mnt/vendor/persist/data 0700 system system + +on post-fs + # set RLIMIT_MEMLOCK to 64MB + setrlimit 8 67108864 67108864 + +on late-fs + wait_for_prop hwservicemanager.ready true + exec_start wait_for_keymaster + mount_all --late + +on post-fs-data + mkdir /vendor/data/tombstones 0771 system system + +on early-boot + start vendor.sensors + +on boot + write /dev/cpuset/audio-app/cpus 1-2 +#USB controller configuration + setprop vendor.usb.rndis.func.name "gsi" + setprop vendor.usb.rmnet.func.name "gsi" + setprop vendor.usb.rmnet.inst.name "rmnet" + setprop vendor.usb.dpl.inst.name "dpl" + setprop vendor.usb.qdss.inst.name "qdss" + setprop vendor.usb.controller 4e00000.dwc3 + +#Load WLAN driver + insmod /vendor/lib/modules/qca_cld3_wlan.ko + +on boot && property:persist.vendor.usb.controller.default=* + setprop vendor.usb.controller ${persist.vendor.usb.controller.default} + +on property:vendor.usb.controller=* + setprop sys.usb.controller ${vendor.usb.controller} + +on charger + start vendor.power_off_alarm + setprop vendor.usb.controller 4e00000.dwc3 + setprop sys.usb.configfs 1 + +#pd-mapper +service vendor.pd_mapper /vendor/bin/pd-mapper + class core + user system + group system log diag + +#Peripheral manager +service vendor.per_mgr /vendor/bin/pm-service + class core + user system + group system + ioprio rt 4 + +service vendor.per_proxy /vendor/bin/pm-proxy + class core + user system + group system + disabled + +service vendor.mdm_helper /vendor/bin/mdm_helper + class core + group system wakelock + disabled + +service vendor.mdm_launcher /vendor/bin/sh /vendor/bin/init.mdm.sh + class core + oneshot + +on property:init.svc.vendor.per_mgr=running + start vendor.per_proxy + +on property:sys.shutdown.requested=* + stop vendor.per_proxy + +on property:vendor.vold.post_fs_data_done=1 && property:ro.debuggable=1 + start vendor.wlan_logging + +on property:vendor.vold.post_fs_data_done=1 && property:persist.wlan.debug_log=1 + start vendor.wlan_logging + +service vendor.wlan_logging /system/vendor/bin/cnss_diag -q -f -t HELIUM + class main + user system + group system wifi inet sdcard_rw media_rw diag + oneshot + disabled + +service dcvs-sh /vendor/bin/init.qti.dcvs.sh + class late_start + user root + group root system + disabled + oneshot + +on property:vendor.dcvs.prop=1 + start dcvs-sh diff --git a/rootdir/etc/ueventd.qcom.rc b/rootdir/etc/ueventd.qcom.rc new file mode 100755 index 0000000..da27c87 --- /dev/null +++ b/rootdir/etc/ueventd.qcom.rc @@ -0,0 +1,522 @@ +# Copyright (c) 2012-2015, 2017-2020, The Linux Foundation. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of The Linux Foundation nor +# the names of its contributors may be used to endorse or promote +# products derived from this software without specific prior written +# permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +# Firmware directory Path +# Below macro will be read by uevent and path will +# be added to search path for firmware loading +firmware_directories /vendor/firmware_mnt/image/ + +# the DIAG device node is not world writable/readable. +/dev/diag 0660 system oem_2901 +/dev/mhi_*_pipe_4 0660 system system +/dev/ttydiag0 0660 system oem_2901 +/dev/ttydiag1 0660 system oem_2901 +/dev/ttydiag2 0660 system oem_2901 + +/dev/genlock 0666 system system +/dev/wlan 0660 wifi wifi +/dev/kgsl 0666 system system +/dev/kgsl-3d0 0666 system system +/dev/kgsl-2d0 0666 root root +/dev/kgsl-2d1 0666 root root +/dev/ion 0664 system system +/dev/membuf 0664 system system +/dev/rtc0 0660 system system +/dev/smd0 0660 system system +/dev/smd4 0660 system system +/dev/smd_cxm_qmi 0640 radio radio +/dev/smd5 0660 system system +/dev/smd6 0660 system system +/dev/smd7 0660 bluetooth bluetooth +/dev/ccid_bridge 0660 system system +/dev/ipa 0660 radio radio +/dev/wwan_ioctl 0660 radio radio +/dev/ipaNatTable 0660 radio radio +/dev/rmnet_ctrl 0660 usb usb +/dev/dpl_ctrl 0660 usb usb +/dev/ipa_odl_ctl 0660 radio radio +/dev/ipa_adpl 0660 system oem_2905 +/dev/synx_device 0660 root camera +/dev/hab 0666 system system +/dev/hgsl 0666 system system +/dev/iio:device* 0664 system system + +#permissions for UFS RPMB BSG device node +/dev/0:0:0:49476 0600 system system + +#permissions for CSVT +/dev/smd11 0660 radio radio + +#permsissions for BT/FM +/dev/smd2 0660 bluetooth bluetooth +/dev/smd3 0660 bluetooth bluetooth +/dev/btpower 0660 bluetooth system +/dev/btfmslim 0660 bluetooth system + +#permissions for pta +/dev/pta 0660 system system + +/dev/radio0 0640 system system +/dev/rfcomm0 0660 bluetooth bluetooth +/dev/ttyUSB0 0660 bluetooth bluetooth +/dev/smdcntl0 0640 radio radio +/dev/smdcntl1 0640 radio radio +/dev/smdcntl2 0640 radio radio +/dev/smdcntl3 0640 radio radio +/dev/smdcntl4 0640 radio radio +/dev/smdcntl5 0640 radio radio +/dev/smdcntl6 0640 radio radio +/dev/smdcntl7 0640 radio radio +/dev/smdcntl8 0640 radio radio +/dev/smdcnt_rev0 0640 radio radio +/dev/smdcnt_rev1 0640 radio radio +/dev/smdcnt_rev2 0640 radio radio +/dev/smdcnt_rev3 0640 radio radio +/dev/smdcnt_rev4 0640 radio radio +/dev/smdcnt_rev5 0640 radio radio +/dev/smdcnt_rev6 0640 radio radio +/dev/smdcnt_rev7 0640 radio radio +/dev/smdcnt_rev8 0640 radio radio +/dev/smuxctl32 0640 radio radio +/dev/sdioctl0 0640 radio radio +/dev/sdioctl1 0640 radio radio +/dev/sdioctl2 0640 radio radio +/dev/sdioctl3 0640 radio radio +/dev/sdioctl4 0640 radio radio +/dev/sdioctl5 0640 radio radio +/dev/sdioctl6 0640 radio radio +/dev/sdioctl7 0640 radio radio +/dev/sdioctl8 0640 radio radio +/dev/rmnet_mux_ctrl 0640 radio radio +/dev/hsicctl0 0640 radio radio +/dev/hsicctl1 0640 radio radio +/dev/hsicctl2 0640 radio radio +/dev/hsicctl3 0640 radio radio +/dev/hsicctl4 0640 radio radio +/dev/hsicctl5 0640 radio radio +/dev/hsicctl6 0640 radio radio +/dev/hsicctl7 0640 radio radio +/dev/hsicctl8 0640 radio radio +/dev/hsicctl9 0640 radio radio +/dev/hsicctl10 0640 radio radio +/dev/hsicctl11 0640 radio radio +/dev/hsicctl12 0640 radio radio +/dev/hsicctl13 0640 radio radio +/dev/hsicctl14 0640 radio radio +/dev/hsicctl15 0640 radio radio +/dev/hsicctl16 0640 radio radio +/dev/mhi_*_pipe_14 0640 radio radio +/dev/mhi_*_pipe_16 0640 radio radio +/dev/mhi_*_pipe_32 0640 radio radio +/dev/at_usb0 0640 radio radio +/dev/at_mdm0 0640 radio radio +/dev/video* 0660 system camera +/dev/cvp* 0660 system camera +/dev/media* 0660 system camera +/dev/v4l-subdev* 0660 system camera +/dev/qseecom 0660 system drmrpc +/dev/qce 0660 system drmrpc +/dev/smcinvoke 0660 system drmrpc +/dev/qsee_ipc_irq_spss 0660 system drmrpc +/dev/seemplog 0660 system system +/dev/pft 0660 system drmrpc +/dev/spcom 0660 system system +/dev/spss_utils 0660 system system +/dev/sp_kernel 0660 system system +/dev/sp_nvm 0660 system system +/dev/sp_ssr 0660 system system +/dev/sp_keymaster 0660 system system +/dev/sp_keymaster_ssr 0660 system system +/dev/sec_nvm_* 0660 system system +/dev/cryptoapp 0660 system system +/dev/spdaemon_ssr 0660 system system +/dev/spu_hal_ssr 0660 system system +/dev/iuicc* 0660 system system +/dev/gemini0 0660 system camera +/dev/jpeg0 0660 system camera +/dev/jpeg1 0660 system camera +/dev/jpeg2 0660 system camera +/dev/jpeg3 0660 system camera +/dev/adsprpc-smd 0664 system system +/dev/adsprpc-smd-secure 0644 system system +/dev/system_health_monitor 0644 radio system +/dev/mdss_rotator 0664 system system + +#QDSS +/dev/byte-cntr 0660 system oem_2902 +/dev/mhi_qdss 0660 system oem_2902 +/sys/class/qdss_bridge/mhi_qdss mode 0660 system oem_2902 + +#qg +/dev/qg 0660 system system +/dev/qg_battery 0660 system system + +#qvr +/dev/qvr_external_sensor_ioctl 0660 system system +/dev/bus/usb/* 0660 root usb +/dev/hidraw* 0660 root usb + +# Trustonic TEE device +/dev/mobicore 0600 system system +/dev/mobicore-user 0666 system system + +# wlan +/dev/wcnss_wlan 0660 system system +/dev/wcnss_ctrl 0660 system system +/sys/devices/soc/a000000.qcom,wcnss-wlan/net/wlan0/queues/rx-* rps_cpus 0660 system system +/sys/devices/soc/a000000.qcom,wcnss-wlan/net/p2p0/queues/rx-* rps_cpus 0660 system system +/sys/devices/platform/soc/*.qcom,icnss/net/wlan*/queues/rx-* rps_cpus 0660 system system +/sys/devices/platform/soc/1c00000.qcom,pcie/pci0000:00/0000:00:00.0/0000:01:00.0/net/wlan*/queues/rx-* rps_cpus 0660 system system +/sys/devices/platform/soc/17a10040.qcom,wcn6750/net/wlan*/queues/rx-* rps_cpus 0660 system system +/dev/spidev0.0 0660 system audio +/dev/i2c-7 0660 system audio +/dev/msm_camera/* 0660 system camera +/dev/gemini/ 0660 system camera +/dev/mercury0 0660 system camera +/dev/msm_vidc_reg 0660 system audio +/dev/msm_vidc_dec 0660 system audio +/dev/msm_vidc_dec_sec 0660 system audio +/dev/msm_vidc_enc 0660 system audio +/dev/msm_rotator 0660 system system +/dev/hw_random 0600 root root +/dev/sdsprpc-smd 0660 system system + +#permissions for audio +/dev/wcd_dsp0_control 0660 system audio +/dev/wcd-dsp-glink 0660 system audio +/dev/audio_slimslave 0660 system audio +/dev/msm_qcelp 0660 system audio +/dev/msm_evrc 0660 system audio +/dev/msm_wma 0660 system audio +/dev/msm_wmapro 0660 system audio +/dev/msm_alac 0660 system audio +/dev/msm_ape 0660 system audio +/dev/msm_amrnb 0660 system audio +/dev/msm_amrwb 0660 system audio +/dev/msm_amrwbplus 0660 system audio +/dev/msm_aac 0660 system audio +/dev/msm_multi_aac 0660 system audio +/dev/msm_aac_in 0660 system audio +/dev/msm_qcelp_in 0660 system audio +/dev/msm_evrc_in 0660 system audio +/dev/msm_amrnb_in 0660 system audio +/dev/msm_amrwb_in 0660 system audio +/dev/msm_a2dp_in 0660 system audio +/dev/msm_ac3 0660 system audio +/dev/msm_audio_cal 0660 system audio +/dev/msm_hweffects 0660 system audio +/dev/msm_cad 0660 system audio +/dev/msm_fm 0660 system audio +/dev/msm_mvs 0660 system audio +/dev/msm_pcm_lp_dec 0660 system audio +/dev/msm_preproc_ctl 0660 system audio +/dev/msm_rtac 0660 system audio +/dev/msm_voicememo 0660 system audio +/dev/ttyHSL1 0660 system system +/dev/ttyHS1 0660 system system +/dev/mdm 0660 system radio +/sys/devices/virtual/smdpkt/smdcntl* open_timeout 0664 radio radio +/dev/sdio_tty_ciq_00 0660 system system +/dev/tty_sdio_00 0660 system system +/dev/ttyGS0 0660 system system +/dev/i2c-5 0660 media media +/dev/avtimer 0660 system audio +/dev/spidev2.0 0660 system audio +/dev/spidev22.0 0660 system audio +/dev/spidev10.0 0660 system audio + +# DVB devices +/dev/dvb/adapter0/demux* 0440 media media +/dev/dvb/adapter0/dvr* 0660 media media +/dev/dvb/adapter0/video* 0660 media media + +# Broadcast devices +/dev/tsc_mux0 0660 media media +/dev/tsc_ci0 0660 media media + +# sensors +/dev/sensors 0660 system system +/sys/devices/i2c-12/12-* pollrate_ms 0664 system system +/sys/devices/f9925000.i2c/i2c-0/0-* enable 0660 input system +/sys/devices/f9925000.i2c/i2c-0/0-* poll_delay 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* enable 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* poll_delay 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* enable_wakeup 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* max_latency 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* flush 0660 input system +/sys/devices/soc.0/78b6000.i2c/i2c-0/0-* calibrate 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* enable 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* poll_delay 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* enable_wakeup 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* max_latency 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* flush 0660 input system +/sys/devices/soc.0/78b5000.i2c/i2c-1/1-* calibrate 0660 input system +/sys/devices/virtual/optical_sensors/proximity ps_adc 0660 input system +/sys/devices/virtual/optical_sensors/proximity ps_poll_delay 0660 input system +/sys/devices/virtual/optical_sensors/lightsensor ls_auto 0660 input system +/sys/devices/virtual/optical_sensors/lightsensor ls_poll_delay 0660 input system +/sys/devices/virtual/input/input* poll 0660 input system +/sys/devices/virtual/input/input* pollrate_ms 0660 input system +/sys/devices/soc/78b7000.i2c/i2c-3/3-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-0020/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-0038/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-0038/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-004b/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/78b7000.i2c/i2c-3/3-004b/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/soc/c179000.i2c/i2c-5/5-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/soc/c179000.i2c/i2c-5/5-0020/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/platform/soc/a98000.i2c/i2c-2/2-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/platform/soc/a98000.i2c/i2c-2/2-0020/input/input* secure_touch_enable 0660 system drmrpc +/sys/devices/platform/soc/a84000.i2c/i2c-2/2-0020/input/input* secure_touch 0440 system drmrpc +/sys/devices/platform/soc/a84000.i2c/i2c-2/2-0020/input/input* secure_touch_enable 0660 system drmrpc + +# GNSS Device premissions +/dev/gnss_sirf 0660 gps gps + +# laser sensor access +/sys/devices/virtual/input/input* enable_ps_sensor 0660 system input +/sys/devices/virtual/input/input* set_delay_ms 0660 system input +/sys/devices/virtual/input/input* do_flush 0660 system input +/dev/laser 0660 system camera + +# vm_bms +/dev/vm_bms 0660 system system +/dev/battery_data 0660 system system + +# wlan +/dev/wcnss_wlan 0660 system system +/dev/wcnss_ctrl 0660 system system +/sys/devices/soc/600000.qcom,pcie/pci0000:00/0000:00:00.0/0000:01:00.0/net/wlan0/queues/rx-* rps_cpus 0660 system system +/sys/devices/soc/600000.qcom,pcie/pci0000:00/0000:00:00.0/0000:01:00.0/net/p2p0/queues/rx-* rps_cpus 0660 system system + +# wigig +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/wil6210/fst_link_loss 0660 wifi wifi +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/wil6210/thermal_throttling 0660 system system +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/wil6210/snr_thresh 0660 wifi wifi +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/net/wigig0/queues/rx-0/rps_cpus 0660 system system +/sys/bus/pci/drivers/wil6210* 0000:01:00.0/net/wigig0/gro_flush_timeout 0660 system system +/sys/devices/virtual/net/bond0 queues/rx-0/rps_cpus 0660 system system + +#nfc permissions +/dev/nfc-nci 0660 nfc nfc +/dev/nq-nci 0660 nfc nfc +/dev/assd 0660 nfc nfc + +# UIO devices +/dev/uio0 0660 system system +/dev/uio1 0660 system system +/dev/uio2 0660 system system + +# SSR devices +/dev/subsys_* 0640 system system + +# Ultrasound device +/dev/usf1 0660 system system + +# Ramdump devices +/dev/ramdump* 0640 system system + +# Fingerprint device +/dev/qbt* 0660 system system +/sys/class/fts/touch_aoi aoi_set 0660 root system +/sys/class/fts/touch_aoi power_set 0660 root system + +#ImproveTouch device +/dev/hbtp_input 0660 system system +/dev/hbtp_vm 0660 system system + +# Add device block for FRP +/dev/block/platform/soc/7824900.sdhci/by-name/config 0600 system system +/dev/block/platform/soc/7464900.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/624000.ufshc/by-name/frp 0600 system system +/dev/block/platform/soc/1da4000.ufshc/by-name/frp 0600 system system +/dev/block/platform/soc/c0c4000.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/1d84000.ufshc/by-name/frp 0600 system system +/dev/block/platform/soc/7c4000.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/4744000.sdhci/by-name/frp 0600 system system +/dev/block/platform/soc/4804000.ufshc/by-name/frp 0600 system system + +# This is temporary while using SD card for initial bring-up +/dev/block/platform/soc/8804000.sdhci/by-name/frp 0600 system system + +# Add device block for MISC +/dev/block/platform/soc/7464900.sdhci/by-name/misc 0660 root system +/dev/block/platform/soc/624000.ufshc/by-name/misc 0660 root system +/dev/block/platform/soc/1da4000.ufshc/by-name/misc 0660 root system +/dev/block/platform/soc/c0c4000.sdhci/by-name/misc 0660 root system +/dev/block/platform/soc/1d84000.ufshc/by-name/misc 0660 root system +/dev/block/platform/soc/7c4000.sdhci/by-name/misc 0660 root system +/dev/block/platform/soc/4744000.sdhci/by-name/misc 0660 root system +/dev/block/platform/soc/4804000.ufshc/by-name/misc 0660 root system + +# Kmsg device +/dev/kmsg 0620 root system + +# LED class devices +/sys/class/leds/red delay_on 0640 system system +/sys/class/leds/red delay_off 0640 system system +/sys/class/leds/red breath 0640 system system +/sys/class/leds/red trigger 0640 system system +/sys/class/leds/green delay_on 0640 system system +/sys/class/leds/green delay_off 0640 system system +/sys/class/leds/green breath 0640 system system +/sys/class/leds/green trigger 0640 system system +/sys/class/leds/blue delay_on 0640 system system +/sys/class/leds/blue delay_off 0640 system system +/sys/class/leds/blue breath 0640 system system +/sys/class/leds/blue trigger 0640 system system + +# LED class vibrator +/sys/class/leds/vibrator state 0660 system system +/sys/class/leds/vibrator duration 0660 system system +/sys/class/leds/vibrator activate 0660 system system +/sys/class/leds/vibrator extra 0660 system system +/sys/class/leds/vibrator seq 0660 system system + +# NPU device +/dev/msm_npu 0644 system system + +# Egistec fingerprint +/dev/esfp0 0660 system system + +# Goodix FPS +/dev/goodix_fp 0664 system system + +# Chipone FPS +/dev/fpsensor 0660 system system + +#Focaltech FPS +/dev/focaltech_fp 0660 system system + +# Change permission for FPC fingerprint +/sys/class/fingerprint/fpc1020 nav 0440 system system +/sys/class/fingerprint/fpc1020 irq 0440 system system +/sys/class/fingerprint/fpc1020 irq_cnt 0440 system system +/sys/class/fingerprint/fpc1020 dev_enable 0220 system system +/sys/class/fingerprint/fpc1020 vendor 0444 system system + +#Memory Offline +/sys/devices/system/memory/memory* state 0660 system system + +/sys/devices/virtual/hdcp/msm_hdcp min_level_change 0664 system graphics + +# sys-fs display +/sys/class/graphics/fb* hpd 0664 system graphics +/sys/class/graphics/fb* res_info 0664 system graphics +/sys/class/graphics/fb* vendor_name 0664 system graphics +/sys/class/graphics/fb* product_description 0664 system graphics +/sys/class/graphics/fb* video_mode 0664 system graphics +/sys/class/graphics/fb* format_3d 0664 system graphics +/sys/class/graphics/fb* s3d_mode 0664 system graphics +/sys/class/graphics/fb* dynamic_fps 0664 system graphics +/sys/class/graphics/fb* msm_fb_dfps_mode 0664 system graphics +/sys/class/graphics/fb* hdr_stream 0664 system graphics +/sys/class/graphics/fb* cec/enable 0664 system graphics +/sys/class/graphics/fb* cec/logical_addr 0664 system graphics +/sys/class/graphics/fb* cec/rd_msg 0664 system graphics +/sys/class/graphics/fb* pa 0664 system graphics +/sys/class/graphics/fb* cec/wr_msg 0600 system graphics +/sys/class/graphics/fb* hdcp/tp 0664 system graphics +/sys/class/graphics/fb* hdcp2p2/min_level_change 0660 system graphics +/sys/class/graphics/fb* hdmi_audio_cb 0600 audioserver audio + +/sys/class/graphics/fb* lineptr_value 0664 system graphics +/sys/class/graphics/fb* msm_fb_persist_mode 0664 system graphics + +/sys/class/graphics/fb0 idle_time 0664 system graphics +/sys/class/graphics/fb0 dynamic_fps 0664 system graphics +/sys/class/graphics/fb0 dyn_pu 0664 system graphics +/sys/class/graphics/fb0 modes 0664 system graphics +/sys/class/graphics/fb0 mode 0664 system graphics +/sys/class/graphics/fb0 msm_cmd_autorefresh_en 0664 system graphics +*/ + +/sys/devices/platform/soc/ae00000.qcom,mdss_mdp power/control 0664 system graphics + +#asm330 sensor +#common sensors files +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* buffer/enable 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* buffer/length 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* buffer/watermark 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* discharded_samples 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* current_timestamp_clock 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* hwfifo_flush 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* hwfifo_watermark 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* hwfifo_watermark_max 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* mount_matrix 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* name 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* sampling_frequency 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* sampling_frequency_available 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_timestamp_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_timestamp_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_timestamp_type 0664 system system + +# standard iio accel attributes +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_scale_available 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_x_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_x_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_y_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_y_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_z_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_accel_z_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_x_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_x_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_x_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_y_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_y_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_y_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_z_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_z_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_accel_z_type 0664 system system + +# standard iio gyro attributes +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_scale_available 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_x_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_x_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_y_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_y_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_z_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_anglvel_z_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_x_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_x_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_x_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_y_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_y_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_y_type 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_z_en 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_z_index 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* scan_elements/in_anglvel_z_type 0664 system system + + +# standard iio temp attributes +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_offset 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_raw 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_scale 0664 system system +/sys/devices/platform/soc/*.i2c/i2c-*/*-*/iio:device* in_temp_scale_available 0664 system system + +# I2C +/dev/i2c-* 0660 system system