From: Shubhrajyoti <shubhrajyoti-l0cyMroinI0@public.gmane.org>
To: "Patil, Rachna" <rachna-l0cyMroinI0@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
Dmitry Torokhov
<dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Dmitry Torokhov <dtor-JGs/UdohzUI@public.gmane.org>,
Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
Subject: Re: [PATCH v4 5/5] MFD: ti_tscadc: add suspend/resume functionality
Date: Wed, 26 Sep 2012 12:10:51 +0530 [thread overview]
Message-ID: <5062A373.4000707@ti.com> (raw)
In-Reply-To: <1348636814-14129-6-git-send-email-rachna-l0cyMroinI0@public.gmane.org>
On Wednesday 26 September 2012 10:50 AM, Patil, Rachna wrote:
> This patch adds support for suspend/resume of
> TSC/ADC MFDevice.
this should be merged with the patch adding support else
we may end up in a case where patch a does the runtime calls
and the call back handlers added later.
>
> Signed-off-by: Patil, Rachna <rachna-l0cyMroinI0@public.gmane.org>
> ---
> Changes in v2:
> Added this patch newly in this patch series.
>
> Changes in v3:
> No changes.
>
> Changes in v4:
> Replaced suspend/resume callbacks with dev_pm_ops.
>
> drivers/iio/adc/ti_am335x_adc.c | 42 +++++++++++++++++++++++++++++
> drivers/input/touchscreen/ti_am335x_tsc.c | 42 +++++++++++++++++++++++++++++
> drivers/mfd/ti_am335x_tscadc.c | 41 +++++++++++++++++++++++++++-
> include/linux/mfd/ti_am335x_tscadc.h | 3 ++
> 4 files changed, 127 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index 9e1b3ac..b16f944 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -200,10 +200,52 @@ static int __devexit tiadc_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM
> +static int tiadc_suspend(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> + struct tiadc_device *adc_dev = iio_priv(indio_dev);
> + struct ti_tscadc_dev *tscadc_dev = dev->platform_data;
> + unsigned int idle;
> +
> + if (!device_may_wakeup(tscadc_dev->dev)) {
> + idle = adc_readl(adc_dev, REG_CTRL);
> + idle &= ~(CNTRLREG_TSCSSENB);
> + adc_writel(adc_dev, REG_CTRL, (idle |
> + CNTRLREG_POWERDOWN));
> + }
> + return 0;
> +}
> +
> +static int tiadc_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> + struct tiadc_device *adc_dev = iio_priv(indio_dev);
> + unsigned int restore;
> +
> + /* Make sure ADC is powered up */
> + restore = adc_readl(adc_dev, REG_CTRL);
> + restore &= ~(CNTRLREG_POWERDOWN);
> + adc_writel(adc_dev, REG_CTRL, restore);
> +
> + adc_step_config(adc_dev);
> + return 0;
> +}
> +
> +static const struct dev_pm_ops tiadc_pm_ops = {
> + .suspend = tiadc_suspend,
> + .resume = tiadc_resume,
> +};
> +#define TIADC_PM_OPS (&tiadc_pm_ops)
> +#else
> +#define TIADC_PM_OPS NULL
> +#endif
> +
> static struct platform_driver tiadc_driver = {
> .driver = {
> .name = "tiadc",
> .owner = THIS_MODULE,
> + .pm = TIADC_PM_OPS,
> },
> .probe = tiadc_probe,
> .remove = __devexit_p(tiadc_remove),
> diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
> index 2d9dec1..b17dbe4 100644
> --- a/drivers/input/touchscreen/ti_am335x_tsc.c
> +++ b/drivers/input/touchscreen/ti_am335x_tsc.c
> @@ -338,12 +338,54 @@ static int __devexit tscadc_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM
> +static int titsc_suspend(struct device *dev)
> +{
> + struct ti_tscadc_dev *tscadc_dev = dev->platform_data;
> + struct tscadc *ts_dev = tscadc_dev->tsc;
> + unsigned int idle;
> +
> + if (device_may_wakeup(tscadc_dev->dev)) {
> + idle = tscadc_readl(ts_dev, REG_IRQENABLE);
> + tscadc_writel(ts_dev, REG_IRQENABLE,
> + (idle | IRQENB_HW_PEN));
> + tscadc_writel(ts_dev, REG_IRQWAKEUP, IRQWKUP_ENB);
> + }
> + return 0;
> +}
> +
> +static int titsc_resume(struct device *dev)
> +{
> + struct ti_tscadc_dev *tscadc_dev = dev->platform_data;
> + struct tscadc *ts_dev = tscadc_dev->tsc;
> +
> + if (device_may_wakeup(tscadc_dev->dev)) {
> + tscadc_writel(ts_dev, REG_IRQWAKEUP,
> + 0x00);
> + tscadc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
> + }
> + tscadc_step_config(ts_dev);
> + tscadc_writel(ts_dev, REG_FIFO0THR,
> + ts_dev->steps_to_configure);
> + return 0;
> +}
> +
> +static const struct dev_pm_ops titsc_pm_ops = {
> + .suspend = titsc_suspend,
> + .resume = titsc_resume,
> +};
> +#define TITSC_PM_OPS (&titsc_pm_ops)
> +#else
> +#define TITSC_PM_OPS NULL
> +#endif
> +
> static struct platform_driver ti_tsc_driver = {
> .probe = tscadc_probe,
> .remove = __devexit_p(tscadc_remove),
> .driver = {
> .name = "tsc",
> .owner = THIS_MODULE,
> + .pm = TITSC_PM_OPS,
> },
> };
> module_platform_driver(ti_tsc_driver);
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 45d66e5..7e949e8 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -170,6 +170,7 @@ static int __devinit ti_tscadc_probe(struct platform_device *pdev)
> if (err < 0)
> goto err_disable_clk;
>
> + device_init_wakeup(&pdev->dev, true);
> platform_set_drvdata(pdev, tscadc);
> return 0;
>
> @@ -203,14 +204,52 @@ static int __devexit ti_tscadc_remove(struct platform_device *pdev)
> return 0;
> }
>
> +#ifdef CONFIG_PM
> +static int tscadc_suspend(struct device *dev)
> +{
> + struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev);
> +
> + tscadc_writel(tscadc_dev, REG_SE, 0x00);
> + pm_runtime_put_sync(dev);
> + return 0;
> +}
> +
> +static int tscadc_resume(struct device *dev)
> +{
> + struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev);
> + unsigned int restore, ctrl;
> +
> + pm_runtime_get_sync(dev);
> +
> + /* context restore */
> + ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_TSCENB |
> + CNTRLREG_STEPID | CNTRLREG_4WIRE;
> + tscadc_writel(tscadc_dev, REG_CTRL, ctrl);
> + tscadc_idle_config(tscadc_dev);
> + tscadc_writel(tscadc_dev, REG_SE, STPENB_STEPENB);
> + restore = tscadc_readl(tscadc_dev, REG_CTRL);
> + tscadc_writel(tscadc_dev, REG_CTRL,
> + (restore | CNTRLREG_TSCSSENB));
> + return 0;
> +}
> +
> +static const struct dev_pm_ops tscadc_pm_ops = {
> + .suspend = tscadc_suspend,
> + .resume = tscadc_resume,
> +};
> +#define TSCADC_PM_OPS (&tscadc_pm_ops)
> +#else
> +#define TSCADC_PM_OPS NULL
> +#endif
> +
> static struct platform_driver ti_tscadc_driver = {
> .driver = {
> .name = "ti_tscadc",
> .owner = THIS_MODULE,
> + .pm = TSCADC_PM_OPS,
> },
> .probe = ti_tscadc_probe,
> .remove = __devexit_p(ti_tscadc_remove),
> -
> };
>
> module_platform_driver(ti_tscadc_driver);
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index bd9fe1d..c7facdc 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -40,6 +40,9 @@
> #define REG_FIFO1 0x200
>
> /* Register Bitfields */
> +/* IRQ wakeup enable */
> +#define IRQWKUP_ENB BIT(0)
> +
> /* Step Enable */
> #define STEPENB_MASK (0x1FFFF << 0)
> #define STEPENB(val) ((val) << 0)
next prev parent reply other threads:[~2012-09-26 6:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-26 5:20 [PATCH v4 0/5] Support for TSC/ADC MFD driver Patil, Rachna
[not found] ` <1348636814-14129-1-git-send-email-rachna-l0cyMroinI0@public.gmane.org>
2012-09-26 5:20 ` [PATCH v4 1/5] input: TSC: ti_tscadc: Rename the existing touchscreen driver Patil, Rachna
2012-09-26 5:20 ` [PATCH v4 2/5] MFD: ti_tscadc: Add support for TI's TSC/ADC MFDevice Patil, Rachna
[not found] ` <1348636814-14129-3-git-send-email-rachna-l0cyMroinI0@public.gmane.org>
2012-09-30 23:15 ` Samuel Ortiz
2012-09-29 7:10 ` [PATCH v4 0/5] Support for TSC/ADC MFD driver Patil, Rachna
2012-09-26 5:20 ` [PATCH v4 3/5] input: TSC: ti_tsc: Convert TSC into a MFDevice Patil, Rachna
2012-09-26 5:20 ` [PATCH v4 4/5] IIO : ADC: tiadc: Add support of TI's ADC driver Patil, Rachna
2012-09-29 9:48 ` Jonathan Cameron
2012-09-26 5:20 ` [PATCH v4 5/5] MFD: ti_tscadc: add suspend/resume functionality Patil, Rachna
[not found] ` <1348636814-14129-6-git-send-email-rachna-l0cyMroinI0@public.gmane.org>
2012-09-26 6:40 ` Shubhrajyoti [this message]
[not found] ` <5062A373.4000707-l0cyMroinI0@public.gmane.org>
2012-09-26 10:09 ` Patil, Rachna
[not found] ` <4CE347531D4CA947960AF71FF095B9323E95738D-Er742YJ7I/eIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2012-09-29 9:50 ` Jonathan Cameron
2012-09-30 23:22 ` Samuel Ortiz
2012-10-03 6:49 ` Patil, Rachna
2012-09-29 9:42 ` [PATCH v4 0/5] Support for TSC/ADC MFD driver Jonathan Cameron
[not found] ` <5066C29D.7040009-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2012-09-29 10:06 ` Patil, Rachna
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=5062A373.4000707@ti.com \
--to=shubhrajyoti-l0cymroini0@public.gmane.org \
--cc=dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=dtor-JGs/UdohzUI@public.gmane.org \
--cc=jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rachna-l0cyMroinI0@public.gmane.org \
--cc=sameo-VuQAYsv1563Yd54FQh9/CA@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).