From a787d4495c5997483ee0214ebab3c878520a18dc Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Thu, 7 Nov 2024 11:41:33 +0000 Subject: [PATCH] overlays: Add pwm-pio overlay Add an overlay to enable a single-channel PIO-assisted PWM interface on any header pin. Signed-off-by: Phil Elwell --- arch/arm/boot/dts/overlays/Makefile | 1 + arch/arm/boot/dts/overlays/README | 8 ++++ arch/arm/boot/dts/overlays/overlay_map.dts | 4 ++ .../arm/boot/dts/overlays/pwm-pio-overlay.dts | 38 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 arch/arm/boot/dts/overlays/pwm-pio-overlay.dts diff --git a/arch/arm/boot/dts/overlays/Makefile b/arch/arm/boot/dts/overlays/Makefile index 6b60068b125c15..560a63c38cc2e2 100644 --- a/arch/arm/boot/dts/overlays/Makefile +++ b/arch/arm/boot/dts/overlays/Makefile @@ -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 \ diff --git a/arch/arm/boot/dts/overlays/README b/arch/arm/boot/dts/overlays/README index 43039b9b6a7a27..d1ed7f64ec5a71 100644 --- a/arch/arm/boot/dts/overlays/README +++ b/arch/arm/boot/dts/overlays/README @@ -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,= +Params: gpio Output GPIO (0-27, default 4) + + Name: pwm1 Info: Configures one or two PWM channel on PWM1 (BCM2711 only) N.B.: diff --git a/arch/arm/boot/dts/overlays/overlay_map.dts b/arch/arm/boot/dts/overlays/overlay_map.dts index 2ddf4c7f4323bb..53256828de0ab5 100644 --- a/arch/arm/boot/dts/overlays/overlay_map.dts +++ b/arch/arm/boot/dts/overlays/overlay_map.dts @@ -240,6 +240,10 @@ bcm2712; }; + pwm-pio { + bcm2712; + }; + pwm1 { bcm2711; }; diff --git a/arch/arm/boot/dts/overlays/pwm-pio-overlay.dts b/arch/arm/boot/dts/overlays/pwm-pio-overlay.dts new file mode 100644 index 00000000000000..2ad79dfbaf0cb5 --- /dev/null +++ b/arch/arm/boot/dts/overlays/pwm-pio-overlay.dts @@ -0,0 +1,38 @@ +// 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"; + }; +};