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

Device Tree • Re: pwm-gpio-fan overlay fails on 32-bit kernel (CM4)

$
0
0
The error message "configured period too big" comes from the Linux hwmon pwm-fan driver. It appears to be testing that the configured PWM period (i.e. frequency) is within a certain range:

Code:

if (ctx->pwm_state.period > ULONG_MAX / MAX_PWM + 1) {dev_err(dev, "Configured period too big\n");return -EINVAL;}
One thing that immediately draws my eye from the above code snippet is that, if I recall correctly, ULONG_MAX will have a different value on a 32-bit system versus a 64-bit system - 4,294,967,295 versus 18,446,744,073,709,551,615. So, on a 32-bit kernel, the value that period is being compared against will be 4294967295 / 255 + 1 = 16843010.

The period value itself is defined in the pwm_state struct as being (together with the duty cycle) in nanoseconds. But where is this period value being set? You'll note that the PWM period is not actually a configurable parameter of the DT overlay.

The period appears to be hard-coded in the overlay to a value appropriate for 50 Hz: 20,000,000 nanoseconds.

Woah, hang on, 20000000 is greater than 16843010! And thus the error condition is satisfied. :)

So it appears that on 32-bit systems the hwmon pwm-fan driver doesn't support such a low PWM frequency as 50 Hz. I can't say whether this is expected behaviour or a bug, because it strikes me that 50 Hz is an unusually low PWM frequency for a fan. It's my experience that computer fans are typically PWM-ed at frequencies of around 25 kHz, outside the human hearing range.

You could try altering the period specified in the overlay source to a higher value (e.g. 10000000 ns, 100 Hz) and re-compiling the overlay .dtbo.

Statistics: Posted by HwAoRrDk — Tue Mar 11, 2025 10:56 am



Viewing all articles
Browse latest Browse all 8013

Trending Articles