USB-C touchscreen not detected on startup or when re-plugged

System I’m working on: Linux Khadas 4.4.194 #2 SMP Fri Jan 10 22:51:04 CST 2020 aarch64 aarch64 aarch64 GNU/Linux (Clean official image, I’ve just run apt upgrade)

I have the issue with USB-C Touchscreen - the touch works only when i plug in the display after system boots up. If the screen is plugged during system startup, or when I unplug display when touch is working fine, and then plug it without rebooting touchscreen isn’t working, and its not even detected (not listed in lsusb). Console logs below:

dmsg and lsusb when everything works fine:

[   18.742412] usb 7-1: new high-speed USB device number 2 using xhci-hcd
[   18.743518] WLC_E_IF: NO_IF set, event Ignored
[   18.744825] P2P interface started
[   18.793897] ttyS0 - failed to request DMA, use interrupt mode
[   18.823212] fusb302 8-0022: PD connected as DFP, supporting 5V
[   18.854306] usb 7-1: Device not responding to setup address.
[   18.947553] fusb302 8-0022: DP config successful, pin_assignment 0x4
[   18.949172] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] Not connected. Disabling cdn
[   19.058261] usb 7-1: Device not responding to setup address.
[   19.262225] usb 7-1: device not accepting address 2, error -71
[   19.374238] usb 7-1: new high-speed USB device number 3 using xhci-hcd
[   19.503358] usb 7-1: New USB device found, idVendor=1a40, idProduct=0801
[   19.503375] usb 7-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[   19.503384] usb 7-1: Product: USB 2.0 Hub
[   19.520917] hub 7-1:1.0: USB hub found
[   19.520985] hub 7-1:1.0: 4 ports detected
[   19.806277] usb 7-1.4: new full-speed USB device number 4 using xhci-hcd
[   19.914231] usb 7-1.4: New USB device found, idVendor=27c0, idProduct=0868
[   19.914246] usb 7-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   19.914253] usb 7-1.4: Product: TouchScreen
[   19.914260] usb 7-1.4: Manufacturer: WingCool Inc.
[   19.914266] usb 7-1.4: SerialNumber: 9LQ0172005164
[   19.943044] input: WingCool Inc. TouchScreen as /devices/platform/usb0/fe800000.dwc3/xhci-hcd.8.auto/usb7/7-1/7-1.4/7-1.4:1.0/0003:27C0:0868.0004/input/input8
[   19.998944] hid-multitouch 0003:27C0:0868.0004: input,hiddev0,hidraw3: USB HID v1.10 Keyboard [WingCool Inc. TouchScreen] on usb-xhci-hcd.8.auto-1.4/input0
[   20.001763] hid-generic 0003:27C0:0868.0005: hiddev0,hidraw4: USB HID v1.10 Device [WingCool Inc. TouchScreen] on usb-xhci-hcd.8.auto-1.4/input1
[   20.004515] input: WingCool Inc. TouchScreen as /devices/platform/usb0/fe800000.dwc3/xhci-hcd.8.auto/usb7/7-1/7-1.4/7-1.4:1.2/0003:27C0:0868.0006/input/input10
[   20.031423] fusb302 8-0022: attention, dp_status 8a
[   20.031663] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] Connected, not enabled. Enabling cdn
[   20.058530] hid-generic 0003:27C0:0868.0006: input,hidraw5: USB HID v1.10 Mouse [WingCool Inc. TouchScreen] on usb-xhci-hcd.8.auto-1.4/input2
[   20.442619] rockchip-vop ff8f0000.vop: [drm:vop_crtc_enable] Update mode to 1920x1200p0, type: 10
[   20.446010] cdn-dp fec00000.dp: 1620Mbps x 4lanes
[   20.530294] fusb302 8-0022: attention, dp_status 8a
[   21.030989] fusb302 8-0022: attention, dp_status 8a
[   25.731774] tty_port_close_start: tty->count = 1 port count = 2.

Bus 005 Device 002: ID 1a2c:0021 China Resource Semico Co., Ltd Keyboard
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 004: ID 27c0:0868  
Bus 007 Device 003: ID 1a40:0801 Terminus Technology Inc. 
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 002: ID 17ef:60d1 Lenovo 
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

dmsg and lsusb when unplugged and plugged again without reboot:

[  263.138460] fusb302 8-0022: CC connected in CC2 as DFP
[  263.142194] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] Not connected. Disabling cdn
[  263.163230] phy phy-ff7c0000.phy.9: phy poweron failed --> -110
[  263.163807] dwc3 fe800000.dwc3: Failed to power on usb3 phy
[  263.187222] phy phy-ff7c0000.phy.9: phy poweron failed --> -110
[  263.198964] xhci-hcd xhci-hcd.8.auto: xHCI Host Controller
[  263.201386] xhci-hcd xhci-hcd.8.auto: new USB bus registered, assigned bus number 7
[  263.201642] xhci-hcd xhci-hcd.8.auto: hcc params 0x0220fe64 hci version 0x110 quirks 0x06030010
[  263.201705] xhci-hcd xhci-hcd.8.auto: irq 227, io mem 0xfe800000
[  263.202123] usb usb7: New USB device found, idVendor=1d6b, idProduct=0002
[  263.202145] usb usb7: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[  263.202163] usb usb7: Product: xHCI Host Controller
[  263.202180] usb usb7: Manufacturer: Linux 4.4.194 xhci-hcd
[  263.202197] usb usb7: SerialNumber: xhci-hcd.8.auto
[  263.212192] hub 7-0:1.0: USB hub found
[  263.212271] hub 7-0:1.0: 1 port detected
[  263.212855] xhci-hcd xhci-hcd.8.auto: xHCI Host Controller
[  263.213550] xhci-hcd xhci-hcd.8.auto: new USB bus registered, assigned bus number 8
[  263.213720] usb usb8: We don't know the algorithms for LPM for this host, disabling LPM.
[  263.213927] usb usb8: New USB device found, idVendor=1d6b, idProduct=0003
[  263.213948] usb usb8: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[  263.213967] usb usb8: Product: xHCI Host Controller
[  263.213984] usb usb8: Manufacturer: Linux 4.4.194 xhci-hcd
[  263.214001] usb usb8: SerialNumber: xhci-hcd.8.auto
[  263.215325] hub 8-0:1.0: USB hub found
[  263.215401] hub 8-0:1.0: 1 port detected
[  263.216503] rockchip-dwc3 usb0: USB HOST connected
[  263.546738] fusb302 8-0022: PD connected as DFP, supporting 5V
[  263.676610] fusb302 8-0022: DP config successful, pin_assignment 0x4
[  263.678452] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] Not connected. Disabling cdn
[  264.799489] fusb302 8-0022: attention, dp_status 8a
[  264.805281] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] Connected with sink. Re-train link
[  264.808425] cdn-dp fec00000.dp: 1620Mbps x 4lanes
[  265.334061] fusb302 8-0022: attention, dp_status 8a
[  265.852582] fusb302 8-0022: attention, dp_status 8a
[  297.209127] IPVS: Creating netns size=2104 id=5
Bus 005 Device 002: ID 1a2c:0021 China Resource Semico Co., Ltd Keyboard
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 002: ID 17ef:60d1 Lenovo 
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Thanks in advance for any ideas!

@Oliver I have encountered this problem on Android 10.0. It was OK to revert a submission.

commit cc8b329fef53c74a4abf98b0755b3832d572d6ce
Author: Mathias Nyman <mathias.nyman@linux.intel.com>
Date:   Thu Nov 15 11:38:41 2018 +0200

    usb: xhci: Prevent bus suspend if a port connect change or polling state is detected
    
    commit 2f31a67f01a8beb22cae754c53522cb61a005750 upstream.
    
    USB3 roothub might autosuspend before a plugged USB3 device is detected,
    causing USB3 device enumeration failure.
    
    USB3 devices don't show up as connected and enabled until USB3 link trainig
    completes. On a fast booting platform with a slow USB3 link training the
    link might reach the connected enabled state just as the bus is suspending.
    
    If this device is discovered first time by the xhci_bus_suspend() routine
    it will be put to U3 suspended state like the other ports which failed to
    suspend earlier.
    
    The hub thread will notice the connect change and resume the bus,
    moving the port back to U0
    
    This U0 -> U3 -> U0 transition right after being connected seems to be
    too much for some devices, causing them to first go to SS.Inactive state,
    and finally end up stuck in a polling state with reset asserted
    
    Fix this by failing the bus suspend if a port has a connect change or is
    in a polling state in xhci_bus_suspend().
    
    Don't do any port changes until all ports are checked, buffer all port
    changes and only write them in the end if suspend can proceed
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>