From patchwork Fri Jan 29 06:14:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 373951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BB91C433E6 for ; Fri, 29 Jan 2021 06:15:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D19164DFB for ; Fri, 29 Jan 2021 06:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232105AbhA2GPL (ORCPT ); Fri, 29 Jan 2021 01:15:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232085AbhA2GO6 (ORCPT ); Fri, 29 Jan 2021 01:14:58 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44E30C06174A for ; Thu, 28 Jan 2021 22:14:18 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id g3so4693025plp.2 for ; Thu, 28 Jan 2021 22:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w/wn3T3iqZt9tVHIDyqV8Hkntdbm1OettNslItOmP6Y=; b=nDx5OMKdWtXkpN/dc9Q5pzLqYss9vnOgoh8QnodPTN4+s7+SzdZf2sDamih5n3VmOV sH1bQ4ZMoEZZf9Y5LLdjF0ju6RZy6puOW6klo8tzT4Gdd3MjtmDQMZT2Svqz4cGKR0Ik ZKk5kSYNAc90P0LhG908KRXmFhP58tB1Kayv8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w/wn3T3iqZt9tVHIDyqV8Hkntdbm1OettNslItOmP6Y=; b=TwAkavn4/cBk/N/F2T7Anhne/nF4uMWQrxV209BmGsWChwY7dg4++smHzEQ5aocZTZ SjjN/HETMvznlVqI9CxGODj8F4UvOc3AnWbnfOxkd6B+ZsJFJ7t8OHQEfrWX8uprdeif UIiy3nSMf98IcIkM7xKwj4kVTI+bWHHIN+hvRz7CRmZU8c7PxGo+0NWCZTiJWxR19KF+ t7iddM3XOKTwMr3uNOtUerryTSBpzKYTp8Qfgau8+uoHJBA2jpUPUM5uCJYX80qp5Q4K XHo265zvqXYyJNb+RJim0B397mXUwi+MB1ljIXNPhd3lD9Y/+7opTiAYCg8REVizMIdc mOxA== X-Gm-Message-State: AOAM532tDYtEOlF54/C91hQbPfxND6aNBx3LISy26blPfIs6uDzSixgi t2uuIcd63Cqy/5GABZDlvNHvBg== X-Google-Smtp-Source: ABdhPJyr/UyrX/i7+3DY+c54vjuNEEirqThXM+GMKNAXpqILTa3y999RCdhvQurmsEVKEJYg9JiOqA== X-Received: by 2002:a17:90a:578a:: with SMTP id g10mr2998943pji.74.1611900857904; Thu, 28 Jan 2021 22:14:17 -0800 (PST) Received: from bleung.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:fc72]) by smtp.gmail.com with ESMTPSA id 17sm7551013pfv.13.2021.01.28.22.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 22:14:17 -0800 (PST) From: Benson Leung To: heikki.krogerus@linux.intel.com, enric.balletbo@collabora.com, pmalani@chromium.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: groeck@chromium.org, bleung@google.com, bleung@chromium.org Subject: [PATCH 1/6] usb: typec: Standardize PD Revision format with Type-C Revision Date: Thu, 28 Jan 2021 22:14:01 -0800 Message-Id: <20210129061406.2680146-2-bleung@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210129061406.2680146-1-bleung@chromium.org> References: <20210129061406.2680146-1-bleung@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The Type-C Revision was in a specific BCD format "0120H" for 1.2. USB PD revision numbers follow a similar pattern with "0300H" for 3.0. Standardizes the sysfs format for usb_power_delivery_revision to align with the BCD format used for usb_typec_revision. Example values: - "2.0": USB Power Delivery Release 2.0 - "3.0": USB Power Delivery Release 3.0 - "3.1": USB Power Delivery Release 3.1 Signed-off-by: Benson Leung Reviewed-by: Heikki Krogerus --- Documentation/ABI/testing/sysfs-class-typec | 7 ++++++- drivers/usb/typec/class.c | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec index 8eab41e79ce6..b61480535fdc 100644 --- a/Documentation/ABI/testing/sysfs-class-typec +++ b/Documentation/ABI/testing/sysfs-class-typec @@ -105,7 +105,12 @@ Date: April 2017 Contact: Heikki Krogerus Description: Revision number of the supported USB Power Delivery - specification, or 0 when USB Power Delivery is not supported. + specification, or 0.0 when USB Power Delivery is not supported. + + Example values: + - "2.0": USB Power Delivery Release 2.0 + - "3.0": USB Power Delivery Release 3.0 + - "3.1": USB Power Delivery Release 3.1 What: /sys/class/typec//usb_typec_revision Date: April 2017 diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 8f77669f9cf4..4f60ee7ba76a 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -1500,8 +1500,9 @@ static ssize_t usb_power_delivery_revision_show(struct device *dev, char *buf) { struct typec_port *p = to_typec_port(dev); + u16 rev = p->cap->pd_revision; - return sprintf(buf, "%d\n", (p->cap->pd_revision >> 8) & 0xff); + return sprintf(buf, "%d.%d\n", (rev >> 8) & 0xff, (rev >> 4) & 0xf); } static DEVICE_ATTR_RO(usb_power_delivery_revision); From patchwork Fri Jan 29 06:14:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 373643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18F1FC433DB for ; Fri, 29 Jan 2021 06:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D579264DFF for ; Fri, 29 Jan 2021 06:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232072AbhA2GPt (ORCPT ); Fri, 29 Jan 2021 01:15:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbhA2GPi (ORCPT ); Fri, 29 Jan 2021 01:15:38 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD01C0613ED for ; Thu, 28 Jan 2021 22:14:19 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id c132so5973167pga.3 for ; Thu, 28 Jan 2021 22:14:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VG+CFdFGOlLcoNTjFCZePZjqocxq9mnm/N79AG4wxhM=; b=cv9Ge/7s9evbDApQ5Vz73qw5LA3h/ChF4WumCkvr0xileVrKKfEaNtOXA765fvAQWT g4tn/VDTZoG9oJFMdTs6zv4s3Nz/OKgQLasg7u8Qd+n9fQ5sgQrSm1+KsYq0FksVGUWu t7kkT7nkrdouy2nHNViC1hgm7xrW36TGsIpIA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VG+CFdFGOlLcoNTjFCZePZjqocxq9mnm/N79AG4wxhM=; b=Htq72qett8MLerxqzd4LodyQjW1i6YGM9VDn6fDcdI4BGcrEFDCdmLgJmspz4teJjt 2nHKjO//Y2oPeQlU+wz+qSu2RoiYAVc6n8hsB2ZEgGpCAbLEGAnXnk8sjanbU5pF6PL+ yqL1Da9zpGFZ08hawWwL83C3G7wUQ5R7/Ip+BaSTWjRum//Dr6+uGtIAWs5zKxKuzIIb 1M45ThfDn9srK6Yk1mp1ieURGOpEeuBCPB2r4j+uf+WRLjZFzi3etCZwlewXy/dGoXPD mKB3IWxnuRHwlTkQDuKftg4S2xmIsAwiOnTMiH2M2wFEbGU1B/7UZUiMEGOxI+x5OAzo NQXQ== X-Gm-Message-State: AOAM532Hb7wIODwIUOYviP7hHowq0uUFytpiOVY7E7GrwcFtbmuy9AyI TWcgGHkeuET+zeA41AZis3pwMg== X-Google-Smtp-Source: ABdhPJykMK4csnuyWBmuvaUcg8Wgc3DUSA1bXJaLLOKmVXiSoxFYwgcEBVc2awHnwzSYfw7ZQFLsFQ== X-Received: by 2002:a63:c207:: with SMTP id b7mr3201495pgd.184.1611900859252; Thu, 28 Jan 2021 22:14:19 -0800 (PST) Received: from bleung.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:fc72]) by smtp.gmail.com with ESMTPSA id 17sm7551013pfv.13.2021.01.28.22.14.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 22:14:18 -0800 (PST) From: Benson Leung To: heikki.krogerus@linux.intel.com, enric.balletbo@collabora.com, pmalani@chromium.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: groeck@chromium.org, bleung@google.com, bleung@chromium.org Subject: [PATCH 2/6] usb: typec: Provide PD Specification Revision for cable and partner Date: Thu, 28 Jan 2021 22:14:02 -0800 Message-Id: <20210129061406.2680146-3-bleung@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210129061406.2680146-1-bleung@chromium.org> References: <20210129061406.2680146-1-bleung@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The USB Power Delivery specification Section 6.2.1.1.5 outlines revision backward compatibility requirements starting from Revision 3.0. The Port, the Cable Plug, and the Port Partner may support either revision 2 or revision 3 independently, and communication between ports, partners, and cables of different revisions are allowed under rules that the parties agree to communicate between each other using the lowest common operating revision. This may mean that Port-to-Partner operating revision comms may be different than Port-to-CablePlug operating revision comms. For example, it is possible for a R3.0 port to communicate with a R3.0 partner using R3.0 messages, while the R3.0 port (in the same session) must communicate with the R2.0 cable using R2.0 messages only. Introduce individual revision number properties for cable and port partner so that the port can track them independently. Signed-off-by: Benson Leung Reviewed-by: Heikki Krogerus --- Documentation/ABI/testing/sysfs-class-typec | 13 +++++++++ drivers/usb/typec/class.c | 30 ++++++++++++++++++--- include/linux/usb/typec.h | 10 +++++++ 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-typec b/Documentation/ABI/testing/sysfs-class-typec index b61480535fdc..40122d915ae1 100644 --- a/Documentation/ABI/testing/sysfs-class-typec +++ b/Documentation/ABI/testing/sysfs-class-typec @@ -112,6 +112,19 @@ Description: - "3.0": USB Power Delivery Release 3.0 - "3.1": USB Power Delivery Release 3.1 +What: /sys/class/typec/-{partner|cable}/usb_power_delivery_revision +Date: January 2021 +Contact: Benson Leung +Description: + Revision number of the supported USB Power Delivery + specification of the port partner or cable, or 0.0 when USB + Power Delivery is not supported. + + Example values: + - "2.0": USB Power Delivery Release 2.0 + - "3.0": USB Power Delivery Release 3.0 + - "3.1": USB Power Delivery Release 3.1 + What: /sys/class/typec//usb_typec_revision Date: April 2017 Contact: Heikki Krogerus diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 4f60ee7ba76a..b5241f4756c2 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -27,6 +27,7 @@ struct typec_cable { enum typec_plug_type type; struct usb_pd_identity *identity; unsigned int active:1; + u16 pd_revision; /* 0300H = "3.0" */ }; struct typec_partner { @@ -36,6 +37,7 @@ struct typec_partner { enum typec_accessory accessory; struct ida mode_ids; int num_altmodes; + u16 pd_revision; /* 0300H = "3.0" */ }; struct typec_port { @@ -264,6 +266,11 @@ type_show(struct device *dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR_RO(type); +static ssize_t usb_power_delivery_revision_show(struct device *dev, + struct device_attribute *attr, + char *buf); +static DEVICE_ATTR_RO(usb_power_delivery_revision); + /* ------------------------------------------------------------------------- */ /* Alternate Modes */ @@ -680,6 +687,7 @@ static struct attribute *typec_partner_attrs[] = { &dev_attr_supports_usb_power_delivery.attr, &dev_attr_number_of_alternate_modes.attr, &dev_attr_type.attr, + &dev_attr_usb_power_delivery_revision.attr, NULL }; @@ -815,6 +823,7 @@ struct typec_partner *typec_register_partner(struct typec_port *port, partner->usb_pd = desc->usb_pd; partner->accessory = desc->accessory; partner->num_altmodes = -1; + partner->pd_revision = desc->pd_revision; if (desc->identity) { /* @@ -1028,6 +1037,7 @@ static DEVICE_ATTR_RO(plug_type); static struct attribute *typec_cable_attrs[] = { &dev_attr_type.attr, &dev_attr_plug_type.attr, + &dev_attr_usb_power_delivery_revision.attr, NULL }; ATTRIBUTE_GROUPS(typec_cable); @@ -1130,6 +1140,7 @@ struct typec_cable *typec_register_cable(struct typec_port *port, cable->type = desc->type; cable->active = desc->active; + cable->pd_revision = desc->pd_revision; if (desc->identity) { /* @@ -1499,12 +1510,23 @@ static ssize_t usb_power_delivery_revision_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct typec_port *p = to_typec_port(dev); - u16 rev = p->cap->pd_revision; + u16 rev = 0; - return sprintf(buf, "%d.%d\n", (rev >> 8) & 0xff, (rev >> 4) & 0xf); + if (is_typec_partner(dev)) { + struct typec_partner *partner = to_typec_partner(dev); + + rev = partner->pd_revision; + } else if (is_typec_cable(dev)) { + struct typec_cable *cable = to_typec_cable(dev); + + rev = cable->pd_revision; + } else if (is_typec_port(dev)) { + struct typec_port *p = to_typec_port(dev); + + rev = p->cap->pd_revision; + } + return sysfs_emit(buf, "%d.%d\n", (rev >> 8) & 0xff, (rev >> 4) & 0xf); } -static DEVICE_ATTR_RO(usb_power_delivery_revision); static ssize_t orientation_show(struct device *dev, struct device_attribute *attr, diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 54475323f83b..42c6b7c07a99 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -164,6 +164,7 @@ struct typec_plug_desc { * @type: The plug type from USB PD Cable VDO * @active: Is the cable active or passive * @identity: Result of Discover Identity command + * @pd_revision: USB Power Delivery Specification revision if supported * * Represents USB Type-C Cable attached to USB Type-C port. */ @@ -171,6 +172,8 @@ struct typec_cable_desc { enum typec_plug_type type; unsigned int active:1; struct usb_pd_identity *identity; + u16 pd_revision; /* 0300H = "3.0" */ + }; /* @@ -178,15 +181,22 @@ struct typec_cable_desc { * @usb_pd: USB Power Delivery support * @accessory: Audio, Debug or none. * @identity: Discover Identity command data + * @pd_revision: USB Power Delivery Specification Revision if supported * * Details about a partner that is attached to USB Type-C port. If @identity * member exists when partner is registered, a directory named "identity" is * created to sysfs for the partner device. + * + * @pd_revision is based on the setting of the "Specification Revision" field + * in the message header on the initial "Source Capabilities" message received + * from the partner, or a "Request" message received from the partner, depending + * on whether our port is a Sink or a Source. */ struct typec_partner_desc { unsigned int usb_pd:1; enum typec_accessory accessory; struct usb_pd_identity *identity; + u16 pd_revision; /* 0300H = "3.0" */ }; /** From patchwork Fri Jan 29 06:14:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 373644 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0025AC433E6 for ; Fri, 29 Jan 2021 06:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B140564E00 for ; Fri, 29 Jan 2021 06:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232109AbhA2GPv (ORCPT ); Fri, 29 Jan 2021 01:15:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231942AbhA2GPi (ORCPT ); Fri, 29 Jan 2021 01:15:38 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24FFFC061788 for ; Thu, 28 Jan 2021 22:14:21 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id gx1so5795171pjb.1 for ; Thu, 28 Jan 2021 22:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BI9IdVQMVElpbGgcuBrXt08uYJZq0+pEMzt9hXMuZM0=; b=oTIxN96Pnswl2tahLxRkixF6JESSYgC+HYnLeLD1zsqufawE8A5Kr4wJ6lNzk+7mgf QVLIhUPQ0IWfBlseY0FlCjq7KlJjc0Lxe4k6MBtQNMt8B7JyLIfQc9MEzthLsyF+DfOk kwgWKxX4QbaqV0yiYtY23HHChP0Yiy6vzK0L0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BI9IdVQMVElpbGgcuBrXt08uYJZq0+pEMzt9hXMuZM0=; b=jVwlYtXrMZSEMk/IHZZZOaVgt8MMWPJAdo5j9oS0o5pJSHdUrU1CXlcW7KQ5bwmQ3U psXd+K6Fryjtbh/cN6suwMacJ+zE+950MKYNSRbwnGlsbaRomRzNxRZiiDz8ntsy1WfV /r7s/AftYQewwtrEmjj+jFC5bPd4t3VulSCSmg9X8ZIEIrhmV2mfRr3b/tDs6wYkQubE PvCCQSRlw8EB6jz2mTkhs0hb7lP4+dD3yL/75712WIKjoU6sipHBTlnjoQozb79SbJrP Sp5zbq4TC+AH161R4/i7z22tO8eQHFMhuhraHZGiNcQZBB9D8M/L0tTt0/PneG77JMcQ 4C0g== X-Gm-Message-State: AOAM533y299hUyIZugdgOt9UGPOr3HH9Gc1UMd77fq/CvkrMaWQX9UVN ssqgGLP10+1XpX1xkLJ8Woe+Nw== X-Google-Smtp-Source: ABdhPJwJiHpiyi13aNcOR2f6u6zQLioDumEXo8sinBNF0uzCVqXD/EGWhhQD+G6s9NXLzeNP9OvY5g== X-Received: by 2002:a17:90a:9a84:: with SMTP id e4mr3063664pjp.87.1611900860669; Thu, 28 Jan 2021 22:14:20 -0800 (PST) Received: from bleung.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:fc72]) by smtp.gmail.com with ESMTPSA id 17sm7551013pfv.13.2021.01.28.22.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 22:14:20 -0800 (PST) From: Benson Leung To: heikki.krogerus@linux.intel.com, enric.balletbo@collabora.com, pmalani@chromium.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: groeck@chromium.org, bleung@google.com, bleung@chromium.org Subject: [PATCH 3/6] usb: typec: Add typec_partner_set_pd_revision Date: Thu, 28 Jan 2021 22:14:03 -0800 Message-Id: <20210129061406.2680146-4-bleung@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210129061406.2680146-1-bleung@chromium.org> References: <20210129061406.2680146-1-bleung@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The partner's PD revision may be resolved later than the port partner registration since the port partner creation may take place once Type-C detects the port has changed state, but before PD communication is completed. Add a setter so that the partner's PD revision can be attached to it once it becomes available. If the revision is set to a valid version (not 0), the setter will also refresh the partner's usb_pd flag and notify on "supports_usb_power_delivery" sysfs property as well. Signed-off-by: Benson Leung Reviewed-by: Heikki Krogerus --- drivers/usb/typec/class.c | 30 ++++++++++++++++++++++++++++++ include/linux/usb/typec.h | 1 + 2 files changed, 31 insertions(+) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index b5241f4756c2..b6ceab3dc16b 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -748,6 +748,36 @@ int typec_partner_set_identity(struct typec_partner *partner) } EXPORT_SYMBOL_GPL(typec_partner_set_identity); +/** + * typec_partner_set_pd_revision - Set the PD revision supported by the partner + * @partner: The partner to be updated. + * @pd_revision: USB Power Delivery Specification Revision supported by partner + * + * This routine is used to report that the PD revision of the port partner has + * become available. + * + * Returns 0 on success or negative error number on failure. + */ +int typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_revision) +{ + int ret; + + if (partner->pd_revision == pd_revision) + return 0; + + partner->pd_revision = pd_revision; + sysfs_notify(&partner->dev.kobj, NULL, "usb_power_delivery_revision"); + if (pd_revision != 0 && !partner->usb_pd) { + partner->usb_pd = 1; + sysfs_notify(&partner->dev.kobj, NULL, + "supports_usb_power_delivery"); + } + kobject_uevent(&partner->dev.kobj, KOBJ_CHANGE); + + return 0; +} +EXPORT_SYMBOL_GPL(typec_partner_set_pd_revision); + /** * typec_partner_set_num_altmodes - Set the number of available partner altmodes * @partner: The partner to be updated. diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h index 42c6b7c07a99..4946eca742d5 100644 --- a/include/linux/usb/typec.h +++ b/include/linux/usb/typec.h @@ -126,6 +126,7 @@ struct typec_altmode_desc { enum typec_port_data roles; }; +int typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_revision); int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes); struct typec_altmode *typec_partner_register_altmode(struct typec_partner *partner, From patchwork Fri Jan 29 06:14:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 373642 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A697AC433DB for ; Fri, 29 Jan 2021 06:16:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A0A664DFB for ; Fri, 29 Jan 2021 06:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232126AbhA2GQN (ORCPT ); Fri, 29 Jan 2021 01:16:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbhA2GPi (ORCPT ); Fri, 29 Jan 2021 01:15:38 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6741BC06178A for ; Thu, 28 Jan 2021 22:14:22 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id cq1so5228807pjb.4 for ; Thu, 28 Jan 2021 22:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mV7nf+buXJQ9+XxF7K4sp0VELy5hFFaKIItPtbNn5WA=; b=VW9HbEAybqcA1AcQzeng934Z38FnPt59yz4mXRIKlMpe5SQDtsrOKXZ7wXiwjXQ5in dMoVzuudHfCWL+oeqJIGNf8rSqwowKHCbbg+nheiIx+FYSXtUeTBSenrjKQvb6KU0W7z zTEdksDK+dbWC3uLKhX9KyO6xRyoP0nQOqY+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mV7nf+buXJQ9+XxF7K4sp0VELy5hFFaKIItPtbNn5WA=; b=ElTJ53PHYKTv4d7z88P0HGH5uq0bBNI2ER9zqSbAysJv0j5A5p59zSZTnlNpdqrC0e weoMzvUuEEqyHvkSN7QckUD4Bhwaizs2zicuhOzT9yLfs8Iq6/2qJ7Va/qZbGCngnFQu 47mlRQ+W3htDgosC34xk8L13fDLNhaMd4kdsBCDeXlWf46bXWgRMsageT2f8Jnpxwy38 rjq6lp0e75Sqs1nGWAzTzaXlhQggK8vqnYaPtvN1+ysTXVLTVMZQxxnlq7casvFYLVVS Wt7mCit68cF4JedN7F7j3C0BFUWim3hlDDxLMGEm/y73ww0D0VhdnEefHouY/2U27Jo3 7wwg== X-Gm-Message-State: AOAM533wHKOyahccRYP38gtMl4IeHV/HxohrKSV/nlrEv2rtSYjL+4Td zVoEO1Hg1YHrqon4twdtwccaoQ== X-Google-Smtp-Source: ABdhPJwtT0ZRfXmWvhktB4knPBnVOUNlL3eryEdErZCiOeAPwExtYPJGu5aBc7eSz+b/QAuGP0mB5A== X-Received: by 2002:a17:902:fe08:b029:de:36a1:9f12 with SMTP id g8-20020a170902fe08b02900de36a19f12mr2816050plj.30.1611900862047; Thu, 28 Jan 2021 22:14:22 -0800 (PST) Received: from bleung.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:fc72]) by smtp.gmail.com with ESMTPSA id 17sm7551013pfv.13.2021.01.28.22.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 22:14:21 -0800 (PST) From: Benson Leung To: heikki.krogerus@linux.intel.com, enric.balletbo@collabora.com, pmalani@chromium.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: groeck@chromium.org, bleung@google.com, bleung@chromium.org Subject: [PATCH 4/6] platform/chrome: cros_ec_typec: Report SOP' PD revision from status Date: Thu, 28 Jan 2021 22:14:04 -0800 Message-Id: <20210129061406.2680146-5-bleung@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210129061406.2680146-1-bleung@chromium.org> References: <20210129061406.2680146-1-bleung@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org cros_typec_handle_sop_prime_disc now takes the PD revision provided by the EC_CMD_TYPEC_STATUS command response for the SOP'. Attach the properly formatted pd_revision to the cable desc before registering the cable. Signed-off-by: Benson Leung Acked-by: Heikki Krogerus Acked-by: Enric Balletbo i Serra Reviewed-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index e724a5eaef1c..30600e9454e1 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -748,7 +748,7 @@ static void cros_typec_parse_pd_identity(struct usb_pd_identity *id, id->vdo[i - 3] = disc->discovery_vdo[i]; } -static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int port_num) +static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int port_num, u16 pd_revision) { struct cros_typec_port *port = typec->ports[port_num]; struct ec_response_typec_discovery *disc = port->disc_data; @@ -794,6 +794,7 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p } c_desc.identity = &port->c_identity; + c_desc.pd_revision = pd_revision; port->cable = typec_register_cable(port->port, &c_desc); if (IS_ERR(port->cable)) { @@ -893,7 +894,11 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num if (resp.events & PD_STATUS_EVENT_SOP_PRIME_DISC_DONE && !typec->ports[port_num]->sop_prime_disc_done) { - ret = cros_typec_handle_sop_prime_disc(typec, port_num); + u16 sop_prime_revision; + + /* Convert BCD to the format preferred by the TypeC framework */ + sop_prime_revision = (le16_to_cpu(resp.sop_prime_revision) & 0xff00) >> 4; + ret = cros_typec_handle_sop_prime_disc(typec, port_num, sop_prime_revision); if (ret < 0) dev_err(typec->dev, "Couldn't parse SOP' Disc data, port: %d\n", port_num); else From patchwork Fri Jan 29 06:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 373950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F59EC433E9 for ; Fri, 29 Jan 2021 06:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05B3264DFB for ; Fri, 29 Jan 2021 06:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232078AbhA2GQA (ORCPT ); Fri, 29 Jan 2021 01:16:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232050AbhA2GPl (ORCPT ); Fri, 29 Jan 2021 01:15:41 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C75B1C061793 for ; Thu, 28 Jan 2021 22:14:23 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id jx18so5786481pjb.5 for ; Thu, 28 Jan 2021 22:14:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5a9vXvilUsJkEIHHvcNcA0AGVYZkJf6YL+90eMCO+bY=; b=T3Hpc4dc1N4vqSVRq5p3mq01HEp6AqFztlf6BwQas3cg7xfpyZccRlAOQ9XaqfUAGT ipsxJmNDkpIYMFLCLk3u4TnJ07YeUB35spN+f9FHqY+hva9oLebpXo8xoubfMR9ijxgE 3yC/KAkW/H2ilEoC5DxRWPpXwK8iHo5gJFsLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5a9vXvilUsJkEIHHvcNcA0AGVYZkJf6YL+90eMCO+bY=; b=X2pQQ8b5zEeu2YrccxFZKV6H5uTv1Pzyfbsge+7e9XdS8ReTrUNwQONWmwvPYRUP7y d8KMhtjFJfzyxE9Lyy/jaEa+8EVG/JfWx7jWwJgn8t3r755d9C43hkYyvkdA0m7yYuXC FpUADbP4mbzMsoUszwfqx3clvaAOj3r7yRvMmxiVi9snMp/GNvKVwJ5VS9Z5gqYgFh9l 2366Q6ir0a3xVCjWxH3dg2HrD8mx107wDNUeuj2y6VMQtYcT9zVktR4WYOYGeUurvWRq Axh+et/FhcF0H5IZ6AULGdb3ybOuRDZhOXziZFUmVqQAFVhj5c+ojDMfPdA8zw130Gcr y6Zw== X-Gm-Message-State: AOAM533rYW+YASreLiqvem3Tnp9AhPUq9G54mERgy9MPZSRSw2HIqNQk rEyxK7CeTh1HXd1m7Tk5QVwikQ== X-Google-Smtp-Source: ABdhPJyQXFkr9PgbtsvuQLM01IhCOynxZCe0HR/Gu+HKZZGhZbp9k/YRtFDa5srPakvAwxkTCuNU7Q== X-Received: by 2002:a17:90b:4b86:: with SMTP id lr6mr3002156pjb.107.1611900863438; Thu, 28 Jan 2021 22:14:23 -0800 (PST) Received: from bleung.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:fc72]) by smtp.gmail.com with ESMTPSA id 17sm7551013pfv.13.2021.01.28.22.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 22:14:22 -0800 (PST) From: Benson Leung To: heikki.krogerus@linux.intel.com, enric.balletbo@collabora.com, pmalani@chromium.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: groeck@chromium.org, bleung@google.com, bleung@chromium.org Subject: [PATCH 5/6] platform/chrome: cros_ec_typec: Set Partner PD revision from status Date: Thu, 28 Jan 2021 22:14:05 -0800 Message-Id: <20210129061406.2680146-6-bleung@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210129061406.2680146-1-bleung@chromium.org> References: <20210129061406.2680146-1-bleung@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Status provides sop_revision. Process it, and set it using the new setter in the typec class. Signed-off-by: Benson Leung Acked-by: Heikki Krogerus Acked-by: Enric Balletbo i Serra Reviewed-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 30600e9454e1..6bc6fafd54a4 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -824,7 +824,7 @@ static int cros_typec_handle_sop_prime_disc(struct cros_typec_data *typec, int p return ret; } -static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num) +static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_num, u16 pd_revision) { struct cros_typec_port *port = typec->ports[port_num]; struct ec_response_typec_discovery *sop_disc = port->disc_data; @@ -842,6 +842,12 @@ static int cros_typec_handle_sop_disc(struct cros_typec_data *typec, int port_nu goto disc_exit; } + ret = typec_partner_set_pd_revision(port->partner, pd_revision); + if (ret < 0) { + dev_err(typec->dev, "Failed to update partner PD revision, port: %d\n", port_num); + goto disc_exit; + } + memset(sop_disc, 0, EC_PROTO2_MAX_RESPONSE_SIZE); ret = cros_typec_ec_command(typec, 0, EC_CMD_TYPEC_DISCOVERY, &req, sizeof(req), sop_disc, EC_PROTO2_MAX_RESPONSE_SIZE); @@ -885,7 +891,11 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num /* Handle any events appropriately. */ if (resp.events & PD_STATUS_EVENT_SOP_DISC_DONE && !typec->ports[port_num]->sop_disc_done) { - ret = cros_typec_handle_sop_disc(typec, port_num); + u16 sop_revision; + + /* Convert BCD to the format preferred by the TypeC framework */ + sop_revision = (le16_to_cpu(resp.sop_revision) & 0xff00) >> 4; + ret = cros_typec_handle_sop_disc(typec, port_num, sop_revision); if (ret < 0) dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num); else From patchwork Fri Jan 29 06:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benson Leung X-Patchwork-Id: 373949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61714C433E0 for ; Fri, 29 Jan 2021 06:16:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2968364DFF for ; Fri, 29 Jan 2021 06:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232076AbhA2GP5 (ORCPT ); Fri, 29 Jan 2021 01:15:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232051AbhA2GPl (ORCPT ); Fri, 29 Jan 2021 01:15:41 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE87C061794 for ; Thu, 28 Jan 2021 22:14:25 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id cq1so5228867pjb.4 for ; Thu, 28 Jan 2021 22:14:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mi7AOcfFUGitVONrprMsQHj4LxmZ5B1spR/6XE6WI24=; b=XWHrA5wQcaxgT/7wCdE1JwDfaXQZ+6ETii1M/NKnsgNmm3Rw0RzKplmiJYI6VPRJqE 0xz1x9AjPLjEBJEKui8w9LNIIVBNokzbBHkM3jJvfhS+ZigqdvXJG2ZKKOWa7PAHVNGV CWqOsMMjCSNOeaHl/EtNw2zhND/tOS0cP5cps= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mi7AOcfFUGitVONrprMsQHj4LxmZ5B1spR/6XE6WI24=; b=ugK3L9NUYo+KtQlo6/bohiJuOZYMqtNZyxNMyc0tcUmYaIcx8l3eP3vxIj17fCJNhK vPRY3t3MIf/EKar2uWW5kYzIRGC0mThn3pwTK8JSEjvSImq+z7iiZrrW14HtzFvWalJd cV2JRP7iJH3BCLzY62JluWGaVjcdOE8cc9xITRW4KTJDhIwa/X8mL4Vl+2t97s65jvcL OYY1BMwZqK3LR93/caVq+vdvU2J3AyB28L0AcCP8GpY3MjWP+001EwHhgSzJ0vXPKppX FtUvmaAk+A2PbFjzUAwDMImRpq4rntarKLoX2ErvSf7Y6PH7m7tA5H8y3/DtD6+DUsx4 3hPQ== X-Gm-Message-State: AOAM5316D5R/x79W8aOBb60bzp5ING6ijCvGUZMfDp68rAqzjbpDZ+n4 taMlXQH/RHoUWOx4hD5wOvCQIg== X-Google-Smtp-Source: ABdhPJwyEQVWnLU1mfrtjCHnnHYhyoYWWlRB3ViU90872VJ/R7QtJKmcFPBN54F36ErRPpUa6buMSg== X-Received: by 2002:a17:90b:246:: with SMTP id fz6mr3087603pjb.131.1611900864828; Thu, 28 Jan 2021 22:14:24 -0800 (PST) Received: from bleung.mtv.corp.google.com ([2620:15c:202:201:f693:9fff:fef4:fc72]) by smtp.gmail.com with ESMTPSA id 17sm7551013pfv.13.2021.01.28.22.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 22:14:24 -0800 (PST) From: Benson Leung To: heikki.krogerus@linux.intel.com, enric.balletbo@collabora.com, pmalani@chromium.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: groeck@chromium.org, bleung@google.com, bleung@chromium.org Subject: [PATCH 6/6] platform/chrome: cros_ec_typec: Set opmode to PD on SOP connected Date: Thu, 28 Jan 2021 22:14:06 -0800 Message-Id: <20210129061406.2680146-7-bleung@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210129061406.2680146-1-bleung@chromium.org> References: <20210129061406.2680146-1-bleung@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When SOP Discovery is done, set the opmode to PD if status indicates SOP is connected. SOP connected indicates a PD contract is in place, and is a solid indication we have transitioned to PD power negotiation, either as source or sink. Signed-off-by: Benson Leung Acked-by: Heikki Krogerus Acked-by: Enric Balletbo i Serra Reviewed-by: Prashant Malani --- drivers/platform/chrome/cros_ec_typec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 6bc6fafd54a4..a7778258d0a0 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -900,6 +900,9 @@ static void cros_typec_handle_status(struct cros_typec_data *typec, int port_num dev_err(typec->dev, "Couldn't parse SOP Disc data, port: %d\n", port_num); else typec->ports[port_num]->sop_disc_done = true; + + if (resp.sop_connected) + typec_set_pwr_opmode(typec->ports[port_num]->port, TYPEC_PWR_MODE_PD); } if (resp.events & PD_STATUS_EVENT_SOP_PRIME_DISC_DONE &&