From 13d00a5b92d5fa21ee8d1299fe01bd53b4b13a3b Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Fri, 7 Dec 2012 18:48:34 +0800 Subject: [PATCH] ENGR00236240 i2c: i2c performance optimization It is unnecessary to calculate and update i2c divider during every transaction. Only do it if current i2c clock is different with the previous clock frequency. Signed-off-by: Fugang Duan --- drivers/i2c/busses/i2c-imx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 70b97b0e290c..8cec1965dec3 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -96,7 +96,7 @@ * Duplicated divider values removed from list */ -static u16 __initdata i2c_clk_div[50][2] = { +static u16 i2c_clk_div[50][2] = { { 22, 0x20 }, { 24, 0x21 }, { 26, 0x22 }, { 28, 0x23 }, { 30, 0x00 }, { 32, 0x24 }, { 36, 0x25 }, { 40, 0x26 }, { 42, 0x03 }, { 44, 0x27 }, { 48, 0x28 }, { 52, 0x05 }, @@ -123,6 +123,7 @@ struct imx_i2c_struct { unsigned int disable_delay; int stopped; unsigned int ifdr; /* IMX_I2C_IFDR */ + unsigned int cur_clk; }; /** Functions for IMX I2C adapter driver *************************************** @@ -190,6 +191,10 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, /* Divider value calculation */ i2c_clk_rate = clk_get_rate(i2c_imx->clk); + if (i2c_imx->cur_clk == i2c_clk_rate) + return; + else + i2c_imx->cur_clk = i2c_clk_rate; div = (i2c_clk_rate + rate - 1) / rate; if (div < i2c_clk_div[0][0]) i = 0; -- 2.39.5