简体   繁体   中英

How do I use pwm-beeper module in Linux Kernel?

I have set my PWM driven beeper up as per the Linux device tree documentation . I see that this results in an extra input device in /sys/class/input:

root:/sys/class/input/input0# ls
capabilities  device        event0        id            modalias      name          phys          power         properties    subsystem     uevent        uniq
root:/sys/class/input/input0# cat name
pwm-beeper

However, I don't see anything related to the duty cycle, polarity etc to actually control the beeper. Perhaps I am very mistaken about pwm-beeper as it is clearly created as an input device. Please help!

[update]

Changes in my dts :

pwm15: dmtimer-pwm@15 {                                                                                                                                                                                                                                                           
            compatible = "ti,omap-dmtimer-pwm";                                                                                                                                                                                                                                       
            ti,timers = <&timer15>;                                                                                                                                                                                                                                                   
            #pwm-cells = <3>;                                                                                                                                                                                                                                                         
};       
beeper: pwm-beeper {                                                                                                                                                                                                                                                              
                compatible = "pwm-beeper";                                                                                                                                                                                                                                        
                pwms = <&pwm15 0 5000>;                                                                                                                                                                                                                                           
                volume-levels = <0 8 20 40 500>;                                                                                                                                                                                                                                  
                default-volume-level = <4>;                                                                                                                                                                                                                                       
};  

Relevant dmesg :

[ 6.716560] OF: /pwm-beeper: arguments longer than property
[ 6.716566] of_pwm_get(): can't parse "pwms" property
[ 6.716574] pwm-beeper pwm-beeper: Failed to request PWM device: -22
[ 6.716590] pwm-beeper: probe of pwm-beeper failed with error -22

I am utterly confused because there is just so little info about this device driver mainlined in Linux!

can you post snippet of DT block you have added? try this block

pwm-beeper {
    compatible = "pwm-beeper";
    pwms = <&pwm4 0 5000>;
    volume-levels = <0 8 20 40 500>;
    default-volume-level = <4>;
};

Update 1

TLDR; either reduce you #pwm-cells to 2 Or add one more field ie third field to list like pwms = <&pwm4 0 5000 1>;

phandle1: node1 {
     #list-cells = <2>;
}   

phandle2: node2 {
     #list-cells = <1>;
}

node3 {
     list = <&phandle1 1 2 &phandle2 3>;
}

here notice list has #list-cells differant

phadle1 has 2

phadle2 has 1

so accordingly list has entries.

This will work whats you linux version ? can you test it on latest stable ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM