如题,pwm3申请失败,wiki上面的教程里边提供的命令
cat /sys/kernel/debug/pwm
使用后,打印的信息如下
platform/ff420020.pwm, 1 PWM device
pwm-0 (vdd-log ): requested enabled period: 24997 ns duty: 8243 ns polarity: inverse
platform/ff420010.pwm, 1 PWM device
pwm-0 ((null) ): period: 0 ns duty: 0 ns polarity: inverse
platform/ff420000.pwm, 1 PWM device
pwm-0 (backlight ): requested enabled period: 24997 ns duty: 10003 ns polarity: normal
ff420020 ff420010 ff420000对应的pwm2 pwm1 pwm0 ,申请的信息确实有了,比如占空比,周期,驱动名称等信息,
但是 没有pwm3,如果有,应该是ff420030 ,没错,事实上没有,然后申请的错误代码 -517
struct pwm_device *pwm_request(int pwm, const char *label)
{
struct pwm_device *dev;
int err;
if (pwm < 0 || pwm >= MAX_PWMS)
return ERR_PTR(-EINVAL);
mutex_lock(&pwm_lock);
dev = pwm_to_device(pwm);
if (!dev) {
dev = ERR_PTR(-EPROBE_DEFER); //错误代码出处
goto out;
}
err = pwm_device_request(dev, label);
if (err < 0)
dev = ERR_PTR(err);
out:
mutex_unlock(&pwm_lock);
return dev;
}
研究了两天,发现居然是这么个小问题,一路下来看寄存器什么的,还用配寄存器的形式去实现过输出pwm,结果只是因为dts里边的问题,pwm通道3,硬件上接了一个红外接收器,dts里边的信息如下:
&pwm3 {
status = "disable";
interrupts = ;
compatible = "rockchip,remotectl-pwm";
remote_pwm_id = <3>;
handle_cpu_id = <0>;
ir_key0 {
rockchip,usercode = <0xff40>;
rockchip,key_table =
<0xb2 KEY_POWER>,
<0xe5 KEY_HOME>,
<0xbd KEY_BACK>,
<0xba KEY_MENU>,
<0xf4 KEY_UP>,
<0xf1 KEY_DOWN>,
<0xef KEY_LEFT>,
<0xee KEY_RIGHT>,
<0xf2 KEY_ENTER>,
<0xf0 KEY_REPLY>,
<0xea KEY_VOLUMEUP>,
<0xe3 KEY_VOLUMEDOWN>,
<0xbc KEY_MUTE>,
<0xfe KEY_1>,
<0xfd KEY_2>,
<0xfc KEY_3>,
<0xfb KEY_4>,
<0xfa KEY_5>,
<0xf9 KEY_6>,
<0xf8 KEY_7>,
<0xf7 KEY_8>,
<0xb6 KEY_9>,
<0xff KEY_0>,
<0xed KEY_BACKSPACE>,
<0xaf KEY_POWER>,
<0x8b KEY_VOLUMEUP>,
<0xb9 KEY_VOLUMEDOWN>;
};
};
这里有个坑,注意,上面是&pwm3,相当于直接控制pwm3的打开与关闭状态, 一开始我以为只要把status = disable就ok了,以为就是把驱动去掉,原来这个是关闭pwm3,还是对dts不太熟悉,反省一下,最后的结果就是申请失败,后来把整段代码注释掉,重新打开pwm3就ok,打开方式很多,你可以在任意dts里边添加一下信息即可
&pwm3 {
status = "okay";
};
也可以在rk3399.dtsi里边改动一下内容
pwm3: pwm@ff420030 {
compatible = "rockchip,rk3399-pwm", "rockchip,rk3288-pwm";
reg = <0x0 0xff420030 0x0 0x10>;
#pwm-cells = <3>;
pinctrl-names = "default";
pinctrl-0 = <&pwm3a_pin>;
clocks = <&pmucru PCLK_RKPWM_PMU>;
clock-names = "pwm";
status = "okay";//原来是disable
};
建议还是第一种方式打开,以上问题会导致错误代码 -517,也就是-EPROBE_DEFER这个错误
下面附上配寄存器这种方式的pwm驱动配寄存器形式的pwm驱动