From 1bed1828a2130b18b4d57c7f7958f8ae4e14a9e8 Mon Sep 17 00:00:00 2001 From: Linyu Yuan Date: Wed, 26 Aug 2020 14:18:51 +0800 Subject: [PATCH] usb: typec: ucsi: check partner changed flag during notification Certain Type-C USB adapters (which doesn't support PD), when connected switch the USB port type from USB3 to USB2. This is because the clients of UCSI receive a notification when the response for GET_CONNECTOR_STATUS has empty partner type. Example UCSI IPC log: 213.212929: sync_write: CONTROL: 12 00 01 00 00 00 00 00 213.216613: read: CCI: 02 09 00 80 213.221135: read: MSG_IN: 00 00 0d 00 00 00 00 00 00 Parsing the logs gives the following information: Connect Status: connected Power Operation Mode: USB Type-C Current - 3A Power Direction: consumer Connector Partner Type: Reserved Fix this by checking whether partner changed flag is set and not notify UCSI clients if it is not set. Change-Id: Id8bd71c325b58f5ff45e9f69cc59776af974a885 Signed-off-by: Linyu Yuan --- drivers/usb/typec/ucsi/ucsi_glink.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c index 4c9343aa7333..13a1b73dd156 100644 --- a/drivers/usb/typec/ucsi/ucsi_glink.c +++ b/drivers/usb/typec/ucsi/ucsi_glink.c @@ -370,6 +370,13 @@ static void ucsi_qti_notify(struct ucsi_dev *udev, unsigned int offset, mutex_unlock(&udev->notify_lock); if (cmd_requested && offset == UCSI_MESSAGE_IN) { + /* + * when Connector Partner Type or Flags changes, + * Connector Partner Changed bit shall be set. + */ + if (!(status->change & UCSI_CONSTAT_PARTNER_CHANGE)) + return; + cancel_work_sync(&udev->notify_work); udev->constat_info.partner_usb = false;