Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp673098pxb; Tue, 2 Feb 2021 15:07:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyytalgPJ9n9zVvr298fu92tjM78+T4PNDWfM6ijrrhgWNxshqld+2/uQyU/HJkcEadh2s1 X-Received: by 2002:aa7:da55:: with SMTP id w21mr406783eds.138.1612307240443; Tue, 02 Feb 2021 15:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612307240; cv=none; d=google.com; s=arc-20160816; b=uEZkfk4vC7w730pGz//YkwkiezC3V+z5nwIFq154BpvNhRItoQetqtbPJRTn/w/e8P jU55/Z2Cw133GhvAD096Bpds7h7yLiWWolZcmMQAyOC64ROO2GH++X9tVAtvtKQvcqWj iOGaZWdoYTaZ0v/OPGFjixR3VH2m9kK1NgWuJosYJPCkoCLhginY0A5JcZVWI55w0KtE zddurWj5Y8PmRyf4ySdrkijfmA8pUhWEgr7cl35ug2syswdtecz4vjpVBnQ3R5SnkYK7 +HDeTurb+t3maG090fOlnp/ooX4niscARCGYlTWYXLj2hKIHSkbgL0540UPX2IF28Maw umxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :dkim-signature; bh=2mfiyle2/q/MwjfOmnbyM806qE9V2e89I7MJjXat1m8=; b=bDCS9wX+ruXreRthDri6YExs+p1kHzrMBToKXxA6sGNtMsXcYOqYYkhQzXKoh+F5sp UgEKHYEytxwM4SACwKq1Cw7zDG9BsjSJPtLXrlMTEwTI6rfHVTdv6NA5oDfp9wt18ALS brlXjaPYSg4W3EfXgKRJRZISI3oyqhZPnT1s9mT8ey+c6q9FpkA2BHm2jGJfDe1DsUQW Y5s4H34yqGfKXARPewM7O/6xJSil3ZVI2qB0NVsqrRygEpRYwxxk68uIq30hW02p7Yeo 8a5ScokEVzBPROFhRM3YHL6vvPMgPsRRlJ49Q8qo6Ii1954SG8kcZUpHGxwivU7U5VXS n3Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n26PWLAf; 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 e18si166265ejd.498.2021.02.02.15.06.54; Tue, 02 Feb 2021 15:07:20 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n26PWLAf; 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 S236384AbhBBQ32 (ORCPT + 99 others); Tue, 2 Feb 2021 11:29:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236107AbhBBQZo (ORCPT ); Tue, 2 Feb 2021 11:25:44 -0500 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ACBCC061573; Tue, 2 Feb 2021 08:25:03 -0800 (PST) Received: by mail-ot1-x329.google.com with SMTP id f6so20326864ots.9; Tue, 02 Feb 2021 08:25:03 -0800 (PST) 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:user-agent; bh=2mfiyle2/q/MwjfOmnbyM806qE9V2e89I7MJjXat1m8=; b=n26PWLAf0nXVvTCrWvIYxTeDC8/n7JX5qrwFUJ7Y3LL1gtRB75+RxKhXsFhlH+ez2j n8xHgnAmCBtY6vPmJCPUD+BEZfAclAMhCLNPmLGkOqRjWuWqJBNKYAb/UR7QyT9D53vy tuznzPxST71V7+U5EBxOnOw5cy45SPIE9H5ihpGPxQmADyZXItWT/G6IISKjQa+9vx34 XqjzrWLD6MmDH6iBF7CQ8TyPvr/WZb0enOZmUIKtjqvuJAMP8eeXpJkeP5e4v2O16Q6j aNMGuKXWAawC1e6t9BetZu7Kfw1h7zT/PJj7W5DVLvHvzRbeao492tCINrXMURGy/XCY MlEw== 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:user-agent; bh=2mfiyle2/q/MwjfOmnbyM806qE9V2e89I7MJjXat1m8=; b=WBm+hXx+CK/oCvYb6dIcWreZp1PhMnh1Ohi7pj7x9Pe03qriqXg99dh5OpR9Yef5Yr 3ySPD79JC194GvboPR+59HEB6swvg1RByFujPT5jIKXR+aJE6/0hWXYgq8edQzaTUvPj RFCbIPbWQrSsnJmXf1WzUJ2E3021WUnuBs4iU9ddhZttCHhBl/E2Ed7wwSP1V1/TsnQC q7BTAba8S08Ff9uYY9Xj8FITpyX98FCSe5BBQS6QwpPXWm/Sb2Apuq1+ZvyBpEsD+tvw YjlbfsciM508N+JmOhGiSbgOnkap6hzVx4JPeJfuQg5q7jjn3bowt4zpDjBHAfAd7TJX f1BA== X-Gm-Message-State: AOAM532PJ4BIqqQ/cRntSh2qo4AVsCtqJ3gKVGPnggqcd2Bn/bh7uMuL HoOvzZG0JCJ8PzVuMoeEOkCI6+U51PI= X-Received: by 2002:a9d:2da2:: with SMTP id g31mr15784508otb.222.1612283103016; Tue, 02 Feb 2021 08:25:03 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t62sm4837414oif.2.2021.02.02.08.25.01 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Feb 2021 08:25:02 -0800 (PST) Sender: Guenter Roeck Date: Tue, 2 Feb 2021 08:25:00 -0800 From: Guenter Roeck To: Badhri Jagan Sridharan Cc: Heikki Krogerus , Greg Kroah-Hartman , Kyle Tso , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/3] usb: typec: tcpm: Add Callback to Usb Communication capable partner Message-ID: <20210202162500.GA159455@roeck-us.net> References: <20210202003101.221145-1-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210202003101.221145-1-badhri@google.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 01, 2021 at 04:30:59PM -0800, Badhri Jagan Sridharan wrote: > The USB Communications Capable bit indicates if port > partner is capable of communication over the USB data lines > (e.g. D+/- or SS Tx/Rx). Notify the status of the bit to low > level drivers to perform chip specific operation. > For instance, low level driver enables USB switches on D+/D- > lines to set up data path when the bit is set. > > Refactored from patch initially authored by > Kyle Tso > > Signed-off-by: Badhri Jagan Sridharan Reviewed-by: Guenter Roeck > --- > Changes since V1: > - Removed partner_usb_comm_capable flag. > - Fixed capable flag for SNK_NEGOTIATE_CAPABILITIES. > --- > drivers/usb/typec/tcpm/tcpm.c | 13 +++++++++++++ > include/linux/usb/tcpm.h | 5 +++++ > 2 files changed, 18 insertions(+) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index 0afd8ef692e8..997a1a56c161 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -3429,6 +3429,14 @@ static void tcpm_unregister_altmodes(struct tcpm_port *port) > memset(modep, 0, sizeof(*modep)); > } > > +static void tcpm_set_partner_usb_comm_capable(struct tcpm_port *port, bool capable) > +{ > + tcpm_log(port, "Setting usb_comm capable %s", capable ? "true" : "false"); > + > + if (port->tcpc->set_partner_usb_comm_capable) > + port->tcpc->set_partner_usb_comm_capable(port->tcpc, capable); > +} > + > static void tcpm_reset_port(struct tcpm_port *port) > { > int ret; > @@ -3445,6 +3453,7 @@ static void tcpm_reset_port(struct tcpm_port *port) > port->attached = false; > port->pd_capable = false; > port->pps_data.supported = false; > + tcpm_set_partner_usb_comm_capable(port, false); > > /* > * First Rx ID should be 0; set this to a sentinel of -1 so that > @@ -3785,6 +3794,8 @@ static void run_state_machine(struct tcpm_port *port) > } > } else { > tcpm_pd_send_control(port, PD_CTRL_ACCEPT); > + tcpm_set_partner_usb_comm_capable(port, > + !!(port->sink_request & RDO_USB_COMM)); > tcpm_set_state(port, SRC_TRANSITION_SUPPLY, > PD_T_SRC_TRANSITION); > } > @@ -4004,6 +4015,8 @@ static void run_state_machine(struct tcpm_port *port) > break; > case SNK_NEGOTIATE_CAPABILITIES: > port->pd_capable = true; > + tcpm_set_partner_usb_comm_capable(port, > + !!(port->source_caps[0] & PDO_FIXED_USB_COMM)); > port->hard_reset_count = 0; > ret = tcpm_pd_send_request(port); > if (ret < 0) { > diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h > index 3af99f85e8b9..42fcfbe10590 100644 > --- a/include/linux/usb/tcpm.h > +++ b/include/linux/usb/tcpm.h > @@ -108,6 +108,10 @@ enum tcpm_transmit_type { > * is supported by TCPC, set this callback for TCPM to query > * whether vbus is at VSAFE0V when needed. > * Returns true when vbus is at VSAFE0V, false otherwise. > + * @set_partner_usb_comm_capable: > + * Optional; The USB Communications Capable bit indicates if port > + * partner is capable of communication over the USB data lines > + * (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. > */ > struct tcpc_dev { > struct fwnode_handle *fwnode; > @@ -139,6 +143,7 @@ struct tcpc_dev { > int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum typec_pwr_opmode mode, > bool pps_active, u32 requested_vbus_voltage); > bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev); > + void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable); > }; > > struct tcpm_port; > -- > 2.30.0.365.g02bc693789-goog >