AnsweredAssumed Answered

PWM with iMX6UL

Question asked by Alvaro Martinez on Jan 1, 2016
Latest reply on Aug 30, 2017 by javier fernandez

Dear all,

 

Happy new year!

 

I am working with the imx6ulevk.

To follow with my device tree customization, I want to add pwm functionality to some pins. I have chosen sd1_nrst (gpio_9) and sd1_vselect (gpio_5). According to imx6ul-pinfunc.h they can be used as pwm2 and pwm4.

 

at imx6ul-14x14-evk.dts I have modified the following:

//backlight

&pwm1 {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_pwm1>;

    status = "okay";

};

 

//added by me

&pwm2 {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_pwm2>;

    status = "okay";

};

&pwm4 {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_pwm4>;

    status = "okay";

};

//end

 

I have redefined the functionality of GPIO1_IO05 and GPIO1_IO09 at iomuxc as it is done for pwm1 (backlight):

 

&iomuxc {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_hog_1>;

    imx6ul-evk {

        pinctrl_hog_1: hoggrp-1 {

            fsl,pins = <

                //MX6UL_PAD_GPIO1_IO05__USDHC1_VSELECT    0x17059 /* SD1 VSELECT */
                //MX6UL_PAD_GPIO1_IO09__GPIO1_IO09        0x17059 /* SD1 RESET */

            >;
        };

.....

        pinctrl_pwm1: pwm1grp {
            fsl,pins = <
                MX6UL_PAD_GPIO1_IO08__PWM1_OUT   0x110b0
            >;
        };

        pinctrl_pwm2: pwm2grp {
            fsl,pins = <
                MX6UL_PAD_GPIO1_IO09__PWM2_OUT   0x110b0
            >;
        };
        pinctrl_pwm4: pwm4grp {
            fsl,pins = <
                MX6UL_PAD_GPIO1_IO05__PWM4_OUT   0x110b0
            >;
        };

 

 

I have not replaced the kernel, as I understand the pwm support is already enabled at Device drivers > pwm support > i.MX pwm support.

 

I can modify brightness of the backlight and it works: echo 5 > /sys/class/backlight/backlight.8/brightness

 

However, when I try to configure pwm2 and pwm4 at command line, the operating system does not respond and I have to reboot.

to work with pwm2 (gpio_9, sd1_nreset), I do the following:

$echo 0 > /sys/class/pwm/pwmchip1/export

it creates pwm0 folder and I try to set the period (1sec)

$echo 1000000000 > /sys/class/pwm/pwmchip1/pwm0/period

The system crashes here.

It happens the same if instead of trying to set the period, I enable the output or try to do any other thing.

 

It also happens with pwm4 (gpio_5, sd1_vselect)

$echo 0 > /sys/class/pwm/pwmchip3/export

it creates pwm0 folder and I try to set the period (1sec)

$echo 1000000000 > /sys/class/pwm/pwmchip3/pwm0/period

The system crashes here.

I happens the same if instead of trying to set the period, I enable the output or try to do any other thing.

 

If I execute cat /sys/kernel/debug/pwm, I get:

 

platform/20fc000.pwm, 1 PWM device

pwm-0   ((null)              ):

platform/20f8000.pwm, 1 PWM device

pwm-0   ((null)              ):

platform/20f4000.pwm, 1 PWM device

pwm-0   ((null)              ):

platform/20f0000.pwm, 1 PWM device

pwm-0   ((null)              ):

platform/208c000.pwm, 1 PWM device

pwm-0   ((null)              ):

platform/2088000.pwm, 1 PWM device

pwm-0   ((null)              ):

platform/2084000.pwm, 1 PWM device

pwm-0   ((null)              ):

platform/2080000.pwm, 1 PWM device

pwm-0   (backlight           ): requested enabled

 

Could you give me any hints about what I am doing wrong??

Thank you in advance!

BR

Outcomes