Skip to content

Commit

Permalink
overlays: Add pwm-pio overlay
Browse files Browse the repository at this point in the history
Add an overlay to enable a single-channel PIO-assisted PWM interface on any
header pin.

Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
pelwell committed Nov 15, 2024
1 parent 903aa45 commit 42e4fa5
Show file tree
Hide file tree
Showing 4 changed files with 52 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 @@ -219,6 +219,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
pwm-2chan.dtbo \
pwm-gpio.dtbo \
pwm-ir-tx.dtbo \
pwm-pio.dtbo \
pwm1.dtbo \
qca7000.dtbo \
qca7000-uart0.dtbo \
Expand Down
8 changes: 8 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -3926,6 +3926,14 @@ Params: gpio_pin Output GPIO (default 18)
func Pin function (default 2 = Alt5)


Name: pwm-pio
Info: Configures a GPIO pin as PIO-assisted PWM output. Unlike hardware PWM,
this can be used on any RP1 GPIO in bank 0 (0-27). Up to 4 are
supported, assuming nothing else is using PIO. Pi 5 only.
Load: dtoverlay=pwm-pio,<param>=<val>
Params: gpio Output GPIO (0-27, default 4)


Name: pwm1
Info: Configures one or two PWM channel on PWM1 (BCM2711 only)
N.B.:
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 @@ -240,6 +240,10 @@
bcm2712;
};

pwm-pio {
bcm2712;
};

pwm1 {
bcm2711;
};
Expand Down
39 changes: 39 additions & 0 deletions arch/arm/boot/dts/overlays/pwm-pio-overlay.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0
// Device tree overlay for RP1 PIO PWM.
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2712";

fragment@0 {
target = <&gpio>;
__overlay__ {
pwm_pio_pins: pwm_pio_pins@4 {
brcm,pins = <4>; /* gpio 4 */
function = "pio";
bias-disable;
};
};
};

fragment@1 {
target-path = "/";
__overlay__ {
pwm_pio: pwm_pio@4 {
compatible = "raspberrypi,pwm-pio-rp1";
pinctrl-names = "default";
pinctrl-0 = <&pwm_pio_pins>;
gpios = <&gpio 4 0>;
};
};
};

__overrides__ {
gpio = <&pwm_pio>,"gpios:4",
<&pwm_pio_pins>,"brcm,pins:0",
/* modify reg values to allow multiple instantiation */
<&pwm_pio>,"reg:0",
<&pwm_pio_pins>,"reg:0";
};
};

0 comments on commit 42e4fa5

Please sign in to comment.