90 lines
2.6 KiB
Bash
Executable file
90 lines
2.6 KiB
Bash
Executable file
#=============================================================================
|
|
# Copyright (c) 2023 Qualcomm Technologies, Inc.
|
|
# All Rights Reserved.
|
|
# Confidential and Proprietary - Qualcomm Technologies, Inc.
|
|
#=============================================================================
|
|
|
|
get_num_logical_cores_in_physical_cluster()
|
|
{
|
|
i=0
|
|
logical_cores=(0 0 0 0 0 0)
|
|
if [ -f /sys/devices/system/cpu/cpu0/topology/cluster_id ] ; then
|
|
physical_cluster="cluster_id"
|
|
else
|
|
physical_cluster="physical_package_id"
|
|
fi
|
|
for i in `ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*`
|
|
do
|
|
if [ -e $i ] ; then
|
|
num_cores=$(cat $i/related_cpus | wc -w)
|
|
first_cpu=$(echo "$i" | sed 's/[^0-9]*//g')
|
|
cluster_id=$(cat /sys/devices/system/cpu/cpu$first_cpu/topology/$physical_cluster)
|
|
logical_cores[cluster_id]=$num_cores
|
|
fi
|
|
done
|
|
cpu_topology=""
|
|
j=0
|
|
physical_cluster_count=$1
|
|
while [[ $j -lt $physical_cluster_count ]]; do
|
|
cpu_topology+=${logical_cores[$j]}
|
|
if [ $j -lt $physical_cluster_count-1 ]; then
|
|
cpu_topology+="_"
|
|
fi
|
|
j=$((j+1))
|
|
done
|
|
echo $cpu_topology
|
|
}
|
|
|
|
#Implementing this mechanism to jump to powersave governor if the script is not running
|
|
#as it would be an indication for devs for debug purposes.
|
|
fallback_setting()
|
|
{
|
|
governor="powersave"
|
|
for i in `ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*`
|
|
do
|
|
if [ -f $i/scaling_governor ] ; then
|
|
echo $governor > $i/scaling_governor
|
|
fi
|
|
done
|
|
}
|
|
|
|
variant=$(get_num_logical_cores_in_physical_cluster "$1")
|
|
echo "CPU topology: ${variant}"
|
|
case "$variant" in
|
|
"3_4_1")
|
|
/vendor/bin/sh /vendor/bin/init.kernel.post_boot-kalama_default_3_4_1.sh
|
|
;;
|
|
"3_2_1")
|
|
/vendor/bin/sh /vendor/bin/init.kernel.post_boot-kalama_3_2_1.sh
|
|
;;
|
|
"3_4_0")
|
|
/vendor/bin/sh /vendor/bin/init.kernel.post_boot-kalama_3_4_0.sh
|
|
;;
|
|
*)
|
|
echo "***WARNING***: Postboot script not present for the variant ${variant}"
|
|
fallback_setting
|
|
;;
|
|
esac
|
|
|
|
# Moto added, yangbq2
|
|
product_specific=`getprop ro.vendor.product.device`
|
|
case "$product_specific" in
|
|
"rtwo")
|
|
if [ $rev == "1.0" ] || [ $rev == "1.1" ]; then
|
|
echo "no specific config for 1.0 or 1.1"
|
|
else
|
|
# configure settings for silver cluster
|
|
echo 1017600 > /sys/devices/system/cpu/cpufreq/policy0/walt/hispeed_freq
|
|
echo 787200 > /sys/devices/system/cpu/cpufreq/policy0/walt/rtg_boost_freq
|
|
# configure settings for gold cluster
|
|
echo 1401600 > /sys/devices/system/cpu/cpufreq/policy3/walt/hispeed_freq
|
|
echo 614400 > /sys/devices/system/cpu/cpufreq/policy3/walt/rtg_boost_freq
|
|
# configure settings for prime cluster
|
|
echo 1593600 > /sys/devices/system/cpu/cpufreq/policy7/walt/hispeed_freq
|
|
fi
|
|
;;
|
|
*)
|
|
echo "no specific config for $product_specific"
|
|
;;
|
|
esac
|
|
# Moto end
|