USB-C is actually dual-role?


#1

So I have a bit of an interesting situation. I’m doing real world testing on my car IVI setup now and occasionally need to be able to debug using the USB-C plug. Ideally, I’d like to not have to constantly lug around a laptop for this, rather I have a perfectly capable phone that is always with me.

But here is the problem; when I plug the phone (pixel 2 xl) into the hikey960 using a USB-C to USB-C cable, the hikey960 takes the host role and the phone takes the device role.

Anybody know of a way of telling the hikey960 to always take the device role for the USB-C? Otherwise I’m going to have to do something crazy like these two adapters plugged into each other at the phone side of the wire;



#2

If I remember correctly you can force USB role via sysfs, something like this:

cat /sys/devices/platform/soc/ff200000.hisi_usb/plugusb
current state: USB_STATE_DEVICE

echo hostoff > plugusb
echo deviceon > plugusb

Hope this can help. Note that all USB connector are connected to the same USB root HUB so device(s) connected to the type-A ports will not be operational concurrently.


#3

I was more meaning an automated way. Its kind of hard to input the command if I can’t connect to the thing in order to input the command.

I’m trying to make some sense of the USB-C specifications in order to understand how two dual-role devices negotiate who becomes host and who becomes peripheral. Its looking to me like there are three possible configurations, and that they are determined by how the “CC” pins are configured;

Dual role: Hi-Z
Host: Pull UP
Device: Pull DOWN

So presumably, since these are both dual role devices, they would both be set for Hi-Z?

But I’m also seeing some indication that there may be some element of cable plug order, that when you connect two dual role devices together, the one that the cable is plugged into first becomes the host.

But I guess the thing is that there should be some way to set this up so that when a wire is plugged into the usb-c port, it always takes the peripheral role.


#4

This could be scripted at init, but it’s a problem if you want to use other ports as host.

When you plug type-c cable, I think everything take place in drivers/usb/pd, so maybe you can hack a bit to unconditionally switch to device on CC change.