Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7272200ybp; Wed, 16 Oct 2019 06:26:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzG3NfK+cDrp7vVGWMP7BKscnuQ+ukKe9tYN+5TURm6enP11uOXs3RRw1bhpz5t0/cMjPUP X-Received: by 2002:a17:906:f54:: with SMTP id h20mr40589876ejj.55.1571232367981; Wed, 16 Oct 2019 06:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571232367; cv=none; d=google.com; s=arc-20160816; b=L7HUW8Ah3oJoWZZbKaFi0dlUA2vFbX2qMsK8DrkYtrtfgTLp604oR08t8FwqyFx22n vv+kkKmuZyyVI0Wlvx50OdE5ihojoixj/1/FIqhirbSw1XtcsSTs+WS2keIyfl1OaPQ+ bJ4QvUm2n1aG6czDc8RraV5O4hRs8CJOz5hb/EEMyeeJk07+wL4qCLMbpW/ioP/KlTS2 U0j7yjZY21Rg6K+3lRcxsbfhkTrKbKg6xGzDilKkAoI5ES45Exd6fCWZo3cv82Utg0hw QGrNGKzSu8sn37GIR3eb7Ti+Wfcb1Xh5YpQc4Kpruk/oMwDHoBdzMvkWKydcGzugz/el fHjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=TZutJZLGF0s525Qo74hWUBEFtHjd5fY3wVdzlXrrh2g=; b=jI7bn7U86wAs3i1/noezpVUg+TNZ/o3NR2s9IFfiEI6Z3PjFDqZaUUA5Ar7RIpgNww CDRNL9TcjMs/XpJQBFmv2WDbv5zz8P9uNw+1m8bGyAJr7gQaoetpz8CBKEyuoYmFx066 yblwsfMscldKJJJTrC1vR2wdxPye8UmvxlW3yNFhfal/CxLgflpYyFcpeznm3lkhtBjq Ea381/NGXjq04W7AOGwznrw3EPFSnjfBmbv67enB2ZdJBwXR/QMPVeJYCHzw2vxuf/e5 AuJq6t2OzMzFwtJnQfaR0IBBp+KtLDEsGZlDG29Tn07382LP/ZE1jZ285vF6PRVKcI8v XNMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZhDjZILu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si16281936eds.389.2019.10.16.06.25.44; Wed, 16 Oct 2019 06:26:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZhDjZILu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391849AbfJPJAI (ORCPT + 99 others); Wed, 16 Oct 2019 05:00:08 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:43847 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388817AbfJPJAI (ORCPT ); Wed, 16 Oct 2019 05:00:08 -0400 Received: by mail-il1-f194.google.com with SMTP id t5so1808175ilh.10 for ; Wed, 16 Oct 2019 02:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=TZutJZLGF0s525Qo74hWUBEFtHjd5fY3wVdzlXrrh2g=; b=ZhDjZILuy3YhF2gSkbfiMnpR25Ut8GlVy3dzCgggDUq1Rl2yWFe7s6IUT85L+YoCtX zNav7Nkq4uWki/D5pvlMY3/clN8kIEcVEPdQNYkEunUcUKGes46sxszFRcTUfeRp27lh eTaeH407eXkavgtu8N5lihIVyrMoTHh22lV99W0RjYBC4zJgIbKELBPX5Z/eRtoiigye +1PzXL3KQ700Ccbo/PfV2hFAB5rj0TlZUMQw6DOtJgprAqnFFFmzG6mcdSv7RXaHKGg+ lestp3pIU39bMzGAZM0yi9eU3GjA6uxwemlic7PkKXBD5WiV5dmadmIqCf12Z/Od4ov8 G1OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=TZutJZLGF0s525Qo74hWUBEFtHjd5fY3wVdzlXrrh2g=; b=sXutyXrrreDbtnBnaltAWTSuu4qgctl5sUJoqhVV0rWFralGQsuttgTtcCYMMcJMBE 7C55jkus2UtALNL0ADRfENtQJeG99BByleNENRhhxejQKYxheL7GsW7W3lkcJD0Q74bd WK4YeJd+9Q8YLmGoAVK8jHtO5TRk6pqOCLB2AGQVuGjIohssfViNjfjmxFrGWeiC0B5o OK8lP9R7VJGrX6J7nI/rle7HvJn/aCQiJ8f8FhP6tCFNTGcbXrHSvpvU+xmUL6dYcxp2 gqoZERPnKLkA4FwWYYSGN0f0nr9cdaa9f8uFnkbesp3K900lyJYeqzMuk7eB1gMHIhLf Ztfg== X-Gm-Message-State: APjAAAW3SlAoQL8mSsNlqWCnHLOGyG8T1g/Kh5iHi+vhhHrehs5xjKXE zYbljvxC3Y7fB4UH2pah2CfItdG4ITExbj6uUfWEMQ== X-Received: by 2002:a92:c10c:: with SMTP id p12mr10520194ile.32.1571216406838; Wed, 16 Oct 2019 02:00:06 -0700 (PDT) MIME-Version: 1.0 References: <20191016034314.231363-1-pumahsu@google.com> <577ac2f6-f073-1bd0-0adb-33fa8243773c@infradead.org> In-Reply-To: <577ac2f6-f073-1bd0-0adb-33fa8243773c@infradead.org> From: Puma Hsu Date: Wed, 16 Oct 2019 16:59:30 +0800 Message-ID: Subject: Re: [PATCH] usb: typec: Add sysfs node to show cc orientation To: Randy Dunlap Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, Badhri Jagan Sridharan , Kyle Tso , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Albert Wang , Puma Hsu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Randy, According to include/linux/usb/typec.h, The value of /sys/class/typec//cc_orientation is usually =E2=80=9C1=E2=80=9D, =E2= =80=9C2=E2=80=9D, or =E2=80=9C0=E2=80=9D corresponding to =E2=80=9Cconfigured in NORMAL side=E2=80=9D, =E2=80=9Cconf= igured in REVERSE side=E2=80=9D, or =E2=80=9Cnothing configured=E2=80=9D. Refer to the usage in tcpm.c, it claims CC1 is NORMAL and CC2 is REVERSE. I will update this into Documentation description. enum typec_orientation { TYPEC_ORIENTATION_NONE, TYPEC_ORIENTATION_NORMAL, TYPEC_ORIENTATION_REVERSE, }; Thanks in advance. =E2=80=A2 Puma Hsu =E8=A8=B1=E8=AA=8C=E5=AE=8F =E2=80=A2 Software Engineer, Pixel Phone =E2=80=A2 Tel: +886 2 8729 0870 =E2=80=A2 pumahsu@google.com Thanks in advance. =E2=80=A2 Puma Hsu =E8=A8=B1=E8=AA=8C=E5=AE=8F =E2=80=A2 Software Engineer, Pixel Phone =E2=80=A2 Tel: +886 2 8729 0870 =E2=80=A2 pumahsu@google.com On Wed, Oct 16, 2019 at 11:47 AM Randy Dunlap wrote= : > > On 10/15/19 8:43 PM, pumahsu wrote: > > Export the Type-C cc orientation so that user space can > > get this information. > > > > Signed-off-by: pumahsu > > Hi, > what the * is cc orientation? > > > --- > > Documentation/ABI/testing/sysfs-class-typec | 7 +++++++ > > drivers/usb/typec/class.c | 11 +++++++++++ > > 2 files changed, 18 insertions(+) > > > > diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentatio= n/ABI/testing/sysfs-class-typec > > index d7647b258c3c..419f952c991d 100644 > > --- a/Documentation/ABI/testing/sysfs-class-typec > > +++ b/Documentation/ABI/testing/sysfs-class-typec > > @@ -108,6 +108,13 @@ Contact: Heikki Krogerus > > Description: > > Revision number of the supported USB Type-C specification= . > > > > +What: /sys/class/typec//cc_orientation > > +Date: September 2019 > > +Contact: Puma Hsu > > +Description: > > + Indicates which cc orientation is active now, or 0 when > > + nothing is connected. > > + > > > > USB Type-C partner devices (eg. /sys/class/typec/port0-partner/) > > > > diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c > > index 7d8805d9bf37..00edae63da8e 100644 > > --- a/drivers/usb/typec/class.c > > +++ b/drivers/usb/typec/class.c > > @@ -1238,6 +1238,16 @@ static ssize_t usb_power_delivery_revision_show(= struct device *dev, > > } > > static DEVICE_ATTR_RO(usb_power_delivery_revision); > > > > +static ssize_t cc_orientation_show(struct device *dev, > > + struct device_attribute *= attr, > > + char *buf) > > +{ > > + struct typec_port *p =3D to_typec_port(dev); > > + > > + return sprintf(buf, "%d\n", typec_get_orientation(p)); > > +} > > +static DEVICE_ATTR_RO(cc_orientation); > > + > > static struct attribute *typec_attrs[] =3D { > > &dev_attr_data_role.attr, > > &dev_attr_power_operation_mode.attr, > > @@ -1248,6 +1258,7 @@ static struct attribute *typec_attrs[] =3D { > > &dev_attr_usb_typec_revision.attr, > > &dev_attr_vconn_source.attr, > > &dev_attr_port_type.attr, > > + &dev_attr_cc_orientation.attr, > > NULL, > > }; > > ATTRIBUTE_GROUPS(typec); > > > > > -- > ~Randy