Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp510336rdh; Tue, 19 Dec 2023 05:54:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuWi0OGI2CxT5Oi/7wIfUqQqRZYs01OaRKs1DO/NNBtTGHq2Viy+5baISPjP3VOqz31YlT X-Received: by 2002:ac2:4838:0:b0:50c:a91:6191 with SMTP id 24-20020ac24838000000b0050c0a916191mr5017622lft.83.1702994091962; Tue, 19 Dec 2023 05:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702994091; cv=none; d=google.com; s=arc-20160816; b=kumLpMuHnFCkRKX1dkGzqi4uZPis+2lcd1udrdQMQ2O51djCtl/Y/yyC5P7n7sf3P1 WCY72WJDeOwYRB48BYdz1TmIZEbeMULd/20RZk3DpUClRfQmv5PsrD7dwY8jESjEOrm/ vwcZz+Yo3ucupvcVBDVCGV3LzdRLcvc+Ru1C6E9tFcWRmuasZ39o/Gp/VmuNvFuzLDuu FsM+/GlCCEO/eRDl67sv7GaImYEMEaT2uII1Ze6beGMSXRTdtR5rR170EuavtfT2nGQs on9JmZjYUQeIbpM2k8ijDiLNU4uRdBWWpUm7G2LlGybO8vbnch7uatjjDqGsRQ6gmBWK vcsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2Tlss4JoK7QwLysGGLW/1Jfziq78Y46Oo+NK1lQ+iZE=; fh=+mOxChHccjSODygiHZulvC2wWQHtOLOc3+c+fn6v4mM=; b=OmDgeTiSfL6O/UGIR3daSD1zAjVLoCDi0+nE04EU0GPXxY2ToC33shOuFCBe9grvji xzsYBpoALv0dIikvgsq4BgqYHpkUP7ZYxjGxZwrskeRuilE++/xXqV3ZPCTPyB8h+QW7 4MhbWEddazd9pth7gw+j9IdThfcz4KjWoZdTvc0ShlCjB3b1CexkgnoDqXoHNZiDmh6r dZeyCVzp0WQ9NYKxTM8k/vgVIiiZmhy1RPM2TYR3ko+67AsbMeUJuTK4Pj/asVuxTQZA FiVroMsrXOf1PZS4AoUKWipGFdWgfEgIyGIcS/3Iq1ik4WOy94+uaIqW4Exw0ZweHrcT eLrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gUvPeHJ8; spf=pass (google.com: domain of linux-kernel+bounces-5292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b9-20020a50ccc9000000b005535915b925si1556440edj.417.2023.12.19.05.54.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 05:54:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gUvPeHJ8; spf=pass (google.com: domain of linux-kernel+bounces-5292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B01851F2568A for ; Tue, 19 Dec 2023 13:54:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D5981A5A5; Tue, 19 Dec 2023 13:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gUvPeHJ8" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCCC319BD8; Tue, 19 Dec 2023 13:54:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702994079; x=1734530079; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=5gQ7r/pmi5wibRZjHmkgsZN5qhQdYc1sTqxinTId8tY=; b=gUvPeHJ8PCUiyxOWawSxDPlY9nYnaNjEF1/U5S2d484cV6iEe7J2o0BO IeWQWBT43XKC+yQ21JJDzU1yNebPlJkE5KhMmwd+DR/S2bFhkGCPos9BC sk2xls4sQ+I5YKl7XmU+NIMmmjk4NGxk6U56/lCgJg1AjtpsQEfVOfg+t ON3QIkaelyHgwi6PN1RHLiRZ82tNUKiDCSLldQk584Bae4NEZF7lrFPlt KFUTb5EIIocNXQt5qBf2CGaSlk+ZDC+SW4pPqv3favh6afwUmrJa7KfSp tLjiaL+aIaYrejWqcHdBdzEsYSp8JEHkXjofOmcI7iUoKQwWXwiRl69HF g==; X-IronPort-AV: E=McAfee;i="6600,9927,10929"; a="14347790" X-IronPort-AV: E=Sophos;i="6.04,288,1695711600"; d="scan'208";a="14347790" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 05:54:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10929"; a="1107357081" X-IronPort-AV: E=Sophos;i="6.04,288,1695711600"; d="scan'208";a="1107357081" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga005.fm.intel.com with SMTP; 19 Dec 2023 05:54:34 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 19 Dec 2023 15:54:33 +0200 Date: Tue, 19 Dec 2023 15:54:33 +0200 From: Heikki Krogerus To: RD Babiera Cc: linux@roeck-us.net, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, badhri@google.com, bryan.odonoghue@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org Subject: Re: [PATCH v2 02/12] usb: typec: altmodes: add svdm version info for typec cables Message-ID: References: <20231214230850.379863-14-rdbabiera@google.com> <20231214230850.379863-16-rdbabiera@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231214230850.379863-16-rdbabiera@google.com> On Thu, Dec 14, 2023 at 11:08:46PM +0000, RD Babiera wrote: > Add typec_cable_set_svdm_version and typec_get_cable_svdm version symbols. > Cables can operate under a lower PD revision than the port partner, and the > max SVDM version is tied to the PD revision. So, typec_cable maintains its > own svdm_version. > > Add typec_altmode_get_cable_svdm_version to return the cable's negotiated > svdm_version for altmode drivers to use. > > Signed-off-by: RD Babiera Reviewed-by: Heikki Krogerus > --- > drivers/usb/typec/class.c | 40 +++++++++++++++++++++++++++++++ > drivers/usb/typec/class.h | 1 + > include/linux/usb/typec.h | 3 +++ > include/linux/usb/typec_altmode.h | 10 ++++++++ > 4 files changed, 54 insertions(+) > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > index 86b5a8414b89..038c6498e683 100644 > --- a/drivers/usb/typec/class.c > +++ b/drivers/usb/typec/class.c > @@ -2129,6 +2129,46 @@ int typec_get_negotiated_svdm_version(struct typec_port *port) > } > EXPORT_SYMBOL_GPL(typec_get_negotiated_svdm_version); > > +/** > + * typec_get_cable_svdm_version - Get cable negotiated SVDM Version > + * @port: USB Type-C Port. > + * > + * Get the negotiated SVDM Version for the cable. The Version is set to the port > + * default value based on the PD Revision during cable registration, and updated > + * after a successful Discover Identity if the negotiated value is less than the > + * default. > + * > + * Returns usb_pd_svdm_ver if the cable has been registered otherwise -ENODEV. > + */ > +int typec_get_cable_svdm_version(struct typec_port *port) > +{ > + enum usb_pd_svdm_ver svdm_version; > + struct device *cable_dev; > + > + cable_dev = device_find_child(&port->dev, NULL, cable_match); > + if (!cable_dev) > + return -ENODEV; > + > + svdm_version = to_typec_cable(cable_dev)->svdm_version; > + put_device(cable_dev); > + > + return svdm_version; > +} > +EXPORT_SYMBOL_GPL(typec_get_cable_svdm_version); > + > +/** > + * typec_cable_set_svdm_version - Set negotiated Structured VDM (SVDM) Version > + * @cable: USB Type-C Active Cable that supports SVDM > + * @svdm_version: Negotiated SVDM Version > + * > + * This routine is used to save the negotiated SVDM Version. > + */ > +void typec_cable_set_svdm_version(struct typec_cable *cable, enum usb_pd_svdm_ver svdm_version) > +{ > + cable->svdm_version = svdm_version; > +} > +EXPORT_SYMBOL_GPL(typec_cable_set_svdm_version); > + > /** > * typec_get_drvdata - Return private driver data pointer > * @port: USB Type-C port > diff --git a/drivers/usb/typec/class.h b/drivers/usb/typec/class.h > index c36761ba3f59..759b98355eeb 100644 > --- a/drivers/usb/typec/class.h > +++ b/drivers/usb/typec/class.h > @@ -23,6 +23,7 @@ struct typec_cable { > struct usb_pd_identity *identity; > unsigned int active:1; > u16 pd_revision; /* 0300H = "3.0" */ > + enum usb_pd_svdm_ver svdm_version; > }; > > struct typec_partner { > diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h > index 38f93d72fd1b..b35b427561ab 100644 > --- a/include/linux/usb/typec.h > +++ b/include/linux/usb/typec.h > @@ -337,6 +337,9 @@ void typec_partner_set_svdm_version(struct typec_partner *partner, > enum usb_pd_svdm_ver svdm_version); > int typec_get_negotiated_svdm_version(struct typec_port *port); > > +int typec_get_cable_svdm_version(struct typec_port *port); > +void typec_cable_set_svdm_version(struct typec_cable *cable, enum usb_pd_svdm_ver svdm_version); > + > struct usb_power_delivery *typec_partner_usb_power_delivery_register(struct typec_partner *partner, > struct usb_power_delivery_desc *desc); > > diff --git a/include/linux/usb/typec_altmode.h b/include/linux/usb/typec_altmode.h > index 72ec8058543a..b3c0866ea70f 100644 > --- a/include/linux/usb/typec_altmode.h > +++ b/include/linux/usb/typec_altmode.h > @@ -95,6 +95,16 @@ int typec_cable_altmode_exit(struct typec_altmode *altmode, enum typec_plug_inde > int typec_cable_altmode_vdm(struct typec_altmode *altmode, enum typec_plug_index sop, > const u32 header, const u32 *vdo, int count); > > +/** > + * typec_altmode_get_cable_svdm_version - Get negotiated SVDM version for cable plug > + * @altmode: Handle to the alternate mode > + */ > +static inline int > +typec_altmode_get_cable_svdm_version(struct typec_altmode *altmode) > +{ > + return typec_get_cable_svdm_version(typec_altmode2port(altmode)); > +} > + > /* > * These are the connector states (USB, Safe and Alt Mode) defined in USB Type-C > * Specification. SVID specific connector states are expected to follow and > -- > 2.43.0.472.g3155946c3a-goog -- heikki