Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

clk: eyeq: Adjust PLL accuracy computation

The spread spectrum of the PLL found in eyeQ OLB is in 1/1024 parts of the
frequency, not in 1/1000, so adjust the computation of the accuracy. Also
correct the downspreading to match.

Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Benoît Monin and committed by
Thomas Bogendoerfer
fe9545bb 8ab1e58c

+9 -9
+9 -9
drivers/clk/clk-eyeq.c
··· 163 163 static int eqc_pll_parse_registers(u32 r0, u32 r1, unsigned long *mult, 164 164 unsigned long *div, unsigned long *acc) 165 165 { 166 - u32 spread; 166 + unsigned long spread; 167 167 168 168 if (r0 & PCSR0_BYPASS) { 169 169 *mult = 1; ··· 195 195 /* 196 196 * Spread spectrum. 197 197 * 198 - * Spread is 1/1000 parts of frequency, accuracy is half of 199 - * that. To get accuracy, convert to ppb (parts per billion). 198 + * Spread is in 1/1024 parts of frequency. Clock accuracy 199 + * is half the spread value expressed in parts per billion. 200 200 * 201 - * acc = spread * 1e6 / 2 202 - * with acc in parts per billion and, 203 - * spread in parts per thousand. 201 + * accuracy = (spread * 1e9) / (1024 * 2) 202 + * 203 + * Care is taken to avoid overflowing or losing precision. 204 204 */ 205 205 spread = FIELD_GET(PCSR1_SPREAD, r1); 206 - *acc = spread * 500000; 206 + *acc = DIV_ROUND_CLOSEST(spread * 1000000000, 1024 * 2); 207 207 208 208 if (r1 & PCSR1_DOWN_SPREAD) { 209 209 /* 210 210 * Downspreading: the central frequency is half a 211 211 * spread lower. 212 212 */ 213 - *mult *= 2000 - spread; 214 - *div *= 2000; 213 + *mult *= 2048 - spread; 214 + *div *= 2048; 215 215 216 216 /* 217 217 * Previous operation might overflow 32 bits. If it