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 clk: actions: Use the correct style for SPDX License Identifier 2019-05-01 13:01:07 -07:00
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 clk: boston: unregister clks on failure in clk_boston_setup() 2018-11-08 10:14:41 -08:00
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 Merge branch 'clk-k3-tisci' into clk-next 2018-10-18 15:40:10 -07:00
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 clk: Remove CLK_IS_BASIC clk flag 2019-04-26 10:40:49 -07:00
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 clk: pistachio: constify clk_ops structures 2018-11-06 09:41:49 -08:00
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 clk: spear: fix WDT clock definition on SPEAr600 2018-04-06 13:45:34 -07:00
sprd clk: sprd: Use the correct style for SPDX License Identifier 2019-05-01 13:01:23 -07:00
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 clk: uniphier: Fix update register for CPU-gear 2019-02-21 13:50:23 -08:00
ux500 clk: ux500: add range to usleep_range 2019-04-11 11:47:50 -07:00
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 clk: core: replace clk_{readl,writel} with {readl,writel} 2019-04-23 10:57:49 -07:00
zynqmp ARM: SoC-related driver updates 2019-05-16 09:19:14 -07:00
clk-asm9260.c clk: Convert to using %pOFn instead of device_node.name 2018-08-30 09:50:20 -07:00
clk-aspeed.c clk: Aspeed: Setup video engine clocking 2019-04-18 14:56:19 -07:00
clk-axi-clkgen.c
clk-axm5516.c clk: axm5516: Remove usage of CLK_IS_BASIC 2018-12-10 14:43:21 -08:00
clk-bd718x7.c clk: bd718x7: Initial support for ROHM bd71837/bd71847 PMIC clock 2018-12-10 12:44:03 -08:00
clk-bulk.c clk: Tag clk core files with SPDX 2018-12-11 09:57:47 -08:00
clk-cdce706.c
clk-cdce925.c Merge branches 'clk-dt-name', 'clk-ti-of-node' and 'clk-sa' into clk-next 2018-10-18 15:33:52 -07:00
clk-clps711x.c clk: clps711x: Remove board support 2019-01-09 12:50:21 -08:00
clk-composite.c clk: Remove CLK_IS_BASIC clk flag 2019-04-26 10:40:49 -07:00
clk-conf.c clk: Tag clk core files with SPDX 2018-12-11 09:57:47 -08:00
clk-cs2000-cp.c clk: cs2000-cp: convert to SPDX identifiers 2018-08-02 13:55:00 -07:00
clk-devres.c clk: Add (devm_)clk_get_optional() functions 2019-02-06 10:33:10 -08:00
clk-divider.c Merge branch 'clk-ti' into clk-next 2019-05-07 11:46:02 -07:00
clk-efm32gg.c treewide: Use struct_size() for kmalloc()-family 2018-06-06 11:15:43 -07:00
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: Remove CLK_IS_BASIC clk flag 2019-04-26 10:40:49 -07:00
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 treewide: Use struct_size() for kmalloc()-family 2018-06-06 11:15:43 -07:00
clk-gpio.c clk: Remove CLK_IS_BASIC clk flag 2019-04-26 10:40:49 -07:00
clk-hi655x.c clk: clk-hi655x: Free of_provider at remove 2018-12-05 09:20:29 -08:00
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: lochnagar: Add support for the Cirrus Logic Lochnagar 2019-04-23 14:59:38 -07:00
clk-max9485.c clk: Add driver for MAX9485 2018-07-06 13:44:06 -07:00
clk-max77686.c clk: clk-max77686: Clean clkdev lookup leak and use devm 2019-02-06 10:35:03 -08:00
clk-milbeaut.c clock: milbeaut: Add Milbeaut M10V clock controller 2019-04-25 16:43:37 -07:00
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: nomadik: Change to use DEFINE_SHOW_ATTRIBUTE macro 2018-11-28 14:13:18 -08:00
clk-npcm7xx.c This time it looks like a quieter release cycle in the clk tree. I guess that's 2018-10-31 11:08:30 -07:00
clk-nspire.c
clk-oxnas.c
clk-palmas.c clk: palmas: constify clk_ops structure 2018-11-06 09:41:44 -08:00
clk-pwm.c clk: Remove CLK_IS_BASIC clk flag 2019-04-26 10:40:49 -07:00
clk-qoriq.c clk: qoriq: increase array size of cmux_to_group 2019-04-25 11:41:18 -07:00
clk-rk808.c clk: rk808: use managed version of of_provider registration 2018-12-05 09:20:35 -08:00
clk-s2mps11.c clk: s2mps11: constify clk_ops structure 2018-11-06 09:42:12 -08:00
clk-scmi.c clk: Convert to using %pOFn instead of device_node.name 2018-08-30 09:50:20 -07:00
clk-scpi.c clk: Convert to using %pOFn instead of device_node.name 2018-08-30 09:50:20 -07:00
clk-si514.c clk-si514, clk-si544: Implement prepare/unprepare/is_prepared operations 2018-06-29 10:59:40 -07:00
clk-si544.c clk-si514, clk-si544: Implement prepare/unprepare/is_prepared operations 2018-06-29 10:59:40 -07:00
clk-si570.c
clk-si5351.c clk: Convert to using %pOFn instead of device_node.name 2018-08-30 09:50:20 -07:00
clk-si5351.h
clk-stm32f4.c clk: stm32: Introduce clocks of STM32F769 board 2019-04-25 11:46:36 -07:00
clk-stm32h7.c clk: Convert to using %pOFn instead of device_node.name 2018-08-30 09:50:20 -07:00
clk-stm32mp1.c clk: stm32mp1: Add ddrperfm clock 2019-04-29 11:13:23 -07:00
clk-tango4.c clk: Convert to using %pOFn instead of device_node.name 2018-08-30 09:50:20 -07:00
clk-twl6040.c clk: clk-twl6040: Fix imprecise external abort for pdmclk 2019-02-21 14:11:23 -08:00
clk-u300.c
clk-versaclock5.c clk: vc5: Abort clock configuration without upstream clock 2019-01-09 10:53:58 -08:00
clk-vt8500.c
clk-wm831x.c
clk-xgene.c clk: core: replace clk_{readl,writel} with {readl,writel} 2019-04-23 10:57:49 -07:00
clk.c Merge branch 'clk-parent-rewrite-1' into clk-next 2019-05-07 11:46:13 -07:00
clk.h clk: Look for parents with clkdev based clk_lookups 2019-04-19 14:53:00 -07:00
clkdev.c clk: Look for parents with clkdev based clk_lookups 2019-04-19 14:53:00 -07:00
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