From 3ceeb9468121eca47e43b4f03fbe49dc1c7b05c0 Mon Sep 17 00:00:00 2001 From: Kyungwoo Kang Date: Mon, 20 Nov 2017 10:48:23 +0900 Subject: [PATCH] [COMMON] i2c: exynos5: Add NACK service routine & property Change-Id: I299b23346b51266719fb908390e01989dcf2fe92 Signed-off-by: Kyungwoo Kang --- drivers/i2c/busses/i2c-exynos5.c | 14 ++++++++++++++ drivers/i2c/busses/i2c-exynos5.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c index fe9cf3095646..ab3f10d4fdec 100644 --- a/drivers/i2c/busses/i2c-exynos5.c +++ b/drivers/i2c/busses/i2c-exynos5.c @@ -112,6 +112,7 @@ static LIST_HEAD(drvdata_list); #define HSI2C_INT_RX_OVERRUN (1u << 5) #define HSI2C_INT_TRAILING (1u << 6) #define HSI2C_INT_I2C (1u << 9) +#define HSI2C_INT_NODEV (1u << 10) #define HSI2C_RX_INT (HSI2C_INT_RX_ALMOSTFULL | \ HSI2C_INT_RX_UNDERRUN | \ HSI2C_INT_RX_OVERRUN | \ @@ -563,6 +564,13 @@ static irqreturn_t exynos5_i2c_irq(int irqno, void *dev_id) dev_err(i2c->dev, "HSI2C Error Interrupt " "occurred(IS:0x%08x, TR:0x%08x)\n", (unsigned int)reg_val, (unsigned int)trans_status); + + if (reg_val & HSI2C_INT_NODEV) { + dev_err(i2c->dev, "HSI2C NO ACK occured\n"); + if (i2c->nack_restart) + goto out; + } + i2c->trans_done = -ENXIO; exynos5_i2c_stop(i2c); goto out; @@ -1012,6 +1020,12 @@ static int exynos5_i2c_probe(struct platform_device *pdev) else i2c->reset_before_trans = 0; + if (of_get_property(np, "samsung,no-dev-restart", NULL)) + i2c->nack_restart = 1; + else + i2c->nack_restart = 0; + + i2c->idle_ip_index = exynos_get_idle_ip_index(dev_name(&pdev->dev)); strlcpy(i2c->adap.name, "exynos5-i2c", sizeof(i2c->adap.name)); diff --git a/drivers/i2c/busses/i2c-exynos5.h b/drivers/i2c/busses/i2c-exynos5.h index 2e7f59c34339..8717b614ebb6 100644 --- a/drivers/i2c/busses/i2c-exynos5.h +++ b/drivers/i2c/busses/i2c-exynos5.h @@ -59,5 +59,6 @@ struct exynos5_i2c { int idle_ip_index; int reset_before_trans; unsigned int runtime_resumed; + int nack_restart; }; #endif /*__I2C_EXYNOS5_H */ -- 2.20.1