From 9b1743cb3a5d7eeb6ce75e355da13aac39ac281b Mon Sep 17 00:00:00 2001 From: Linyu Yuan Date: Wed, 4 Nov 2020 10:32:22 +0800 Subject: [PATCH] usb: misc: nb7vpq904m: disable chip when boot up without cable When boot up without USB cable, first UCSI_GET_CONNECTOR_STATUS command will return all zero message, Example UCSI IPC log: 40.319381997: sync_write: CONTROL: 12 00 01 00 00 00 00 00 40.319507987: read: CCI: 00 09 00 80 40.319620018: read: MSG_IN: 00 00 00 00 00 00 00 00 00 Disable chip when connect status not set. Change-Id: I6c91e462b10a8fc6798d95148be799706861ab46 Signed-off-by: Linyu Yuan --- drivers/usb/misc/ssusb-redriver-nb7vpq904m.c | 23 +++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/usb/misc/ssusb-redriver-nb7vpq904m.c b/drivers/usb/misc/ssusb-redriver-nb7vpq904m.c index d1566dc595b2..f597879b9fdb 100644 --- a/drivers/usb/misc/ssusb-redriver-nb7vpq904m.c +++ b/drivers/usb/misc/ssusb-redriver-nb7vpq904m.c @@ -458,13 +458,17 @@ static int ssusb_redriver_ucsi_notifier(struct notifier_block *nb, if (info->connect && !info->partner_change) return NOTIFY_DONE; - /* - * when connect a DP only cable, - * ucsi set usb flag first, then set usb and alternate mode - * after dp start link training. - * it should only set alternate_mode flag ??? - */ - if (info->partner_usb && info->partner_alternate_mode) { + if (!info->connect) { + if (info->partner_usb || info->partner_alternate_mode) + dev_err(redriver->dev, "set partner when no connection\n"); + op_mode = OP_MODE_NONE; + } else if (info->partner_usb && info->partner_alternate_mode) { + /* + * when connect a DP only cable, + * ucsi set usb flag first, then set usb and alternate mode + * after dp start link training. + * it should only set alternate_mode flag ??? + */ if (redriver->op_mode == OP_MODE_DP) return NOTIFY_OK; op_mode = OP_MODE_USB_AND_DP; @@ -472,10 +476,9 @@ static int ssusb_redriver_ucsi_notifier(struct notifier_block *nb, if (redriver->op_mode == OP_MODE_DP) return NOTIFY_OK; op_mode = OP_MODE_USB; - } - else if (info->partner_alternate_mode) + } else if (info->partner_alternate_mode) { op_mode = OP_MODE_DP; - else + } else op_mode = OP_MODE_NONE; if (redriver->op_mode == op_mode)