overlays: Add overlay pwm1
authorPhil Elwell <phil@raspberrypi.com>
Wed, 16 Nov 2022 14:54:08 +0000 (14:54 +0000)
committerPhil Elwell <phil@raspberrypi.com>
Wed, 16 Nov 2022 15:33:37 +0000 (15:33 +0000)
pwm1 enables the second PWM interface found on BCM2711. It can only
be mapped to GPIOs 40 & 41.

See: https://forums.raspberrypi.com/viewtopic.php?t=342458

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
arch/arm/boot/dts/overlays/Makefile
arch/arm/boot/dts/overlays/README
arch/arm/boot/dts/overlays/overlay_map.dts
arch/arm/boot/dts/overlays/pwm1-overlay.dts [new file with mode: 0644]

index c64172e..86014f5 100644 (file)
@@ -183,6 +183,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
        pwm.dtbo \
        pwm-2chan.dtbo \
        pwm-ir-tx.dtbo \
+       pwm1.dtbo \
        qca7000.dtbo \
        qca7000-uart0.dtbo \
        ramoops.dtbo \
index 3973fb9..1665537 100644 (file)
@@ -3216,6 +3216,24 @@ Params: gpio_pin                Output GPIO (default 18)
         func                    Pin function (default 2 = Alt5)
 
 
+Name:   pwm1
+Info:   Configures one or two PWM channel on PWM1 (BCM2711 only)
+        N.B.:
+          1) The onboard analogue audio output uses both PWM channels.
+          2) So be careful mixing audio and PWM.
+        Note that even when only one pin is enabled, both channels are available
+        from the PWM driver, so be careful to use the correct one.
+Load:   dtoverlay=pwm1,<param>=<val>
+Params: clock                   PWM clock frequency (informational)
+        pins_40                 Enable channel 0 (PWM1_0) on GPIO 40
+        pins_41                 Enable channel 1 (PWM1_1) on GPIO 41
+        pins_40_41              Enable channels 0 (PWM1_0) and 1 (PW1_1) on
+                                GPIOs 40 and 41 (default)
+        pull_up                 Enable pull-ups on the PWM pins (default)
+        pull_down               Enable pull-downs on the PWM pins
+        pull_off                Disable pull-downs on the PWM pins
+
+
 Name:   qca7000
 Info:   in-tech's Evaluation Board for PLC Stamp micro
         This uses spi0 and a separate GPIO interrupt to connect the QCA7000.
index 18d8881..627855b 100644 (file)
                renamed = "miniuart-bt";
        };
 
+       pwm1 {
+               bcm2711;
+       };
+
        ramoops {
                bcm2835;
                bcm2711 = "ramoops-pi4";
diff --git a/arch/arm/boot/dts/overlays/pwm1-overlay.dts b/arch/arm/boot/dts/overlays/pwm1-overlay.dts
new file mode 100644 (file)
index 0000000..e1f03b0
--- /dev/null
@@ -0,0 +1,60 @@
+/dts-v1/;
+/plugin/;
+
+#include <dt-bindings/pinctrl/bcm2835.h>
+
+/ {
+       compatible = "brcm,bcm2711";
+       
+       fragment@0 {
+               target = <&pins>;
+               __overlay__ {
+                       brcm,pins = <40 41>;
+               };
+       };
+       
+       fragment@1 {
+               target = <&pins>;
+               __dormant__ {
+                       brcm,pins = <40>;
+               };
+       };
+       
+       fragment@2 {
+               target = <&pins>;
+               __dormant__ {
+                       brcm,pins = <41>;
+               };
+       };
+       
+       fragment@3 {
+               target = <&gpio>;
+               __overlay__ {
+                       pins: pwm1_overlay_pins {
+                               brcm,pins = <40 41>;
+                               brcm,function = <BCM2835_FSEL_ALT0>;
+                               brcm,pull = <BCM2835_PUD_UP>;
+                       };
+               };
+       };
+
+       fragment@4 {
+               target = <&pwm1>;
+               pwm: __overlay__ {
+                       status = "okay";
+                       assigned-clock-rates = <100000000>;
+                       pinctrl-names = "default";
+                       pinctrl-0 = <&pins>;
+               };
+       };
+
+       __overrides__ {
+               clock = <&pwm>, "assigned-clock-rates:0";
+               pins_40_41 = <0>,"+0-1-2";
+               pins_40 = <0>,"-0+1-2";
+               pins_41 = <0>,"-0-1+2";
+               pull_up = <&pins>, "brcm,pull:0=", <BCM2835_PUD_UP>;
+               pull_down = <&pins>, "brcm,pull:0=", <BCM2835_PUD_DOWN>;
+               pull_off = <&pins>, "brcm,pull:0=", <BCM2835_PUD_OFF>;
+       };
+};