From 202902f042780ea06ec2d1a0f9de6f4f957ecb5e Mon Sep 17 00:00:00 2001 From: Luke go Date: Tue, 18 Aug 2020 12:24:15 +0900 Subject: [PATCH] ODROID-COMMON: arm64/dts: overlay: Add pwm examples. - N2 - pwm_c(33) - pwm fan. - pwm_d(35) - pwm backlight. - C4 - pwm_a(33) - pwm fan. - pwm_b(35) - pwm backlight. Change-Id: If5382b0f5fa515d74d547b1cb20107be5ad813bd --- .../dts/amlogic/overlays/odroidc4/Makefile | 7 +- .../overlays/odroidc4/pwm_a-pwmfan.dts | 75 +++++++++++++++++++ .../overlays/odroidc4/pwm_b-backlight.dts | 42 +++++++++++ .../dts/amlogic/overlays/odroidn2/Makefile | 7 +- .../overlays/odroidn2/pwm_c-pwmfan.dts | 75 +++++++++++++++++++ .../overlays/odroidn2/pwm_d-backlight.dts | 42 +++++++++++ arch/arm64/configs/odroidc4_android_defconfig | 2 +- arch/arm64/configs/odroidn2_android_defconfig | 2 +- arch/arm64/configs/odroidn2_defconfig | 2 +- 9 files changed, 249 insertions(+), 5 deletions(-) create mode 100644 arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_a-pwmfan.dts create mode 100644 arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_b-backlight.dts create mode 100644 arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_c-pwmfan.dts create mode 100644 arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_d-backlight.dts diff --git a/arch/arm64/boot/dts/amlogic/overlays/odroidc4/Makefile b/arch/arm64/boot/dts/amlogic/overlays/odroidc4/Makefile index 8e5b0f15f94d..5867b9e439cd 100644 --- a/arch/arm64/boot/dts/amlogic/overlays/odroidc4/Makefile +++ b/arch/arm64/boot/dts/amlogic/overlays/odroidc4/Makefile @@ -12,7 +12,12 @@ dtbo-$(CONFIG_ARCH_MESON64_ODROIDC4) += spi0.dtbo \ sx865x-i2c1.dtbo \ pcf8563.dtbo \ onewire.dtbo \ - can0.dtbo + can0.dtbo \ + pwm_ab.dtbo \ + pwm_cd.dtbo \ + pwm_ef.dtbo \ + pwm_a-pwmfan.dtbo \ + pwm_b-backlight.dtbo targets += $(dtbo-y) always := $(dtbo-y) diff --git a/arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_a-pwmfan.dts b/arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_a-pwmfan.dts new file mode 100644 index 000000000000..e9acda3e2379 --- /dev/null +++ b/arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_a-pwmfan.dts @@ -0,0 +1,75 @@ +/dts-v1/; +/plugin/; + +#include +#include +#include + +/{ + fragment@0 { + // pwm_ab + // This activates pwm_ab. + target = <&pwm_ab>; + + __overlay__ { + status = "okay"; + pinctrl-names = "pwm_pins"; + pinctrl-0 = <&pwm_a_pins &pwm_b_pins2>; + }; + }; + + fragment@1 { + target-path = "/"; + + __overlay__ { + pwmcfan: pwm_c-fan { + compatible = "pwm-fan"; + status = "okay"; + #cooling-cells = <2>; + cooling-levels = <0 128 180 240>; + pwms = <&pwm_ab MESON_PWM_0 40000 0>; + }; + }; + }; + + fragment@2 { + target = <&soc_thermal>; + + __overlay__ { + trips { + pwmc_fan_low: trip-point@7 { + temperature = <65000>; + hysteresis = <5000>; + type = "active"; + }; + pwmc_fan_mid: trip-point@8 { + temperature = <75000>; + hysteresis = <5000>; + type = "active"; + }; + pwmc_fan_high: trip-point@9 { + temperature = <90000>; + hysteresis = <5000>; + type = "active"; + }; + }; + cooling-maps { + pwmc_fan_cooling_map0 { + trip = <&pwmc_fan_low>; + cooling-device = <&pwmcfan THERMAL_NO_LIMIT 1>; + contribution = <1024>; + }; + pwmc_fan_cooling_map1 { + trip = <&pwmc_fan_mid>; + cooling-device = <&pwmcfan THERMAL_NO_LIMIT 2>; + contribution = <1024>; + }; + pwmc_fan_cooling_map2 { + trip = <&pwmc_fan_high>; + cooling-device = <&pwmcfan 3 THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + }; + }; + }; +}; diff --git a/arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_b-backlight.dts b/arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_b-backlight.dts new file mode 100644 index 000000000000..ee1c1f9239df --- /dev/null +++ b/arch/arm64/boot/dts/amlogic/overlays/odroidc4/pwm_b-backlight.dts @@ -0,0 +1,42 @@ +/dts-v1/; +/plugin/; + +#include +#include + +/{ + fragment@0 { + // pwm_ab + // This activates pwm_ab. + target = <&pwm_ab>; + + __overlay__ { + status = "okay"; + pinctrl-names = "pwm_pins"; + pinctrl-0 = <&pwm_a_pins &pwm_b_pins2>; + }; + }; + + fragment@1 { + target-path = "/"; + + __overlay__ { + backlight: backlight { + compatible = "pwm-backlight"; + brightness-levels = <0 + 8 16 24 32 + 40 48 56 64 + 72 80 88 96 + 104 112 120 128 + 136 144 152 160 + 168 176 184 192 + 200 208 216 224 + 232 240 248 255 + >; + default-brightness-level = <16>; + pwms = <&pwm_ab MESON_PWM_1 1000000 0>; + status = "okay"; + }; + }; + }; +}; diff --git a/arch/arm64/boot/dts/amlogic/overlays/odroidn2/Makefile b/arch/arm64/boot/dts/amlogic/overlays/odroidn2/Makefile index 6344efaf1f47..274530447195 100644 --- a/arch/arm64/boot/dts/amlogic/overlays/odroidn2/Makefile +++ b/arch/arm64/boot/dts/amlogic/overlays/odroidn2/Makefile @@ -12,9 +12,14 @@ dtbo-$(CONFIG_ARCH_MESON64_ODROIDN2) += spi0.dtbo \ saradc.dtbo \ irblaster.dtbo \ odroidn2-opp.dtbo \ + odroidn2_plus-opp.dtbo \ onewire.dtbo \ can0.dtbo \ - fanspeed-full.dtbo + fanspeed-full.dtbo \ + pwm_cd.dtbo \ + pwm_ef.dtbo \ + pwm_c-pwmfan.dtbo \ + pwm_d-backlight.dtbo targets += $(dtbo-y) always := $(dtbo-y) diff --git a/arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_c-pwmfan.dts b/arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_c-pwmfan.dts new file mode 100644 index 000000000000..14c0b4564c00 --- /dev/null +++ b/arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_c-pwmfan.dts @@ -0,0 +1,75 @@ +/dts-v1/; +/plugin/; + +#include +#include +#include + +/{ + fragment@0 { + // pwm_cd + // This activates pwm_cd. + target = <&pwm_cd>; + + __overlay__ { + status = "okay"; + pinctrl-names = "pwm_pins"; + pinctrl-0 = <&pwm_c_pins2 &pwm_d_pins2>; + }; + }; + + fragment@1 { + target-path = "/"; + + __overlay__ { + pwmcfan: pwm_c-fan { + compatible = "pwm-fan"; + status = "okay"; + #cooling-cells = <2>; + cooling-levels = <0 128 180 240>; + pwms = <&pwm_cd MESON_PWM_0 40000 0>; + }; + }; + }; + + fragment@2 { + target = <&soc_thermal>; + + __overlay__ { + trips { + pwmc_fan_low: trip-point@7 { + temperature = <65000>; + hysteresis = <5000>; + type = "active"; + }; + pwmc_fan_mid: trip-point@8 { + temperature = <75000>; + hysteresis = <5000>; + type = "active"; + }; + pwmc_fan_high: trip-point@9 { + temperature = <90000>; + hysteresis = <5000>; + type = "active"; + }; + }; + cooling-maps { + pwmc_fan_cooling_map0 { + trip = <&pwmc_fan_low>; + cooling-device = <&pwmcfan THERMAL_NO_LIMIT 1>; + contribution = <1024>; + }; + pwmc_fan_cooling_map1 { + trip = <&pwmc_fan_mid>; + cooling-device = <&pwmcfan THERMAL_NO_LIMIT 2>; + contribution = <1024>; + }; + pwmc_fan_cooling_map2 { + trip = <&pwmc_fan_high>; + cooling-device = <&pwmcfan 3 THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + }; + }; + }; +}; diff --git a/arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_d-backlight.dts b/arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_d-backlight.dts new file mode 100644 index 000000000000..81c5ec15956b --- /dev/null +++ b/arch/arm64/boot/dts/amlogic/overlays/odroidn2/pwm_d-backlight.dts @@ -0,0 +1,42 @@ +/dts-v1/; +/plugin/; + +#include +#include + +/{ + fragment@0 { + // pwm_cd + // This activates pwm_cd. + target = <&pwm_cd>; + + __overlay__ { + status = "okay"; + pinctrl-names = "pwm_pins"; + pinctrl-0 = <&pwm_c_pins2 &pwm_d_pins2>; + }; + }; + + fragment@1 { + target-path = "/"; + + __overlay__ { + backlight: backlight { + compatible = "pwm-backlight"; + brightness-levels = <0 + 8 16 24 32 + 40 48 56 64 + 72 80 88 96 + 104 112 120 128 + 136 144 152 160 + 168 176 184 192 + 200 208 216 224 + 232 240 248 255 + >; + default-brightness-level = <16>; + pwms = <&pwm_cd MESON_PWM_1 1000000 0>; + status = "okay"; + }; + }; + }; +}; diff --git a/arch/arm64/configs/odroidc4_android_defconfig b/arch/arm64/configs/odroidc4_android_defconfig index fafe743453af..f901dbc8e6b5 100644 --- a/arch/arm64/configs/odroidc4_android_defconfig +++ b/arch/arm64/configs/odroidc4_android_defconfig @@ -3290,7 +3290,7 @@ CONFIG_LCD_CLASS_DEVICE=m # CONFIG_LCD_HX8357 is not set CONFIG_BACKLIGHT_CLASS_DEVICE=y CONFIG_BACKLIGHT_GENERIC=y -# CONFIG_BACKLIGHT_PWM is not set +CONFIG_BACKLIGHT_PWM=y # CONFIG_BACKLIGHT_PM8941_WLED is not set # CONFIG_BACKLIGHT_ADP8860 is not set # CONFIG_BACKLIGHT_ADP8870 is not set diff --git a/arch/arm64/configs/odroidn2_android_defconfig b/arch/arm64/configs/odroidn2_android_defconfig index d9ae7c869ac9..a97e5129cddf 100644 --- a/arch/arm64/configs/odroidn2_android_defconfig +++ b/arch/arm64/configs/odroidn2_android_defconfig @@ -3290,7 +3290,7 @@ CONFIG_LCD_CLASS_DEVICE=m # CONFIG_LCD_HX8357 is not set CONFIG_BACKLIGHT_CLASS_DEVICE=y CONFIG_BACKLIGHT_GENERIC=y -# CONFIG_BACKLIGHT_PWM is not set +CONFIG_BACKLIGHT_PWM=y # CONFIG_BACKLIGHT_PM8941_WLED is not set # CONFIG_BACKLIGHT_ADP8860 is not set # CONFIG_BACKLIGHT_ADP8870 is not set diff --git a/arch/arm64/configs/odroidn2_defconfig b/arch/arm64/configs/odroidn2_defconfig index e692086a9a71..e2a97253e541 100644 --- a/arch/arm64/configs/odroidn2_defconfig +++ b/arch/arm64/configs/odroidn2_defconfig @@ -3244,7 +3244,7 @@ CONFIG_LCD_CLASS_DEVICE=m # CONFIG_LCD_HX8357 is not set CONFIG_BACKLIGHT_CLASS_DEVICE=y CONFIG_BACKLIGHT_GENERIC=y -# CONFIG_BACKLIGHT_PWM is not set +CONFIG_BACKLIGHT_PWM=y # CONFIG_BACKLIGHT_PM8941_WLED is not set # CONFIG_BACKLIGHT_ADP8860 is not set # CONFIG_BACKLIGHT_ADP8870 is not set