From: dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: alan.cox-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
shinya.kuribayashi.px-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org,
ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org,
khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org,
Dirk Brandewie
<dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 08/10] i2c-designware: Push all register reads/writes into the core code.
Date: Wed, 2 Feb 2011 18:20:06 -0800 [thread overview]
Message-ID: <1296699608-13227-9-git-send-email-dirk.brandewie@gmail.com> (raw)
In-Reply-To: <1296699608-13227-1-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Move all register manipulation into the core code.
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/i2c/busses/i2c-designware-core.c | 49 ++++++++++++++++++++++++++-
drivers/i2c/busses/i2c-designware-core.h | 6 +++
drivers/i2c/busses/i2c-designware-pcidrv.c | 4 +-
drivers/i2c/busses/i2c-designware-platdrv.c | 6 ++--
4 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index 5452e3b..35960db 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -247,7 +247,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
ic_con |= DW_IC_CON_10BITADDR_MASTER;
else
ic_con &= ~DW_IC_CON_10BITADDR_MASTER;
- dw_writel(dev->base, ic_con, DW_IC_CON);
+ dw_writel(dev, ic_con, DW_IC_CON);
/* Enable the adapter */
dw_writel(dev, 1, DW_IC_ENABLE);
@@ -571,3 +571,50 @@ tx_aborted:
return IRQ_HANDLED;
}
+void i2c_dw_enable(struct dw_i2c_dev *dev)
+{
+ /* Enable the adapter */
+ dw_writel(dev, 1, DW_IC_ENABLE);
+}
+
+
+void i2c_dw_disable(struct dw_i2c_dev *dev)
+{
+ int ret;
+
+ /*
+ * Disabling DW_apb_i2c
+ *
+ * The IC_ENABLE register allows software to immediately shut down
+ * the DW_apb_i2c hardware, preventing its further participation in
+ * an I2C subsystem. The I2C protocol, however, does not allow
+ * transfers to be abruptly stopped, it's necessary for software to
+ * manage the correct shutdown of DW_apb_i2c, ensuring no data loss
+ * or bus lockup occurs.
+ */
+ ret = i2c_dw_wait_bus_not_busy(dev);
+ if (ret < 0)
+ BUG();
+
+ /* Disable controller */
+ dw_writel(dev, 0, DW_IC_ENABLE);
+
+ /* Disable all interupts */
+ dw_writel(dev, 0, DW_IC_INTR_MASK);
+ dw_readl(dev, DW_IC_CLR_INTR);
+}
+
+void i2c_dw_clear_int(struct dw_i2c_dev *dev)
+{
+ dw_readl(dev, DW_IC_CLR_INTR);
+}
+
+void i2c_dw_disable_int(struct dw_i2c_dev *dev)
+{
+ dw_writel(dev, 0, DW_IC_INTR_MASK);
+}
+
+u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev)
+{
+ return dw_readl(dev, DW_IC_COMP_PARAM_1);
+}
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 8d715b9..2060a53 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -195,3 +195,9 @@ extern int i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int num);
extern u32 i2c_dw_func(struct i2c_adapter *adap);
extern irqreturn_t i2c_dw_isr(int this_irq, void *dev_id);
+extern void i2c_dw_enable(struct dw_i2c_dev *dev);
+extern void i2c_dw_disable(struct dw_i2c_dev *dev);
+extern void i2c_dw_clear_int(struct dw_i2c_dev *dev);
+extern void i2c_dw_disable_int(struct dw_i2c_dev *dev);
+extern u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev);
+
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index f548064..d943318 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -231,8 +231,8 @@ const struct pci_device_id *id)
goto err_iounmap;
}
- dw_readl(dev, DW_IC_CLR_INTR);
- dw_writel(dev, 0, DW_IC_INTR_MASK); /* disable IRQ */
+ i2c_dw_disable_int(dev);
+ i2c_dw_clear_int(dev);
r = i2c_add_numbered_adapter(adap);
if (r) {
dev_err(&pdev->dev, "failure adding adapter\n");
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 964494e..dff9b52 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -107,7 +107,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
goto err_unuse_clocks;
}
{
- u32 param1 = dw_readl(dev, DW_IC_COMP_PARAM_1);
+ u32 param1 = i2c_dw_read_comp_param(dev);
dev->tx_fifo_depth = ((param1 >> 16) & 0xff) + 1;
dev->rx_fifo_depth = ((param1 >> 8) & 0xff) + 1;
@@ -116,7 +116,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
if (r)
goto err_iounmap;
- dw_writel(dev, 0, DW_IC_INTR_MASK); /* disable IRQ */
+ i2c_dw_disable_int(dev);
r = request_irq(dev->irq, i2c_dw_isr, IRQF_DISABLED, pdev->name, dev);
if (r) {
dev_err(&pdev->dev, "failure requesting irq %i\n", dev->irq);
@@ -172,7 +172,7 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev)
clk_put(dev->clk);
dev->clk = NULL;
- dw_writel(dev, 0, DW_IC_ENABLE);
+ i2c_dw_disable(dev);
free_irq(dev->irq, dev);
kfree(dev);
--
1.7.3.4
next prev parent reply other threads:[~2011-02-03 2:20 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-03 2:19 [PATCH 00/10] Split i2c-designware.c to support PCI drivers dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1296699608-13227-1-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-03 2:19 ` [PATCH 01/10] i2c-designware: Allow mixed endianness accesses dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1296699608-13227-2-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-04 4:05 ` Shinya Kuribayashi
[not found] ` <4D4B7B23.9010705-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2011-02-05 17:39 ` Ben Dooks
[not found] ` <20110205173935.GG15795-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2011-02-08 15:52 ` Dirk Brandewie
2011-02-09 15:34 ` Shinya Kuribayashi
2011-02-09 15:42 ` Shinya Kuribayashi
2011-02-03 2:20 ` [PATCH 02/10] i2c-designware: split of i2c-designware.c into core and bus specific parts dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1296699608-13227-3-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-04 4:23 ` Shinya Kuribayashi
2011-02-05 17:45 ` Ben Dooks
[not found] ` <20110205174507.GH15795-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2011-02-08 16:20 ` Dirk Brandewie
[not found] ` <4D516D48.6000104-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-09 0:59 ` Shinya Kuribayashi
2011-02-03 2:20 ` [PATCH 03/10] i2c-designware: retrieve clock frequency based CONFIG_HAVE_CLK dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1296699608-13227-4-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-04 4:28 ` Shinya Kuribayashi
2011-02-05 17:46 ` Ben Dooks
[not found] ` <20110205174636.GI15795-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2011-02-08 16:00 ` Dirk Brandewie
2011-02-03 2:20 ` [PATCH 04/10] i2c-designware: Add support for Designware core behind PCI devices dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1296699608-13227-5-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-05 17:50 ` Ben Dooks
2011-02-03 2:20 ` [PATCH 05/10] i2c-designware: move i2c functionality bit field to be adapter specific dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-02-03 2:20 ` [PATCH 06/10] i2c-designware: move controller config to bus specific portion of driver dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-02-03 2:20 ` [PATCH 07/10] i2c-designware: Support multiple cores using same ISR dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-02-03 2:20 ` dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w [this message]
2011-02-03 2:20 ` [PATCH 09/10] i2c-designware: Add runtime power management support dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-02-03 2:20 ` [PATCH 10/10] i2c-intel-mid.c: Remove i2c-intel-mid.c dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
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=1296699608-13227-9-git-send-email-dirk.brandewie@gmail.com \
--to=dirk.brandewie-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=alan.cox-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=shinya.kuribayashi.px-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).