]> git.itanic.dy.fi Git - linux-stable/commitdiff
i2c: mediatek: Fix send master code at more than 1MHz
authorQii Wang <qii.wang@mediatek.com>
Sat, 17 Apr 2021 06:46:50 +0000 (14:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:56:44 +0000 (10:56 +0200)
commit 63ce8e3df8f6deca2da52eaf064751ad4018b46e upstream.

There are some omissions in the previous patch about replacing
I2C_MAX_FAST_MODE__FREQ with I2C_MAX_FAST_MODE_PLUS_FREQ and
need to fix it.

Fixes: b44658e755b5("i2c: mediatek: Send i2c master code at more than 1MHz")
Signed-off-by: Qii Wang <qii.wang@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/i2c/busses/i2c-mt65xx.c

index 86f70c7513192f444a9447f8e988a2ca76034bdb..bf25acba2ed53e3a5f878453f96d8d3491d2d9a0 100644 (file)
@@ -564,7 +564,7 @@ static const struct i2c_spec_values *mtk_i2c_get_spec(unsigned int speed)
 
 static int mtk_i2c_max_step_cnt(unsigned int target_speed)
 {
-       if (target_speed > I2C_MAX_FAST_MODE_FREQ)
+       if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ)
                return MAX_HS_STEP_CNT_DIV;
        else
                return MAX_STEP_CNT_DIV;
@@ -635,7 +635,7 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c,
        if (sda_min > sda_max)
                return -3;
 
-       if (check_speed > I2C_MAX_FAST_MODE_FREQ) {
+       if (check_speed > I2C_MAX_FAST_MODE_PLUS_FREQ) {
                if (i2c->dev_comp->ltiming_adjust) {
                        i2c->ac_timing.hs = I2C_TIME_DEFAULT_VALUE |
                                (sample_cnt << 12) | (high_cnt << 8);
@@ -850,7 +850,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,
 
        control_reg = mtk_i2c_readw(i2c, OFFSET_CONTROL) &
                        ~(I2C_CONTROL_DIR_CHANGE | I2C_CONTROL_RS);
-       if ((i2c->speed_hz > I2C_MAX_FAST_MODE_FREQ) || (left_num >= 1))
+       if ((i2c->speed_hz > I2C_MAX_FAST_MODE_PLUS_FREQ) || (left_num >= 1))
                control_reg |= I2C_CONTROL_RS;
 
        if (i2c->op == I2C_MASTER_WRRD)
@@ -1067,7 +1067,8 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
                }
        }
 
-       if (i2c->auto_restart && num >= 2 && i2c->speed_hz > I2C_MAX_FAST_MODE_FREQ)
+       if (i2c->auto_restart && num >= 2 &&
+               i2c->speed_hz > I2C_MAX_FAST_MODE_PLUS_FREQ)
                /* ignore the first restart irq after the master code,
                 * otherwise the first transfer will be discarded.
                 */