From: Fugang Duan Date: Fri, 7 Dec 2012 10:48:34 +0000 (+0800) Subject: ENGR00236240 i2c: i2c performance optimization X-Git-Tag: v3.0.35-fsl~187 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=13d00a5b92d5fa21ee8d1299fe01bd53b4b13a3b;p=karo-tx-linux.git 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 --- 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;