Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3928731pxu; Tue, 20 Oct 2020 04:23:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFlU4Syi1tRgZmYiQy9TJiIhQslM9XC3Jc0fbBtV9FXm/ST9MQ5UHuhXG8g4KQFj2192/+ X-Received: by 2002:a17:906:c0c8:: with SMTP id bn8mr2675036ejb.256.1603193035697; Tue, 20 Oct 2020 04:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603193035; cv=none; d=google.com; s=arc-20160816; b=fevOZSDonOdwpygbSgooRK/gzIuv3U+8t3dcXi/yiaMhKFeMJZimrhwbtqUBZeROnn kPJkbphXVfoNdOYeTN9KZR34qPIUHIa+dEbzLU65kfLl+AFpozXItobF7akJqUdpPvQj 3XZhjh0oH4WdlINCMxR/An306DlJL0Ui9eS3BJttN2FovFWmwVWH4bYV+rgW27zCZqV0 3jDPxBIP2LTmO1rpCk7Yj3TbBsB1egZ+xO9sfZJbImNmHThuikzLHTOeXXW6t+JanYIM JjMCoreUa7DNhYvHQxco1dxJ+uiuCR59NTTudUv5mnI3qpLtT/HJPHgc+fgyD/4+zE4j Njeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=68+qkqJJ0yGLVD99S4hdTLHhp4Q61Io/XotXvcoBiV8=; b=Ocbpt4l2hpkinSwwRtlVuUa7abUrKDYEfvH2HpdyIR4kB52uSM0HTAExW44t35A9sw e6aulM8mca0+ATjJZhdLSvweD8cvBoD0Uywx7PAQ6y8pZvHAqKkkDWzVhPMNBpk2HH/P B4G19/8m5jRdfRRwi+iG5PZOnymZ2mYN0l3BDpUGgYgdTMpagA5+A4DqqJJnKpDkZG4u DPRymf+ejV5EdSsdkgBOhFkgSSuZDLzyUS6LGiTACHrJhaC94ssdmGpLnuzKmLnraj+E Gc0fwzRYh2C4sRmDT90J4NHKbofGtZZT/l5UWr6RmHaEaMdoUPJESq7LfdhKN0sav1tq TBpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ZR2wc6ds; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w23si1075599ejn.69.2020.10.20.04.23.33; Tue, 20 Oct 2020 04:23:55 -0700 (PDT) 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=@google.com header.s=20161025 header.b=ZR2wc6ds; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391792AbgJTJgn (ORCPT + 99 others); Tue, 20 Oct 2020 05:36:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405631AbgJTJgl (ORCPT ); Tue, 20 Oct 2020 05:36:41 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F979C061755 for ; Tue, 20 Oct 2020 02:36:41 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id a12so1460882ybc.20 for ; Tue, 20 Oct 2020 02:36:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=68+qkqJJ0yGLVD99S4hdTLHhp4Q61Io/XotXvcoBiV8=; b=ZR2wc6dslObVvINB9BUikIlKrnpZm/ejNhWBSswVwuHXvxAX9xWLlasnBYoDLa2QFX S3aAcemb9GkFUrue0XxER8DBdvl91wF3vcDl7FtI8k+F4cNA+/8PcCwYjSz/Klcs37SW zI7QywfZicOrHzgPcypyayEfKcsIE3m7k0jgGsDoGEh386tmay9J3AwoAPUcMit7307F 1kvgZAJJ33mie4RXZSuuw4BXx+AdTYXnoEWClQ+HzXuTIti4Y5YXApZgujTAoa2c+1ve aGmsQoyeXW0qPmqWKsLQ3JdYooQko3Lu8UDl+FINeY1tWZGngo+nglwnFAv5W/AEPLLL hWjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=68+qkqJJ0yGLVD99S4hdTLHhp4Q61Io/XotXvcoBiV8=; b=OhcnZIt9PEo866U9fDL4+Hkit5jx5He1qaZqvRc9YWx++RMHomN6c0xm4qvRl8WRh9 J4U0AWjOFyhypDmTUZd2GB25PqjtVIBDHeYcRdoryQ80qVy5FBlZ+m1zMJ9T166YZC3J uFKZLuMQBW30vWHw1VohDdkWBifVmwZUDravt6bc+Uy/gyWzX5Q2ST3r2KpOAuKenb7M z9sEd8Oq6/NEZEYRak37rbVUa/zpSM6YtCxZ8LmEbpiAPQBrGZH8u5OKxmYLShdvNpDr pVeUWU7Z30B9cjXIbVqgLTvATPzUfIizssYkXI1EHlpkz3m2GspYAGEoek8EyhZDAhkb eubw== X-Gm-Message-State: AOAM533je/V6gnB7ebEafN2lfiosIbyEtIvFoC+CmHIs9I+D+SRnusSI aa/lKa8UmRMUBnUnAYRAGeO7sV4LFVQ= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:1:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a25:84cd:: with SMTP id x13mr2587479ybm.430.1603186600445; Tue, 20 Oct 2020 02:36:40 -0700 (PDT) Date: Tue, 20 Oct 2020 02:36:21 -0700 In-Reply-To: <20201020093627.256885-1-badhri@google.com> Message-Id: <20201020093627.256885-5-badhri@google.com> Mime-Version: 1.0 References: <20201020093627.256885-1-badhri@google.com> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog Subject: [PATCH v11 04/10] usb: typec: tcpm: Refactor logic for new-source-frs-typec-current From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Rob Herring , Lee Jones , Mark Brown , Maxime Ripard , Alexandre Belloni , Thierry Reding , Prashant Malani , Badhri Jagan Sridharan Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org New source's current capability is now defined through new-source-frs-typec-current. Refactor tcpm code to parse new-source-frs-typec-current and infer local port's new source current capability during frs. Signed-off-by: Badhri Jagan Sridharan --- v9 is the first version of this patch in this series to rebase TCPM code to read new source frs current from new-source-frs-typec-current. Changes since v10: - Moving back to u32 for new-source-frs-typec-current. --- drivers/usb/typec/tcpm/tcpm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 55535c4f66bf..561480b67bce 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -363,8 +363,8 @@ struct tcpm_port { /* port belongs to a self powered device */ bool self_powered; - /* FRS */ - enum frs_typec_current frs_current; + /* Sink FRS */ + enum frs_typec_current new_source_frs_current; /* Sink caps have been queried */ bool sink_cap_done; @@ -1713,7 +1713,7 @@ static void tcpm_pd_data_request(struct tcpm_port *port, unsigned int cnt = pd_header_cnt_le(msg->header); unsigned int rev = pd_header_rev_le(msg->header); unsigned int i; - enum frs_typec_current frs_current; + enum frs_typec_current partner_frs_current; bool frs_enable; int ret; @@ -1786,12 +1786,13 @@ static void tcpm_pd_data_request(struct tcpm_port *port, for (i = 0; i < cnt; i++) port->sink_caps[i] = le32_to_cpu(msg->payload[i]); - frs_current = (port->sink_caps[0] & PDO_FIXED_FRS_CURR_MASK) >> + partner_frs_current = (port->sink_caps[0] & PDO_FIXED_FRS_CURR_MASK) >> PDO_FIXED_FRS_CURR_SHIFT; - frs_enable = frs_current && (frs_current <= port->frs_current); + frs_enable = partner_frs_current && (partner_frs_current <= + port->new_source_frs_current); tcpm_log(port, "Port partner FRS capable partner_frs_current:%u port_frs_current:%u enable:%c", - frs_current, port->frs_current, frs_enable ? 'y' : 'n'); + partner_frs_current, port->new_source_frs_current, frs_enable ? 'y' : 'n'); if (frs_enable) { ret = port->tcpc->enable_frs(port->tcpc, true); tcpm_log(port, "Enable FRS %s, ret:%d\n", ret ? "fail" : "success", ret); @@ -4808,9 +4809,10 @@ static int tcpm_fw_get_caps(struct tcpm_port *port, /* FRS can only be supported byb DRP ports */ if (port->port_type == TYPEC_PORT_DRP) { - ret = fwnode_property_read_u32(fwnode, "frs-typec-current", &frs_current); + ret = fwnode_property_read_u32(fwnode, "new-source-frs-typec-current", + &frs_current); if (ret >= 0 && frs_current <= FRS_5V_3A) - port->frs_current = frs_current; + port->new_source_frs_current = frs_current; } return 0; -- 2.29.0.rc1.297.gfa9743e501-goog