Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2222278pxb; Fri, 5 Feb 2021 11:59:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV4Uh4SW3kFSfTo7UNUE2I9UXP4viKQGeBJZC1ksH6JfDwVU80ifV6DBl4HNFPhce2RXcy X-Received: by 2002:a17:906:e18:: with SMTP id l24mr5465669eji.500.1612555196333; Fri, 05 Feb 2021 11:59:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612555196; cv=none; d=google.com; s=arc-20160816; b=VOz/kpmsczfdRwNrqmdSIWEJ/eJuHDmjbqsmVYLRdq/721Ha2x0sFpWMgxQBRS5k36 aGD2RgwedqyDqj0m5K1XdHPGhs3CkLqtSF+g8qDjTD9niZUgdc/7M8mrWFtt6IYdjHDx J4YCwfsPIJmXdDQZyjgk0wkFK6NL1bqPmRAy/IH5uClIop33Z0+0cHAJHrvNNL37M3Ny yVxw4A0SoKinxlLmkfv9rMNF5ldtSGa1A3M9jvCLXbA59dNRGPpH2jStcEQlFMsFNqbc srQNVllqRo5T8OGSwO525FTOhpPc4G9LMKwe67STmd2KNlOf1lZR0qwrOujtAn2eJm/x 7nAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=RPy0ZWC1193aRWaFH2dOu940axBYAPxChiDTqC9mEdA=; b=a3BVsANXfzpVuCbvZTmdBoPP3bOklv7VDaIDxCbaRICyzIi5QtzirzYJWPzn2d4qTB pg7bsaQAHtpAcDSka25A70zHA0f1uNgDS/LcnzHOA5FyGpg9BNgkDLzMZGHMFhiBfSue 3nlliVbmD4MbEvnLNzVDaVYk8GYI/qgPJHtnTk/uQuT9Wu5LPtmG1Oy27NYvlf09+BrL 2h0+RPjnQ8NtcDrS24uRijPdwiPxatUWacrQRffI4VaO1tKD9el/HUnSXbYuWsMhClzZ FpbRLO0kBgT0f+Zs3Xc8RPIEwlUIzbTllMh8jMUSjMy9SPV85ctPCKcEkyxAVUlAUMY9 IoeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si5742109ejs.148.2021.02.05.11.59.28; Fri, 05 Feb 2021 11:59:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230436AbhBESPZ (ORCPT + 99 others); Fri, 5 Feb 2021 13:15:25 -0500 Received: from mga01.intel.com ([192.55.52.88]:26179 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233258AbhBESLy (ORCPT ); Fri, 5 Feb 2021 13:11:54 -0500 IronPort-SDR: Rt4NGCn8Si2K1FNEiGluATf2s0fJMC3mubnRs1RstOe1oMKtvyU6d614PrKowTA2/cJiUAqz5z LDbc/fNhJumw== X-IronPort-AV: E=McAfee;i="6000,8403,9886"; a="200493377" X-IronPort-AV: E=Sophos;i="5.81,156,1610438400"; d="scan'208";a="200493377" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2021 11:52:06 -0800 IronPort-SDR: XEJrU5nLrdYY6CBx7Ht8qEi2CeTAA8ghWxDMsHr4g8h4WW/0y4O+Ua9nWTYXNkYnc163aHyVVg HLSQxNrCublg== X-IronPort-AV: E=Sophos;i="5.81,156,1610438400"; d="scan'208";a="434580884" Received: from glacier.sc.intel.com ([10.3.62.63]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 05 Feb 2021 11:52:05 -0800 From: Rajmohan Mani To: Benson Leung , Enric Balletbo i Serra , Guenter Roeck , linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, pmalani@chromium.org, Rajmohan Mani Subject: [PATCH 2/2] platform/chrome: cros_ec_types: Support disconnect events without partners Date: Fri, 5 Feb 2021 11:51:13 -0800 Message-Id: <20210205195113.20277-3-rajmohan.mani@intel.com> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210205195113.20277-1-rajmohan.mani@intel.com> References: <20210205195113.20277-1-rajmohan.mani@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are certain scenarios, where a disconnect event might occur on a Type-C port with no port partners. This is required to enable communication to Burnside Bridge USB4 retimers. Signed-off-by: Rajmohan Mani --- drivers/platform/chrome/cros_ec_typec.c | 26 ++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 3d8ff3f8a514..d89fe51b74b1 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -203,20 +203,26 @@ static void cros_typec_unregister_altmodes(struct cros_typec_data *typec, int po } } -static void cros_typec_remove_partner(struct cros_typec_data *typec, - int port_num) +static int cros_typec_usb_disconnect_state(struct cros_typec_port *port) { - struct cros_typec_port *port = typec->ports[port_num]; - - cros_typec_unregister_altmodes(typec, port_num, true); - port->state.alt = NULL; port->state.mode = TYPEC_STATE_USB; port->state.data = NULL; usb_role_switch_set_role(port->role_sw, USB_ROLE_NONE); typec_switch_set(port->ori_sw, TYPEC_ORIENTATION_NONE); - typec_mux_set(port->mux, &port->state); + + return typec_mux_set(port->mux, &port->state); +} + +static void cros_typec_remove_partner(struct cros_typec_data *typec, + int port_num) +{ + struct cros_typec_port *port = typec->ports[port_num]; + + cros_typec_unregister_altmodes(typec, port_num, true); + + cros_typec_usb_disconnect_state(port); typec_unregister_partner(port->partner); port->partner = NULL; @@ -536,6 +542,11 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, enum typec_orientation orientation; int ret; + if (mux_flags == USB_PD_MUX_NONE) { + ret = cros_typec_usb_disconnect_state(port); + goto mux_ack; + } + if (mux_flags & USB_PD_MUX_POLARITY_INVERTED) orientation = TYPEC_ORIENTATION_REVERSE; else @@ -569,6 +580,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, mux_flags); } +mux_ack: if (!typec->needs_mux_ack) return ret; -- 2.30.0