1、修改DTS
- dr_mode: tells Dual-Role USB controllers that we want to work on a
particular mode. Valid arguments are “host”,
“peripheral” and “otg”. In case this attribute isn’t
passed via DT, USB DRD controllers should default to
OTG.
usb20_otg: usb@ff400000 {
compatible = "rockchip,rk3066-usb", "snps,dwc2";
reg = <0x0 0xff400000 0x0 0x40000>;
interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cru HCLK_OTG>;
clock-names = "otg";
dr_mode = "otg";
g-np-tx-fifo-size = <16>;
g-rx-fifo-size = <280>;
g-tx-fifo-size = <256 128 128 64 32 16>;
g-use-dma;
phys = <&u2phy_otg>;
phy-names = "usb2-phy";
status = "disabled";
};
2、用户空间软件控制
找到USB设备,修改otg_mode即可
# pwd
/sys/bus/platform/drivers/rockchip-usb2phy/ff008000.syscon:usb2-phy@100
# ls
driver modalias phy uevent
driver_override of_node power
extcon otg_mode subsystem
# cat otg_mode
host
#