Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5844

Advanced users • Re: Pi5 - PWM on GPIO 18

$
0
0
Hmm, I'm on this as well. Prepared an overlay, seems working but throws one error when it comes to setting the PWM frequency.

Here's the overlay

Code:

/* * pwm-gpio12to15-pi5-overlay.dts *//dts-v1/;/plugin/;//#include <dt-bindings/gpio/gpio.h>//#include <dt-bindings/leds/common.h>/ {compatible = "brcm,bcm2712";fragment@0 {target = <&rp1_gpio>;__overlay__ {pwm_pins: pwm_pins {pins = "gpio12", "gpio13", "gpio14", "gpio15";function = "pwm0", "pwm0", "pwm0", "pwm0";};};};fragment@1 {target = <&rp1_pwm0>;frag1: __overlay__ {pinctrl-names = "default";pinctrl-0 = <&pwm_pins>;/* in Hz *//* Max supported frequency is 76.8MHz *//* https://forums.raspberrypi.com/viewtopic.php?p=2199962#p2199885 */assigned-clock-rates = <75000000>;status = "okay";};};fragment@2 {target-path = "/";__overlay__ {leds: leds@0 {compatible = "pwm-leds";     status = "okay";// available PWM range for LED 0 - 255// PWM LED on PWM0.0 on GPIO12status0: status0 {label = "status0";pwms = <&rp1_pwm0 0 3500000 0>;pwm-names = "status0";linux,default-trigger = "none";};// PWM LED on PWM0.1 on GPIO13status1: status1 {label = "status1";pwms = <&rp1_pwm0 1 3500000 0>;pwm-names = "status1";linux,default-trigger = "default-on";};// PWM LED on PWM0.2 on GPIO14status2: status02 {label = "status2";pwms = <&rp1_pwm0 2 3500000 0>;pwm-names = "status2";linux,default-trigger = "none";};// PWM LED on PWM0.3 on GPIO15status3: status3 {label = "status3";pwms = <&rp1_pwm0 3 3500000 0>;pwm-names = "status3";linux,default-trigger = "none";};};};};};
In viewtopic.php?p=2199962#p2199885 it was stated that RP1 max PWM frequency is 76.8MHz. Hence I'm trying to stay below that limit with

Code:

assigned-clock-rates = <75000000>;
Doesn't work because I see

Code:

pi@book13th:~ $ dmesg -l warn,err[    1.275113] F2FS not supported on PAGE_SIZE(16384) != 4096[    2.174147] brcm-pcie 1000110000.pcie: link down[    3.031359] clk: couldn't set clk_pwm0 clk rate to 75000000 (-22), current rate: 30720000[    7.144801] rpivid_hevc: module is from the staging directory, the quality is unknown, you have been warned.[    7.208463] hci_uart_bcm serial0-0: supply vbat not found, using dummy regulator[    7.208511] hci_uart_bcm serial0-0: supply vddio not found, using dummy regulator[    7.971139] alsactl[600]: memfd_create() called without MFD_EXEC or MFD_NOEXEC_SEAL set[    7.971139] alsactl[599]: memfd_create() called without MFD_EXEC or MFD_NOEXEC_SEAL set
Sorry, don't know what causes the 'F2FS not supported on PAGE_SIZE(16384) != 4096' as this DUT was used for some DT overlay compiling already.

Anyhow, my PWM0.0 to PWM0.3 are working (status1 is 'default-on', duty of status2=PWM0.2 was changed to 10 and then to 128)

Code:

pi@book13th:~ $ sudo cat /sys/kernel/debug/pwmplatform/1f0009c000.pwm, 4 PWM devices pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-2   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-3   (cooling_fan         ): requested enabled period: 41566 ns duty: 24450 ns polarity: inverse usage_powerplatform/1f00098000.pwm, 4 PWM devices pwm-0   (status0             ): requested enabled period: 3500000 ns duty: 0 ns polarity: normal pwm-1   (status1             ): requested enabled period: 3500000 ns duty: 3500000 ns polarity: normal pwm-2   (status2             ): requested enabled period: 3500000 ns duty: 0 ns polarity: normal pwm-3   (status3             ): requested enabled period: 3500000 ns duty: 0 ns polarity: normalplatform/107d517a80.pwm, 2 PWM devices pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normalpi@book13th:~ $ sudo cat /sys/kernel/debug/pwmplatform/1f0009c000.pwm, 4 PWM devices pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-2   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-3   (cooling_fan         ): requested enabled period: 41566 ns duty: 14670 ns polarity: inverse usage_powerplatform/1f00098000.pwm, 4 PWM devices pwm-0   (status0             ): requested enabled period: 3500000 ns duty: 0 ns polarity: normal pwm-1   (status1             ): requested enabled period: 3500000 ns duty: 3500000 ns polarity: normal pwm-2   (status2             ): requested enabled period: 3500000 ns duty: 137254 ns polarity: normal pwm-3   (status3             ): requested enabled period: 3500000 ns duty: 0 ns polarity: normalplatform/107d517a80.pwm, 2 PWM devices pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normalpi@book13th:~ $ sudo cat /sys/kernel/debug/pwmplatform/1f0009c000.pwm, 4 PWM devices pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-2   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-3   (cooling_fan         ): requested enabled period: 41566 ns duty: 14670 ns polarity: inverse usage_powerplatform/1f00098000.pwm, 4 PWM devices pwm-0   (status0             ): requested enabled period: 3500000 ns duty: 0 ns polarity: normal pwm-1   (status1             ): requested enabled period: 3500000 ns duty: 3500000 ns polarity: normal pwm-2   (status2             ): requested enabled period: 3500000 ns duty: 1756862 ns polarity: normal pwm-3   (status3             ): requested enabled period: 3500000 ns duty: 0 ns polarity: normalplatform/107d517a80.pwm, 2 PWM devices pwm-0   ((null)              ): period: 0 ns duty: 0 ns polarity: normal pwm-1   ((null)              ): period: 0 ns duty: 0 ns polarity: normal

Code:

...12: a0    pd | lo // GPIO12 = PWM0_CHAN013: a0    pd | hi // GPIO13 = PWM0_CHAN114: a0    pd | lo // GPIO14 = PWM0_CHAN215: a0    pd | lo // GPIO15 = PWM0_CHAN3...
https://paste.debian.net/hidden/f018c21b/


Question: How to set the PWM clock frequency when using 'rp1_pwm0'?

With reference to my linked threat - when configuring PWM0.0 like below (different compatibility string) I don't see that error and PWM on GPIO12 is active as well.

Code:

compatible = "brcm,bcm2835";fragment@0 {target = <&gpio>;__overlay__ {pwm_pins: pwm_pins {brcm,pins = <12>;brcm,function = <4>; /* ALT4 = PWM out */brcm,pull = <0>;};};};fragment@1 {target = <&pwm>;frag1: __overlay__ {pinctrl-names = "default";pinctrl-0 = <&pwm_pins>;/* in Hz */assigned-clock-rates = <750000000>;status = "okay";};};

Statistics: Posted by aBUGSworstnightmare — Wed Mar 06, 2024 4:46 pm



Viewing all articles
Browse latest Browse all 5844

Trending Articles