This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: "echo 0 > export", but got "-sh: echo: write error: Device or resource busy"

Part Number: AM625

I refer to this thread Linux/AM5728: PWM on Timer15, and after "echo 0 > export", I get "-sh: echo: write error: Device or resource busy".

I want to use TIMER_IO3 and GPIO0_43 to drive the pwm signal to make the buzzer sound.

How can I fix this error?

step 1:

I add following node to k3-am62x-sk-common.dtsi

/{
	buzzer1: buzzer {
		status = "okay";
		compatible = "pwm-beeper";
		pwms = <&main_pwm3 0 322580 0>; // 3.1khz
	};

	main_pwm3: dmtimer-main-pwm-3 {
		compatible = "ti,omap-dmtimer-pwm";
		#pwm-cells = <3>;
		ti,timers = <&main_timer3>;
	};
};

&main_timer3 {
 status = "okay";
 pinctrl-names = "default";
 pinctrl-0 = <&buzzer_pwm_pins_default>;
};

&main_pmx0 {
    buzzer_pwm_pins_default: buzzer-pwm-pins-default {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x00b0, PIN_OUTPUT, 7) /* (K22) GPIO0_43*/ // Buzzer GPIO
		>;
	};
};

&cbass_main {
	status = "okay";
};

step 2:

dmesg | grep "pwm"

[    1.027597] omap-dmtimer-pwm dmtimer-main-pwm-3: Please implement the .get_state() callback
[    1.286667] pwm-beeper buzzer: supply amp not found, using dummy regulator
[    1.293804] input: pwm-beeper as /devices/platform/buzzer/input/input0

step 3:

dmesg | grep "timer"

[    0.000000] arch_timer: cp15 timer(s) running at 200.00MHz (phys).
[    0.013110] Calibrating delay loop (skipped), value calculated using timer frequency.. 400.00 BogoMIPS (lpj=800000)
[    1.027597] omap-dmtimer-pwm dmtimer-main-pwm-3: Please implement the .get_state() callback

step 4:

cat /sys/kernel/debug/pwm

platform/dmtimer-main-pwm-3, 1 PWM device
 pwm-0   (buzzer              ): requested period: 322581 ns duty: 0 ns polarity: normal

step 5:

cd /sys/class/pwm/

ls -al

total 0
drwxr-xr-x  2 root root 0 Feb 24 04:51 .
drwxr-xr-x 68 root root 0 Feb 24 04:51 ..
lrwxrwxrwx  1 root root 0 Feb 24 04:51 pwmchip0 -> ../../devices/platform/dmtimer-main-pwm-3/pwm/pwmchip0

step 6:

cd pwmchip0

ls -al

total 0
drwxr-xr-x 3 root root    0 Feb 24 04:51 .
drwxr-xr-x 3 root root    0 Feb 24 04:51 ..
lrwxrwxrwx 1 root root    0 Feb 24 04:52 device -> ../../../dmtimer-main-pwm-3
--w------- 1 root root 4096 Feb 24 04:52 export
-r--r--r-- 1 root root 4096 Feb 24 04:52 npwm
drwxr-xr-x 2 root root    0 Feb 24 04:52 power
lrwxrwxrwx 1 root root    0 Feb 24 04:51 subsystem -> ../../../../../class/pwm
-rw-r--r-- 1 root root 4096 Feb 24 04:51 uevent
--w------- 1 root root 4096 Feb 24 04:52 unexport

step 7:

echo 0 > export

-sh: echo: write error: Device or resource busy

 

Thanks,

Andrew