Export a PWM regularly (without LED Driver)


Does one known how to change the device tree so that a pwm is not attached to the pwm_leds driver. I need to be able to control the frequency (period) from user space. in my case PWM. setting it to a lower value with the led driver got the frequency within acceptable range but we require changing at runtime.


 	pwmleds {
 		compatible = "pwm-leds";
 #ifndef PCAP
 #if 0
                 ledpwm2 {
 			label = "PWM<B>";
 			pwms = <&pwm1 0 2000>;
 			max-brightness = <255>;
 		ledpwm3 {
 			label = "PWM<C>";
 			pwms = <&pwm4 0 50000>;
 			max-brightness = <255>;
 		ledpwm4 {
 			label = "PWM<D>";
 			pwms = <&pwm2 0 50000>;
 			max-brightness = <255>;

Turns out just removing the entry under pwmleds then allows to use the node under /sys/class/pwm/pwmchip?
where in my case chip 0 mapped to PWM from the device tree

The PWM channels are exported from the PWM driver. The nodes listed in your question are all about binding the available PWM channels to the PWM LED driver. Hence removing those nodes (or disabling them) should allow free access through sysfs.

Note that also the backlight driver uses a PWM channel, depending on which channels you use you might want to disable/remove that node too.

I’ve got the same issue with the Colibri T30. I’ve created the attached patch, but it just removes the /sys/class/leds objects, but no other PWM objects appear.

As far as I remember does the downstream Colibri T30 Linux kernel being part of our BSP not feature the same generic sysfs PWM binding as of yet which was the reason for us to add that PWM LED stuff in the first place.


I’ve got a raw piezo connected to a PWM line, but currently it only outputs at 12kHz. Is there a way to shift the frequency down (even if we can’t control it from userspace)? I’d be happy with a plain 1kHz tone.

Changing the line

.pwm_period_ns = 19600,

to a higher value (196000) doesn’t seem to do anything.

For some reason, changing the clock frequency that drives the PWMs fixed the issue.
There is a table in board_colibri-t30.c where the frequency is ~3.1MHz

{“pwm”, “pll_p”, 3187500, false},

and changing that down to a quarter of the value

{“pwm”, “pll_p”, 796875, false},

suddenly meant that the pwm_period_ns values were used.