From db91f66fd2c6555cebec8cf63fc83dbceaa7ffdc Mon Sep 17 00:00:00 2001 From: Krystian Lewandowski Date: Sat, 7 Sep 2019 03:26:33 +0200 Subject: [PATCH] different patching mechanism, battery and thermal zones --- overlays/axp803-battery.dtso | 11 ++++ overlays/sun50i-a64-opp.dtso | 4 +- overlays/sun50i-a64-pinebook-battery.dtso | 7 +++ overlays/sun50i-a64-pwm.dtso | 3 - overlays/sun50i-a64-rpwm.dtso | 3 - overlays/sun50i-a64-sid.dtso | 3 - overlays/sun50i-a64-thermal_zones.dtso | 69 +++++++++++++++++++++++ overlays/sun50i-a64-ths.dtso | 5 +- overlays/sun50i-a64-timer.dtso | 3 - prepare.sh | 45 +++++++++++---- 10 files changed, 124 insertions(+), 29 deletions(-) create mode 100644 overlays/axp803-battery.dtso create mode 100644 overlays/sun50i-a64-pinebook-battery.dtso create mode 100644 overlays/sun50i-a64-thermal_zones.dtso diff --git a/overlays/axp803-battery.dtso b/overlays/axp803-battery.dtso new file mode 100644 index 0000000..3614b15 --- /dev/null +++ b/overlays/axp803-battery.dtso @@ -0,0 +1,11 @@ +/ { + compatible = "allwinner,sun50i-a64"; +}; + +&axp803 { + battery_power_supply: battery-power-supply { + compatible = "x-powers,axp803-battery-power-supply", + "x-powers,axp813-battery-power-supply"; + status = "disabled"; + }; +}; diff --git a/overlays/sun50i-a64-opp.dtso b/overlays/sun50i-a64-opp.dtso index ec95235..d32ae53 100644 --- a/overlays/sun50i-a64-opp.dtso +++ b/overlays/sun50i-a64-opp.dtso @@ -1,6 +1,3 @@ -/dts-v1/; -/plugin/; - / { compatible = "allwinner,sun50i-a64"; }; @@ -63,6 +60,7 @@ clocks = <&ccu 21>; clock-names = "cpu"; cpu-supply = <®_dcdc2>; + #cooling-cells = <2>; }; &{/cpus/cpu@1} { diff --git a/overlays/sun50i-a64-pinebook-battery.dtso b/overlays/sun50i-a64-pinebook-battery.dtso new file mode 100644 index 0000000..4d7ae2d --- /dev/null +++ b/overlays/sun50i-a64-pinebook-battery.dtso @@ -0,0 +1,7 @@ +/ { + compatible = "allwinner,sun50i-a64"; +}; + +&battery_power_supply { + status = "okay"; +}; diff --git a/overlays/sun50i-a64-pwm.dtso b/overlays/sun50i-a64-pwm.dtso index 92c9312..f9aceef 100644 --- a/overlays/sun50i-a64-pwm.dtso +++ b/overlays/sun50i-a64-pwm.dtso @@ -1,6 +1,3 @@ -/dts-v1/; -/plugin/; - / { compatible = "allwinner,sun50i-a64"; }; diff --git a/overlays/sun50i-a64-rpwm.dtso b/overlays/sun50i-a64-rpwm.dtso index 5bf8bd2..93a16eb 100644 --- a/overlays/sun50i-a64-rpwm.dtso +++ b/overlays/sun50i-a64-rpwm.dtso @@ -1,6 +1,3 @@ -/dts-v1/; -/plugin/; - / { compatible = "allwinner,sun50i-a64"; }; diff --git a/overlays/sun50i-a64-sid.dtso b/overlays/sun50i-a64-sid.dtso index 3d1b351..01ecf97 100644 --- a/overlays/sun50i-a64-sid.dtso +++ b/overlays/sun50i-a64-sid.dtso @@ -1,6 +1,3 @@ -/dts-v1/; -/plugin/; - / { compatible = "allwinner,sun50i-a64"; }; diff --git a/overlays/sun50i-a64-thermal_zones.dtso b/overlays/sun50i-a64-thermal_zones.dtso new file mode 100644 index 0000000..c0f5c26 --- /dev/null +++ b/overlays/sun50i-a64-thermal_zones.dtso @@ -0,0 +1,69 @@ +#include + +/ { + compatible = "allwinner,sun50i-a64"; +}; + +&{/} { + thermal-zones { + cpu-thermal { + /* milliseconds */ + polling-delay-passive = <250>; + polling-delay = <1000>; + thermal-sensors = <&ths 0>; + + trips { + cpu_warm: cpu_warm { + temperature = <65000000>; + hysteresis = <2000000>; + type = "passive"; + }; + + cpu_hot_pre: cpu_hot_pre { + temperature = <70000000>; + hysteresis = <2000000>; + type = "passive"; + }; + + cpu_hot: cpu_hot { + temperature = <75000000>; + hysteresis = <2000000>; + type = "passive"; + }; + + cpu_very_hot: cpu_very_hot { + temperature = <90000000>; + hysteresis = <2000000>; + type = "passive"; + }; + }; + + cooling-maps { + cpu_warm_limit_cpu { + trip = <&cpu_warm>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT 2>; + }; + + cpu_hot_pre_limit_cpu { + trip = <&cpu_hot_pre>; + cooling-device = <&cpu0 2 3>; + }; + + cpu_hot_limit_cpu { + trip = <&cpu_hot>; + cooling-device = <&cpu0 3 4>; + }; + + cpu_very_hot_pre_limit_cpu { + trip = <&cpu_very_hot>; + cooling-device = <&cpu0 5 6>; + }; + + cpu_very_hot_limit_cpu { + trip = <&cpu_very_hot>; + cooling-device = <&cpu0 7 THERMAL_NO_LIMIT>; + }; + }; + }; + }; +}; diff --git a/overlays/sun50i-a64-ths.dtso b/overlays/sun50i-a64-ths.dtso index a7c7dd2..6958feb 100644 --- a/overlays/sun50i-a64-ths.dtso +++ b/overlays/sun50i-a64-ths.dtso @@ -1,6 +1,3 @@ -/dts-v1/; -/plugin/; - #include #include #include @@ -18,7 +15,7 @@ clock-names = "apb", "ths"; resets = <&ccu RST_BUS_THS>; reset-names = "apb"; - #thermal-sensor-cells = <2>; + #thermal-sensor-cells = <1>; status = "okay"; nvmem-cells = <&ths_calib>; diff --git a/overlays/sun50i-a64-timer.dtso b/overlays/sun50i-a64-timer.dtso index 0e7bb8f..273cc23 100644 --- a/overlays/sun50i-a64-timer.dtso +++ b/overlays/sun50i-a64-timer.dtso @@ -1,6 +1,3 @@ -/dts-v1/; -/plugin/; - #include / { compatible = "allwinner,sun50i-a64"; diff --git a/prepare.sh b/prepare.sh index 5d2c96b..96b2e5e 100755 --- a/prepare.sh +++ b/prepare.sh @@ -1,27 +1,52 @@ #!/usr/bin/env ksh -FLAVOR=aarch64 +export FLAVOR=aarch64 UBOOT_OVERLAYS_PATH=$(pwd)/overlays cd /usr/ports/sysutils/u-boot WRKDIST=$(make show=WRKDIST) +echo ${WRKDIST} +make uninstall make clean=all make patch cd - -WRKDIST_OVERLAYS_PATH=${WRKDIST}/arch/arm/dts/overlays/arm64 +WRKDIST_DTS_PATH="${WRKDIST}/arch/arm/dts/" +WRKDIST_OVERLAYS_PATH="${WRKDIST}/arch/arm/dts/overlays/" if [ -z "${WRKDIST}" ]; then - echo "no WRKDIST" - exit 1 + echo "no WRKDIST" + exit 1 fi -cd ${WRKDIST} +cd "${WRKDIST}" -rm -rf ${WRKDIST_OVERLAYS_PATH} -mkdir -p ${WRKDIST_OVERLAYS_PATH} +rm -rf "${WRKDIST_OVERLAYS_PATH}" +mkdir -p "${WRKDIST_OVERLAYS_PATH}" -for F in $(find ${UBOOT_OVERLAYS_PATH} -name "sun50i-a64*.dtso"); do - tail -n+3 ${F} > ${WRKDIST_OVERLAYS_PATH}/$(basename ${F}.updated) - echo "#include " >> ${WRKDIST}/arch/arm/dts/sun50i-a64.dtsi +for P in $(find "${UBOOT_OVERLAYS_PATH}" -name "*.dtso"); do + F=$(basename "${P}") + SUFFIX=${F##*-} + TARGET_DTS=${WRKDIST_DTS_PATH}${F%-"${SUFFIX}"}.dts + TARGET_DTSI=${WRKDIST_DTS_PATH}${F%-"${SUFFIX}"}.dtsi + TARGET="" + + if [ -f "${TARGET_DTS}" ]; then + TARGET="${TARGET_DTS}" + elif [ -f "${TARGET_DTSI}" ]; then + TARGET="${TARGET_DTSI}" + fi + + if [ ! -z "${TARGET}" ]; then + cp "${P}" "${WRKDIST_OVERLAYS_PATH}/${F}" + echo -n "Adding ${F} include to $(basename ${TARGET})... " + echo "#include " >> ${TARGET} + echo "OK" + else + echo "Couldn't fid target for ${P} overlay!" + fi done + +cd /usr/ports/sysutils/u-boot +make install +cd -