imx6s PWM sysfs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx6s PWM sysfs

6,842 Views
markusbraitner
Contributor IV

Hello to all,

I'm trying to get pwm4 of imx6s running in linux. However, I don't get any "export"/"unexport" files in the sysfs ("/sys/class/pwm"), so I can't configure it via sysfs. Maybe somebody has an idea?

I'm using freescale kernel 3.10.17 (adapted by COM module vendor) with

CONFIG_PWM=y

CONFIG_PWM_SYSFS=y

CONFIG_PWM_IMX=y

are turned on in the kernel config.

In the freescale part of the device tree (imx6qdl.dtsi), it has

pwm4: pwm@0208c000 {

                #pwm-cells = <2>;

                compatible = "fsl,imx6q-pwm", "fsl,imx27-pwm";

                reg = <0x0208c000 0x4000>;

                interrupts = <0 86 0x04>;

                clocks = <&clks 62>, <&clks 148>;

                clock-names = "ipg", "per";

            };

My device tree extension (to imx6s.dtsi) is as follows:

&pwm4 {

        #pwm-cells = <3>;

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_mabr_pwm4>;

        status = "okay";

    };

&iomuxc {

        pinctrl-names = "default";

        pinctrl-0 = <&pinctrl_mabr_gpio_test &pinctrl_mabr_pwm4>;

        imx6s-mabr{

            pinctrl_mabr_gpio_test: gpio_test_grp {

                fsl,pins = <

                    MX6QDL_PAD_KEY_COL2__GPIO4_IO10 0x130B0     //CAN_TX | X18:14 | 100k PD, enabled

                    MX6QDL_PAD_GPIO_8__GPIO1_IO08 0x1B0B0         //CAN_RX | X18:28 | 100k PU, enabled

                    MX6QDL_PAD_CSI0_VSYNC__GPIO5_IO21 0x130B0    //CIF_D8 | X20:13 | 100k PD, enabled

                    MX6QDL_PAD_NANDF_CS1__GPIO6_IO14 0x1B0B0     //CIF_HSYNC | X20:15 | 100k PU, enabled

                >;

        };  

        pinctrl_mabr_pwm4: pwm4_grp {

                fsl,pins = <

                    MX6QDL_PAD_SD1_CMD__PWM4_OUT 0x1b0b1        //CIF_D6 | X20:11

                >;

        };

};  

ls /sys/class/pwm gives:

/sys/class/pwm# ll

drwxr-xr-x    2 root     root             0 Apr  6 15:47 ./

drwxr-xr-x   44 root     root             0 Apr  6 15:47 ../

lrwxrwxrwx    1 root     root             0 Apr  6 15:47 pwmchip0 -> ../../devices/soc0/soc.1/2000000.aips-bus/2080000.pwm/pwm/pwmchip0/

lrwxrwxrwx    1 root     root             0 Apr  6 15:47 pwmchip1 -> ../../devices/soc0/soc.1/2000000.aips-bus/2084000.pwm/pwm/pwmchip1/

lrwxrwxrwx    1 root     root             0 Apr  6 15:47 pwmchip2 -> ../../devices/soc0/soc.1/2000000.aips-bus/2088000.pwm/pwm/pwmchip2/

lrwxrwxrwx    1 root     root             0 Apr  6 15:47 pwmchip3 -> ../../devices/soc0/soc.1/2000000.aips-bus/208c000.pwm/pwm/pwmchip3/

But no "export" / "unexport" files to export/unexport a pwm device...

Has anybody an idea? Any help would be much appreciated...

Kind regards,

Markus

PS: Does anybody know what exactly the "pwm-beeper" driver does?  https://www.kernel.org/doc/Documentation/devicetree/bindings/input/pwm-beeper.txt is not really useful here... Anybody an idea how to use it?

Labels (3)
3 Replies

2,152 Views
markusbraitner
Contributor IV

By the way, meanwhile I've also figured out what the pwm-beeper driver does - it registers the pwm unit as input event source. Writing to the input event file, it is possible to control the pwm unit. Using the C code from http://oselas.community.pengutronix.narkive.com/CqLsgeFr/mini2440-pwm-beeper-works-unreliably​, I was able to control the PWM nicely. However, each time I switch the pwm unit on with it, the kernel complains ("scheduling while atomic"), so I would still prefer to simply use the pwm sysfs (or ioctl).

Kind regards,

Markus

0 Kudos

2,153 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Markus,

Besides of enabling the PWM pins on the Device Tree, have you verified the usage of the same pins by other peripherals in order to avoid pin conflicts? It is recommended having one access at time.

Additionally, you could check the following links, maybe some information would be useful:

Linux Software User Manual (i.MX6) - BlueWiki

linux/pwm – Gateworks

Linux/drivers/pwm/pwm-imx.c - Linux Cross Reference - Free Electrons

[U-Boot] [PATCH v3 3/6] pwm, imx6: add support for pwm modul on imx6

And the following document for reference in case of modifying the Device Tree:

Basic Device Tree for the Udoo Board

Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,153 Views
markusbraitner
Contributor IV

Hello Carlos,

thank you very much for your answer!

I had tried also with the pwm-backlight driver using

backlight2 {

        compatible = "pwm-backlight";

        pwms = <&pwm4 0 50000 PWM_POLARITY_INVERTED>;

        pwm-names = "backlight2";

        brightness-levels = <0 16 23 32 45 64 91 128 181 256>;

        default-brightness-level = <6>;

        status = "okay";

    };

and this worked perfectly - so I assume it is no problem with pin conflicts (which I tried to avoid).

However, the pwm-backlight driver is in my case only useful to control the backlight, but not for controlling buzzer frequency.

Thanks also for your links.

- The first one, however, uses the pwm-backlight driver, which works in my case, but is not useful, since I need the PWM unit to control a buzzer (and thus, I would like to be able to change the frequency rather than the duty cycle).

- The second link uses the pwm sysfs which I would also like to use, but since I'm missing the file like "export", I can't - which is my problem...

- The pwm-imx.c is, of course, great, but since I'm not (yet) too familiar with kernel drivers, I couldn't find out whether it somehow indirectly should set up the pwm sysfs (I didn't find any direct references to it in the code)

- I'm not sure what I can learn from the link to the uboot patch

- The link to the device tree changes for the Udoo board looks great, but as far as I can see I have done my changes exactly in the same way.

Do you maybe have still some other idea?

I've read somewhere that the kernel version could be a problem (too old), but since the kernel docu also describes the pwm sysfs (Documentation/pwm.txt), I guess that it should work even for 3.10.17, right?

Kind regards,

Markus

0 Kudos