3

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!

Adam Lee
  • 2,983
  • 7
  • 35
  • 47

1 Answers1

0

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 i.e. 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 ?

Devidas
  • 2,479
  • 9
  • 24
  • It is on 4.14.54. Not the latest, but pretty up to date. I just tried it and put the details in my post! – Adam Lee Jun 18 '19 at 14:37
  • 6.716560] OF: /pwm-beeper: arguments longer than property [ 6.716566] of_pwm_get(): can't parse "pwms" property suggestes that pwms has more arguments than expected. can you please try removing 0 and 5000 from pwms. – Devidas Jun 19 '19 at 06:13
  • can you also provide entries for pwm15 ? – Devidas Jun 19 '19 at 06:23
  • `pwm15` added above. Let me try removing 0 / 5000. – Adam Lee Jun 19 '19 at 12:30
  • Strangely, I am still getting the same "more arguments than expected" error with those two values removed. – Adam Lee Jun 19 '19 at 12:38
  • &pwm3 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pwm3_2>; status = "okay"; }; beeper { compatible = "pwm-beeper"; pwms = <&pwm3 0 5000000>; }; from file arch/arm/boot/dts/imx6qdl-qmx6.dtsi can you please give this a try – Devidas Jun 19 '19 at 14:29
  • hi Adam I have gone through code it. FYI root cause drivers/of/base.c:of_parse_phandle_with_args returns -EINVAL drivers/pwm/core.c:of_pwm_get -> of_parse_phandle_with_args drivers/pwm/core.c:pwm_get -> of_pwm_get drivers/pwm/core.c:devm_pwm_get -> pwm_get drivers/input/misc/pwm-beeper.c:pwm_beeper_probe -> devm_pwm_get – Devidas Jun 19 '19 at 14:54