前言
rk3568主板扩展gpio口不够用,于是想着将主板uart3串口的改成普通gpio口使用,用于控制输出高低电平。
修改步骤
- 修改dts关闭uart3的功能:
&uart3 { - status = "okay"; + status = "disabled"; pinctrl-names = "default"; pinctrl-0 = <&uart3m1_xfer>;
- 添加uart的gpio控制节点驱动配置:
+ + uartgpioctr: uartgpioctr { + status = "okay"; + compatible = "uart,uartgpioctr"; + uartio1-gpio = <&gpio3 RK_PC0 GPIO_ACTIVE_HIGH>; + uartio2-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_HIGH>; + }; +
- 添加gpio控制节点驱动uartgpioctl.c:
#include <linux/module.h> #include <linux/i2c.h> #include <linux/slab.h> #include <linux/rtc.h> #include <linux/init.h> #include <linux/errno.h> #include &l