STM32MP1/STUSB1600 - DRP to DRP negotiation guidelines (no PD controller)
Hi there,
I am working on an STM32MP157F-DK2 board and an STUSB1600 with hsotg gadget support and no PD controller. I am running a buildroot image with all the necessary drivers enabled including dwc2, SystemFS etc.
The gadget is working as expected in most configurations. It can be hotplugged and get recognised with a high-speed unique address without any issues on several computers running windows or linux with a usb-c to usb-c cable . Recently I attempted to connect the board to a series of apple computers to test compatibility. I faced several unexpected behaviours during these tests.
- Apple Macbooks (Intel) will have a 50-50 chance of recognising the DK board as a peripheral. The rest of the times the DK is recognised as a charger and the MBP will start charging
- Apple Macbooks (M1) will still have a 50-50 chance of recognising the DK board as a peripheral but the rest of the gadget will not get recognised at all.
- Apple Mac Mini (M2) will not get recognised at all. The dwc2 otg driver will do several attempts always on address 1 until time-out.
None of the above issues are present by using a usb-c to usb-A cable, usb Hub or usb-c to usb-A adapter.
Following the Apple Accessory Design Guidelines it seems that any usb typec device is expected to work as long as it follows the Universal Serial Bus Type-C Cable and Connector Specification.
I believe that a good hypothesis on the cause of the issue according to USB Type-C specification is hinted on
"In the special case of a DRP being attached to another DRP, an initialization protocol across the CC pins is used to establish the initial host-to-device relationship. Given no role-swapping intervention, the determination of which is DFP or UFP is random from the user’s perspective."
- Universal Serial Bus Type-C Cable and Connector Specification. Pg:34
More information on actual mechanisms on Pg: 200
It seems that the behaviour of the symptom is consistent with a random DRP to DRP negotiation between Apple machines and the DK board. In this particular application my goal is to create a mechanism that when the STUSB1600 detects a DRP or any DFP it always keeps the CC pins on UFP so the DK will always gets recognised as a peripheral in the case of a DRP to DRP connection.
Following the stusb160x driver and the Device Tree Configuration guide I was not able to see an exposed entry or a direct modification that can account for such case. To my understanding all the dts entries on the typec connector will point to initial configurations but none of the available entries can achieve such behaviour. I attach my current dts entries for both hsusbotg and stusb1600 below:
typec: stusb1600@28 {
compatible = "st,stusb1600";
reg = <0x28>;
interrupts = <11 IRQ_TYPE_LEVEL_LOW>;
interrupt-parent = <&gpioi>;
vsys-supply = <&vdd_usb>;
pinctrl-names = "default";
pinctrl-0 = <&stusb1600_pins_a>;
status = "okay";
vdd-supply = <&vin>;
typec_con: connector {
compatible = "usb-c-connector";
label = "USB-C";
power-role = "dual";
data-role = "dual";
typec-power-opmode = "default"; //Advertise usb2 power capabilities (up to 500mV on PD negotiation)
port {
con_usbotg_hs_ep: endpoint {
remote-endpoint = <&usbotg_hs_ep>;
};
};
};
};
Board level
&usbotg_hs {
compatible = "st,stm32mp15-hsotg", "snps,dwc2";
phys = <&usbphyc_port1 0>; /* 0: UTMI switch selects the OTG controller */
phy-names = "usb2-phy";
dr_mode = "peripheral";
g-rx-fifo-size = <256>;
g-np-tx-fifo-size = <32>;
g-tx-fifo-size = <128 128 128 128 64 32 16 16>;
usb-role-switch;
role-switch-default-mode = "peripheral"; /* see USB generic bindings [4] */
status = "okay"; /* enable OTG */
port {
usbotg_hs_ep: endpoint {
remote-endpoint = <&con_usbotg_hs_ep>; /* point the Type-C controller endpoint node */
};
};
};
I was wondering if I am missing a dts or software configuration that can handle DRP to DRP connections for the STUSB1600.
Any advice or ideas on this topic are highly appreciated.
