pwm: imx: Allow keeping the PWM active during suspend
Subsystems (3)
Fabio Estevam
reviewerPATCH v2 1/1 pwm: imx: Allow keeping the PWM active during suspend
In some systems it is desirable to keep the PWM active during system suspend.
One use case is the imx6q-cubox-i board, which has an LED driven by PWM. When the system goes into suspend the PWM block is disabled by default, the PWM pin goes to 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 the pwm-leds driver sets the brightness to zero in suspend and then the LED is turned off as expected.
Introduce the 'fsl,active-in-suspend' property to indicate that the PWM will stay active during suspend.
---
Changes since v1:
- Rename the property to 'fsl,active-in-suspend' to better describe its purpose.
Documentation/devicetree/bindings/pwm/imx-pwm.txt | 5 +++++ drivers/pwm/pwm-imx.c | 8 ++++++++ 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/pwm/imx-pwm.txt +5 -0
@@ -14,6 +14,11 @@ See the clock consumer binding, Documentation/devicetree/bindings/clock/clock-bindings.txt - interrupts: The interrupt for the pwm controller +Optional properties: +- fsl,active-in-suspend: Boolean property that indicates that the PWM block + stays active during system suspend. If not present, + the PWM block stays inactive during suspend. + Example: pwm1: pwm@53fb4000 {
drivers/pwm/pwm-imx.c +8 -0
@@ -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)
@@ -54,6 +55,7 @@ struct imx_chip {void __iomem *mmio_base;struct pwm_chip chip; +bool active; };#define to_imx_chip (chip) container_of(chip, struct imx_chip, chip)
@@ -217,6 +219,9 @@ static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm,if (state->polarity ==PWM_POLARITY_INVERSED ) cr |=MX3_PWMCR_POUTC ; +if (imx->active) + cr |=MX3_PWMCR_STOPEN ; +writel (cr, imx->mmio_base +MX3_PWMCR ); }else if (cstate.enabled) {writel (0 , imx->mmio_base +MX3_PWMCR );
@@ -264,6 +269,7 @@ static int imx_pwm_probe(struct platform_device *pdev) {const struct of_device_id *of_id =of_match_device (imx_pwm_dt_ids, &pdev->dev); +struct device_node *np = pdev->dev.of_node;const struct imx_pwm_data *data;struct imx_chip *imx;struct resource *r;
@@ -301,6 +307,8 @@ static int imx_pwm_probe(struct platform_device *pdev)if (IS_ERR (imx->mmio_base))return PTR_ERR (imx->mmio_base); + imx->active =of_property_read_bool (np,"fsl,active-in-suspend" ); + ret =pwmchip_add (&imx->chip);if (ret <0 )return ret;
Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 1511015768-14140-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 7 lines · Fabio Estevam
In some systems it is desirable to keep the PWM active during system suspend.
One use case is the imx6q-cubox-i board, which has an LED driven by PWM. When the system goes into suspend the PWM block is disabled by default, the PWM pin goes to zero and turn on the LED during suspend, which is not really the behaviour we want to see.
Seems to me the default behavior should be LEDs are off in suspend and you'd add a property to enable them if desired.
You problem to me sounds like something that should be fixed in the pwm and/or pwm-led drivers.
Quoted 7 lines
By keeping the PWM enabled during suspend the pwm-leds driver sets the brightness to zero in suspend and then the LED is turned off as expected.
Introduce the 'fsl,active-in-suspend' property to indicate that the PWM will stay active during suspend.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Rob Herring
Seems to me the default behavior should be LEDs are off in suspend and you'd add a property to enable them if desired.
You problem to me sounds like something that should be fixed in the pwm and/or pwm-led drivers.
pwm-leds does set brightness to 0 in suspend and the fix here is to make pwm-imx active during suspend, so that when pwm-leds sets the brightness to 0, then pwm-imx really goes to logic level 1.
Please note that on imx6qdl-cuboxi the pwm is active low.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Fabio Estevam
reviewerHi Rob,
Quoted 2 lines · Rob Herring
Seems to me the default behavior should be LEDs are off in suspend and you'd add a property to enable them if desired.
Are you suggesting that I set the MX3_PWMCR_STOPEN bit unconditionally?
I see some old version of vendor driver that does exactly that:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/plat-mxc/pwm.c?h=imx_2.6.35_11.09.01
I can do that and then we do not need to add an extra device tree property.
Thanks