将TypeC的adb切换到USB3.0口

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

前言

目前大多数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

硬件

首先,参考原理图如下:

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

  1. 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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值