linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch V1] i2c: imx-lpi2c: add VLLS mode support
@ 2017-01-04  9:20 Gao Pan
  2017-01-06 21:20 ` Vladimir Zapolskiy
  0 siblings, 1 reply; 3+ messages in thread
From: Gao Pan @ 2017-01-04  9:20 UTC (permalink / raw)
  To: wsa, wsa-dev; +Cc: linux-i2c, pandy.gao, frank.li, fugang.duan

When system enters VLLS mode, module power is turned off. As a result,
all registers are reset to HW default value. After exiting VLLS mode,
registers are still in default mode. As a result, the pinctrl settings
are incorrect, which will affect the module function.

The patch recovers the pinctrl setting when exit VLLS mode.

Signed-off-by: Gao Pan <pandy.gao@nxp.com>
---
 drivers/i2c/busses/i2c-imx-lpi2c.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index c62b7cd..e528c1d1 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -636,12 +636,34 @@ static int lpi2c_imx_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int lpi2c_imx_suspend(struct device *dev)
+{
+	pinctrl_pm_select_sleep_state(dev);
+
+	return 0;
+}
+
+static int lpi2c_imx_resume(struct device *dev)
+{
+	pinctrl_pm_select_default_state(dev);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(imx_lpi2c_pm, lpi2c_imx_suspend, lpi2c_imx_resume);
+#define IMX_LPI2C_PM	(&imx_lpi2c_pm)
+#else
+#define IMX_LPI2C_PM	NULL
+#endif
+
 static struct platform_driver lpi2c_imx_driver = {
 	.probe = lpi2c_imx_probe,
 	.remove = lpi2c_imx_remove,
 	.driver = {
 		.name = DRIVER_NAME,
 		.of_match_table = lpi2c_imx_of_match,
+		.pm = IMX_LPI2C_PM,
 	},
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch V1] i2c: imx-lpi2c: add VLLS mode support
  2017-01-04  9:20 [Patch V1] i2c: imx-lpi2c: add VLLS mode support Gao Pan
@ 2017-01-06 21:20 ` Vladimir Zapolskiy
  2017-01-17  6:11   ` Pandy Gao
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Zapolskiy @ 2017-01-06 21:20 UTC (permalink / raw)
  To: Gao Pan, wsa, wsa-dev; +Cc: linux-i2c, frank.li, fugang.duan

Hi,

On 01/04/2017 11:20 AM, Gao Pan wrote:
> When system enters VLLS mode, module power is turned off. As a result,
> all registers are reset to HW default value. After exiting VLLS mode,
> registers are still in default mode. As a result, the pinctrl settings
> are incorrect, which will affect the module function.
> 
> The patch recovers the pinctrl setting when exit VLLS mode.
> 
> Signed-off-by: Gao Pan <pandy.gao@nxp.com>
> ---
>  drivers/i2c/busses/i2c-imx-lpi2c.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index c62b7cd..e528c1d1 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -636,12 +636,34 @@ static int lpi2c_imx_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int lpi2c_imx_suspend(struct device *dev)
> +{
> +	pinctrl_pm_select_sleep_state(dev);
> +
> +	return 0;
> +}
> +
> +static int lpi2c_imx_resume(struct device *dev)
> +{
> +	pinctrl_pm_select_default_state(dev);
> +
> +	return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(imx_lpi2c_pm, lpi2c_imx_suspend, lpi2c_imx_resume);
> +#define IMX_LPI2C_PM	(&imx_lpi2c_pm)
> +#else
> +#define IMX_LPI2C_PM	NULL

Please drop #else branch and IMX_LPI2C_PM completely.

> +#endif
> +
>  static struct platform_driver lpi2c_imx_driver = {
>  	.probe = lpi2c_imx_probe,
>  	.remove = lpi2c_imx_remove,
>  	.driver = {
>  		.name = DRIVER_NAME,
>  		.of_match_table = lpi2c_imx_of_match,
> +		.pm = IMX_LPI2C_PM,

Here it should be:

		.pm = &imx_lpi2c_pm,

>  	},
>  };
>  

--
With best wishes,
Vladimir

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [Patch V1] i2c: imx-lpi2c: add VLLS mode support
  2017-01-06 21:20 ` Vladimir Zapolskiy
@ 2017-01-17  6:11   ` Pandy Gao
  0 siblings, 0 replies; 3+ messages in thread
From: Pandy Gao @ 2017-01-17  6:11 UTC (permalink / raw)
  To: Vladimir Zapolskiy, wsa@the-dreams.de,
	wsa-dev@sang-engineering.com
  Cc: linux-i2c@vger.kernel.org, Frank Li, Andy Duan

 From: Vladimir Zapolskiy <mailto:vz@mleia.com>  Sent: Saturday, January 07, 2017 5:20 AM
> To: Pandy Gao <pandy.gao@nxp.com>; wsa@the-dreams.de; wsa-
> dev@sang-engineering.com
> Cc: linux-i2c@vger.kernel.org; Frank Li <frank.li@nxp.com>; Andy Duan
> <fugang.duan@nxp.com>
> Subject: Re: [Patch V1] i2c: imx-lpi2c: add VLLS mode support
> 
> Hi,
> 
> On 01/04/2017 11:20 AM, Gao Pan wrote:
> > When system enters VLLS mode, module power is turned off. As a
> result,
> > all registers are reset to HW default value. After exiting VLLS mode,
> > registers are still in default mode. As a result, the pinctrl settings
> > are incorrect, which will affect the module function.
> >
> > The patch recovers the pinctrl setting when exit VLLS mode.
> >
> > Signed-off-by: Gao Pan <pandy.gao@nxp.com>
> > ---
> >  drivers/i2c/busses/i2c-imx-lpi2c.c | 22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> >
> > diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c
> > b/drivers/i2c/busses/i2c-imx-lpi2c.c
> > index c62b7cd..e528c1d1 100644
> > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> > @@ -636,12 +636,34 @@ static int lpi2c_imx_remove(struct
> platform_device *pdev)
> >  	return 0;
> >  }
> >
> > +#ifdef CONFIG_PM_SLEEP
> > +static int lpi2c_imx_suspend(struct device *dev) {
> > +	pinctrl_pm_select_sleep_state(dev);
> > +
> > +	return 0;
> > +}
> > +
> > +static int lpi2c_imx_resume(struct device *dev) {
> > +	pinctrl_pm_select_default_state(dev);
> > +
> > +	return 0;
> > +}
> > +
> > +static SIMPLE_DEV_PM_OPS(imx_lpi2c_pm, lpi2c_imx_suspend,
> lpi2c_imx_resume);
> > +#define IMX_LPI2C_PM	(&imx_lpi2c_pm)
> > +#else
> > +#define IMX_LPI2C_PM	NULL
> 
> Please drop #else branch and IMX_LPI2C_PM completely.

Thanks,  will change it in next version. 

> > +#endif
> > +
> >  static struct platform_driver lpi2c_imx_driver = {
> >  	.probe = lpi2c_imx_probe,
> >  	.remove = lpi2c_imx_remove,
> >  	.driver = {
> >  		.name = DRIVER_NAME,
> >  		.of_match_table = lpi2c_imx_of_match,
> > +		.pm = IMX_LPI2C_PM,
> 
> Here it should be:
> 
> 		.pm = &imx_lpi2c_pm,

Thanks, will change it in next version.  As the above "#else branch" is removed, the following condition is necessary.
#ifdef CONFIG_PM_SLEEP
                .pm = &imx_lpi2c_pm,
#endif

Best Regards
Pandy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-17  6:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-04  9:20 [Patch V1] i2c: imx-lpi2c: add VLLS mode support Gao Pan
2017-01-06 21:20 ` Vladimir Zapolskiy
2017-01-17  6:11   ` Pandy Gao

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).