Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1746855pxb; Wed, 9 Feb 2022 03:44:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXPTYeyrZOCa/HnhwGWzBH+sOG+jvH3AhiWK9f7hE9NRpqCLyapxgDra2zOa0c7xdke4jm X-Received: by 2002:a17:902:d64a:: with SMTP id y10mr1760780plh.66.1644407053035; Wed, 09 Feb 2022 03:44:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644407053; cv=none; d=google.com; s=arc-20160816; b=ImhjEjOvAlMGQFZIS4EXeu4uUFNJ9SOdZXy0YU0RbJENkwcPx3P1q9DF/hxDpnK5Yy vZgOfLNnzpqSqdXPwEaM2gDnwFJjDo/1SsFwjVZp7O0FKWgYowMuZwJdbj25EqirVaAg yF1M7JyViX2oKtbGIV/CLLT7Yt/jpI05BCvbszuV02jLBAZnfsNzn3lPlvGh3q75V5z8 BfP99OpZnS+LBXXgqDY2yoGeUzHJh4YK06P8g4bNUb3XWUFRA0CEyrJgV3JGGx7FGY5b ZafVIHqJ1eCgPKdAyj/dYQq5YptQ+tWK2rp1uDQt2SHql70PuMBErR+BOtEJV0gzd01u pgtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:dkim-signature; bh=v+HG5AG509udiPdf4BbsPVUGkODFt7xt8GFthycqDiw=; b=d1JD7tkE/zZw/XxgQjJ3/TjHmf37LNosc34wvC/wzuO/s/swyTn4JKd+TcNkpeGvHG f8RDPN0syly4RFHKw1R+6lY7OSDXbSisJKvQJ82cxP5Axu12xPRJFiIgHC82BJUOSua7 ydpfmALzPezo94YpgqKaRwHOjxirN/mibGBGfIrqXHf2h2wVUrC6TV9xPKdUjJh1ddbo mjJVyJfq2X0k11ImJnBtAZlT1P1ydj0e8yQHJmn4S/HeHmBz4Lwqo23bcuUAI+/nWdj9 QOYJzhVnIr5bxgN40m991IfwPpc/iwQhWMqade4Y5HC8Kl9hHYU8SrwK31ShHwFmZZJT wMpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n9OrIeg0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g5si15315515pfu.50.2022.02.09.03.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 03:44:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=n9OrIeg0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 237B9E03E785; Wed, 9 Feb 2022 01:57:28 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380139AbiBHP0N (ORCPT + 99 others); Tue, 8 Feb 2022 10:26:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380168AbiBHP0C (ORCPT ); Tue, 8 Feb 2022 10:26:02 -0500 Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 948EDC0612B9; Tue, 8 Feb 2022 07:25:59 -0800 (PST) Received: by mail-oo1-xc2c.google.com with SMTP id f11-20020a4abb0b000000b002e9abf6bcbcso17936516oop.0; Tue, 08 Feb 2022 07:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=v+HG5AG509udiPdf4BbsPVUGkODFt7xt8GFthycqDiw=; b=n9OrIeg0JbTsKqYhfSoL7aOmHBxhHJOBZT3Nf+McGU4HY/ifvP7QLdcLGmQJwmjcMq etKBJK8lBatTtV6Ahy+4SC5KVAlljP26qriG5qcO4ZqGC9mZz78KBsD8nbjnCMNssWAi llLr4bsundwoZvMa2IWwUG28hF3jUWLPqfnn37VMcvq5Oosi+8ElyKHI7Y3Q892qAnDX eCRUYX7DH3RM9XBHWJCfw8xy7NIkIp12yLytR0jW6vy2Xi13KJrVKmPIVStlN9g1yfDy +zhRxEtvuIEsVSJ9po64vWsTts/bmUV8NDdF93SrlSGS9AfiV65Kaca5pUz9XPGsBTlS f9Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=v+HG5AG509udiPdf4BbsPVUGkODFt7xt8GFthycqDiw=; b=hyzYokMoGIMJfLe67pJh7qcQbWt6FLJr/Lz0utovcD2amVrDaSqIUaVRLccEBiMxej AxZe/bYMI6RHFnG9lrwVJOhdbzVlTMs7+O2KmKDrWkWNv0ZHu0HKZ/gn5rPs1rDgH3EF J7CgkGdsqQScb3/AAW3vxA2spVDj7+P6BPUuSTeIa2picoCQUdf3H46uK/mRQ70vosUz 2b8avIxfLCnGZHkoU6v8yZir43oeGEQ8OmWDJtb/PkidCeZ0IvwqkCtsVkQ9QnGnjYHJ YiWRgdhvCun/m2zk2ALpxAQu19QEpBj9x7ArGQrmgdzu5X+Ug24hkZ1k2BuT6bOptTO9 j5Wg== X-Gm-Message-State: AOAM533E2GC3zFRRIcUWAVVDdSyLU4T+BauFd5dn+LmyI8bEyZDuCkGj Ko17EVyYiCzpvDc3YQXU3yISOTR80IzzMg== X-Received: by 2002:a05:6870:3655:: with SMTP id v21mr523749oak.302.1644333958441; Tue, 08 Feb 2022 07:25:58 -0800 (PST) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 1sm4725791oab.16.2022.02.08.07.25.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Feb 2022 07:25:57 -0800 (PST) Sender: Guenter Roeck Message-ID: <106b27d7-6845-ed3c-411e-9ef5aee7f224@roeck-us.net> Date: Tue, 8 Feb 2022 07:25:56 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2 1/2] usb: typec: tcpm: add interface for passing supported_pd_rev from tcpc_dev Content-Language: en-US To: Potin Lai , Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Patrick Williams References: <20220208082026.4855-1-potin.lai@quantatw.com> <20220208112226.9108-1-potin.lai@quantatw.com> <20220208112226.9108-2-potin.lai@quantatw.com> From: Guenter Roeck In-Reply-To: <20220208112226.9108-2-potin.lai@quantatw.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/8/22 03:22, Potin Lai wrote: > Current TCPM allways assume using PD_MAX_REV for negotiation, > but for some USB controller only support PD 2.0, adding an interface > for passing supported_pd_rev from tcpc_dev. > The PD revision supported by the usb controller is a constant. I don't see why this would need a callback function. Other capabilitied are passed to tcpm using the fwnode pointer. I don't see why this capability would have to be handled differently. Guenter > Signed-off-by: Potin Lai > --- > drivers/usb/typec/tcpm/tcpm.c | 14 ++++++++++++-- > include/linux/usb/tcpm.h | 4 ++++ > 2 files changed, 16 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c > index 59d4fa2443f2..22e7d226826e 100644 > --- a/drivers/usb/typec/tcpm/tcpm.c > +++ b/drivers/usb/typec/tcpm/tcpm.c > @@ -571,6 +571,16 @@ static bool tcpm_port_is_disconnected(struct tcpm_port *port) > port->cc2 == TYPEC_CC_OPEN))); > } > > +static u32 tcpm_pd_supported_rev(struct tcpm_port *port) > +{ > + u32 rev = PD_MAX_REV; > + > + if (port->tcpc->supported_pd_rev) > + rev = port->tcpc->supported_pd_rev(port->tcpc); > + > + return min(rev, PD_MAX_REV); > +} > + > /* > * Logging > */ > @@ -3932,7 +3942,7 @@ static void run_state_machine(struct tcpm_port *port) > typec_set_pwr_opmode(port->typec_port, opmode); > port->pwr_opmode = TYPEC_PWR_MODE_USB; > port->caps_count = 0; > - port->negotiated_rev = PD_MAX_REV; > + port->negotiated_rev = tcpm_pd_supported_rev(port); > port->message_id = 0; > port->rx_msgid = -1; > port->explicit_contract = false; > @@ -4167,7 +4177,7 @@ static void run_state_machine(struct tcpm_port *port) > port->cc2 : port->cc1); > typec_set_pwr_opmode(port->typec_port, opmode); > port->pwr_opmode = TYPEC_PWR_MODE_USB; > - port->negotiated_rev = PD_MAX_REV; > + port->negotiated_rev = tcpm_pd_supported_rev(port); > port->message_id = 0; > port->rx_msgid = -1; > port->explicit_contract = false; > diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h > index bffc8d3e14ad..36282b2a9d9c 100644 > --- a/include/linux/usb/tcpm.h > +++ b/include/linux/usb/tcpm.h > @@ -114,6 +114,9 @@ enum tcpm_transmit_type { > * Optional; The USB Communications Capable bit indicates if port > * partner is capable of communication over the USB data lines > * (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit. > + * @supported_pd_rev: > + * Optional; TCPM call this function to get supported PD revesion > + * from lower level driver. > */ > struct tcpc_dev { > struct fwnode_handle *fwnode; > @@ -148,6 +151,7 @@ struct tcpc_dev { > bool pps_active, u32 requested_vbus_voltage); > bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev); > void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable); > + u32 (*supported_pd_rev)(struct tcpc_dev *dev); > }; > > struct tcpm_port;