From: Shinya Kuribayashi <shinya.kuribayashi.px-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
To: dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org
Subject: Re: [PATCH 8/9] i2c-designware-pci: Add runtime power management support
Date: Tue, 25 Jan 2011 12:00:00 +0900 [thread overview]
Message-ID: <4D3E3CB0.8020006@renesas.com> (raw)
In-Reply-To: <1295033256-30077-9-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 1/15/2011 4:27 AM, dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:
> diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
> index 746b4bb..e8b354b 100644
> --- a/drivers/i2c/busses/i2c-designware-core.c
> +++ b/drivers/i2c/busses/i2c-designware-core.c
> @@ -580,3 +583,31 @@ tx_aborted:
> }
> EXPORT_SYMBOL(i2c_dw_isr);
>
> +void i2c_dw_enable(struct dw_i2c_dev *dev)
> +{
> + /* Enable the adapter */
> + writel(1, dev->base + DW_IC_ENABLE);
> +}
> +EXPORT_SYMBOL(i2c_dw_enable);
Having enable/disable wrapper functions is good and promissing, as
that helps us to avoid direct references to the IC_ENABLE register
from -pci.c and -plat.c.
> +void i2c_dw_disable(struct dw_i2c_dev *i2c)
> +{
> + /* Disable controller */
> + writel(0, i2c->base + DW_IC_ENABLE);
> +
> + /* Disable all interupts */
> + writel(0x0000, i2c->base + DW_IC_INTR_MASK);
> +
> + /* Clear all interrupts */
> + readl(i2c->base + DW_IC_CLR_INTR);
> + readl(i2c->base + DW_IC_CLR_STOP_DET);
> + readl(i2c->base + DW_IC_CLR_START_DET);
> + readl(i2c->base + DW_IC_CLR_ACTIVITY);
> + readl(i2c->base + DW_IC_CLR_TX_ABRT);
> + readl(i2c->base + DW_IC_CLR_RX_OVER);
> + readl(i2c->base + DW_IC_CLR_RX_UNDER);
> + readl(i2c->base + DW_IC_CLR_TX_OVER);
> + readl(i2c->base + DW_IC_CLR_RX_DONE);
> + readl(i2c->base + DW_IC_CLR_GEN_CALL);
> +}
> +EXPORT_SYMBOL(i2c_dw_disable);
Note that when you read the IC_CLR_INTR register, all interrupt status
bits asserted at that time will be cleared, so no need to read
remaining the IC_CLR_STOP_DET..IC_CLER_GEN_CALL registers.
By the way, I have one patch regarding safely shutdown the controller.
Will send a patch to Dirk later.
> diff --git a/drivers/i2c/busses/i2c-designware-pci.c b/drivers/i2c/busses/i2c-designware-pci.c
> index 1d57761..bea467e 100644
> --- a/drivers/i2c/busses/i2c-designware-pci.c
> +++ b/drivers/i2c/busses/i2c-designware-pci.c
[...]
> +static int i2c_dw_pci_resume(struct pci_dev *pdev)
> +{
> + struct dw_i2c_dev *i2c = pci_get_drvdata(pdev);
> + int err;
> + u32 enabled;
> +
> + enabled = dw_readl(i2c, DW_IC_ENABLE);
> + if (enabled)
> + return 0;
Hmm, we still have a direct reference to IC_ENABLE here.
> @@ -219,27 +300,28 @@ const struct pci_device_id *id)
> adap = &dev->adapter;
> i2c_set_adapdata(adap, dev);
> adap->owner = THIS_MODULE;
> - adap->class = I2C_CLASS_HWMON;
> - strlcpy(adap->name, "Synopsys DesignWare I2C adapter",
> - sizeof(adap->name));
> + adap->class = 0;
> adap->algo = &i2c_dw_algo;
> adap->dev.parent = &pdev->dev;
> -
> adap->nr = controller->bus_num;
> + snprintf(adap->name, sizeof(adap->name), "i2c-dw-pci-%d",
> + adap->nr);
>
> - writel(0, dev->base + DW_IC_INTR_MASK); /* disable IRQ */
> r = request_irq(pdev->irq, i2c_dw_isr, IRQF_SHARED, adap->name, dev);
> if (r) {
> dev_err(&pdev->dev, "failure requesting irq %i\n", dev->irq);
> goto err_iounmap;
> }
>
> + dw_readl(dev, DW_IC_CLR_INTR);
> + dw_writel(dev, 0, DW_IC_INTR_MASK); /* disable IRQ */
Replacing with i2c_dw_disable()?
> r = i2c_add_numbered_adapter(adap);
> if (r) {
> dev_err(&pdev->dev, "failure adding adapter\n");
> goto err_free_irq;
> }
>
> + pm_runtime_enable(&pdev->dev);
> return 0;
>
> err_free_irq:
--
Shinya Kuribayashi
Renesas Electronics
next prev parent reply other threads:[~2011-01-25 3:00 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-14 19:27 [PATCH RFC] Splitting i2c-designware.c to support PCI drivers dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1295033256-30077-1-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-14 19:27 ` [PATCH 1/9] i2c-designware: Add designware PCI config option dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-01-14 19:27 ` [PATCH 2/9] i2c-designware: Initial split of i2c-designware.c into core and bus specific parts dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1295033256-30077-3-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-25 1:58 ` Shinya Kuribayashi
[not found] ` <4D3E2E3F.1060506-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2011-01-25 15:26 ` Dirk Brandewie
2011-01-14 19:27 ` [PATCH 3/9] i2c-designware: retrieve clock frequency based CONFIG_HAVE_CLK dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-01-14 19:27 ` [PATCH 4/9] i2c-designware: Add support for Designware core behind PCI devices dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-01-14 19:27 ` [PATCH 5/9] i2c-designware: move i2c functionality bit field to be adapter specific dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1295033256-30077-6-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-25 2:07 ` Shinya Kuribayashi
2011-01-14 19:27 ` [PATCH 6/9] i2c-designware: move controller config to bus specific portion of driver dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1295033256-30077-7-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-25 2:22 ` Shinya Kuribayashi
2011-01-14 19:27 ` [PATCH 7/9] i2c-designware: Allow mixed endianness accesses dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1295033256-30077-8-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-17 17:19 ` Jean-Hugues Deschenes
[not found] ` <2C61B7B7755780449CA3ED217819DA761BC7B3BD-VR+kULHyjlM/vpUtHNqADA@public.gmane.org>
2011-01-25 2:28 ` Shinya Kuribayashi
[not found] ` <4D3E3546.80806-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2011-01-25 15:30 ` Dirk Brandewie
2011-01-25 2:45 ` Shinya Kuribayashi
2011-01-14 19:27 ` [PATCH 8/9] i2c-designware-pci: Add runtime power management support dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
[not found] ` <1295033256-30077-9-git-send-email-dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-25 3:00 ` Shinya Kuribayashi [this message]
2011-01-14 19:27 ` [PATCH 9/9] i2c-designware: Support multiple cores using same ISR dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w
2011-01-14 20:30 ` [PATCH RFC] Splitting i2c-designware.c to support PCI drivers Jean Delvare
[not found] ` <20110114213007.58c8b237-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-01-14 21:48 ` Ben Dooks
[not found] ` <20110114214839.GC15795-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2011-01-17 16:06 ` Dirk Brandewie
[not found] ` <4D346909.6030503-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-01-18 12:15 ` Jean Delvare
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=4D3E3CB0.8020006@renesas.com \
--to=shinya.kuribayashi.px-zm6kxycvzfbbdgjk7y7tuq@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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).