diff mbox

[U-Boot,4/7] i2c: lpc32xx: use api to get hclk instead of fix value

Message ID 1438018660-19858-5-git-send-email-slemieux.tyco@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Sylvain Lemieux July 27, 2015, 5:37 p.m. UTC
From: Sylvain Lemieux <slemieux@tycoint.com>

The HCLK is not constant and can take different value; use the api function to get the value of the HCLK for the I2C clock high and low computation.

Signed-off-by: Sylvain Lemieux <slemieux@tycoint.com>
---
 drivers/i2c/lpc32xx_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini Aug. 13, 2015, 1:20 p.m. UTC | #1
On Mon, Jul 27, 2015 at 01:37:37PM -0400, slemieux.tyco@gmail.com wrote:

> From: Sylvain Lemieux <slemieux@tycoint.com>
> 
> The HCLK is not constant and can take different value; use the api function to get the value of the HCLK for the I2C clock high and low computation.
> 
> Signed-off-by: Sylvain Lemieux <slemieux@tycoint.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/i2c/lpc32xx_i2c.c b/drivers/i2c/lpc32xx_i2c.c
index 78d26e4..98106fa 100644
--- a/drivers/i2c/lpc32xx_i2c.c
+++ b/drivers/i2c/lpc32xx_i2c.c
@@ -72,7 +72,7 @@  static unsigned int lpc32xx_i2c_set_bus_speed(struct i2c_adapter *adap,
 	if (speed == 0)
 		return -EINVAL;
 
-	half_period = (105000000 / speed) / 2;
+	half_period = (get_hclk_clk_rate() / speed) / 2;
 
 	if ((half_period > 255) || (half_period < 0))
 		return -EINVAL;