Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:common:applications:gpio:pwm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:sbc:common:applications:gpio:pwm [2023/11/07 04:55]
nick [Enable PWM]
products:sbc:common:applications:gpio:pwm [2024/08/22 02:40] (current)
nick
Line 17: Line 17:
  
 ===== Enable PWM ===== ===== Enable PWM =====
 +
 +==== Linux ====
 +
  
 In order to use the PWM, you need to enable the PWM function via [[products:sbc:common:configurations:device-tree-overlay|Device Tree Overlay]]. In order to use the PWM, you need to enable the PWM function via [[products:sbc:common:configurations:device-tree-overlay|Device Tree Overlay]].
Line 122: Line 125:
 </tabbox> </tabbox>
  
 +
 +==== Android ====
 +
 +<tabbox VIM4>
 +
 +The ''PWM'' function is disabled by default, you need to modify the dts to enable it.
 +
 +```diff
 +diff --git a/arch/arm64/boot/dts/amlogic/kvim4.dts b/arch/arm64/boot/dts/amlogic/kvim4.dts
 +--- a/arch/arm64/boot/dts/amlogic/kvim4.dts
 ++++ b/arch/arm64/boot/dts/amlogic/kvim4.dts
 + &pwm_ef {
 ++    pinctrl-names = "default";
 ++    pinctrl-0 = <&pwm_f_pins>;
 +        status = "okay";
 + };
 + 
 +diff --git a/arch/arm64/boot/dts/amlogic/kvim4n.dts b/arch/arm64/boot/dts/amlogic/kvim4n.dts
 +--- a/arch/arm64/boot/dts/amlogic/kvim4n.dts
 ++++ b/arch/arm64/boot/dts/amlogic/kvim4n.dts
 + &pwm_ef {
 ++    pinctrl-names = "default";
 ++    pinctrl-0 = <&pwm_f_pins>;
 +        status = "okay";
 + };
 + 
 +diff --git a/arch/arm64/boot/dts/amlogic/mesont7_an400-panel.dtsi b/arch/arm64/boot/dts/amlogic/mesont7_an400-panel.dtsi
 +--- a/arch/arm64/boot/dts/amlogic/mesont7_an400-panel.dtsi
 ++++ b/arch/arm64/boot/dts/amlogic/mesont7_an400-panel.dtsi
 +@@ -1442,13 +1442,13 @@
 + 
 +        backlight1{
 +                compatible = "amlogic, backlight-t7";
 +-               status = "okay";
 ++               status = "disabled";
 +                index = <1>;
 +                key_valid = <0>;
 +                pinctrl-names = "pwm_on",
 +                                "pwm_off";
 +-               pinctrl-0 = <&pwm_f_pins>;
 +-               pinctrl-1 = <&bl1_pwm_off_pins>;
 +                pinctrl_version = <2>; /* for uboot */
 +                interrupts = <0 197 1
 +
 +```
 +
 +<tabbox VIM1S>
 +
 +The ''PWM'' function is disabled by default, you need to modify the dts to enable it.
 +
 +```diff
 +--- a/arch/arm64/boot/dts/amlogic/kvim1s.dts
 ++++ b/arch/arm64/boot/dts/amlogic/kvim1s.dts
 +@@ -1411,8 +1411,8 @@
 + };
 + 
 + &pwm_ef {
 +-       /*pinctrl-0 = <&pwm_f_pins2>;*/
 +-       /*pinctrl-names = "default";*/
 ++       pinctrl-0 = <&pwm_f_pins2>;
 ++       pinctrl-names = "default";
 +        status = "okay";
 + };
 +
 +```
 +</tabbox>
  
 ===== Control PWM ===== ===== Control PWM =====
Line 153: Line 222:
 echo 1 | sudo tee /sys/class/pwm/pwmchip0/pwm1/enable echo 1 | sudo tee /sys/class/pwm/pwmchip0/pwm1/enable
 ``` ```
 +
 </tabbox> </tabbox>
  
Line 177: Line 247:
 echo 0 | sudo tee /sys/class/pwm/pwmchip0/pwm1/enable echo 0 | sudo tee /sys/class/pwm/pwmchip0/pwm1/enable
 ``` ```
 +
 </tabbox> </tabbox>
  
Last modified: 2023/11/07 04:55 by nick