Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp662666pxj; Tue, 18 May 2021 11:16:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4WLEsWnrvfIVVXbikh3ZOJW+gRubb8cIpFvWL7G/D9nx/H6s56Je1cX1MHSmbbtIpsmV9 X-Received: by 2002:a05:6402:2064:: with SMTP id bd4mr8395413edb.96.1621361814971; Tue, 18 May 2021 11:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621361814; cv=none; d=google.com; s=arc-20160816; b=XkodKsUX1b4peQnMH7+nxEl5mUs7v+5jv5PHnwR5+JgQehF9KbAuBq3cElATzMIVzp RXxBFD0LoK7cu2fEpRJ/5oxk9CDS8PfZ/0EmNbwutetE2Vr+mje0pVe5PZmL5a4D1lFg ltW+CU9wJsyMJM+Q5E66A+r5POFfN2hWVHKZEJvDcpMRLgsP9y6u9gzniuDvYcJuthdo qCuV/EnLIbq90zeior3jDzPcjM/1+/HrYxWFcvTVh8VgB3yaeF0pGSUhTqJwzWog9nUA GqYYQtLyWXpmzHILIgzq5PXHTitH+z0C2WaualjyCM+djMfgBYdcPClc9fZzQdMoa1Md iLeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=uNcMlxmGe0/KHpC/yKgEws6zzml6blB7GcOty29DOBI=; b=lkhez/YCG48GnKQB5LfTzYqKNJsL7jBDpwjOdwZMXF9UiTo/5V0tBQ3bsfDJsx8v+g oiEN5sXo8zhcL/+Kj2DSWRuc1mm5W3bFW0DzQ/3OU58SiDK/+h+ll7aftQKGdHkIagM0 V0SmFc/rPpiP1eRBe8vpvCQK7/xYgC6n7rAII6buhmETt7JDiW384xBgD7HPJxc7pRyu 5UOe1mqmJjFQmL9tn1hm5/MC8viqXO0xKbCF0iLcpL0sVvQnD93zAHIuY2SXfjrhDaG3 t3iXDZviRAR34cvNlhwk2IpCJP309V3QGu/sHbNXn1lQ3haHQ/6ocIKLfw4mEpiT8S1C p3TQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kqLqC53M; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si253314edn.213.2021.05.18.11.16.31; Tue, 18 May 2021 11:16:54 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kqLqC53M; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345468AbhEQQM6 (ORCPT + 99 others); Mon, 17 May 2021 12:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245566AbhEQPsx (ORCPT ); Mon, 17 May 2021 11:48:53 -0400 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57E39C07E5FC; Mon, 17 May 2021 07:38:31 -0700 (PDT) Received: by mail-qv1-xf31.google.com with SMTP id ez19so3194294qvb.3; Mon, 17 May 2021 07:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=uNcMlxmGe0/KHpC/yKgEws6zzml6blB7GcOty29DOBI=; b=kqLqC53Mu3wSLvV9gQtWSdGf6U/KsZd1lLq9SusTQeIg3BVK3J66/3F2eJtYNAQkzb 22/9oIWqk+jx/Yy/UEYg/RkbCwVYCPKYxUohmwkjaR31UIPVa6hdKrnn6mACi961hlZX HxMYsE8jzKidtjb8LvWVmpLhS3YTaKjfJ3cFdV2NAgsnyiSECLLFzn0Mz/hVnKmzAbvb P///s1NE3EkQykKejmi0yShD9dfz8BFclJcpHTQgj4I2evBU2y0JfBJU/wtVa164SMXv eFKOouzbX2ktygTOzifMkrRCAeWB07KabKYeEB1yRGoLne0XRpS2scApgwRFVpMYj2km ZHmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=uNcMlxmGe0/KHpC/yKgEws6zzml6blB7GcOty29DOBI=; b=LshZ+S2fuOfeQHJzSuOXfy2zA8Ulhb39dpx0PDvNluLaaRtfEiEBNEEUzxFQicN8WF mh38nGXDOcFgmrGuVDf9/lB47hbFf/sCkEUKXt6J3bwG/NmucDe2tIhv0N8rOxS1Wbwc jyKKaDeWlNU3tqeDT2pm8XHS8gRuFDnZCyyCuzQ/8jxbNafciy7kqfzsUNe8iH0flY10 eWZR16U9Fy7mbG1buhQ2bg3LXcZbFh+Q7WZmw3clOTyhbNG756g7CzdSSJj4I0Yypw5I sG7dZHs5q7TNoGPP4VgXZ3Ig7r0PlekWxNQEznPAvMQzE8YR1aXWj/IWcOx7PMe2W1/z hS/A== X-Gm-Message-State: AOAM533Q0T8SRyGIqTuU8lVDFOlJrzHL03pBs2bJMfBTeNLDPOd46org 7gQZjYXiGP6W7fg4bHIQAl+mgsYJmxU= X-Received: by 2002:a0c:9ccc:: with SMTP id j12mr60481248qvf.30.1621262310662; Mon, 17 May 2021 07:38:30 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id c9sm4086104qke.8.2021.05.17.07.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 07:38:30 -0700 (PDT) Sender: Guenter Roeck Date: Mon, 17 May 2021 07:38:28 -0700 From: Guenter Roeck To: Badhri Jagan Sridharan Cc: Heikki Krogerus , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org Subject: Re: [PATCH v1 4/4] usb: typec: tcpci: Implement callback for apply_rc Message-ID: <20210517143828.GC3434992@roeck-us.net> References: <20210515052613.3261340-1-badhri@google.com> <20210515052613.3261340-4-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210515052613.3261340-4-badhri@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 14, 2021 at 10:26:13PM -0700, Badhri Jagan Sridharan wrote: > APPLY RC is defined as ROLE_CONTROL.CC1 != ROLE_CONTROL.CC2 and > POWER_CONTROL.AutodischargeDisconnect is 0. When ROLE_CONTROL.CC1 == > ROLE_CONTROL.CC2, set the other CC to OPEN. > > Fixes: f321a02caebd ("usb: typec: tcpm: Implement enabling Auto Discharge disconnect support") > Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck > --- > drivers/usb/typec/tcpm/tcpci.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c > index 25b480752266..34b5095cc84f 100644 > --- a/drivers/usb/typec/tcpm/tcpci.c > +++ b/drivers/usb/typec/tcpm/tcpci.c > @@ -115,6 +115,32 @@ static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) > return 0; > } > > +int tcpci_apply_rc(struct tcpc_dev *tcpc, enum typec_cc_status cc, enum typec_cc_polarity polarity) > +{ > + struct tcpci *tcpci = tcpc_to_tcpci(tcpc); > + unsigned int reg; > + int ret; > + > + ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, ®); > + if (ret < 0) > + return ret; > + > + /* > + * APPLY_RC state is when ROLE_CONTROL.CC1 != ROLE_CONTROL.CC2 and vbus autodischarge on > + * disconnect is disabled. Bail out when ROLE_CONTROL.CC1 != ROLE_CONTROL.CC2. > + */ > + if (((reg & (TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT)) >> > + TCPC_ROLE_CTRL_CC2_SHIFT) != > + ((reg & (TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT)) >> > + TCPC_ROLE_CTRL_CC1_SHIFT)) > + return 0; > + > + return regmap_update_bits(tcpci->regmap, TCPC_ROLE_CTRL, polarity == TYPEC_POLARITY_CC1 ? > + TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT : > + TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT, > + TCPC_ROLE_CTRL_CC_OPEN); > +} > + > static int tcpci_start_toggling(struct tcpc_dev *tcpc, > enum typec_port_type port_type, > enum typec_cc_status cc) > @@ -728,6 +754,7 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data) > tcpci->tcpc.get_vbus = tcpci_get_vbus; > tcpci->tcpc.set_vbus = tcpci_set_vbus; > tcpci->tcpc.set_cc = tcpci_set_cc; > + tcpci->tcpc.apply_rc = tcpci_apply_rc; > tcpci->tcpc.get_cc = tcpci_get_cc; > tcpci->tcpc.set_polarity = tcpci_set_polarity; > tcpci->tcpc.set_vconn = tcpci_set_vconn; > -- > 2.31.1.751.gd2f1c929bd-goog >