aboutsummaryrefslogtreecommitdiff
path: root/net/lapb/lapb_in.c
diff options
context:
space:
mode:
authorMartin Blumenstingl <[email protected]>2019-06-12 21:59:07 +0200
committerThierry Reding <[email protected]>2019-06-26 11:39:09 +0200
commitfb2081e870e9d59a0e6d076989e04c932c3ba23d (patch)
tree946a8c6e6389b3ba87a5a771253c11bc77c3f14d /net/lapb/lapb_in.c
parent1064c6bacedd70edfcea6b1b6af529f621e681ae (diff)
pwm: meson: Simplify the calculation of the pre-divider and count
Replace the loop to calculate the pre-divider and count with two separate div64_u64() calculations. This makes the code easier to read and improves the precision. Three example cases: 1) 32.768kHz LPO clock for the SDIO wifi chip on Khadas VIM clock input: 500MHz (FCLK_DIV4) period: 30518ns duty cycle: 15259ns old algorithm: pre_div=0, cnt=15259 new algorithm: pre_div=0, cnt=15259 (no difference in calculated values) 2) PWM LED on Khadas VIM clock input: 24MHz (XTAL) period: 7812500ns duty cycle: 7812500ns old algorithm: pre_div=2, cnt=62004 new algorithm: pre_div=2, cnt=62500 Using a scope (24MHz sampling rate) shows the actual difference: - old: 7753000ns, off by -59500ns (0.7616%) - new: 7815000ns, off by +2500ns (0.032%) 3) Theoretical case where pre_div is different clock input: 24MHz (XTAL) period: 2730624ns duty cycle: 1365312ns old algorithm: pre_div=1, cnt=32768 new algorithm: pre_div=0, cnt=65534 Using a scope (24MHz sampling rate) shows the actual difference: - old: 2731000ns - new: 2731000ns (my scope is not precise enough to measure the difference if there's any) Suggested-by: Uwe Kleine-König <[email protected]> Acked-by: Uwe Kleine-König <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Martin Blumenstingl <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
Diffstat (limited to 'net/lapb/lapb_in.c')
0 files changed, 0 insertions, 0 deletions