autocore: use mhz to calc cpufreq for mvebu

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit 00c38b88e052d04b8932c76d01f26a082166be5c)
This commit is contained in:
Tianling Shen 2022-10-20 20:23:09 +08:00
parent 6ab19dcb51
commit f834fa99ce
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
2 changed files with 21 additions and 12 deletions

View File

@ -11,7 +11,8 @@ PKG_RELEASE:=$(COMMITCOUNT)
PKG_CONFIG_DEPENDS:= \
CONFIG_TARGET_bcm27xx \
CONFIG_TARGET_bcm53xx
CONFIG_TARGET_bcm53xx \
CONFIG_TARGET_mvebu
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/target.mk
@ -21,7 +22,8 @@ define Package/autocore-arm
MAINTAINER:=CN_SZTL
DEPENDS:=@(arm||aarch64) \
+TARGET_bcm27xx:bcm27xx-userland \
+TARGET_bcm53xx:nvram
+TARGET_bcm53xx:nvram \
+TARGET_mvebu:mhz
VARIANT:=arm
endef

View File

@ -21,16 +21,22 @@ case "$DISTRIB_TARGET" in
cpu_freq="$(( $(vcgencmd measure_clock arm | awk -F '=' '{print $2}') / 1000000 ))Mhz" ;;
"bcm53xx"/*)
cpu_freq="$(nvram get clkfreq | awk -F ',' '{print $1}')MHz" ;;
"mvebu"/*)
cpu_freq="$(awk -F ': ' '/BogoMIPS/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz" ;;
"x86"/*)
cpu_freq="$(awk -F ': ' '/MHz/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz"
"mvebu/cortexa72")
cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")"
big_cpu_freq="$(awk '{printf("%.fMHz ", $0 / 1000)}' "$CPUFREQ_PATH/policy2/cpuinfo_cur_freq")"
;;
"mvebu"/*)
cpu_freq="$(mhz | awk -F 'cpu_MHz=' '{printf("%.fMHz",$2)}')" ;;
"rockchip"/*)
cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")"
[ ! -e "$CPUFREQ_PATH/policy4/cpuinfo_cur_freq" ] || \
big_cpu_freq="$(awk '{printf("%.fMHz ", $0 / 1000)}' "$CPUFREQ_PATH/policy4/cpuinfo_cur_freq")"
;;
"x86"/*)
cpu_freq="$(awk -F ': ' '/MHz/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz" ;;
*)
[ ! -e "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq" ] || \
cpu_freq="$(awk '{printf("%.fMHz", $0 / 1000)}' "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq")"
[ ! -e "$CPUFREQ_PATH/policy4/cpuinfo_cur_freq" ] || \
big_cpu_freq="$(awk '{printf("%.fMHz ", $0 / 1000)}' "$CPUFREQ_PATH/policy4/cpuinfo_cur_freq")"
;;
esac
@ -38,10 +44,11 @@ case "$DISTRIB_TARGET" in
"bcm27xx"/*)
cpu_temp="$(vcgencmd measure_temp | awk -F '=' '{print $2}' | awk -F "'" '{print $1}')°C" ;;
"x86"/*)
# Intel
cpu_temp="$(sensors "coretemp-*" 2>"/dev/null" | grep -E "(Package id |Core )" | grep -Eo "\+[0-9.]*°C" | head -n1 | tr -d "+")"
# AMD
[ -n "${cpu_temp}" ] || cpu_temp="$(sensors "k*temp-*" 2>"/dev/null" | awk '/Tdie/ {print $2}' | head -n1 | tr -d "+")"
if grep -q "GenuineIntel" "/proc/cpuinfo"; then
cpu_temp="$(sensors "coretemp-*" 2>"/dev/null" | grep -E "(Package id |Core )" | grep -Eo "\+[0-9.]*°C" | head -n1 | tr -d "+")"
else grep -q "AuthenticAMD" "/proc/cpuinfo"; then
cpu_temp="$(sensors "k*temp-*" 2>"/dev/null" | awk '/Tdie/ {print $2}' | head -n1 | tr -d "+")"
fi
;;
*)
[ ! -e "$THERMAL_PATH/thermal_zone0/temp" ] || \