lkml.org 
[lkml]   [2018]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.16 116/279] i2c: sprd: Fix the i2c count issue
    Date
    4.16-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Baolin Wang <baolin.wang@linaro.org>

    [ Upstream commit 2a010461207cc96bee5ab81748325dec1972976f ]

    We found the I2C controller count register is unreliable sometimes,
    that will cause I2C to lose data. Thus we can read the data count
    from 'i2c_dev->count' instead of the I2C controller count register.

    Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
    Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/i2c/busses/i2c-sprd.c | 6 ++----
    1 file changed, 2 insertions(+), 4 deletions(-)

    --- a/drivers/i2c/busses/i2c-sprd.c
    +++ b/drivers/i2c/busses/i2c-sprd.c
    @@ -368,13 +368,12 @@ static irqreturn_t sprd_i2c_isr_thread(i
    struct sprd_i2c *i2c_dev = dev_id;
    struct i2c_msg *msg = i2c_dev->msg;
    bool ack = !(readl(i2c_dev->base + I2C_STATUS) & I2C_RX_ACK);
    - u32 i2c_count = readl(i2c_dev->base + I2C_COUNT);
    u32 i2c_tran;

    if (msg->flags & I2C_M_RD)
    i2c_tran = i2c_dev->count >= I2C_FIFO_FULL_THLD;
    else
    - i2c_tran = i2c_count;
    + i2c_tran = i2c_dev->count;

    /*
    * If we got one ACK from slave when writing data, and we did not
    @@ -412,14 +411,13 @@ static irqreturn_t sprd_i2c_isr(int irq,
    {
    struct sprd_i2c *i2c_dev = dev_id;
    struct i2c_msg *msg = i2c_dev->msg;
    - u32 i2c_count = readl(i2c_dev->base + I2C_COUNT);
    bool ack = !(readl(i2c_dev->base + I2C_STATUS) & I2C_RX_ACK);
    u32 i2c_tran;

    if (msg->flags & I2C_M_RD)
    i2c_tran = i2c_dev->count >= I2C_FIFO_FULL_THLD;
    else
    - i2c_tran = i2c_count;
    + i2c_tran = i2c_dev->count;

    /*
    * If we did not get one ACK from slave when writing data, then we

    \
     
     \ /
      Last update: 2018-06-18 11:56    [W:4.161 / U:0.408 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site