Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp250037lqa; Sat, 27 Apr 2024 00:24:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWS18b8CL+rTB+Xs6LZ1MmgqMB6MeE+uQq0zmAuR9wSzkN1d+L3BasFluHVGBM5gJ0cxwzjqAYKUigZ3lqBCmQ4G8quFzRq90TbHOUgHQ== X-Google-Smtp-Source: AGHT+IGk6AnzGqhVb9JOQ9YTyOC0gtaviYYJUtGQ/V+QN3n3Fca5Ha2kzFjewVKpUDs6Yb5Jl5/v X-Received: by 2002:a05:6a20:5647:b0:1ad:7fb2:2c0d with SMTP id is7-20020a056a20564700b001ad7fb22c0dmr5070929pzc.27.1714202651874; Sat, 27 Apr 2024 00:24:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714202651; cv=pass; d=google.com; s=arc-20160816; b=QPT5uwNVAI3/wR55TGcGWzf7Mxwayq2mMwrrHpDmjMsprv0++tGPrrM/tw/AgHOery Gd0yk6eDosPC3NPFxrEWCKkHctCcd78AX+YLX1DH1UqOFYFwiWsYSigBrS3TJkLlQXAf 98iYt5W8P/DIE/t1ACFN4XXJxg11JY+jP6XHsg6ZpFIHUDFU9OWVhhDQC74aEaQN5iNc DDTTGxfdfMSd+SCeE29m1fg7CbYR1m29m6YcHAMbeEe4YXralFRUEtNfoxCvdBeYN9zu 1+AnuBE1FgHisvq7zJpNb8dVzd90Ttle9csBCHHQQ152f5X23DuzAo8c7rcFxtoQmKX5 KpHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=X6/zlDycsKlLm9oMWJCj8T6cyudX5ggjd/VxiVnvZxs=; fh=veDqBZqK2FCOWYfYiqQU2VW++ceNT0Z9DDfQt3G2bZo=; b=R0lOujJr1mJZ5fcc9bu89b6ESWT8pW+C7hc+5sK4WzxLXIPQigydWTqBb1heXRVovU S0qyCq/np4oVszVffCfJehxRh3qF1I7MX/tPaaCh7R2We/W90sWB4MrTwieU0nnRxu+F o+WvYb8m3CFpPjUabXnOmdeklxT5a4iSZuq9PyqlqpMNWFDYk+QZ8Vao3rSIvnzETtCT Mo4s3AP9R66ZibOso3L7J+JWIaBEcLXaeIjLonQWBsNlDCRgJGl3lMyZIbkdAPS4gb1i 9ajNaj2S80B2fGMMqxbGXoJExRtA8O3uF/mWHmu/SIIUO50w2xErVWzLvej8yK89mQ9B IamQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fg/2IeCW"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-160935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ng9-20020a17090b1a8900b002af405c4066si6295152pjb.154.2024.04.27.00.24.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 00:24:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fg/2IeCW"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-160935-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160935-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 889F3B213C1 for ; Sat, 27 Apr 2024 07:24:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C92CD43AC1; Sat, 27 Apr 2024 07:23:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fg/2IeCW" Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E16744205F for ; Sat, 27 Apr 2024 07:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714202634; cv=none; b=ktuNUMLlmVrrbqTe7IdTh2D8UxoExKNW0iWdOJeS1mK9L8zFx0/HJkjm+aSBgTF7wKzzL4RjPjSpuB3oVcJnDZvdVJ/VwW3qvO2UNB5wZXIS4c7mHu8HluT0StbaY5Pa+v0allu8PdiWjgdcLK/csQ53RSMaBtrBuvB/ANo5BUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714202634; c=relaxed/simple; bh=QQ9X6/B/OY5Rpbf27ZZgDjJFLbBrR5d8bJENXinX6zw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=II+XqeS/pfxnsmzXdWF/O8LuyMP5s4yMmSt1QEUhSpBrmkFwKyPm38Ka3ogj/lQU3f7Wi5cpdjrnQjYf5GyNFlc9UHalvZCWTfiueks1FMdefeSXtavACq+4k3ilFfB423uQrWY12GbPBVJW8HNj49kTqa7esXbduOkV28RtPnQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=fg/2IeCW; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3bbbc6b4ed1so1837777b6e.2 for ; Sat, 27 Apr 2024 00:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714202631; x=1714807431; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=X6/zlDycsKlLm9oMWJCj8T6cyudX5ggjd/VxiVnvZxs=; b=fg/2IeCWyMO/S6izUCgCQNDghhIKYjU+T6hOND0LtmyTjS8Byu2OiK4pMtEivGByOs r2xXmIJe/oxBCwRhLSEuapbFxR/vMymVGFlDuCW/mLscC4Qb+QKKut/+DZwezvQGB6CY 68reJeSPKIi7flNd1LfjDl40RNIsGwkzySSaE3DYJmInQNRxFtoPwKYW8jty9XKDd1Kh sTzY1h7Fhly2ijIiKCEj7cBwuvxxCPvM29RDIZSYzMJ5mFTMvGKRFasJvP+SVGfzeT8w zrMR1ATysDxQ3dnVor8ovLWSoGtQYrbCYWT7xY77FDfAuErpQNeyEQYbN61M2z1KbWVN BYEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714202631; x=1714807431; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X6/zlDycsKlLm9oMWJCj8T6cyudX5ggjd/VxiVnvZxs=; b=fYa/Z3Lb98XEK/thFu8UBKctHQFP1ouF7WVeZ1yx9Hj3n/zxjCmghNrYsqgoi7sQzN mKT9YENCDSY93AbpWIitVAwdbgXuzLedVsc9JXDJ8Xw0dJprJBLmFDbbqUWhBwQW0zwD xabWACAHO+9/gKbQHh5fIYwUofQs9YnL9p2HnzjCZHsMT+yA5Sm7z3Ayqtm3WXUTqgVu HujuQY7OcqJB6eQTrXMUtb0krzvoNkKXJVbkPD6rPEyPnXvTHippV3wRNqhF654Nvo/G bx235/kBMeB3SLIXPImmjCRMogXS1/xYjTA+5QqSNjXfTjH5QEtt/tYZPpUgAPgrr5HG 83Ag== X-Forwarded-Encrypted: i=1; AJvYcCVk0+bO1X131MR6Sdc3Jr6WMjDhr5Y4OntKsm7M0Sku9Ji1WW8WA2zuPk8d1q3DlH1em53SNj+s4gdPW/+PFi16d9H58zA6UY4pNTh+ X-Gm-Message-State: AOJu0YxHPOQNdc0s2jPyPOi8/sX149lkrWl+nvMfbvjYb8B7i+aUFXX6 ZpCDBkZJ8gHOWgmGtkZGzUHG+d0FiaPsVHLIBm5Vr/ldjwdhl1pxlqBeLsg7jQ== X-Received: by 2002:a05:6808:85:b0:3c7:4b27:57fb with SMTP id s5-20020a056808008500b003c74b2757fbmr5763377oic.29.1714202630707; Sat, 27 Apr 2024 00:23:50 -0700 (PDT) Received: from thinkpad ([120.60.53.237]) by smtp.gmail.com with ESMTPSA id i123-20020a639d81000000b005f7ff496050sm13702516pgd.76.2024.04.27.00.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Apr 2024 00:23:50 -0700 (PDT) Date: Sat, 27 Apr 2024 12:53:35 +0530 From: Manivannan Sadhasivam To: Andy Shevchenko Cc: Frank Li , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-omap@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, Vignesh Raghavendra , Siddharth Vadapalli , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Yue Wang , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Xiaowei Song , Binghui Wang , Thierry Reding , Jonathan Hunter , Thomas Petazzoni , Pali =?iso-8859-1?Q?Roh=E1r?= Subject: Re: [PATCH v2 4/4] PCI: kirin: Convert to agnostic GPIO API Message-ID: <20240427072335.GC1981@thinkpad> References: <20240423172208.2723892-1-andriy.shevchenko@linux.intel.com> <20240423172208.2723892-5-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240423172208.2723892-5-andriy.shevchenko@linux.intel.com> On Tue, Apr 23, 2024 at 08:19:07PM +0300, Andy Shevchenko wrote: > The of_gpio.h is going to be removed. In preparation of that convert > the driver to the agnostic API. > > Signed-off-by: Andy Shevchenko > Reviewed-by: Rob Herring > --- > drivers/pci/controller/dwc/pcie-kirin.c | 105 ++++++++---------------- > 1 file changed, 35 insertions(+), 70 deletions(-) > > diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c > index d5523f302102..1753ab63a541 100644 > --- a/drivers/pci/controller/dwc/pcie-kirin.c > +++ b/drivers/pci/controller/dwc/pcie-kirin.c > @@ -12,12 +12,10 @@ > #include > #include > #include > -#include > #include > #include > #include > #include > -#include > #include > #include > #include > @@ -78,16 +76,16 @@ struct kirin_pcie { > void *phy_priv; /* only for PCIE_KIRIN_INTERNAL_PHY */ > > /* DWC PERST# */ > - int gpio_id_dwc_perst; > + struct gpio_desc *id_dwc_perst_gpio; > > /* Per-slot PERST# */ > int num_slots; > - int gpio_id_reset[MAX_PCI_SLOTS]; > + struct gpio_desc *id_reset_gpio[MAX_PCI_SLOTS]; > const char *reset_names[MAX_PCI_SLOTS]; > > /* Per-slot clkreq */ > int n_gpio_clkreq; > - int gpio_id_clkreq[MAX_PCI_SLOTS]; > + struct gpio_desc *id_clkreq_gpio[MAX_PCI_SLOTS]; > const char *clkreq_names[MAX_PCI_SLOTS]; > }; > > @@ -381,15 +379,20 @@ static int kirin_pcie_get_gpio_enable(struct kirin_pcie *pcie, > pcie->n_gpio_clkreq = ret; > > for (i = 0; i < pcie->n_gpio_clkreq; i++) { > - pcie->gpio_id_clkreq[i] = of_get_named_gpio(dev->of_node, > - "hisilicon,clken-gpios", i); > - if (pcie->gpio_id_clkreq[i] < 0) > - return pcie->gpio_id_clkreq[i]; > + pcie->id_clkreq_gpio[i] = devm_gpiod_get_index(dev, > + "hisilicon,clken", i, > + GPIOD_ASIS); Please don't use GPIOD_ASIS even if the old code was using it. For all 3 GPIOs in this driver, GPIOD_OUT_LOW flag should be used as the default state is assert (considering the fact that the DT uses GPIO_ACTIVE_HIGH). - Mani > + if (IS_ERR(pcie->id_clkreq_gpio[i])) > + return dev_err_probe(dev, PTR_ERR(pcie->id_clkreq_gpio[i]), > + "unable to get a valid clken gpio\n"); > > pcie->clkreq_names[i] = devm_kasprintf(dev, GFP_KERNEL, > "pcie_clkreq_%d", i); > if (!pcie->clkreq_names[i]) > return -ENOMEM; > + > + gpiod_set_consumer_name(pcie->id_clkreq_gpio[i], > + pcie->clkreq_names[i]); > } > > return 0; > @@ -407,10 +410,16 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie, > for_each_available_child_of_node(parent, child) { > i = pcie->num_slots; > > - pcie->gpio_id_reset[i] = of_get_named_gpio(child, > - "reset-gpios", 0); > - if (pcie->gpio_id_reset[i] < 0) > - continue; > + pcie->id_reset_gpio[i] = devm_fwnode_gpiod_get_index(dev, > + of_fwnode_handle(child), > + "reset", 0, GPIOD_ASIS, > + NULL); > + if (IS_ERR(pcie->id_reset_gpio[i])) { > + if (PTR_ERR(pcie->id_reset_gpio[i]) == -ENOENT) > + continue; > + return dev_err_probe(dev, PTR_ERR(pcie->id_reset_gpio[i]), > + "unable to get a valid reset gpio\n"); > + } > > pcie->num_slots++; > if (pcie->num_slots > MAX_PCI_SLOTS) { > @@ -434,6 +443,9 @@ static int kirin_pcie_parse_port(struct kirin_pcie *pcie, > ret = -ENOMEM; > goto put_node; > } > + > + gpiod_set_consumer_name(pcie->id_reset_gpio[i], > + pcie->reset_names[i]); > } > } > > @@ -463,14 +475,11 @@ static long kirin_pcie_get_resource(struct kirin_pcie *kirin_pcie, > return PTR_ERR(kirin_pcie->apb); > > /* pcie internal PERST# gpio */ > - kirin_pcie->gpio_id_dwc_perst = of_get_named_gpio(dev->of_node, > - "reset-gpios", 0); > - if (kirin_pcie->gpio_id_dwc_perst == -EPROBE_DEFER) { > - return -EPROBE_DEFER; > - } else if (!gpio_is_valid(kirin_pcie->gpio_id_dwc_perst)) { > - dev_err(dev, "unable to get a valid gpio pin\n"); > - return -ENODEV; > - } > + kirin_pcie->id_dwc_perst_gpio = devm_gpiod_get(dev, "reset", GPIOD_ASIS); > + if (IS_ERR(kirin_pcie->id_dwc_perst_gpio)) > + return dev_err_probe(dev, PTR_ERR(kirin_pcie->id_dwc_perst_gpio), > + "unable to get a valid gpio pin\n"); > + gpiod_set_consumer_name(kirin_pcie->id_dwc_perst_gpio, "pcie_perst_bridge"); > > ret = kirin_pcie_get_gpio_enable(kirin_pcie, pdev); > if (ret) > @@ -553,7 +562,7 @@ static int kirin_pcie_add_bus(struct pci_bus *bus) > > /* Send PERST# to each slot */ > for (i = 0; i < kirin_pcie->num_slots; i++) { > - ret = gpio_direction_output(kirin_pcie->gpio_id_reset[i], 1); > + ret = gpiod_direction_output_raw(kirin_pcie->id_reset_gpio[i], 1); > if (ret) { > dev_err(pci->dev, "PERST# %s error: %d\n", > kirin_pcie->reset_names[i], ret); > @@ -623,44 +632,6 @@ static int kirin_pcie_host_init(struct dw_pcie_rp *pp) > return 0; > } > > -static int kirin_pcie_gpio_request(struct kirin_pcie *kirin_pcie, > - struct device *dev) > -{ > - int ret, i; > - > - for (i = 0; i < kirin_pcie->num_slots; i++) { > - if (!gpio_is_valid(kirin_pcie->gpio_id_reset[i])) { > - dev_err(dev, "unable to get a valid %s gpio\n", > - kirin_pcie->reset_names[i]); > - return -ENODEV; > - } > - > - ret = devm_gpio_request(dev, kirin_pcie->gpio_id_reset[i], > - kirin_pcie->reset_names[i]); > - if (ret) > - return ret; > - } > - > - for (i = 0; i < kirin_pcie->n_gpio_clkreq; i++) { > - if (!gpio_is_valid(kirin_pcie->gpio_id_clkreq[i])) { > - dev_err(dev, "unable to get a valid %s gpio\n", > - kirin_pcie->clkreq_names[i]); > - return -ENODEV; > - } > - > - ret = devm_gpio_request(dev, kirin_pcie->gpio_id_clkreq[i], > - kirin_pcie->clkreq_names[i]); > - if (ret) > - return ret; > - > - ret = gpio_direction_output(kirin_pcie->gpio_id_clkreq[i], 0); > - if (ret) > - return ret; > - } > - > - return 0; > -} > - > static const struct dw_pcie_ops kirin_dw_pcie_ops = { > .read_dbi = kirin_pcie_read_dbi, > .write_dbi = kirin_pcie_write_dbi, > @@ -680,7 +651,7 @@ static int kirin_pcie_power_off(struct kirin_pcie *kirin_pcie) > return hi3660_pcie_phy_power_off(kirin_pcie); > > for (i = 0; i < kirin_pcie->n_gpio_clkreq; i++) > - gpio_direction_output(kirin_pcie->gpio_id_clkreq[i], 1); > + gpiod_direction_output_raw(kirin_pcie->id_clkreq_gpio[i], 1); > > phy_power_off(kirin_pcie->phy); > phy_exit(kirin_pcie->phy); > @@ -707,10 +678,6 @@ static int kirin_pcie_power_on(struct platform_device *pdev, > if (IS_ERR(kirin_pcie->phy)) > return PTR_ERR(kirin_pcie->phy); > > - ret = kirin_pcie_gpio_request(kirin_pcie, dev); > - if (ret) > - return ret; > - > ret = phy_init(kirin_pcie->phy); > if (ret) > goto err; > @@ -723,11 +690,9 @@ static int kirin_pcie_power_on(struct platform_device *pdev, > /* perst assert Endpoint */ > usleep_range(REF_2_PERST_MIN, REF_2_PERST_MAX); > > - if (!gpio_request(kirin_pcie->gpio_id_dwc_perst, "pcie_perst_bridge")) { > - ret = gpio_direction_output(kirin_pcie->gpio_id_dwc_perst, 1); > - if (ret) > - goto err; > - } > + ret = gpiod_direction_output_raw(kirin_pcie->id_dwc_perst_gpio, 1); > + if (ret) > + goto err; > > usleep_range(PERST_2_ACCESS_MIN, PERST_2_ACCESS_MAX); > > -- > 2.43.0.rc1.1336.g36b5255a03ac > -- மணிவண்ணன் சதாசிவம்