From patchwork Thu Oct 29 06:31:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 314793 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL 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 2B21FC55178 for ; Thu, 29 Oct 2020 07:57:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1ED520EDD for ; Thu, 29 Oct 2020 07:57:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ns2vttpr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730532AbgJ2H5Q (ORCPT ); Thu, 29 Oct 2020 03:57:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727030AbgJ2HYl (ORCPT ); Thu, 29 Oct 2020 03:24:41 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D5C8C05BD1F for ; Wed, 28 Oct 2020 23:31:50 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id j13so1354583pgp.11 for ; Wed, 28 Oct 2020 23:31:50 -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=4wHFl4meLUDTdOosTidWDBrzaH5xNKR+XS3gXiGY0NA=; b=ns2vttprtXN9/utBZvDjOQXSukPuYNiUYHkRWXxOGG8FOeY0jwlTU0vyDxCut2B4ow hjB6CFc6jLogU+TrmqYU42xuWHCDKRyJufy66DpkKdDu/FCe2MD9ymdi4HjFdcR3d0eD dcMV4aWb24qZatXGqFj8/j1HqjoYZDrJAL1W3/QokzNf+tzzj6shLZe3K9M+DYHBoMxa jsIA0vFS8S8LnOAPw9pLU1MwBeu6sMOtwgh7mHeRdKzkMux73DVpDaPrrTch2UAsdO/6 V0MEyXurcRvuXkkjvBW1UYeIK+rFYHXp05rMx8eREW/UT1ZsyYzi3GZi7h4fp0oYjgm7 Ba0w== 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=4wHFl4meLUDTdOosTidWDBrzaH5xNKR+XS3gXiGY0NA=; b=aoZN0P5kwa664/GaBTfDT4K45FrwFzCWkYmmD+G7/F9N52XAyvInmfXkdb/PijnPjd pVYhatKbnRgqBJy58dWr+YjCxkAMKQSj56cKx3Z4ol3JlhDpOxgUyMxqF7vJc+ZGAogk f6OF7fmd8ThTBTa8mo8+8B4aDj38Kuexz3mjSW1nzCTpUfaL9X2Z+xhipEqp8PweqquS nNEpG+ru30VAJXH9i7MThKl30xz92VE6Bkydz/VqnUOADknwPJ2zYwSJLVo3c+CunwQc JjkDTdwgeWsRvBO1KN/UIaZHZMih+P2NTVYQ1KPPfgdzD0paMkVXsEDAZkOsOn/v7OPA 0n9w== X-Gm-Message-State: AOAM533fZV+R6olWuKW54t1Z7hUZ1p4iBDWc1KzXcIz6KpPmTyqEABpa VcuvFyezfCqg3loIxVrHOp93neclPF4= X-Google-Smtp-Source: ABdhPJyqr6P1eHBIcxxZMWOIXb1uzSEGuPkBvGUKtmTm+MsMdmlVOfimEuOlasKxR3dlB5vET6KFbh4T6AA= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a62:6496:0:b029:155:b152:f0cf with SMTP id y144-20020a6264960000b0290155b152f0cfmr3032733pfb.75.1603953110146; Wed, 28 Oct 2020 23:31:50 -0700 (PDT) Date: Wed, 28 Oct 2020 23:31:31 -0700 In-Reply-To: <20201029063138.1429760-1-badhri@google.com> Message-Id: <20201029063138.1429760-4-badhri@google.com> Mime-Version: 1.0 References: <20201029063138.1429760-1-badhri@google.com> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v12 03/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 , Dan Carpenter Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org New source's current capability is now defined as string based device tree property 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. Changes since v11: - None --- 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;