AnsweredAssumed Answered

Can't Enable Multiple PWM on iMX8M-Mini

Question asked by Jon Sowers on May 28, 2020
Latest reply on May 29, 2020 by Jon Sowers

I am trying to enable two PWMs to control manually via sysfs. Enabling one with the following additions to my device tree sources works as expected:

&iomuxc {
    ...
    ucm-imx8m-mini {
        ...
        pinctrl_pwm1: pwm@1 {
            fsl,pins = <
                MX8MM_IOMUXC_GPIO1_IO01_PWM1_OUT    0x80000000
            >;
        };
    };
};
&pwm1 { /* buzzer */
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_pwm1>;
    status = "okay";
};

this creates /sys/class/pwm/pwmchip0 from which I can export pwm0

 

However, if I try to enable any other pwm as with the following, it fails:

&iomuxc {
    ...
    ucm-imx8m-mini {
        ...
        pinctrl_pwm2: pwm@2 {
            fsl,pins = <
                MX8MM_IOMUXC_SPDIF_RX_PWM2_OUT    0x80000000
            >;
        };
    };
    ...
};


&pwm2 { /* constant current source */
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_pwm2>;
    status = "okay";
};

 

I have verified that the above is actually compiled into my final dtb by de-compiling it:

...
            pwm@1 {
                fsl,pins = <0x2c 0x294 0x0 0x1 0x0 0x80000000>;
                linux,phandle = <0x4b>;
                phandle = <0x4b>;
            };

            pwm@2 {
                fsl,pins = <0x1ec 0x454 0x0 0x1 0x0 0x80000000>;
                linux,phandle = <0x4c>;
                phandle = <0x4c>;
            };
...


    pwm@30660000 {
        compatible = "fsl,imx8mm-pwm", "fsl,imx27-pwm";
        reg = <0x0 0x30660000 0x0 0x10000>;
        interrupts = <0x0 0x51 0x4>;
        clocks = <0x4 0x18f 0x4 0x18f>;
        clock-names = "ipg", "per";
        #pwm-cells = <0x2>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <0x4b>;
    };

    pwm@30670000 {
        compatible = "fsl,imx8mm-pwm", "fsl,imx27-pwm";
        reg = <0x0 0x30670000 0x0 0x10000>;
        interrupts = <0x0 0x52 0x4>;
        clocks = <0x4 0x190 0x4 0x190>;
        clock-names = "ipg", "per";
        #pwm-cells = <0x2>;
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <0x4c>;
    };

 

I did have to delete a pinctrl node exporting PWM2 on a different pad in an inherited dts file, but I have verified this did not make it to the final compiled dtb.

 

The result of adding the second (and I have tried with both PWM2 and PWM3) is the following error suggesting that PWM2 is trying to use the same pinctrl pad as PWM1 which from the above device tree seems like an error.

 

[] imx8mm-pinctrl 30330000.pinctrl: pin MX8MM_IOMUXC_GPIO1_IO01 already requested by 30660000.pwm; cannot claim for 30670000.pwm
[] imx8mm-pinctrl 30330000.pinctrl: pin-11 (30670000.pwm) status -22
[] imx8mm-pinctrl 30330000.pinctrl: could not request pin 11 (MX8MM_IOMUXC_GPIO1_IO01) from group pwm  on device 30330000.pinctrl
[] imx-pwm 30670000.pwm: Error applying setting, reverse things back
[] imx-pwm: probe of 30670000.pwm failed with error -22

 

If I remove PWM1 from the device tree, PWM2 seems to work fine.

 

Is there something I'm missing to be able to setup both PWM chips in parallel?

Outcomes