From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 108F1C4708F for ; Tue, 1 Jun 2021 07:35:28 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2A6F61364 for ; Tue, 1 Jun 2021 07:35:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2A6F61364 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4D94681D48; Tue, 1 Jun 2021 09:35:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="Bihs0opH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4439481D0B; Tue, 1 Jun 2021 09:35:22 +0200 (CEST) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3866E81D0B for ; Tue, 1 Jun 2021 09:35:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge@foundries.io Received: by mail-wr1-x434.google.com with SMTP id n4so13158476wrw.3 for ; Tue, 01 Jun 2021 00:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dc4gAxgVTf3BiI3TSEqGwAcdgI/LuYPMnPrjuJ7/bAc=; b=Bihs0opHFpnacYTq61ysHIsCoEOB4/g/TUxzpeWN+6xHGtvR9uB+Ux7YVybRXg+oci CBuM4yLlowQetdX1SZWHyv90kEe1b9eN4T2gafWI8tqD16rC2xQvJgqrIk+TmjLft1Pc AHOeF+VfFSCHxGuQQhQY0t7w2JOKbvsTrJW+MZULn7pZmgeS0AjvkKByRQNzbbb3BfEo OwUe0EFM9h/2CQ224Zan+FH5Crqsvt8+hGPGvRnUHQZ2s8KtszjWhWECa2qdTh7Isns1 2Fe94ceZlWfVSiVSxDG+wNqWzHX8wjDSvpJeyz2YnnB0XuIFsVs3Ojr1TbKJDiF0Ja8Z FHVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dc4gAxgVTf3BiI3TSEqGwAcdgI/LuYPMnPrjuJ7/bAc=; b=LD47yzfX2Zf6D90Pg8CXpPylznot5SkTE09F6NV3mVyGpJhwIJ5iSUbKobym2xyew6 MwOWQiYYROrge9fw9Nl+gvcesmdRc1yj/w9VQ+fb6WUHvKAjees0zOIiU5mM13YHuhwk 5mtlGmfclqYa/jlFF8UHsnXp1NUu3xEpMyGHjtjr7f8+d5oJqe0fXDxcpFRlVSfGTATT Z1rY4FG5sQtCTY/RHcFwvmVMelV38BC0w888pY7VzYPpJzMeEQgCoNqeCBEQrjhFchHF Sw3WrHa254bFLeYmMS78XvPogP7RtMEF9NECmMi99l+ca75+chTi19eeMOWEqDqcWcSH vexw== X-Gm-Message-State: AOAM533BAg9MTjGnu8dwN+CmCTddU9pBuwxSoHLAfgbpfdfe2NwBnNSz xk3N0DPJZf9Q5cAVj/saeUWnHA== X-Google-Smtp-Source: ABdhPJyHhJz02hYvVGWr4jNa6OWakUQ9wPrGcs7pvvUb4Y/776yCrmeac8n3nfMSpIECUB007lglQA== X-Received: by 2002:adf:e788:: with SMTP id n8mr13145908wrm.387.1622532918731; Tue, 01 Jun 2021 00:35:18 -0700 (PDT) Received: from trex (113.red-79-154-202.dynamicip.rima-tde.net. [79.154.202.113]) by smtp.gmail.com with ESMTPSA id a77sm15394547wmd.14.2021.06.01.00.35.17 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Jun 2021 00:35:18 -0700 (PDT) From: "Jorge Ramirez-Ortiz, Foundries" X-Google-Original-From: "Jorge Ramirez-Ortiz, Foundries" Date: Tue, 1 Jun 2021 09:35:17 +0200 To: Michal Simek Cc: Jorge Ramirez-Ortiz , sjg@chromium.org, bruno.thomsen@gmail.com, u-boot@lists.denx.de Subject: Re: [PATCHv2] drivers: tpm2: update reset gpio semantics Message-ID: <20210601073517.GA2523@trex> References: <20210601060927.30894-1-jorge@foundries.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean On 01/06/21, Michal Simek wrote: > > > On 6/1/21 8:09 AM, Jorge Ramirez-Ortiz wrote: > > Use the more generic reset-gpios propery name. > > > > Signed-off-by: Jorge Ramirez-Ortiz > > --- > > v2: kept gpio-reset as legacy > > > > .../tpm2/tis-tpm2-spi.txt | 2 +- > > drivers/tpm/tpm2_tis_spi.c | 21 ++++++++++++------- > > 2 files changed, 14 insertions(+), 9 deletions(-) > > > > diff --git a/doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt b/doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt > > index 3a2ee4bd17..bbcd12950f 100644 > > --- a/doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt > > +++ b/doc/device-tree-bindings/tpm2/tis-tpm2-spi.txt > > @@ -6,7 +6,7 @@ Required properties: > > - reg : SPI Chip select > > > > Optional properties: > > -- gpio-reset : Reset GPIO (if not connected to the SoC reset line) > > As I said you shouldn't remove this. Just extend description that it is > deprecated and reset-gpios should be used instead. I dont really agree with that. IMO we should remove the documentation since it is obsolete after this commit and anyone reading it should not care about the gpio-reset property. > > > +- reset-gpios : Reset GPIO (if not connected to the SoC reset line) > > - spi-max-frequency : See spi-bus.txt > > > > Example: > > diff --git a/drivers/tpm/tpm2_tis_spi.c b/drivers/tpm/tpm2_tis_spi.c > > index 4b33ac8fd3..1f9f89f68f 100644 > > --- a/drivers/tpm/tpm2_tis_spi.c > > +++ b/drivers/tpm/tpm2_tis_spi.c > > @@ -589,18 +589,23 @@ static int tpm_tis_spi_probe(struct udevice *dev) > > if (CONFIG_IS_ENABLED(DM_GPIO)) { > > struct gpio_desc reset_gpio; > > > > - ret = gpio_request_by_name(dev, "gpio-reset", 0, > > + ret = gpio_request_by_name(dev, "reset-gpios", 0, > > &reset_gpio, GPIOD_IS_OUT); > > if (ret) { > > - log(LOGC_NONE, LOGL_NOTICE, "%s: missing reset GPIO\n", > > - __func__); > > - } else { > > - dm_gpio_set_value(&reset_gpio, 1); > > - mdelay(1); > > - dm_gpio_set_value(&reset_gpio, 0); > > + /* legacy reset */ > > + ret = gpio_request_by_name(dev, "gpio-reset", 0, > > + &reset_gpio, GPIOD_IS_OUT); > > + if (ret) { > > + log(LOGC_NONE, LOGL_NOTICE, > > + "%s: missing reset GPIO\n", __func__); > > + goto init; > > + } > > And here it is clear that gpio-reset is used which should deprecated > that's why you should print message about it here. yes, I can do that. makes sense > > > > } > > + dm_gpio_set_value(&reset_gpio, 1); > > + mdelay(1); > > + dm_gpio_set_value(&reset_gpio, 0); > > } > > What about this to remove that goto? um, what is the problem with the goto (IMO tidier than yet another conditional); it is not as if this goto is making the code obscure. with the change below you just removed previous functionality (ie indicating that there is no GPIO reset provided, hence why at first sight might look cleaner than a goto) > > ret = gpio_request_by_name(dev, "reset-gpios", 0, > &reset_gpio, GPIOD_IS_OUT); > if (ret) { > /* trying legacy reset */ > ret = gpio_request_by_name(dev, "gpio-reset", 0, > &reset_gpio, GPIOD_IS_OUT); > if (!ret) > log(LOGC_NONE, LOGL_NOTICE, > "%s: Using deprecated gpio-reset switch to reset-gpios\n", __func__); > } > > if (!ret) { > dm_gpio_set_value(&reset_gpio, 1); > mdelay(1); > dm_gpio_set_value(&reset_gpio, 0); > } > > > - > > +init: > > /* Ensure a minimum amount of time elapsed since reset of the TPM */ > > mdelay(drv_data->time_before_first_cmd_ms); > > > > > > M