diff mbox

[V2] i2c: imx-lpi2c: add VLLS mode support

Message ID 1484636967-23599-1-git-send-email-pandy.gao@nxp.com
State Superseded
Headers show

Commit Message

Gao Pan Jan. 17, 2017, 7:09 a.m. UTC
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>
---
V2:
 -drop "#else branch" and IMX_LPI2C_PM completely
 -pm = &imx_lpi2c_pm

 drivers/i2c/busses/i2c-imx-lpi2c.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Vladimir Zapolskiy Jan. 17, 2017, 9:10 a.m. UTC | #1
Hello Pandy,

On 01/17/2017 09:09 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>
> ---
> V2:
>  -drop "#else branch" and IMX_LPI2C_PM completely
>  -pm = &imx_lpi2c_pm
> 
>  drivers/i2c/busses/i2c-imx-lpi2c.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index c62b7cd..dbde95d 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -636,12 +636,33 @@ 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);
> +#endif

in case if I didn't manage to explain what is desirable, please change
the order of two lines above, you may find that commonly SIMPLE_DEV_PM_OPS()
macro is used outside #ifdef CONFIG_PM_SLEEP, due to the feature that
CONFIG_PM_SLEEP token is incorporated into SIMPLE_DEV_PM_OPS() internals.

> +
>  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,
> +#ifdef CONFIG_PM_SLEEP
> +		.pm = &imx_lpi2c_pm,
> +#endif

Then this #ifdef won't be needed here.

>  	},
>  };
>  
> 

--
With best wishes,
Vladimir
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gao Pan Jan. 17, 2017, 10:14 a.m. UTC | #2
From: Vladimir Zapolskiy <mailto:vz@mleia.com>  Sent: Tuesday, January 17, 2017 5:10 PM

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

> Subject: Re: [Patch V2] i2c: imx-lpi2c: add VLLS mode support

> 

> Hello Pandy,

> 

> On 01/17/2017 09:09 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>

> > ---

> > V2:

> >  -drop "#else branch" and IMX_LPI2C_PM completely  -pm =

> &imx_lpi2c_pm

> >

> >  drivers/i2c/busses/i2c-imx-lpi2c.c | 21 +++++++++++++++++++++

> >  1 file changed, 21 insertions(+)

> >

> > diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c

> > b/drivers/i2c/busses/i2c-imx-lpi2c.c

> > index c62b7cd..dbde95d 100644

> > --- a/drivers/i2c/busses/i2c-imx-lpi2c.c

> > +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c

> > @@ -636,12 +636,33 @@ 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); #endif

> 

> in case if I didn't manage to explain what is desirable, please change

> the order of two lines above, you may find that commonly

> SIMPLE_DEV_PM_OPS() macro is used outside #ifdef CONFIG_PM_SLEEP,

> due to the feature that CONFIG_PM_SLEEP token is incorporated into

> SIMPLE_DEV_PM_OPS() internals.

> 

> > +

> >  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,

> > +#ifdef CONFIG_PM_SLEEP

> > +		.pm = &imx_lpi2c_pm,

> > +#endif

> 

> Then this #ifdef won't be needed here.


Yes, you are right. Will change it in next version. Thanks

Best Regards
Gao Pan
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index c62b7cd..dbde95d 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -636,12 +636,33 @@  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);
+#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,
+#ifdef CONFIG_PM_SLEEP
+		.pm = &imx_lpi2c_pm,
+#endif
 	},
 };