Skip to content

Commit b9960b9

Browse files
Suneel GarapatiAndi Shyti
authored andcommitted
i2c: octeon: Handle watchdog timeout
Add watchdog timeout handling to cater to the unhandled warnings seen during validation on boards with different I2C slaves. This status code reflects the state that controller couldn't receive any response from slave while being in non-idle state and HW recommends to reset before any further bus access. Signed-off-by: Suneel Garapati <sgarapati@marvell.com> Signed-off-by: Piyush Malgujar <pmalgujar@marvell.com> Acked-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 0b042c7 commit b9960b9

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/i2c/busses/i2c-octeon-core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
182182
static int octeon_i2c_check_status(struct octeon_i2c *i2c, int final_read)
183183
{
184184
u8 stat;
185+
u64 mode;
185186

186187
/*
187188
* This is ugly... in HLC mode the status is not in the status register
@@ -244,6 +245,13 @@ static int octeon_i2c_check_status(struct octeon_i2c *i2c, int final_read)
244245
case STAT_RXADDR_NAK:
245246
case STAT_AD2W_NAK:
246247
return -ENXIO;
248+
249+
case STAT_WDOG_TOUT:
250+
mode = __raw_readq(i2c->twsi_base + OCTEON_REG_MODE(i2c));
251+
/* Set BUS_MON_RST to reset bus monitor */
252+
mode |= BUS_MON_RST_MASK;
253+
octeon_i2c_writeq_flush(mode, i2c->twsi_base + OCTEON_REG_MODE(i2c));
254+
return -EIO;
247255
default:
248256
dev_err(i2c->dev, "unhandled state: %d\n", stat);
249257
return -EIO;

drivers/i2c/busses/i2c-octeon-core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#define STAT_SLAVE_ACK 0xC8
7474
#define STAT_AD2W_ACK 0xD0
7575
#define STAT_AD2W_NAK 0xD8
76+
#define STAT_WDOG_TOUT 0xF0
7677
#define STAT_IDLE 0xF8
7778

7879
/* TWSI_INT values */
@@ -107,6 +108,9 @@ struct octeon_i2c_reg_offset {
107108
#define TWSX_MODE_HS_MODE BIT(0)
108109
#define TWSX_MODE_HS_MASK (TWSX_MODE_REFCLK_SRC | TWSX_MODE_HS_MODE)
109110

111+
/* Set BUS_MON_RST to reset bus monitor */
112+
#define BUS_MON_RST_MASK BIT(3)
113+
110114
struct octeon_i2c {
111115
wait_queue_head_t queue;
112116
struct i2c_adapter adap;

0 commit comments

Comments
 (0)