Bug 240740 - aw_pwm - clk_rate may be never found
Summary: aw_pwm - clk_rate may be never found
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-21 23:15 UTC by Krystian Lewandowski
Modified: 2019-09-21 23:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krystian Lewandowski 2019-09-21 23:15:48 UTC
I found this when I was looking at aw_pwm.c code, I tried to contact manu@ but never got any feedback.

Suspected line is:
https://github.com/freebsd/freebsd/blob/master/sys/arm/allwinner/aw_pwm.c#L276

If 'div' does not fit '0xffff' (prescaler == 1) at the beginning:
...
div = AW_PWM_MAX_FREQ / period_freq;
if ((div - 1) > AW_PWM_PERIOD_TOTAL_MASK) {
...

then traversing prescalers and multiplying freq:
...
div = (AW_PWM_MAX_FREQ * aw_pwm_clk_prescaler[i]) / period_freq;
...
will make the 'div' even bigger and this condition:
...
if ((div - 1) < AW_PWM_PERIOD_TOTAL_MASK )
...
will never be met.

Shouldn't prescaler be used to divide the AW_PWM_MAX_FREQ instead? And with prescalers
visited in increasing order eventually best match would be found?

I may be wrong though, just wanted to check,

-- 
Krystian