前言
目前大多数Android的嵌入式系统都会使用TypeC做为adb的调试口,这样很方便。但是在有的时候,迫不得已必须将adb功能切换到USB3.0口,但由于当前的内核USB框架只能支持一个USB口作为Peripheral
功能,所以RK3399 SDK默认配置Type-C0作为OTG mode 支持USB Peripheral功能,而Type-C1只支持Hostmode。
注意: 下面介绍的方法只在rk3399的Industry的7.1版本上实现成功并测试过,其他版本仅做参考,但也大同小异。
Kernel: v4.4.126
Device: rk3399
Platform Version: Android 7.1
硬件
首先,参考原理图如下:

Device Tree
RK提供的dts中默认的rk3399.dtsi,默认
usbdrd3_0: usb@fe800000 {
...
usbdrd_dwc3_0: dwc3@fe800000 {
compatible = "snps,dwc3";
dr_mode = "otg";
};
...
};
usbdrd3_1: usb@fe900000 {
...
usbdrd_dwc3_1: dwc3@fe900000 {
compatible = "snps,dwc3";
dr_mode = "host";
};
...
};
我们需要在自己的dts中修改usbdrd_dwc3_1的dr_mode模式为otg,将usbdrd_dwc3_0的模式修改为host
&usbdrd_dwc3_0 {
status = "okay";
dr_mode = "host";
};
&usbdrd_dwc3_1 {
status = "okay";
dr_mode = "otg";
};
Drivers
-
kernel/include/linux/phy/phy.h
diff --git a/kernel/include/linux/phy/phy.h b/kernel/include/linux/phy/phy.h index a3965c3..c0daa66 100644 --- a/kernel/include/linux/phy/phy.h +++ b/kernel/include/linux/phy/phy.h @@ -36,6 +36,7 @@ enum phy_mode { * @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy + * @set_vbusdet: usb disconnect of the phy * @reset: resetting the phy * @cp_test: prepare for the phy compliance test * @owner: the module owner containing the ops @@ -46,6 +47,7 @@ struct phy_ops { int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); int (*set_mode)(struct phy *phy, enum phy_mode mode); + int (*set_vbusdet)(struct phy *phy, bool level); int (*reset)(struct phy *phy); int (*cp_test)(struct phy *phy); struct module *owner; @@ -133,6 +135,7 @@ int phy_exit(struct phy *phy); int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); int phy_set_mode(struct phy *phy, enum phy_mode mode); +int phy_set_vbusdet(struct phy *phy, bool level); int phy_reset(struct phy *phy); int phy_cp_test(struct phy *phy); static inline int phy_get_bus_width(struct phy *p

本文介绍在Rockchip RK3399平台上,如何通过修改设备树和内核配置,将ADB调试接口从Type-C切换至USB3.0端口。此方法适用于Android 7.1版本,涉及设备树修改、内核编译及系统设置。

3011

被折叠的 条评论
为什么被折叠?



