i2c: exynos5: Preserve high speed master code
authorMårten Lindahl <martenli@axis.com>
Tue, 16 Feb 2021 22:25:38 +0000 (23:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 10:38:20 +0000 (11:38 +0100)
[ Upstream commit f4ff0104d4c807a7f96aa3358c03d694895ee8ea ]

When the driver starts to send a message with the MASTER_ID field
set (high speed), the whole I2C_ADDR register is overwritten including
MASTER_ID as the SLV_ADDR_MAS field is set.

This patch preserves already written fields in I2C_ADDR when writing
SLV_ADDR_MAS.

Fixes: 8a73cd4cfa15 ("i2c: exynos5: add High Speed I2C controller driver")
Signed-off-by: Mårten Lindahl <martenli@axis.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Tested-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/busses/i2c-exynos5.c

index 6ce3ec0..b6f2c63 100644 (file)
@@ -606,6 +606,7 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop)
        u32 i2c_ctl;
        u32 int_en = 0;
        u32 i2c_auto_conf = 0;
+       u32 i2c_addr = 0;
        u32 fifo_ctl;
        unsigned long flags;
        unsigned short trig_lvl;
@@ -640,7 +641,12 @@ static void exynos5_i2c_message_start(struct exynos5_i2c *i2c, int stop)
                int_en |= HSI2C_INT_TX_ALMOSTEMPTY_EN;
        }
 
-       writel(HSI2C_SLV_ADDR_MAS(i2c->msg->addr), i2c->regs + HSI2C_ADDR);
+       i2c_addr = HSI2C_SLV_ADDR_MAS(i2c->msg->addr);
+
+       if (i2c->op_clock >= I2C_MAX_FAST_MODE_PLUS_FREQ)
+               i2c_addr |= HSI2C_MASTER_ID(MASTER_ID(i2c->adap.nr));
+
+       writel(i2c_addr, i2c->regs + HSI2C_ADDR);
 
        writel(fifo_ctl, i2c->regs + HSI2C_FIFO_CTL);
        writel(i2c_ctl, i2c->regs + HSI2C_CTL);