linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] pwm: ftm: add Power Management support
@ 2014-10-15  5:21 Xiubo Li
  2014-10-15  5:21 ` [PATCH v2 1/3] pwm: ftm: fix one bug of wrong counting the use counter Xiubo Li
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Xiubo Li @ 2014-10-15  5:21 UTC (permalink / raw)
  To: thierry.reding, linux-pwm; +Cc: linux-kernel, Xiubo Li

Changes in v2:
- Fix one bug.
- Add regmap cache support.
- Remove run time PM for now.

Xiubo Li (3):
  pwm: ftm: fix one bug of wrong counting the use counter.
  pwm: ftm: add regmap rbtree type cache support.
  pwm: ftm: add Power Management support for FTM pwm.

 drivers/pwm/pwm-fsl-ftm.c | 64 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 60 insertions(+), 4 deletions(-)

-- 
2.1.0.27.g96db324

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

* [PATCH v2 1/3] pwm: ftm: fix one bug of wrong counting the use counter.
  2014-10-15  5:21 [PATCH v2 0/3] pwm: ftm: add Power Management support Xiubo Li
@ 2014-10-15  5:21 ` Xiubo Li
  2014-10-15  5:21 ` [PATCH v2 2/3] pwm: ftm: add regmap rbtree type cache support Xiubo Li
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Xiubo Li @ 2014-10-15  5:21 UTC (permalink / raw)
  To: thierry.reding, linux-pwm; +Cc: linux-kernel, Xiubo Li

No matter what times the FTM pwm is enabled, the use_count will
always be one.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/pwm/pwm-fsl-ftm.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c
index 0f2cc7e..1150598 100644
--- a/drivers/pwm/pwm-fsl-ftm.c
+++ b/drivers/pwm/pwm-fsl-ftm.c
@@ -299,7 +299,7 @@ static int fsl_counter_clock_enable(struct fsl_pwm_chip *fpc)
 {
 	int ret;
 
-	if (fpc->use_count != 0)
+	if (fpc->use_count++ != 0)
 		return 0;
 
 	/* select counter clock source */
@@ -316,8 +316,6 @@ static int fsl_counter_clock_enable(struct fsl_pwm_chip *fpc)
 		return ret;
 	}
 
-	fpc->use_count++;
-
 	return 0;
 }
 
-- 
2.1.0.27.g96db324


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

* [PATCH v2 2/3] pwm: ftm: add regmap rbtree type cache support.
  2014-10-15  5:21 [PATCH v2 0/3] pwm: ftm: add Power Management support Xiubo Li
  2014-10-15  5:21 ` [PATCH v2 1/3] pwm: ftm: fix one bug of wrong counting the use counter Xiubo Li
@ 2014-10-15  5:21 ` Xiubo Li
  2014-10-15  5:21 ` [PATCH v2 3/3] pwm: ftm: add Power Management support for FTM pwm Xiubo Li
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Xiubo Li @ 2014-10-15  5:21 UTC (permalink / raw)
  To: thierry.reding, linux-pwm; +Cc: linux-kernel, Xiubo Li

This patch is to prepare for adding PM support for FTM pwm driver
using callback function suspend and resume in .driver.pm of
platform_driver.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/pwm/pwm-fsl-ftm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c
index 1150598..9bfbea5 100644
--- a/drivers/pwm/pwm-fsl-ftm.c
+++ b/drivers/pwm/pwm-fsl-ftm.c
@@ -397,12 +397,23 @@ static int fsl_pwm_init(struct fsl_pwm_chip *fpc)
 	return 0;
 }
 
+static bool fsl_pwm_volatile_reg(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case FTM_CNT:
+		return true;
+	}
+	return false;
+}
+
 static const struct regmap_config fsl_pwm_regmap_config = {
 	.reg_bits = 32,
 	.reg_stride = 4,
 	.val_bits = 32,
 
 	.max_register = FTM_PWMLOAD,
+	.volatile_reg = fsl_pwm_volatile_reg,
+	.cache_type = REGCACHE_RBTREE,
 };
 
 static int fsl_pwm_probe(struct platform_device *pdev)
-- 
2.1.0.27.g96db324

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

* [PATCH v2 3/3] pwm: ftm: add Power Management support for FTM pwm.
  2014-10-15  5:21 [PATCH v2 0/3] pwm: ftm: add Power Management support Xiubo Li
  2014-10-15  5:21 ` [PATCH v2 1/3] pwm: ftm: fix one bug of wrong counting the use counter Xiubo Li
  2014-10-15  5:21 ` [PATCH v2 2/3] pwm: ftm: add regmap rbtree type cache support Xiubo Li
@ 2014-10-15  5:21 ` Xiubo Li
  2014-10-28  6:01 ` [PATCH v2 0/3] pwm: ftm: add Power Management support Li.Xiubo
  2014-12-01  3:25 ` Li.Xiubo
  4 siblings, 0 replies; 8+ messages in thread
From: Xiubo Li @ 2014-10-15  5:21 UTC (permalink / raw)
  To: thierry.reding, linux-pwm; +Cc: linux-kernel, Xiubo Li

Add PM support for FTM pwm driver using callback function suspend
and resume in .driver.pm of platform_driver.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/pwm/pwm-fsl-ftm.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c
index 9bfbea5..666e1be 100644
--- a/drivers/pwm/pwm-fsl-ftm.c
+++ b/drivers/pwm/pwm-fsl-ftm.c
@@ -17,6 +17,7 @@
 #include <linux/mutex.h>
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 #include <linux/pwm.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
@@ -436,7 +437,7 @@ static int fsl_pwm_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	fpc->regmap = devm_regmap_init_mmio_clk(&pdev->dev, NULL, base,
+	fpc->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "ftm_sys", base,
 						&fsl_pwm_regmap_config);
 	if (IS_ERR(fpc->regmap)) {
 		dev_err(&pdev->dev, "regmap init failed\n");
@@ -487,6 +488,51 @@ static int fsl_pwm_remove(struct platform_device *pdev)
 	return pwmchip_remove(&fpc->chip);
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int fsl_pwm_suspend(struct device *dev)
+{
+	struct fsl_pwm_chip *fpc = dev_get_drvdata(dev);
+	u32 val;
+
+	regcache_cache_only(fpc->regmap, true);
+	regcache_mark_dirty(fpc->regmap);
+
+	/* read from cache */
+	regmap_read(fpc->regmap, FTM_OUTMASK, &val);
+	if ((val & 0xFF) != 0xFF) {
+		clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_CNTEN]);
+		clk_disable_unprepare(fpc->clk[fpc->cnt_select]);
+		clk_disable_unprepare(fpc->clk[FSL_PWM_CLK_SYS]);
+	}
+
+	return 0;
+}
+
+static int fsl_pwm_resume(struct device *dev)
+{
+	struct fsl_pwm_chip *fpc = dev_get_drvdata(dev);
+	u32 val;
+
+	/* read from cache */
+	regmap_read(fpc->regmap, FTM_OUTMASK, &val);
+	if ((val & 0xFF) != 0xFF) {
+		clk_prepare_enable(fpc->clk[FSL_PWM_CLK_SYS]);
+		clk_prepare_enable(fpc->clk[fpc->cnt_select]);
+		clk_prepare_enable(fpc->clk[FSL_PWM_CLK_CNTEN]);
+	}
+
+	/* restore all registers from cache */
+	regcache_cache_only(fpc->regmap, false);
+	regcache_sync(fpc->regmap);
+
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_pwm_pm_ops = {
+		SET_SYSTEM_SLEEP_PM_OPS(fsl_pwm_suspend, fsl_pwm_resume)
+};
+
 static const struct of_device_id fsl_pwm_dt_ids[] = {
 	{ .compatible = "fsl,vf610-ftm-pwm", },
 	{ /* sentinel */ }
@@ -497,6 +543,7 @@ static struct platform_driver fsl_pwm_driver = {
 	.driver = {
 		.name = "fsl-ftm-pwm",
 		.of_match_table = fsl_pwm_dt_ids,
+		.pm = &fsl_pwm_pm_ops,
 	},
 	.probe = fsl_pwm_probe,
 	.remove = fsl_pwm_remove,
-- 
2.1.0.27.g96db324

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

* RE: [PATCH v2 0/3] pwm: ftm: add Power Management support
  2014-10-15  5:21 [PATCH v2 0/3] pwm: ftm: add Power Management support Xiubo Li
                   ` (2 preceding siblings ...)
  2014-10-15  5:21 ` [PATCH v2 3/3] pwm: ftm: add Power Management support for FTM pwm Xiubo Li
@ 2014-10-28  6:01 ` Li.Xiubo
  2014-12-01  3:25 ` Li.Xiubo
  4 siblings, 0 replies; 8+ messages in thread
From: Li.Xiubo @ 2014-10-28  6:01 UTC (permalink / raw)
  To: thierry.reding@gmail.com, linux-pwm@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org

Hi Thierry, 

Ping...


Thanks,

BRs
Xiubo


> -----Original Message-----
> From: Xiubo Li [mailto:Li.Xiubo@freescale.com]
> Sent: Wednesday, October 15, 2014 1:22 PM
> To: thierry.reding@gmail.com; linux-pwm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; Xiubo Li-B47053
> Subject: [PATCH v2 0/3] pwm: ftm: add Power Management support
> 
> Changes in v2:
> - Fix one bug.
> - Add regmap cache support.
> - Remove run time PM for now.
> 
> Xiubo Li (3):
>   pwm: ftm: fix one bug of wrong counting the use counter.
>   pwm: ftm: add regmap rbtree type cache support.
>   pwm: ftm: add Power Management support for FTM pwm.
> 
>  drivers/pwm/pwm-fsl-ftm.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
> -
>  1 file changed, 60 insertions(+), 4 deletions(-)
> 
> --
> 2.1.0.27.g96db324

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

* RE: [PATCH v2 0/3] pwm: ftm: add Power Management support
  2014-10-15  5:21 [PATCH v2 0/3] pwm: ftm: add Power Management support Xiubo Li
                   ` (3 preceding siblings ...)
  2014-10-28  6:01 ` [PATCH v2 0/3] pwm: ftm: add Power Management support Li.Xiubo
@ 2014-12-01  3:25 ` Li.Xiubo
  2014-12-01  9:49   ` Thierry Reding
  4 siblings, 1 reply; 8+ messages in thread
From: Li.Xiubo @ 2014-12-01  3:25 UTC (permalink / raw)
  To: thierry.reding@gmail.com
  Cc: linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org

Ping :) .

Thanks very much.

BRs
Xiubo



> -----Original Message-----
> From: Xiubo Li [mailto:Li.Xiubo@freescale.com]
> Sent: Wednesday, October 15, 2014 1:22 PM
> To: thierry.reding@gmail.com; linux-pwm@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org; Xiubo Li-B47053
> Subject: [PATCH v2 0/3] pwm: ftm: add Power Management support
> 
> Changes in v2:
> - Fix one bug.
> - Add regmap cache support.
> - Remove run time PM for now.
> 
> Xiubo Li (3):
>   pwm: ftm: fix one bug of wrong counting the use counter.
>   pwm: ftm: add regmap rbtree type cache support.
>   pwm: ftm: add Power Management support for FTM pwm.
> 
>  drivers/pwm/pwm-fsl-ftm.c | 64 ++++++++++++++++++++++++++++++++++++++++++++--
> -
>  1 file changed, 60 insertions(+), 4 deletions(-)
> 
> --
> 2.1.0.27.g96db324


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

* Re: [PATCH v2 0/3] pwm: ftm: add Power Management support
  2014-12-01  3:25 ` Li.Xiubo
@ 2014-12-01  9:49   ` Thierry Reding
  2014-12-01  9:51     ` Li.Xiubo
  0 siblings, 1 reply; 8+ messages in thread
From: Thierry Reding @ 2014-12-01  9:49 UTC (permalink / raw)
  To: Li.Xiubo@freescale.com
  Cc: linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 174 bytes --]

On Mon, Dec 01, 2014 at 03:25:02AM +0000, Li.Xiubo@freescale.com wrote:
> Ping :) .
> 
> Thanks very much.

Applied with a few whitespace cleanups.

Thanks,
Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

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

* RE: [PATCH v2 0/3] pwm: ftm: add Power Management support
  2014-12-01  9:49   ` Thierry Reding
@ 2014-12-01  9:51     ` Li.Xiubo
  0 siblings, 0 replies; 8+ messages in thread
From: Li.Xiubo @ 2014-12-01  9:51 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org

> Subject: Re: [PATCH v2 0/3] pwm: ftm: add Power Management support
> 
> On Mon, Dec 01, 2014 at 03:25:02AM +0000, Li.Xiubo@freescale.com wrote:
> > Ping :) .
> >
> > Thanks very much.
> 
> Applied with a few whitespace cleanups.
> 
Hi Thierry,

Thanks verrry much.

BRs
Xiubo

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

end of thread, other threads:[~2014-12-01  9:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15  5:21 [PATCH v2 0/3] pwm: ftm: add Power Management support Xiubo Li
2014-10-15  5:21 ` [PATCH v2 1/3] pwm: ftm: fix one bug of wrong counting the use counter Xiubo Li
2014-10-15  5:21 ` [PATCH v2 2/3] pwm: ftm: add regmap rbtree type cache support Xiubo Li
2014-10-15  5:21 ` [PATCH v2 3/3] pwm: ftm: add Power Management support for FTM pwm Xiubo Li
2014-10-28  6:01 ` [PATCH v2 0/3] pwm: ftm: add Power Management support Li.Xiubo
2014-12-01  3:25 ` Li.Xiubo
2014-12-01  9:49   ` Thierry Reding
2014-12-01  9:51     ` Li.Xiubo

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