Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp550331pxb; Wed, 18 Nov 2020 10:58:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2NTchB26L3fRy07ciyqPuKh8jpkjMskIf2Nq30mdnsxycbBkOXm5mIvzZDHkgbUqWnZdG X-Received: by 2002:a17:906:4ed7:: with SMTP id i23mr16065691ejv.172.1605725883927; Wed, 18 Nov 2020 10:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605725883; cv=none; d=google.com; s=arc-20160816; b=OnJWQQvhQUifVLAqZa/VUzmrLncDZLPBxu3iNRrszJOsE40Mv+OXxLmSBDf1um0dAT D+Ksmtu3Z2FW0h3HKPSMSuIYZ92022gn1xHGDK+ZW3YyrZ2wm2WDUGxEnb3sjkTJeRVW d7IyDRyrovFjlhQ1R5g7lfnSXYYbBs1042A8c198xKaeu0H0y86IcwX2oYRDfArz3CIT Vyf1M25rGvWbDAI/1ne5C0joal+ai0IzitXc/oWCPwrJwQqgw8N/emxsSX6+azlPoLOU 8dL/vp/d3FurAHbpT7y9wRnjpUUVyaa+HzcmU8pwzb9nSj8FccmKknsyrrilimD5gE2a PbLw== 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:dkim-signature; bh=/EQtQALhCEqfL4DGAhnne0Mwd7FFhtVFNWFyL4AwZ5c=; b=oBaXF5ZjldbQ8ojb3L7Udb3wMqZeL5wrh83ToLyDlflmJxlxfxygu4vUqFgNsZre+9 d60CeFLmhPwglX9ToIuRRqdzHoBHlVcGjze/FxUn1SDQMFEMUK/D7Ui/ZYTpqj0DNUTX nULgCxuO8HVqxIG44yW+dt4yf7TgNx88HSIE4BIcRdEBvNmMghIGA2I0UXCRNmuDATXb 6GbMmvnY1b7hLnS0mcDhILq6QydPPxHOLFKKMaTWiP1dZjRYH44HH9Rot0WDdhcDGzBJ x3/Lcx+4jN7sIQDvrbc75nLs074NmNHRBHKi4EMmH5XvmwRGyeCK9zzjfAGbSciYsg13 UJVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KZojK7bE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si15358192ejr.344.2020.11.18.10.57.38; Wed, 18 Nov 2020 10:58:03 -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=@chromium.org header.s=google header.b=KZojK7bE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726868AbgKRSxx (ORCPT + 99 others); Wed, 18 Nov 2020 13:53:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726827AbgKRSxw (ORCPT ); Wed, 18 Nov 2020 13:53:52 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5A1BC0613D4 for ; Wed, 18 Nov 2020 10:53:52 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id kk16so867949pjb.1 for ; Wed, 18 Nov 2020 10:53:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/EQtQALhCEqfL4DGAhnne0Mwd7FFhtVFNWFyL4AwZ5c=; b=KZojK7bEWDx5hLzKhd5MrNlmQvCB68Xnk6S2Q6YCJSkfRUARg97yNUwy03/QvCfMe+ mcVZJOV1aImmFjNLZVPIu2YiNhBRbIWf/3JNg2ScWbszzsK/ifIpFhiGhUdKBsLPU0WV Xb2Wdc2pde+TVtwNHnqBsVcPxhZdVFoqMwdrY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/EQtQALhCEqfL4DGAhnne0Mwd7FFhtVFNWFyL4AwZ5c=; b=E3GLYXL+S8RsVvAn2JVeA1MvPpJXCRXWkHQVnyPfUXdCwQjIb08bgociQSUL3ZO3Yu LaKfVcxqcLpLJzk1/j8FGy7vT/NkjomLcwgVDF0ySnfJeBEYaXfnfjc2C7wMn7NpmhPz RkZtL/R0v8xw6cLoKB19W5lly1TWVt0bowI+rVTU+msGaARdTq4SLxRiAGZTByEkHutQ wG0uZGGo0ls7WceTfvO1FrCrdw6bwcXFnGm4rqzHl5AVEMQCZkA8+IBcNSN7/aPdUtsO 613bUr4GeTTCbOY5AjftpJNJYM00oyoyu3jCR6CgZv5I8VWuIX5I7nz0fIyi9snCtvti cCYQ== X-Gm-Message-State: AOAM530JM/Kz7BETtHZLmUQIud4dKEvb6EEHY6J1jNzrxDOvchRagL5j ZBp5gvp0jLKtEzr1cn5F5lq2nw== X-Received: by 2002:a17:90b:3512:: with SMTP id ls18mr473430pjb.70.1605725632000; Wed, 18 Nov 2020 10:53:52 -0800 (PST) Received: from google.com ([2620:15c:202:201:a28c:fdff:fef0:49dd]) by smtp.gmail.com with ESMTPSA id t9sm3277973pjo.4.2020.11.18.10.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 10:53:51 -0800 (PST) Date: Wed, 18 Nov 2020 10:53:50 -0800 From: Prashant Malani To: Heikki Krogerus Cc: Benson Leung , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [RFC PATCH 2/3] usb: typec: Add product_type sysfs attribute file for partners and cables Message-ID: <20201118185350.GB3652649@google.com> References: <20201118150059.3419-1-heikki.krogerus@linux.intel.com> <20201118150059.3419-3-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118150059.3419-3-heikki.krogerus@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Heikki, On Wed, Nov 18, 2020 at 06:00:58PM +0300, Heikki Krogerus wrote: > USB Power Delivery Specification defines a set of product > types for partners and cables. The product type is defined > in the ID Header VDO, which is the first object in the > response to the Discover Identity command. > > This sysfs attribute file is only created for the partners > and cables if the product type is really known in the > driver. Some interfaces do not give access to the Discover > Identity response from the partner or cable, but they may > still supply the product type separately in some cases. > > When the product type of the partner or cable is detected, > uevent is also raised with PRODUCT_TYPE set to show the > actual product type (for example PRODUCT_TYPE=host). > > Signed-off-by: Heikki Krogerus I tried this out with the following peripherals: - Thunderbolt 3 active cable. - Thunderbolt 3 passive cable. - Dell WD19TB dock. - Type C DisplayPort enabled monitor (which advertises as AMA). For the above, the product_type seems to be getting parsed and displayed correctly, so FWIW: Tested-by: Prashant Malani > --- > Documentation/ABI/testing/sysfs-class-typec | 55 ++++++++ > drivers/usb/typec/class.c | 132 ++++++++++++++++++-- > 2 files changed, 180 insertions(+), 7 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec > index b7794e02ad205..4c09e327c62be 100644 > --- a/Documentation/ABI/testing/sysfs-class-typec > +++ b/Documentation/ABI/testing/sysfs-class-typec > @@ -139,6 +139,42 @@ Description: > Shows if the partner supports USB Power Delivery communication: > Valid values: yes, no > > +What: /sys/class/typec/-partner/product_type > +Date: December 2020 > +Contact: Heikki Krogerus > +Description: USB Power Delivery Specification defines a set of product types > + for the partner devices. This file will show the product type of > + the partner if it is known. Dual-role capable partners will have > + both UFP and DFP product types defined, but only one that > + matches the current role will be active at the time. If the > + product type of the partner is not visible to the device driver, > + this file will not exist. > + > + When the partner product type is detected, or changed with role > + swap, uvevent is also raised that contains PRODUCT_TYPE= + type> (for example PRODUCT_TYPE=hub). > + > + Valid values: > + > + UFP / device role > + ======================== ========================== > + undefined - > + hub PDUSB Hub > + peripheral PDUSB Peripheral > + psd Power Bank > + ama Alternate Mode Adapter > + vpd VCONN Powered USB Device > + ======================== ========================== > + > + DFP / host role > + ======================== ========================== > + undefined - > + hub PDUSB Hub > + host PDUSB Host > + power_brick Power Brick > + amc Alternate Mode Controller > + ======================== ========================== > + > What: /sys/class/typec/-partner>/identity/ > Date: April 2017 > Contact: Heikki Krogerus > @@ -202,6 +238,25 @@ Description: > - type-c > - captive > > +What: /sys/class/typec/-cable/product_type > +Date: December 2020 > +Contact: Heikki Krogerus > +Description: USB Power Delivery Specification defines a set of product types > + for the cables. This file will show the product type of the > + cable if it is known. If the product type of the cable is not > + visible to the device driver, this file will not exist. > + > + When the cable product type is detected, uvevent is also raised > + with PRODUCT_TYPE showing the product type of the cable. > + > + Valid values: > + > + ======================== ========================== > + undefined - > + active Active Cable > + passive Passive Cable > + ======================== ========================== There exists a /sys/class/typec/-cable/type attribute (connected to the "active" field in struct typec_cable [1]), which is supposed to be populated by the Type C port driver. Won't the newly introduced attribute duplicate the same information as "type"? [1] https://elixir.bootlin.com/linux/v5.10-rc4/source/include/linux/usb/typec.h#L170 Thanks, -Prashant