VIM3 change SPDIF_OUT as PWMAO_D

你好!
怎么样修改dts文件可以实现将SPDIF_OUT作为PWMAO_D使用。
我的尝试如下
//=在kvim3_linux.dts文件中添加了如下启用PWMAO_D=//
&pwm_AO_cd {

status = "okay";

pinctrl-names = "default";

pinctrl-0 = <&pwm_ao_d_pins2>;

};
//=我将spdif设置为disables==//
aml_spdif: spdif {
compatible = “amlogic, g12a-snd-spdif-a”;
#sound-dai-cells = <0>;
clocks = <&clkc CLKID_MPLL0
&clkc CLKID_FCLK_DIV4
&clkaudio CLKID_AUDIO_SPDIFIN
&clkaudio CLKID_AUDIO_SPDIFOUT
&clkaudio CLKID_AUDIO_SPDIFIN_CTRL
&clkaudio CLKID_AUDIO_SPDIFOUT_CTRL>;
clock-names = “sysclk”, “fixed_clk”, “gate_spdifin”,
“gate_spdifout”, “clk_spdifin”, “clk_spdifout”;
interrupts =
<GIC_SPI 151 IRQ_TYPE_EDGE_RISING>;

	interrupt-names = "irq_spdifin";
	pinctrl-names = "spdif_pins",
				"spdif_pins_mute";
	pinctrl-0 = <&spdifout>;
	pinctrl-1 = <&spdifout_a_mute>;
	status = "disables";
};

//===============================//
//===============================//
I try this steps:

$ make kernel

Then , Copy fenix/linux/arch/arm64/boot/Image to my board and replace /boot/zImage ,
copy fenix/linux/arch/arm64/boot/dts/amlogic/kvim3_linux.dtb to my board /boot/dtb .

Final,run $sync && sudo reboot in my board .
//=下面是我写的测试程序=//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
system(“echo 1 > /sys/class/pwm/pwmchip4/unexport”);
system(“echo 3 > /sys/class/pwm/pwmchip8/unexport”);
sleep(1);
system(“echo 1 > /sys/class/pwm/pwmchip4/export”);
system(“echo 1000000 > /sys/class/pwm/pwmchip4/pwm1/period”);
system(“echo 1 > /sys/class/pwm/pwmchip4/pwm1/enable”);

system("echo 3 > /sys/class/pwm/pwmchip8/export");
system("echo 1000000 > /sys/class/pwm/pwmchip8/pwm3/period");
system("echo 1 > /sys/class/pwm/pwmchip8/pwm3/enable");

while (1)
{
  system("echo 333333 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle");
  system("echo 333333 > /sys/class/pwm/pwmchip8/pwm3/duty_cycle");
  printf("33%%\n");
  sleep(3);
  
  system("echo 666666 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle"); 
  system("echo 666666 > /sys/class/pwm/pwmchip8/pwm3/duty_cycle");
  printf("66%%\n");
  sleep(3);
}

return 0;

}
//========================//
问题:PWMAO_D会有PWM信号输出,但是会死机然后重启。

看了下,PWMAO_D已经被vddcpu0占用了,你在把GPIOAO_10配置为PWMAO_D是有问题的。你可以使用PIN 35 PWM_F

1 Like

OK,Thank you very much !