整理中 创建 2026/06/06 更新 2026/07/14
无法进行串口键盘的连接
#mtk
#uart
[MTK] SIPO 串口键盘驱动接入说明
1. 初步现象
1.1 问题描述
设备无法连接 SIPO 串口键盘。
初步怀疑:
sipo_seri_kb.ko 未加载
但是查看 Kernel Log:
modprobe: calling ... [sipo_seri_kb]
modprobe: initcall ... [sipo_seri_kb] returned 0
说明:
sipo_seri_kb.ko 已经成功加载。
但是:
没有发现驱动 probe 日志。
因此问题不是:
ko 未加载
而是:
platform device 没有匹配成功,导致 driver probe 没有执行。
2. 为什么驱动加载了但是没有 probe?
Linux Platform Driver 需要同时满足两个条件:
1. Driver 已经注册
2. Device Tree 中存在 compatible 匹配的 platform device
2.1 Driver compatible
驱动代码:
.compatible = "sipo,sipo_seri_kb"
因此 Device Tree 必须存在:
compatible = "sipo,sipo_seri_kb";
2.2 失败状态检查
设备端执行:
find /proc/device-tree -name "*sipo*"
find /proc/device-tree -name "sipo_keyboard"
ls /sys/bus/platform/devices | grep -i sipo
结果:
无输出
说明:
当前运行时 Device Tree 中不存在 sipo_keyboard 节点。
因此:
driver 无法触发 probe。
3. 容易误判的位置
检查:
strings /dev/block/by-name/dtbo_a | grep -i sipo
发现:
sipo_kb_pins_default
sipo_kb_pins_sleep
sipo_keyboard
sipo,sipo_seri_kb
说明:
DTBO 镜像中确实存在 SIPO 节点信息。
但是:
不代表运行时 Device Tree 已经生效。
原因:
DTBO 属于 Device Tree Overlay。
需要 overlay 成功挂载到主 DTB。
如果:
Overlay target 节点不存在
那么:
/proc/device-tree 中不会出现对应节点。
4. 失败根因分析
当时:
tb8781p1_64_wifi.dts
使用:
&sipo_keyboard {
...
};
含义:
修改一个已经存在的 sipo_keyboard 节点。
但是检查:
strings /dev/block/by-name/lk_a | grep -i sipo
无输出。
说明:
主 DTB 中不存在:
sipo_keyboard: sipo_keyboard {
};
因此:
&sipo_keyboard
无法找到目标节点。
最终结果:
DTBO overlay 没有真正生效。
5. 正确 Device Tree 配置方式
5.1 主 DTS 添加基础节点
文件:
kernel-5.10/arch/arm64/boot/dts/mediatek/mt6789.dts
添加:
sipo_keyboard: sipo_keyboard {
compatible = "sipo,sipo_seri_kb";
};
作用:
创建 platform device 节点。
5.2 产品 DTS 添加资源配置
文件:
kernel-5.10/arch/arm64/boot/dts/mediatek/tb8781p1_64_wifi.dts
增加:
&sipo_keyboard {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&sipo_kb_pins_default>;
pinctrl-1 = <&sipo_kb_pins_sleep>;
detect-gpios = <&pio 107 0>;
docking_5v_en-gpios = <&pio 106 0>;
rxirq-gpios = <&pio 89 0>;
wakeup-source;
status = "okay";
};
6. GPIO 功能说明
SIPO 键盘主要使用以下 GPIO:
| GPIO | 功能 | 说明 |
|---|---|---|
| GPIO107 | detect | 键盘插拔检测 |
| GPIO106 | docking_5v_en | 控制键盘供电 |
| GPIO89 | rxirq | RX唤醒中断 |
| GPIO100 | LDO 3.3V enable | 电源控制 |
| GPIO88 | UART2 TX | 串口发送 |
| GPIO89 | UART2 RX | 串口接收 |
6.1 GPIO89 工作模式
正常工作:
GPIO89 = UART RX
Pinmux:
PINMUX_GPIO89__FUNC_URXD2
休眠状态:
GPIO89 = GPIO interrupt
Pinmux:
PINMUX_GPIO89__FUNC_GPIO89
工作流程:
正常状态:
GPIO89 作为 UART RX
↓
进入休眠:
GPIO89 切换为 GPIO EINT
↓
检测 RX 唤醒事件
↓
唤醒后恢复 UART RX
7. Kernel Driver 编译配置
7.1 Driver路径
kernel-5.10/drivers/misc/mediatek/sipo_seri_kb/
7.2 子目录 Makefile
文件:
drivers/misc/mediatek/sipo_seri_kb/Makefile
配置:
obj-$(CONFIG_SIPO_SERI_KB) += sipo_seri_kb.o
7.3 父级 Makefile
文件:
drivers/misc/mediatek/Makefile
配置:
obj-$(CONFIG_SIPO_SERI_KB) += sipo_seri_kb/
7.4 Kconfig
文件:
drivers/misc/mediatek/Kconfig
配置:
config SIPO_SERI_KB
tristate "SIPO serial keyboard helper driver"
7.5 Defconfig
文件:
arch/arm64/configs/xxx_defconfig
配置:
CONFIG_SIPO_SERI_KB=m
说明:
m = 编译为 Kernel Module
生成:
sipo_seri_kb.ko
8. KO 加载验证
如果配置:
CONFIG_SIPO_SERI_KB=m
需要确认:
sipo_seri_kb.ko
已经加入:
vendor/lib/modules/
并且启动时加载。
成功日志:
modprobe: calling ... [sipo_seri_kb]
modprobe: initcall ... [sipo_seri_kb] returned 0
9. 分层验证方法
9.1 验证 KO 是否加载
lsmod | grep sipo
dmesg | grep -i sipo
9.2 验证 Driver 是否注册
ls /sys/bus/platform/drivers/sipo_drv
9.3 验证 Device Tree 是否存在
find /proc/device-tree -name "sipo_keyboard"
cat /proc/device-tree/sipo_keyboard/compatible
预期:
sipo,sipo_seri_kb
9.4 验证 Platform Device
ls /sys/bus/platform/devices | grep -i sipo
预期:
sipo_keyboard
9.5 验证 DTBO 是否包含 SIPO
strings /dev/block/by-name/dtbo_a | grep -i sipo
9.6 验证主 DTB 是否包含 SIPO
strings /dev/block/by-name/lk_a | grep -i sipo
9.7 当前启动 Slot
getprop ro.boot.slot_suffix
确认当前使用:
dtbo_a
还是:
dtbo_b
10. 成功 Probe 日志
正常启动应该看到:
sipo_drv sipo_keyboard:
probe SIPO Driver 3.3.0-20260428
sipo_drv[DBG]:
sipo_probe:455:
Pinctrl dynamically initialized to 'default' (UART) state.
sipo_drv[DBG]:
sipo_set_rx_irq_state:
RX IRQ Disabled (depth 0 -> +1)
input:
sipo_kb as /devices/platform/sipo_keyboard/input/input5
probe of sipo_keyboard returned 1 after 5675 usecs
11. 成功判定
出现以上日志说明:
| 项目 | 状态 |
|---|---|
| ko加载 | OK |
| Driver注册 | OK |
| compatible匹配 | OK |
| Platform device创建 | OK |
| probe执行 | OK |
| pinctrl default生效 | OK |
| input设备注册 | OK |
最终:
SIPO串口键盘驱动接入完成。