Skip to content

Commit

Permalink
overlays: Add overlay pwm1
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pelwell authored and popcornmix committed Nov 21, 2022
1 parent 9628979 commit 56da667
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm/boot/dts/overlays/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
18 changes: 18 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -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 pulls 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.
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/overlays/overlay_map.dts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
renamed = "miniuart-bt";
};

pwm1 {
bcm2711;
};

ramoops {
bcm2835;
bcm2711 = "ramoops-pi4";
Expand Down
60 changes: 60 additions & 0 deletions arch/arm/boot/dts/overlays/pwm1-overlay.dts
Original file line number Diff line number Diff line change
@@ -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>;
};
};

0 comments on commit 56da667

Please sign in to comment.