linux_dsm_epyc7002/drivers/clk
Douglas Anderson 1e2d08a837 clk: rockchip: Slightly more accurate math in rockchip_mmc_get_phase()
There's a bit of math in rockchip_mmc_get_phase() to calculate the
"fine delay".  This math boils down to:

 PSECS_PER_SEC = 1000000000000.
 ROCKCHIP_MMC_DELAY_ELEMENT_PSEC = 60
 card_clk * ROCKCHIP_MMC_DELAY_ELEMENT_PSEC * 360 * x / PSECS_PER_SEC

...but we do it in pieces to avoid overflowing 32-bits.  Right now we
overdo it a little bit, though, and end up getting less accurate math
than we could.  Right now we do:

 DIV_ROUND_CLOSEST((card_clk / 1000000) *
                   (ROCKCHIP_MMC_DELAY_ELEMENT_PSEC / 10) *
                   (360 / 10) *
		   delay_num,
		   PSECS_PER_SEC / 1000000 / 10 / 10)

This is non-ideal because:
A) The pins on Rockchip SoCs are rated to go at most 150 MHz, so the
   max card clock is 150 MHz.  Even ignoring this the maximum SD card
   clock (for SDR104) would be 208 MHz.  This means you can decrease
   your division by 100x and still not overflow:
     hex(208000000 / 10000 * 6 * 36 * 0xff) == 0x44497200
B) On many Rockchip SoCs we end up with a card clock that is actually
   148500000 because we parent off the 297 MHz PLL.  That means the
   math we're actually doing today is less than ideal.  Specifically:
   148500000 / 1000000 = 148

Let's fix the math to be slightly more accurate.

NOTE: no known problems are fixed by this.  It was found simply by
code inspection.  If you want to see the difference between the old
and the new on a 148.5 MHz clock, this python can help:

  old = [x for x in
         (int(round(148 * 6 * 36 * x / 10000.)) for x in range(256))
	 if x < 90]
  new = [x for x in
         (int(round(1485 * 6 * 36 * x / 100000.)) for x in range(256))
	 if x < 90]

The only differences are:
  delay_num=17 54=>55
  delay_num=22 70=>71
  delay_num=27 86=>87

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
2019-05-20 01:00:53 +02:00
..
actions
analogbits clk: analogbits: add Wide-Range PLL library 2019-05-03 09:20:48 -07:00
at91 Merge branches 'clk-stm32f4', 'clk-tegra', 'clk-at91', 'clk-sifive-fu540' and 'clk-spdx' into clk-next 2019-05-07 11:45:29 -07:00
axis
axs10x clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
bcm clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
berlin clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
davinci clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
h8300 clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
hisilicon clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
imgtec
imx clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
ingenic clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
keystone
loongson1 clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
mediatek Merge branches 'clk-renesas', 'clk-qcom', 'clk-mtk', 'clk-milbeaut' and 'clk-imx' into clk-next 2019-05-07 11:44:21 -07:00
meson Merge branches 'clk-doc', 'clk-more-critical', 'clk-meson' and 'clk-basic-be' into clk-next 2019-05-07 11:44:42 -07:00
microchip clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
mmp
mvebu clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
mxs
nxp clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
pistachio
pxa clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
qcom Merge branches 'clk-stm32f4', 'clk-tegra', 'clk-at91', 'clk-sifive-fu540' and 'clk-spdx' into clk-next 2019-05-07 11:45:29 -07:00
renesas clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
rockchip clk: rockchip: Slightly more accurate math in rockchip_mmc_get_phase() 2019-05-20 01:00:53 +02:00
samsung clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
sifive clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
sirf
socfpga clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
spear
sprd
st clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
sunxi clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
sunxi-ng clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
tegra clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
ti clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
uniphier
ux500
versatile clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
x86 clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
zte
zynq
zynqmp ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
clk-asm9260.c
clk-aspeed.c
clk-axi-clkgen.c
clk-axm5516.c
clk-bd718x7.c
clk-bulk.c
clk-cdce706.c
clk-cdce925.c
clk-clps711x.c
clk-composite.c
clk-conf.c
clk-cs2000-cp.c
clk-devres.c
clk-divider.c Merge branch 'clk-ti' into clk-next 2019-05-07 11:46:02 -07:00
clk-efm32gg.c
clk-fixed-factor.c Merge branch 'clk-parent-rewrite-1' into clk-next 2019-05-07 11:46:13 -07:00
clk-fixed-mmio.c clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
clk-fixed-rate.c
clk-fractional-divider.c clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
clk-gate.c Merge branch 'clk-ti' into clk-next 2019-05-07 11:46:02 -07:00
clk-gemini.c
clk-gpio.c
clk-hi655x.c
clk-highbank.c Merge branches 'clk-doc', 'clk-more-critical', 'clk-meson' and 'clk-basic-be' into clk-next 2019-05-07 11:44:42 -07:00
clk-hsdk-pll.c clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
clk-lochnagar.c
clk-max9485.c
clk-max77686.c
clk-milbeaut.c
clk-moxart.c
clk-multiplier.c clk: Remove io.h from clk-provider.h 2019-05-15 13:21:37 -07:00
clk-mux.c Merge branch 'clk-ti' into clk-next 2019-05-07 11:46:02 -07:00
clk-nomadik.c
clk-npcm7xx.c
clk-nspire.c
clk-oxnas.c
clk-palmas.c
clk-pwm.c
clk-qoriq.c
clk-rk808.c
clk-s2mps11.c
clk-scmi.c
clk-scpi.c
clk-si514.c
clk-si544.c
clk-si570.c
clk-si5351.c
clk-si5351.h
clk-stm32f4.c
clk-stm32h7.c
clk-stm32mp1.c
clk-tango4.c
clk-twl6040.c
clk-u300.c
clk-versaclock5.c
clk-vt8500.c
clk-wm831x.c
clk-xgene.c
clk.c Merge branch 'clk-parent-rewrite-1' into clk-next 2019-05-07 11:46:13 -07:00
clk.h
clkdev.c
Kconfig Merge branches 'clk-stm32f4', 'clk-tegra', 'clk-at91', 'clk-sifive-fu540' and 'clk-spdx' into clk-next 2019-05-07 11:45:29 -07:00
Makefile Merge branches 'clk-stm32f4', 'clk-tegra', 'clk-at91', 'clk-sifive-fu540' and 'clk-spdx' into clk-next 2019-05-07 11:45:29 -07:00