RK3568系列8——串口与PWM配置

  串口和PWM已经在rk3568-evb.dtsi文件中有很多相关的示例,如果原理图中有用到相关的配置可以直接将对应的节点使能,这里再重新贴一下相关的DTS配置。

配置要点

  • 相关PIN脚是接在M1通道还是M2通道

DTS配置

  • PWM红外接收器:
    • remote_pwm_id: 未知
    • handle_cpu_id: 用来处理红外信号的CPU,4核CPU合法值为0~3
    • remote_support_psci:未知
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 串口配置
&uart7 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&uart7m2_xfer>;
};


# PWM配置
&pwm14 {
status = "okay";
pinctrl-names = "active";
pinctrl-0 = <&pwm14m0_pins>;
};

# 如果使用到了PWM7,"rk3568-evb.dtsi"默认将其定义为了PWM红外接收器
# 需要将相关的配置删除,恢复成PWM功能
&pwm7 {
status = "okay";
compatible = "rockchip,rk3568-pwm", "rockchip,rk3328-pwm";
pinctrl-names = "active";
pinctrl-0 = <&pwm7_pins>;

/delete-property/ remote_pwm_id;
/delete-property/ handle_cpu_id;
/delete-property/ remote_support_psci;
/delete-node/ ir_key1;
/delete-node/ ir_key2;
/delete-node/ ir_key3;
};

# PWM红外接收器配置
&pwm3 {
status = "okay";

compatible = "rockchip,remotectl-pwm";
remote_pwm_id = <3>;
handle_cpu_id = <1>;
remote_support_psci = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pwm3_pins>;

ir_key1 {
rockchip,usercode = <0x00ff>;
rockchip,key_table =
<0xea KEY_VOLUMEUP>,
<0xe3 KEY_VOLUMEDOWN>;
};
ir_key2 {
........
};
};

PWM调试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 查看PWM汇总信息
cat /sys/kernel/debug/pwm
> platform/fe700030.pwm, 1 PWM device
> pwm-0 (red ): requested period: 25000 ns duty: 0 ns polarity: normal
>
> platform/fe700020.pwm, 1 PWM device
> pwm-0 (blue ): requested period: 25000 ns duty: 0 ns polarity: normal
>
> platform/fe6e0030.pwm, 1 PWM device
> pwm-0 (green ): requested period: 25000 ns duty: 0 ns polarity: normal
>
> platform/fe6e0020.pwm, 1 PWM device
> pwm-0 (all ): requested period: 25000 ns duty: 0 ns polarity: inverse
>
> platform/fe6e0010.pwm, 1 PWM device
> pwm-0 (backlight ): requested enabled period: 25000 ns duty: 11750 ns polarity: normal

# 调试PWM,前提是该PWM不能被占用
cd /sys/class/pwm/pwmchip3/
echo 0 > export # 一个PWM芯片可以控制多个PWM节点,RK3568只有1个
cd pwm0/
echo normal > polarity # 设置极性 normal | inverse
echo 25000 > period # 设置工作周期(ns)
echo 12500 > duty_cycle # 设置占空比(ns)
echo 1 > enable # 使能pwm节点