All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] pwm-tiehrpwm: fixes for disabling PWMs
@ 2018-06-11  6:09 ` Vignesh R
  0 siblings, 0 replies; 7+ messages in thread
From: Vignesh R @ 2018-06-11  6:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, linux-omap, linux-kernel, Vignesh R

EHRPWM has two PWM outputs. Currently with pwm-tiehrpwm driver, if PWMA
is enabled and then disabled, and then PWMB is enabled, it is seen that
PWMA turns on automatically. This series fixes the bug.

Vignesh R (2):
  pwm: pwm-tiehrpwm: Don't use emulation mode bits to control PWM output
  pwm: pwm-tiehrpwm: Fix disabling of output of PWMs

 drivers/pwm/pwm-tiehrpwm.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

-- 
2.17.1

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

* [PATCH 0/2] pwm-tiehrpwm: fixes for disabling PWMs
@ 2018-06-11  6:09 ` Vignesh R
  0 siblings, 0 replies; 7+ messages in thread
From: Vignesh R @ 2018-06-11  6:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, linux-omap, linux-kernel, Vignesh R

EHRPWM has two PWM outputs. Currently with pwm-tiehrpwm driver, if PWMA
is enabled and then disabled, and then PWMB is enabled, it is seen that
PWMA turns on automatically. This series fixes the bug.

Vignesh R (2):
  pwm: pwm-tiehrpwm: Don't use emulation mode bits to control PWM output
  pwm: pwm-tiehrpwm: Fix disabling of output of PWMs

 drivers/pwm/pwm-tiehrpwm.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

-- 
2.17.1

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

* [PATCH 1/2] pwm: pwm-tiehrpwm: Don't use emulation mode bits to control PWM output
  2018-06-11  6:09 ` Vignesh R
@ 2018-06-11  6:09   ` Vignesh R
  -1 siblings, 0 replies; 7+ messages in thread
From: Vignesh R @ 2018-06-11  6:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, linux-omap, linux-kernel, Vignesh R

As per AM335x TRM SPRUH73P "15.2.2.11 ePWM Behavior During Emulation",
TBCTL[15:14] only have effect during emulation suspend events (IOW,
to stop PWM when debugging using a debugger). These bits have no effect
on PWM output during normal running of system. Hence, remove code
accessing these bits as they have no role in enabling/disabling PWMs.

Fixes: 19891b20e7c2 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM")
Cc: stable@vger.kernel.org
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/pwm/pwm-tiehrpwm.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 4c22cb395040..768176f54d5e 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -33,10 +33,6 @@
 #define TBCTL			0x00
 #define TBPRD			0x0A
 
-#define TBCTL_RUN_MASK		(BIT(15) | BIT(14))
-#define TBCTL_STOP_NEXT		0
-#define TBCTL_STOP_ON_CYCLE	BIT(14)
-#define TBCTL_FREE_RUN		(BIT(15) | BIT(14))
 #define TBCTL_PRDLD_MASK	BIT(3)
 #define TBCTL_PRDLD_SHDW	0
 #define TBCTL_PRDLD_IMDT	BIT(3)
@@ -360,7 +356,7 @@ static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 	/* Channels polarity can be configured from action qualifier module */
 	configure_polarity(pc, pwm->hwpwm);
 
-	/* Enable TBCLK before enabling PWM device */
+	/* Enable TBCLK */
 	ret = clk_enable(pc->tbclk);
 	if (ret) {
 		dev_err(chip->dev, "Failed to enable TBCLK for %s: %d\n",
@@ -368,9 +364,6 @@ static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 		return ret;
 	}
 
-	/* Enable time counter for free_run */
-	ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_FREE_RUN);
-
 	return 0;
 }
 
@@ -400,9 +393,6 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 	/* Disabling TBCLK on PWM disable */
 	clk_disable(pc->tbclk);
 
-	/* Stop Time base counter */
-	ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_STOP_NEXT);
-
 	/* Disable clock on PWM disable */
 	pm_runtime_put_sync(chip->dev);
 }
-- 
2.17.1

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

* [PATCH 1/2] pwm: pwm-tiehrpwm: Don't use emulation mode bits to control PWM output
@ 2018-06-11  6:09   ` Vignesh R
  0 siblings, 0 replies; 7+ messages in thread
From: Vignesh R @ 2018-06-11  6:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, linux-omap, linux-kernel, Vignesh R

As per AM335x TRM SPRUH73P "15.2.2.11 ePWM Behavior During Emulation",
TBCTL[15:14] only have effect during emulation suspend events (IOW,
to stop PWM when debugging using a debugger). These bits have no effect
on PWM output during normal running of system. Hence, remove code
accessing these bits as they have no role in enabling/disabling PWMs.

Fixes: 19891b20e7c2 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM")
Cc: stable@vger.kernel.org
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/pwm/pwm-tiehrpwm.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 4c22cb395040..768176f54d5e 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -33,10 +33,6 @@
 #define TBCTL			0x00
 #define TBPRD			0x0A
 
-#define TBCTL_RUN_MASK		(BIT(15) | BIT(14))
-#define TBCTL_STOP_NEXT		0
-#define TBCTL_STOP_ON_CYCLE	BIT(14)
-#define TBCTL_FREE_RUN		(BIT(15) | BIT(14))
 #define TBCTL_PRDLD_MASK	BIT(3)
 #define TBCTL_PRDLD_SHDW	0
 #define TBCTL_PRDLD_IMDT	BIT(3)
@@ -360,7 +356,7 @@ static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 	/* Channels polarity can be configured from action qualifier module */
 	configure_polarity(pc, pwm->hwpwm);
 
-	/* Enable TBCLK before enabling PWM device */
+	/* Enable TBCLK */
 	ret = clk_enable(pc->tbclk);
 	if (ret) {
 		dev_err(chip->dev, "Failed to enable TBCLK for %s: %d\n",
@@ -368,9 +364,6 @@ static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 		return ret;
 	}
 
-	/* Enable time counter for free_run */
-	ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_FREE_RUN);
-
 	return 0;
 }
 
@@ -400,9 +393,6 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 	/* Disabling TBCLK on PWM disable */
 	clk_disable(pc->tbclk);
 
-	/* Stop Time base counter */
-	ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_STOP_NEXT);
-
 	/* Disable clock on PWM disable */
 	pm_runtime_put_sync(chip->dev);
 }
-- 
2.17.1

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

* [PATCH 2/2] pwm: pwm-tiehrpwm: Fix disabling of output of PWMs
  2018-06-11  6:09 ` Vignesh R
@ 2018-06-11  6:09   ` Vignesh R
  -1 siblings, 0 replies; 7+ messages in thread
From: Vignesh R @ 2018-06-11  6:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, linux-omap, linux-kernel, Vignesh R

pwm-tiehrpwm driver disables PWM output by putting it in low output
state via active AQCSFRC register in ehrpwm_pwm_disable(). But, the
AQCSFRC shadow register is not updated. Therefore, when shadow AQCSFRC
register is re-enabled in ehrpwm_pwm_enable() (say to enable second PWM
output), previous settings are lost as shadow register value is loaded
into active register. This results in things like PWMA getting enabled
automatically, when PWMB is enabled and vice versa. Fix this by
updating AQCSFRC shadow register as well during ehrpwm_pwm_disable().

Fixes: 19891b20e7c2 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM")
Cc: stable@vger.kernel.org
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/pwm/pwm-tiehrpwm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 768176f54d5e..f7b8a86fa5c5 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -381,6 +381,8 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 		aqcsfrc_mask = AQCSFRC_CSFA_MASK;
 	}
 
+	/* Update shadow register first before modifying active register */
+	ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val);
 	/*
 	 * Changes to immediate action on Action Qualifier. This puts
 	 * Action Qualifier control on PWM output from next TBCLK
-- 
2.17.1

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

* [PATCH 2/2] pwm: pwm-tiehrpwm: Fix disabling of output of PWMs
@ 2018-06-11  6:09   ` Vignesh R
  0 siblings, 0 replies; 7+ messages in thread
From: Vignesh R @ 2018-06-11  6:09 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm, linux-omap, linux-kernel, Vignesh R

pwm-tiehrpwm driver disables PWM output by putting it in low output
state via active AQCSFRC register in ehrpwm_pwm_disable(). But, the
AQCSFRC shadow register is not updated. Therefore, when shadow AQCSFRC
register is re-enabled in ehrpwm_pwm_enable() (say to enable second PWM
output), previous settings are lost as shadow register value is loaded
into active register. This results in things like PWMA getting enabled
automatically, when PWMB is enabled and vice versa. Fix this by
updating AQCSFRC shadow register as well during ehrpwm_pwm_disable().

Fixes: 19891b20e7c2 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM")
Cc: stable@vger.kernel.org
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
 drivers/pwm/pwm-tiehrpwm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 768176f54d5e..f7b8a86fa5c5 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -381,6 +381,8 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 		aqcsfrc_mask = AQCSFRC_CSFA_MASK;
 	}
 
+	/* Update shadow register first before modifying active register */
+	ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val);
 	/*
 	 * Changes to immediate action on Action Qualifier. This puts
 	 * Action Qualifier control on PWM output from next TBCLK
-- 
2.17.1

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

* Re: [PATCH 0/2] pwm-tiehrpwm: fixes for disabling PWMs
  2018-06-11  6:09 ` Vignesh R
                   ` (2 preceding siblings ...)
  (?)
@ 2018-07-09 16:58 ` Thierry Reding
  -1 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2018-07-09 16:58 UTC (permalink / raw)
  To: Vignesh R; +Cc: linux-pwm, linux-omap, linux-kernel

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

On Mon, Jun 11, 2018 at 11:39:54AM +0530, Vignesh R wrote:
> EHRPWM has two PWM outputs. Currently with pwm-tiehrpwm driver, if PWMA
> is enabled and then disabled, and then PWMB is enabled, it is seen that
> PWMA turns on automatically. This series fixes the bug.
> 
> Vignesh R (2):
>   pwm: pwm-tiehrpwm: Don't use emulation mode bits to control PWM output
>   pwm: pwm-tiehrpwm: Fix disabling of output of PWMs
> 
>  drivers/pwm/pwm-tiehrpwm.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)

Applied, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2018-07-09 16:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11  6:09 [PATCH 0/2] pwm-tiehrpwm: fixes for disabling PWMs Vignesh R
2018-06-11  6:09 ` Vignesh R
2018-06-11  6:09 ` [PATCH 1/2] pwm: pwm-tiehrpwm: Don't use emulation mode bits to control PWM output Vignesh R
2018-06-11  6:09   ` Vignesh R
2018-06-11  6:09 ` [PATCH 2/2] pwm: pwm-tiehrpwm: Fix disabling of output of PWMs Vignesh R
2018-06-11  6:09   ` Vignesh R
2018-07-09 16:58 ` [PATCH 0/2] pwm-tiehrpwm: fixes for disabling PWMs Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.