I am using Yocto to build a custom system with the Kernel 5.15.91 on an i.mx6 Chip. Unfortunatley USB OTG never seams to work. With the following Device Tree I can get it into Device Mode, but it never switches to host mode:
/ {
regulators {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <0>;
reg_usb_otg1_vbus: regulator@2 {
compatible = "regulator-fixed";
reg = <2>;
regulator-name = "usb_otg1_vbus";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usb_otg1_vbus>;
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio5 8 GPIO_ACTIVE_HIGH>;
enable-active-high;
status = "okay";
};
};
};
&usbotg1 {
dr_mode = "otg";
status = "okay";
disable-over-current;
vbus-supply = <®_usb_otg1_vbus>;
};
&iomuxc {
pinctrl_usb_otg1_vbus: usbotg1 {
fsl,pins = <
MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08 0x000000b9
>;
};
};
But as soon as I add anything remotely resembling OTG mode switching it stops working entirely.
For example adding usb-role-switch:
&usbotg1 {
dr_mode = "otg";
status = "okay";
usb-role-switch;
disable-over-current;
vbus-supply = <®_usb_otg1_vbus>;
};
= FAIL
Or adding extcon with the ID pin:
/ {
regulators {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <0>;
reg_usb_otg1_vbus: regulator@2 {
compatible = "regulator-fixed";
reg = <2>;
regulator-name = "usb_otg1_vbus";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usb_otg1_vbus>;
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio5 8 GPIO_ACTIVE_HIGH>;
enable-active-high;
status = "okay";
};
};
extcon_usb: extcon_iddig {
compatible = "linux,extcon-usb-gpio";
id-gpio = <&gpio1 00 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usbotg1>;
};
};
&usbotg1 {
dr_mode = "otg";
status = "okay";
disable-over-current;
vbus-supply = <®_usb_otg1_vbus>;
extcon = <&extcon_usb>;
};
&iomuxc {
pinctrl_usbotg1: usbotg1_id {
fsl,pins = <
MX6UL_PAD_GPIO1_IO00__GPIO1_IO00 0x0001b020 /* ID Pin */
>;
};
pinctrl_usb_otg1_vbus: usbotg1 {
fsl,pins = <
MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08 0x000000b9
>;
};
};
= FAIL
I even tried to use endpoints in conjunction with the PTN5110 driver:
/ {
regulators {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <0>;
reg_usb_otg1_vbus: regulator@2 {
compatible = "regulator-fixed";
reg = <2>;
regulator-name = "usb_otg1_vbus";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usb_otg1_vbus>;
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio5 8 GPIO_ACTIVE_HIGH>;
status = "okay";
};
};
};
&usbotg1 {
dr_mode = "otg";
status = "okay";
disable-over-current;
vbus-supply = <®_usb_otg1_vbus>;
port {
usb1_drd_sw: endpoint {
remote-endpoint = <&typec1_dr_sw>;
};
};
};
&i2c4 {
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c4>;
status = "okay";
usb_pd: ptn5110@50 {
compatible = "nxp,ptn5110";
reg = <0x50>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usb_pd>;
interrupt-parent = <&gpio5>;
interrupts = <5 IRQ_TYPE_LEVEL_LOW>;
wakeup-source;
port {
typec1_dr_sw: endpoint {
remote-endpoint = <&usb1_drd_sw>;
};
};
usb_con: connector {
compatible = "usb-c-connector";
label = "USB-C";
data-role = "dual";
power-role = "dual";
try-power-role = "source";
source-pdos = <PDO_FIXED(VSAFE5V, 2000, PDO_FIXED_USB_COMM | PDO_FIXED_DUAL_ROLE)>;
sink-pdos = <PDO_FIXED(VSAFE5V, 2000, PDO_FIXED_USB_COMM | PDO_FIXED_DUAL_ROLE)
/*PDO_FIXED(VSAFE5V, 3000, 0)
PDO_FIXED(9000, 3000, 0)*/
PDO_FIXED(12000, 3000, 0)
PDO_FIXED(20000, 3000, 0)>;
op-sink-microwatt = <10000000>;
/*vbus-supply = <®_usb_otg1_vbus>;*/
/*id-gpios = <&gpio1 00 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;*/
};
};
};
&iomuxc {
pinctrl_i2c4: i2c4grp {
fsl,pins = <
MX6UL_PAD_UART2_TX_DATA__I2C4_SCL 0x4001b8b0
MX6UL_PAD_UART2_RX_DATA__I2C4_SDA 0x4001b8b0
>;
};
pinctrl_usb_pd: usbpdgrp {
fsl,pins = <
MX6UL_PAD_SNVS_TAMPER5__GPIO5_IO05 0x0001b020 /* Alert Interrupt */
MX6UL_PAD_SNVS_TAMPER9__GPIO5_IO09 0x0001b020 /* Fault Interrupt */
MX6UL_PAD_GPIO1_IO00__GPIO1_IO00 0x0001b020 /* ID Pin */
>;
};
pinctrl_usb_otg1_vbus: usbotg1 {
fsl,pins = <
MX6UL_PAD_SNVS_TAMPER8__GPIO5_IO08 0x000000b9
>;
};
};
= FAIL
And I tried all the permutations I could think of but nothing worked. I hope that someone with a better understanding of the device tree might be able to help. We could even discuss compensation for your help.