aboutsummaryrefslogtreecommitdiff
path: root/src/soc/rockchip/common
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2016-11-01 15:24:54 -0700
committerMartin Roth <martinroth@google.com>2016-11-17 17:59:09 +0100
commit8e42bd1cbcf8edad69fac402b43cd8740c0ad870 (patch)
treea9b31c5ecd8e7cb9801cea946cef5cd709857eb4 /src/soc/rockchip/common
parentc295d5e24964e877c427d82bd02803fddf90e9fe (diff)
rockchip/rk3399: Change PLL configuration to match Linux kernel
The Kevin project has been too smooth and boring for our tastes in the last last few weeks, so we've decided to stir the pot a little bit and reshuffle all our PLL settings at the last minute. The new settings match exactly what the Linux kernel expects on boot, so it doesn't need to reinitialize anything and risk a glitch. Naturally, changing PLL rates will affect child clocks, so this patch changes vop_aclk (192MHz -> 200MHz, 400MHz in the kernel), pmu_pclk (99MHz -> 96.57MHz) and i2c0_src (198MHz -> 338MHz, leading to an effective I2C0 change 399193Hz -> 398584Hz). BRANCH=gru BUG=chrome-os-partner:59139 TEST=Booted Kevin, sanity checking display and beep. Instrumented rockchip_rk3399_pll_set_params() in the kernel and confirmed that GPLL, PPLL and CPLL do not get reinitialized anymore (with additional kernel patch to ignore frac divider when it's not used). Also confirmed that /sys/kernel/debug/clk_summary now shows pclk_pmu_src 96571429 because the kernel doesn't even bother to reinitialize the divisor. Change-Id: Ib44d872a7b7f177fb2e60ccc6992f888835365eb Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 9b82056037be5a5aebf146784ffb246780013c96 Original-Change-Id: Ie112104035b01166217a8c5b5586972b4d7ca6ec Original-Signed-off-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/405785 Original-Commit-Ready: Xing Zheng <zhengxing@rock-chips.com> Original-Tested-by: Xing Zheng <zhengxing@rock-chips.com> Original-Reviewed-by: Xing Zheng <zhengxing@rock-chips.com> Original-Reviewed-by: Douglas Anderson <dianders@chromium.org> Reviewed-on: https://review.coreboot.org/17378 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'src/soc/rockchip/common')
-rw-r--r--src/soc/rockchip/common/i2c.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/soc/rockchip/common/i2c.c b/src/soc/rockchip/common/i2c.c
index 1bd88bbe9d..a00d538ba2 100644
--- a/src/soc/rockchip/common/i2c.c
+++ b/src/soc/rockchip/common/i2c.c
@@ -273,16 +273,19 @@ void i2c_init(unsigned int bus, unsigned int hz)
unsigned int divl;
unsigned int divh;
unsigned int i2c_src_clk;
+ unsigned int i2c_clk;
struct rk_i2c_regs *regs = (struct rk_i2c_regs *)(i2c_bus[bus]);
i2c_src_clk = rkclk_i2c_clock_for_bus(bus);
- /*SCL Divisor = 8*(CLKDIVL + 1 + CLKDIVH + 1)
- SCL = PCLK/ SCLK Divisor
- */
+ /* SCL Divisor = 8*(CLKDIVL + 1 + CLKDIVH + 1)
+ SCL = PCLK / SCLK Divisor */
clk_div = div_round_up(i2c_src_clk, hz * 8);
divh = clk_div * 3 / 7 - 1;
divl = clk_div - divh - 2;
- assert((divh < 65536) && (divl < 65536));
+ i2c_clk = i2c_src_clk / (8 * (divl + 1 + divh + 1));
+ printk(BIOS_DEBUG, "I2C bus %u: %uHz (divh = %u, divl = %u)\n",
+ bus, i2c_clk, divh, divl);
+ assert((divh < 65536) && (divl < 65536) && hz - i2c_clk < 10*KHz);
write32(&regs->i2c_clkdiv, (divh << 16) | (divl << 0));
}