Skip to contentSkip to conversation

How to test a pwm device, is there a test program?

exynos4412 randy 3 participants 9 messages Dec 8, 2013 – Dec 14, 2013

Subsystems (2)
lore
Share & tools
lore

randy

author
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The dts for my board tiny4412 is ready, in my board, the pwm 0 is connect to a buzzer. I want to test whether it works, but I don't know any test util. As I have a oscillograph, there is no problem for me to measure whether the output is correct.
Thanks
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJSpKq6AAoJEPb4VsMIzTzizgMH/0uYcf0oMc6Hvc4X8zmMFJRm QKgoPv4y0v0jQmN59ZANQC4AkqU3PiUEeirBufYTEFEn0EYtSKSOGj+fcRy6tXUq 22FibOy/S3zdrFM3kt3XiXHhGjJyiMlLgHoOWk0KnkSbXT99/c3wDtspLtcwTa4j r7iUx7kqdQd+o6Q05ahMcMr+33jMVLDinr/ixTJsvXWa0dLJmYa3vMkVKGa8aOZb jlwwJ8Nj3VzQcVfjiVdJ90OGshAQ/1auF7DGWHKcWX4IoLuAtKZPYZrhq8nno9Cy xDVA0uO+zUX1iCTQxSHNw269K1uQT+XdGusN6cZ/JUw9+9r+VI2dIzO/e/ASk+8= =PfFs
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 8 lines · randy

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The dts for my board tiny4412 is ready, in my board, the pwm 0 is connect to a buzzer. I want to test whether it works, but I don't know any test util. As I have a oscillograph, there is no problem for me to measure whether the output is correct.
Thanks

You can use the sysfs interface to easily test the PWM functionality. The documentation for that is in Documentation/pwm.txt and Documentation/ABI/testing/sysfs-class-pwm.

Generally this should work somewhat like this:

	# echo 0 > /sys/class/pwm/pwmchip0/export
	# echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period
	# echo 25000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
	# echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable

Which should configure PWM 0 to run at a period of 50000 ns and a 50% duty-cycle.

	# echo 0 > /sys/class/pwm/pwmchip0/pwm0/disable

Stops the PWM signal and when you're done with all the testing you can export the PWM (so that it can be reused):

	# echo 0 > /sys/class/pwm/pwmchip0/unexport

Thierry

author
#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

? 2013?12?09? 16:52, Thierry Reding ??:

Quoted 8 lines · randy
Quoted 6 lines

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

The dts for my board tiny4412 is ready, in my board, the pwm 0 is connect to a buzzer. I want to test whether it works, but I don't know any test util. As I have a oscillograph, there is no problem for me to measure whether the output is correct. Thanks

Quoted 5 lines

You can use the sysfs interface to easily test the PWM functionality. The documentation for that is in Documentation/pwm.txt and Documentation/ABI/testing/sysfs-class-pwm.

I am sorry for I didn't notice that documents.

Quoted 3 lines

Generally this should work somewhat like this:

# echo 0 > /sys/class/pwm/pwmchip0/export

It seems can't work.

root@mifu:~# LANG=C echo 0 > /sys/class/pwm/pwmchip0/export
- -bash: echo: write error: Invalid argument
Quoted 7 lines
# echo 50000 > /sys/class/pwm/pwmchip0/pwm0/period # echo 25000 >
/sys/class/pwm/pwmchip0/pwm0/duty_cycle # echo 1 >
/sys/class/pwm/pwmchip0/pwm0/enable

Which should configure PWM 0 to run at a period of 50000 ns and a 50% duty-cycle.

Quoted 8 lines
# echo 0 > /sys/class/pwm/pwmchip0/pwm0/disable

Stops the PWM signal and when you're done with all the testing you can export the PWM (so that it can be reused):

# echo 0 > /sys/class/pwm/pwmchip0/unexport

Thierry

Actually, I don't know whether the pwm works or not. In dmesg, I saw:

[  853.690000] samsung-pwm 139d0000.pwm: tried to request PWM channel
0 without output
[  876.930000] samsung-pwm 139d0000.pwm: tried to request PWM channel
0 without output
[  879.615000] samsung-pwm 139d0000.pwm: tried to request PWM channel

1 without output

in my dts, I only add
================================

pwm@139D0000 {
	status = "okay";
};

================================
is it enough to make pwm work, if the driver in kernel has been correct. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJSpaOrAAoJEPb4VsMIzTzicUkH+gJXR61k2/29tnZ01FtMprY+ LFO8taGcFn+P8rHXFm9v6911PBzJtuUtHgGhvjap2nb6cKpvxdGxPey/Jo3tyKwi KuNsq1SJUcKBoS2RyqwbBEKkFsHHxtUQhu5IQ3ZjqtWIPsefhgUiPV0LlnmnxH6E eLs9NCtuZx0Gb8PekKZRlNK15wAQNKouUFZvOAmeQ8/kR9cOYreWkmgrJUU5AaE2 qnBqGD8Z4V1I/0qrFlyx5upu87Z3thU6bAy4IxbJGSMb8/ESPsoCIps7EXFLlD3o LWkPQNbE6a5I+78Ugb44JNgW6gR/fAFAXReupiteXeAfwhugQOIUSqdtBJNrp6I= =w87N
-----END PGP SIGNATURE-----

#3 lore raw

On Mon, Dec 09, 2013 at 07:04:12PM +0800, randy wrote:
[...]

Quoted 8 lines

Actually, I don't know whether the pwm works or not. In dmesg, I saw:

[  853.690000] samsung-pwm 139d0000.pwm: tried to request PWM channel
0 without output
[  876.930000] samsung-pwm 139d0000.pwm: tried to request PWM channel
0 without output
[  879.615000] samsung-pwm 139d0000.pwm: tried to request PWM channel

1 without output

Quoted 7 lines

in my dts, I only add
================================

pwm@139D0000 {
	status = "okay";
};

================================
is it enough to make pwm work, if the driver in kernel has been correct.

It seems like you're missing the samsung,pwm-outputs property (see Documentation/devicetree/bindings/pwm/pwm-samsung.txt).

Thierry

author
#4 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 10 lines · Thierry Reding

On Mon, Dec 09, 2013 at 07:04:12PM +0800, randy wrote: [...]

Quoted 9 lines

Actually, I don't know whether the pwm works or not. In dmesg, I
saw: [ 853.690000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 876.930000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 879.615000] samsung-pwm 139d0000.pwm: tried to request PWM channel 1 without output

in my dts, I only add ================================ pwm@139D0000 { status = "okay";

I added
samsung,pwm-outputs = <0>;

Quoted 7 lines
Quoted 2 lines

}; ================================ is it enough to make pwm work, if the driver in kernel has been correct.

It seems like you're missing the samsung,pwm-outputs property (see
Documentation/devicetree/bindings/pwm/pwm-samsung.txt).

Thierry

Well I have make it output to channel 0 now. But it doesn't work with the config below. As it is a buzzer, I change your config.
=============================================

root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/enable

1

root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/period
1000000
root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/duty_cycle
500000
==============================================
I have used a function generator with Vpp=2.2, it works.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJSpcBdAAoJEPb4VsMIzTzir6kH/izw1ALJVXhEw3C28tj5grKk zgJ5eTh4fiATR6nMg9539YTmkH65nmrK7C7QdrwAmsb9t/lnX5ulcZUZmrrRKE+j 03r+L45PH7Vqx7ZMt3UO74jMThs9+vHFY+Kj0dALoxZsnBS1aaheGaHuShrcTbpG ZaKOZs7lSuxuZsWKr1njodYG3hL3z418JISII7DQ7J8RHYQF88JwIAMPw8Ybt1U8 7J2qA4DDKmQmL/kPQqTiPMfj64fcZ6E8jtLY5jZ0OLN78T8+juHrm+8l5xBm0AFa 3HNzLrmyAKPYD4yjPI8LYdNhk3EVVOaxA+lcDy26aYJ1PpIHxHuFgGdvqM47eq4= =1SNZ
-----END PGP SIGNATURE-----

#5 lore raw
Quoted 29 lines · randy

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 10 lines · Thierry Reding

On Mon, Dec 09, 2013 at 07:04:12PM +0800, randy wrote: [...]

Quoted 9 lines

Actually, I don't know whether the pwm works or not. In dmesg, I
saw: [ 853.690000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 876.930000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 879.615000] samsung-pwm 139d0000.pwm: tried to request PWM channel 1 without output

in my dts, I only add ================================ pwm@139D0000 { status = "okay";

I added
samsung,pwm-outputs = <0>;

Quoted 7 lines
Quoted 2 lines

}; ================================ is it enough to make pwm work, if the driver in kernel has been correct.

It seems like you're missing the samsung,pwm-outputs property (see
Documentation/devicetree/bindings/pwm/pwm-samsung.txt).

Thierry

Well I have make it output to channel 0 now. But it doesn't work with the config below. As it is a buzzer, I change your config.
=============================================

root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/enable
Quoted 7 lines

1

root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/period
1000000
root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/duty_cycle
500000
==============================================
I have used a function generator with Vpp=2.2, it works.

Are you sure the function generator runs at the same frequency? Do you have the possibility to check the PWM output with a scope to see if it outputs anything?

Thierry

author
#6 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 28 lines · Thierry Reding
Quoted 27 lines · randy

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Quoted 10 lines · Thierry Reding

On Mon, Dec 09, 2013 at 07:04:12PM +0800, randy wrote: [...]

Quoted 9 lines

Actually, I don't know whether the pwm works or not. In dmesg, I saw: [ 853.690000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 876.930000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 879.615000] samsung-pwm 139d0000.pwm: tried to request PWM channel 1 without output

in my dts, I only add ================================ pwm@139D0000 { status = "okay";

I added samsung,pwm-outputs = <0>;

Quoted 7 lines
Quoted 2 lines

}; ================================ is it enough to make pwm
work, if the driver in kernel has been correct.

It seems like you're missing the samsung,pwm-outputs property (see Documentation/devicetree/bindings/pwm/pwm-samsung.txt).

Thierry

Well I have make it output to channel 0 now. But it doesn't work with the config below. As it is a buzzer, I change your config. ============================================= root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/enable

Quoted 7 lines
Quoted 4 lines

1 root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/period 1000000

root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/duty_cycle 500000 
============================================== I have used a
function generator with Vpp=2.2, it works.

Are you sure the function generator runs at the same frequency? Do you

Yes, I am sure.

Quoted 2 lines

have the possibility to check the PWM output with a scope to see if it outputs anything?

I have used a oscillograph to capture, nothing(althought it show some waves, but it is nosie single captured by autoset). I have a scope but I don't think there is any different.

Quoted 2 lines

Thierry

Ayaka
Thank you
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJSqce4AAoJEPb4VsMIzTzikV4H/3NF4D2kcHYYt6axhgdnlDaI rHUVYBDHcWR0gDUY6rHN7eyStCKWdGzant0pR8AcPOSTYStwXJbFnoqPHPb9sI2J KU/EmhA+YOCzIlxeagovpFmlGopVQEWPbKM99txzljsIvjOD4xKZ2kSQv4L/QHLc CHyi1p9NzL1uSz4h5N5XcpMiMWHSNbCBXWgjqejseTjli9n1A0o0ehY5Ip9507un rYfJETB+imHOck9TH9Rol1QdS7PjIpInFMZiqkzxWKnjFXrlNQJujzPlgoJCTrv3 XIci86cnK9F2DEqkl3tJ1XsxMp0LlfEn45ZCKySeuZ2muyYpBSAHPo0uOj0DcEM= =L3au
-----END PGP SIGNATURE-----

#7 lore raw
Quoted 42 lines · randy

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 28 lines · Thierry Reding
Quoted 27 lines · randy

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Quoted 10 lines · Thierry Reding

On Mon, Dec 09, 2013 at 07:04:12PM +0800, randy wrote: [...]

Quoted 9 lines

Actually, I don't know whether the pwm works or not. In dmesg, I saw: [ 853.690000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 876.930000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 879.615000] samsung-pwm 139d0000.pwm: tried to request PWM channel 1 without output

in my dts, I only add ================================ pwm@139D0000 { status = "okay";

I added samsung,pwm-outputs = <0>;

Quoted 7 lines
Quoted 2 lines

}; ================================ is it enough to make pwm
work, if the driver in kernel has been correct.

It seems like you're missing the samsung,pwm-outputs property (see Documentation/devicetree/bindings/pwm/pwm-samsung.txt).

Thierry

Well I have make it output to channel 0 now. But it doesn't work with the config below. As it is a buzzer, I change your config. ============================================= root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/enable

Quoted 7 lines
Quoted 4 lines

1 root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/period 1000000

root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/duty_cycle 500000 
============================================== I have used a
function generator with Vpp=2.2, it works.

Are you sure the function generator runs at the same frequency? Do you

Yes, I am sure.

Quoted 2 lines

have the possibility to check the PWM output with a scope to see if it outputs anything?

Quoted 7 lines

I have used a oscillograph to capture, nothing(althought it show some waves, but it is nosie single captured by autoset). I have a scope but I don't think there is any different.

Quoted 2 lines

Thierry

Ayaka
Thank you

I don't know what else you could try, so I'm Cc'ing a couple of people who have worked with this driver before, perhaps they can help resolve this.

Thierry

#8 lore raw

Hi Thierry, Ayaka,

Quoted 47 lines · On Saturday 14 of December 2013 13:44:09 Thierry Reding wrote:
Quoted 46 lines · randy

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 28 lines · Thierry Reding
Quoted 27 lines · randy

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1

Quoted 10 lines · Thierry Reding

On Mon, Dec 09, 2013 at 07:04:12PM +0800, randy wrote: [...]

Quoted 9 lines

Actually, I don't know whether the pwm works or not. In dmesg, I saw: [ 853.690000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 876.930000] samsung-pwm 139d0000.pwm: tried to request PWM channel 0 without output [ 879.615000] samsung-pwm 139d0000.pwm: tried to request PWM channel 1 without output

in my dts, I only add ================================ pwm@139D0000 { status = "okay";

I added samsung,pwm-outputs = <0>;

Quoted 7 lines
Quoted 2 lines

}; ================================ is it enough to make pwm
work, if the driver in kernel has been correct.

It seems like you're missing the samsung,pwm-outputs property (see Documentation/devicetree/bindings/pwm/pwm-samsung.txt).

Thierry

Well I have make it output to channel 0 now. But it doesn't work with the config below. As it is a buzzer, I change your config. ============================================= root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/enable

Quoted 7 lines
Quoted 4 lines

1 root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/period 1000000

root@mifu:~# cat /sys/class/pwm/pwmchip0/pwm0/duty_cycle 500000 
============================================== I have used a
function generator with Vpp=2.2, it works.

Are you sure the function generator runs at the same frequency? Do you

Yes, I am sure.

Quoted 2 lines

have the possibility to check the PWM output with a scope to see if it outputs anything?

I have used a oscillograph to capture, nothing(althought it show some waves, but it is nosie single captured by autoset). I have a scope but I don't think there is any different.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thierry

Ayaka
Thank you

I don't know what else you could try, so I'm Cc'ing a couple of people who have worked with this driver before, perhaps they can help resolve this.

I suspect invalid hardware configuration here.

Ayaka, could you post your board dts file with PWM enabled?

Btw. For topics related to Samsung's platforms, it's good to always CC linux-samsung-soc ML.

Best regards,
Tomasz