[QUESTION] ANX7688 USB Type-C driver issues on CM4 Yocto project

Pavel de Wavrechin <[email protected]>
Newsgroups org.yoctoproject.lists.yocto
Message-ID <CAACb1KHW9bgtBrATx8+LeajavToKAZQSNkhxHpA+va=VNCgiYw@mail.gmail.com>
Hello Yocto community,

I am currently working on a Yocto project to create a Linux system for an
electronic board based on a Raspberry Pi Compute Module 4 (CM4). Many
components are integrated on the board to provide various features.

One of these features is the *ANX7688*, which manages the board’s USB
Type-C port. We need to support *video output* through this port, but also
allow *USB flash drive access*. The Type-C port is connected to the
ANX7688, and if a non-video device is connected, it switches to the *VL805* USB
controller.

The *ANX7688 driver is not included in the Linux mainline*, so I adapted
the driver from the PinePhone project for our board. The driver *loads
correctly*, and the *work function executes properly*, displaying the state
of the three main pins: Cable Detect, Power Enable, and Reset.

*Observed issues:*

   -

   When I plug in a USB flash drive, the ANX7688 powers on and the Cable
   Detect pin does not change, but the *PD negotiation reports a 0 mA limit*,
   so communication with the USB device does not occur.
   -

   Occasionally, when removing the USB flash drive, *Cable Detect remains
   high (1)* even though no device is connected to the Type-C port.
   -

   Many PD messages are exchanged, but *nothing happens when connecting a
   monitor* to the Type-C port.

*Relevant Device Tree overlay:*

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2711";

    fragment@0 {
        target = <&usb>;
        __overlay__ {
            dr_mode = "otg";
            usb-role-switch;
            role-switch-default-mode = "host";
            status = "okay";
        };
    };

    fragment@1 {
        target = <&i2c1>;
        __overlay__ {
            #address-cells = <1>;
            #size-cells = <0>;

            gpio_expander: gpio_expander@23 {
                compatible = "nxp,pcal6524";
                status = "okay";
                reg = <0x23>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&gpio>;
                interrupts = <6 2>;
                interrupt-controller;
                #interrupt-cells = <2>;
                int-gpios = <&gpio 6 0>;

                gpio-line-names =
                    "CMD_MOSFET_ALIM",
                    "RS_BUS_RESET",
                    "CAN_BUS_RESET",
                    "OI_GPIO",
                    "CAN_USER_RESET",
                    "RS_USER_RESET",
                    "CTRL_USB_SWITCH",
                    "5V_BORNIER_PG",
                    "BORNIER_EN",
                    "ANX7688_PE",
                    "ANX7688_CABLE_DET",
                    "ANX7688_RESET",
                    "STOR_Sensor4_Digital",
                    "ETOR1",
                    "STOR_Sensor1_Digital",
                    "ETOR2",
                    "ETOR4",
                    "STOR_Sensor2_Digital",
                    "ETOR3",
                    "STOR_Sensor3_Digital",
                    "STOR_CMD_1",
                    "STOR_CMD_2",
                    "STOR_CMD_3",
                    "STOR_CMD_4";
            };

            anx7688: anx7688@28 {
                compatible = "analogix,anx7688";
                reg = <0x28>;
                status = "okay";

                interrupt-parent = <&gpio>;
                interrupts = <45 8>;

                reset-gpios = <&gpio_expander 11 0>;
                enable-gpios = <&gpio_expander 9 0>;
                cabledet-gpios = <&gpio_expander 10 0>;

                source-caps = <0x26019032>;
                sink-caps = <0x2601912C>;

                vbus-supply = <&vdd_5v0_reg>;
                vbus_in-supply = <&power 6>;

                role-switch = <&usb>;
            };
        };
    };
};

I would greatly appreciate any guidance on the following:

   -

   Is my approach for integrating this non-mainline driver into Yocto
   correct?
   -

   Are there recommended steps or best practices for debugging USB
   Type-C/PD negotiation and video output on such hardware?

Thank you very much for your help!

Best regards,
Pavel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.