@@ -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,suspend-enable: Boolean property that indicates that the PWM block stays
+ enabled during system suspend. If not present, the PWM
+ block will be disabled during suspend.
+
Example:
pwm1: pwm@53fb4000 {
@@ -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 suspend_enable;
};
#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->suspend_enable)
+ 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->suspend_enable = of_property_read_bool(np, "fsl,suspend-enable");
+
ret = pwmchip_add(&imx->chip);
if (ret < 0)
return ret;