From: Xiangliang Yu <Xiangliang.Yu@amd.com>
To: <andriy.shevchenko@linux.intel.com>,
<jarkko.nikula@linux.intel.com>,
<mika.westerberg@linux.intel.com>, <wsa@the-dreams.de>,
<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <Ken.Xue@amd.com>, <Vincent.Wan@amd.com>, <Ray.Huang@amd.com>,
<Annie.Wang@amd.com>, <Tony.Li@amd.com>,
Xiangliang Yu <Xiangliang.Yu@amd.com>
Subject: [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller
Date: Thu, 5 Nov 2015 20:34:44 +0800 [thread overview]
Message-ID: <1446726884-30558-1-git-send-email-Xiangliang.Yu@amd.com> (raw)
Because of some hardware limitation, AMD I2C controller can't
trigger next interrupt if interrupt status has been changed
after clearing interrupt status bits. Then, I2C will lost
interrupt and IO timeout.
According to hardware design, this patch implements a workaround
to disable i2c controller interrupt after clearing interrupt bits
when entering ISR and to enable i2c interrupt before exiting ISR.
To reduce the performance impacts on other vendors, use unlikely
function to check flag in ISR.
Signed-off-by: Xiangliang Yu <Xiangliang.Yu@amd.com>
---
drivers/i2c/busses/i2c-designware-core.c | 6 ++++++
drivers/i2c/busses/i2c-designware-core.h | 1 +
drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++++
3 files changed, 11 insertions(+)
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 7441cdc..04e7b65 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -783,6 +783,9 @@ irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
stat = i2c_dw_read_clear_intrbits(dev);
+ if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+ i2c_dw_disable_int(dev);
+
if (stat & DW_IC_INTR_TX_ABRT) {
dev->cmd_err |= DW_IC_ERR_TX_ABRT;
dev->status = STATUS_IDLE;
@@ -811,6 +814,9 @@ tx_aborted:
if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err)
complete(&dev->cmd_complete);
+ if (unlikely(dev->accessor_flags & ACCESS_INTR_MASK))
+ dw_writel(dev, DW_IC_INTR_DEFAULT_MASK, DW_IC_INTR_MASK);
+
return IRQ_HANDLED;
}
EXPORT_SYMBOL_GPL(i2c_dw_isr);
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 9630222..808ef6a 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -111,6 +111,7 @@ struct dw_i2c_dev {
#define ACCESS_SWAP 0x00000001
#define ACCESS_16BIT 0x00000002
+#define ACCESS_INTR_MASK 0x00000004
extern u32 dw_readl(struct dw_i2c_dev *dev, int offset);
extern void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 472b882..0c59357 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -251,6 +251,10 @@ static int dw_i2c_probe(struct platform_device *pdev)
dev->rx_fifo_depth = ((param1 >> 8) & 0xff) + 1;
dev->adapter.nr = pdev->id;
}
+
+ if (!strncmp(pdev->name, "AMD0010", 7))
+ dev->accessor_flags |= ACCESS_INTR_MASK;
+
r = i2c_dw_init(dev);
if (r)
return r;
--
1.9.1
next reply other threads:[~2015-11-05 7:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 12:34 Xiangliang Yu [this message]
2015-11-05 13:52 ` [PATCH 1/1] I2C: designware: fix IO timeout issue for AMD controller Mika Westerberg
2015-11-06 4:34 ` Yu, Xiangliang
2015-11-06 7:46 ` Mika Westerberg
2015-11-06 8:33 ` Yu, Xiangliang
2015-12-01 0:43 ` Wolfram Sang
2015-11-06 8:59 ` Jarkko Nikula
2015-11-06 9:11 ` Yu, Xiangliang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446726884-30558-1-git-send-email-Xiangliang.Yu@amd.com \
--to=xiangliang.yu@amd.com \
--cc=Annie.Wang@amd.com \
--cc=Ken.Xue@amd.com \
--cc=Ray.Huang@amd.com \
--cc=Tony.Li@amd.com \
--cc=Vincent.Wan@amd.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jarkko.nikula@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox