Skip to contentSkip to conversation

pwm: imx: Let PWM be active during suspend

PATCH RESEND Applied Fabio Estevam 3 participants 3 messages Jan 2, 2018 – Mar 27, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND v3 1/1 pwm: imx: Let PWM be active during suspend

On a imx6q-cubox-i board, which has an LED driven by PWM, when the system goes into suspend the PWM block is disabled by default, then the PWM pin goes to logic level zero and turn on the LED during suspend, which is not really the behaviour we want to see.

By keeping the PWM enabled during suspend via STOPEN bit, the pwm-leds driver sets the brightness to zero in suspend and then the LED is turned off as expected.

So always set the STOPEN to fix the PWM behaviour in suspend.

---
Hi Thierry,

Resending it in the hope we can still get this in for 4.16.

Please not that STOPEN is also unconditionally set in vendor's kernel:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/plat-mxc/pwm.c?h=imx_3.0.35_4.1.0#n106

 drivers/pwm/pwm-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pwm/pwm-imx.c +2 -1
index 2ba5c3a..08cbe81 100644
@@ -35,6 +35,7 @@
 #define MX3_PWMSAR			0x0C    /* PWM Sample Register */
 #define MX3_PWMPR			0x10    /* PWM Period Register */
 #define MX3_PWMCR_PRESCALER(x)		((((x) - 1) & 0xFFF) << 4)
+#define MX3_PWMCR_STOPEN		(1 << 25)
 #define MX3_PWMCR_DOZEEN		(1 << 24)
 #define MX3_PWMCR_WAITEN		(1 << 23)
 #define MX3_PWMCR_DBGEN			(1 << 22)
@@ -210,7 +211,7 @@ static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm,
 		writel(period_cycles, imx->mmio_base + MX3_PWMPR);
 
 		cr = MX3_PWMCR_PRESCALER(prescale) |
-		     MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
+		     MX3_PWMCR_STOPEN | MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
 		     MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH |
 		     MX3_PWMCR_EN;
 
Signature · 1 line
2.7.4
reviewer
#1 lore raw

Hi Thierry,

Quoted 11 lines · Fabio Estevam

On a imx6q-cubox-i board, which has an LED driven by PWM, when the system goes into suspend the PWM block is disabled by default, then the PWM pin goes to logic level zero and turn on the LED during suspend, which is not really the behaviour we want to see.

By keeping the PWM enabled during suspend via STOPEN bit, the pwm-leds driver sets the brightness to zero in suspend and then the LED is turned off as expected.

So always set the STOPEN to fix the PWM behaviour in suspend.

Quoted 8 lines

---
Hi Thierry,

Resending it in the hope we can still get this in for 4.16.

Please not that STOPEN is also unconditionally set in vendor's kernel:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/plat-mxc/pwm.c?h=imx_3.0.35_4.1.0#n106

We missed 4.16.

Can we get this one for 4.17?

Quoted 28 lines
 drivers/pwm/pwm-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pwm/pwm-imx.c +2 -2
index 2ba5c3a..08cbe81 100644
@@ -35,6 +35,7 @@
 #define MX3_PWMSAR                     0x0C    /* PWM Sample Register */
 #define MX3_PWMPR                      0x10    /* PWM Period Register */
 #define MX3_PWMCR_PRESCALER(x)         ((((x) - 1) & 0xFFF) << 4)
+#define MX3_PWMCR_STOPEN               (1 << 25)
 #define MX3_PWMCR_DOZEEN               (1 << 24)
 #define MX3_PWMCR_WAITEN               (1 << 23)
 #define MX3_PWMCR_DBGEN                        (1 << 22)
@@ -210,7 +211,7 @@ static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm,
                writel(period_cycles, imx->mmio_base + MX3_PWMPR);
 
                cr = MX3_PWMCR_PRESCALER(prescale) |
-                    MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
+                    MX3_PWMCR_STOPEN | MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
                     MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH |
                     MX3_PWMCR_EN;
 
--

2.7.4

#2 lore raw
In reply to Fabio Estevam
Quoted 15 lines · Fabio Estevam

On a imx6q-cubox-i board, which has an LED driven by PWM, when the system goes into suspend the PWM block is disabled by default, then the PWM pin goes to logic level zero and turn on the LED during suspend, which is not really the behaviour we want to see.

By keeping the PWM enabled during suspend via STOPEN bit, the pwm-leds driver sets the brightness to zero in suspend and then the LED is turned off as expected.

So always set the STOPEN to fix the PWM behaviour in suspend.

---
Hi Thierry,

Quoted 7 lines

Resending it in the hope we can still get this in for 4.16.

Please not that STOPEN is also unconditionally set in vendor's kernel:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/plat-mxc/pwm.c?h=imx_3.0.35_4.1.0#n106

 drivers/pwm/pwm-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks.

Thierry