From patchwork Tue Sep 6 20:43:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12968165 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9135EC38145 for ; Tue, 6 Sep 2022 20:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbiIFUnH (ORCPT ); Tue, 6 Sep 2022 16:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbiIFUnG (ORCPT ); Tue, 6 Sep 2022 16:43:06 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8C7B8B9A8; Tue, 6 Sep 2022 13:43:05 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id j12so120115pfi.11; Tue, 06 Sep 2022 13:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=BbfLC4ws9R3hOi3BD7bYuf4EI7Nopwizd0E+k/EX/0A=; b=MGxrErQNBHHEyo3yV2iAOVLhCgCaAvaYt7Bzz7VgtkO6RUXDbAKAf7+na033usLCiz A/GApEIG35dtYK2nsLsBx5s6I62ti3uJ6VyolvPzp5CbNDW5Jh0P+86lW/wklP1Fw5hp f2WEHsGtcJ5wk5PfnVocKHMSxZyPGA+B57twdpiPfsoLoQ/FemUeXT1MRuMmpJ8oUZG6 70Qk9oF1Igmr56rvay46VFHMsAu71UFwA45E+sqFyq5rvSq9DCf1oX8xDQQMw9db9+iD 3+AFlhaPb8Fa8e8ph4U9iznZYZi2FVn7HRroKZr4IBJ4cDsnTl+/RcBqHT85pjDAquVl Jg4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=BbfLC4ws9R3hOi3BD7bYuf4EI7Nopwizd0E+k/EX/0A=; b=Iji5PYPCYZvaR8dhA25ODUueocz9i4AHbju37GlbzkKa7P5cGMGxA345uG0yxMJ9b3 fyclKR87a9WMynT+2AgKpbQth9ewJBkM8fw5dPnYoYHaSoglfEtk3vbglzIVhTa4WNjE YuWjhaXl7d+Yh2xFePphlCsb1qHeZrZFozSfYXSMPm7zlprbzO9hnwfGEkDrk1g7/AWY djBtQm2Y6lgLnojS9gI1Y+Y5fGhZnsOChIH4ENk7zvRXxQ4jLCL/35qgPWG3UQmLGM4N 8HRrLtSZ5jsavhVKu7tEGN4o/R+EoNkQHP0LlYdyjaO+r5iPDNg/YkAPr3gRvOIl86mO U/2Q== X-Gm-Message-State: ACgBeo29qq62htOa4mCUriUwEuQ33GHf+oxL1E2QrhLT/S3PlejQ96WY gsQycJlfBTb4vnNdQTyb8CQ= X-Google-Smtp-Source: AA6agR4P7/Q89Ibh2uv7NJ/hfhkLqfRn1N8AF8nhdtd7xNbngL9NiJDO7m8sN3R3OuTpTW0EFFVBaA== X-Received: by 2002:a63:8241:0:b0:42b:c6e8:d3e4 with SMTP id w62-20020a638241000000b0042bc6e8d3e4mr394812pgd.113.1662496985237; Tue, 06 Sep 2022 13:43:05 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:abc4:5d24:5a73:a96b]) by smtp.gmail.com with ESMTPSA id u3-20020a170902e80300b0016c57657977sm10359961plg.41.2022.09.06.13.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 13:43:04 -0700 (PDT) From: Dmitry Torokhov To: Shawn Guo , Lorenzo Pieralisi , Thomas Petazzoni , =?utf-8?q?Pali_Roh=C3=A1r?= , Bjorn Helgaas Cc: Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Linus Walleij , Bartosz Golaszewski , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] PCI: histb: switch to using gpiod API Date: Tue, 6 Sep 2022 13:43:00 -0700 Message-Id: <20220906204301.3736813-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of of_get_named_gpio_flags() which I want to make private to gpiolib. Signed-off-by: Dmitry Torokhov Reviewed-by: Linus Walleij --- drivers/pci/controller/dwc/pcie-histb.c | 39 ++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-histb.c b/drivers/pci/controller/dwc/pcie-histb.c index e2b80f10030d..43c27812dd6d 100644 --- a/drivers/pci/controller/dwc/pcie-histb.c +++ b/drivers/pci/controller/dwc/pcie-histb.c @@ -10,11 +10,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -60,7 +60,7 @@ struct histb_pcie { struct reset_control *sys_reset; struct reset_control *bus_reset; void __iomem *ctrl; - int reset_gpio; + struct gpio_desc *reset_gpio; struct regulator *vpcie; }; @@ -212,8 +212,8 @@ static void histb_pcie_host_disable(struct histb_pcie *hipcie) clk_disable_unprepare(hipcie->sys_clk); clk_disable_unprepare(hipcie->bus_clk); - if (gpio_is_valid(hipcie->reset_gpio)) - gpio_set_value_cansleep(hipcie->reset_gpio, 0); + if (hipcie->reset_gpio) + gpiod_set_value_cansleep(hipcie->reset_gpio, 1); if (hipcie->vpcie) regulator_disable(hipcie->vpcie); @@ -235,8 +235,8 @@ static int histb_pcie_host_enable(struct dw_pcie_rp *pp) } } - if (gpio_is_valid(hipcie->reset_gpio)) - gpio_set_value_cansleep(hipcie->reset_gpio, 1); + if (hipcie->reset_gpio) + gpiod_set_value_cansleep(hipcie->reset_gpio, 0); ret = clk_prepare_enable(hipcie->bus_clk); if (ret) { @@ -298,10 +298,7 @@ static int histb_pcie_probe(struct platform_device *pdev) struct histb_pcie *hipcie; struct dw_pcie *pci; struct dw_pcie_rp *pp; - struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; - enum of_gpio_flags of_flags; - unsigned long flag = GPIOF_DIR_OUT; int ret; hipcie = devm_kzalloc(dev, sizeof(*hipcie), GFP_KERNEL); @@ -336,17 +333,19 @@ static int histb_pcie_probe(struct platform_device *pdev) hipcie->vpcie = NULL; } - hipcie->reset_gpio = of_get_named_gpio_flags(np, - "reset-gpios", 0, &of_flags); - if (of_flags & OF_GPIO_ACTIVE_LOW) - flag |= GPIOF_ACTIVE_LOW; - if (gpio_is_valid(hipcie->reset_gpio)) { - ret = devm_gpio_request_one(dev, hipcie->reset_gpio, - flag, "PCIe device power control"); - if (ret) { - dev_err(dev, "unable to request gpio\n"); - return ret; - } + hipcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_HIGH); + ret = PTR_ERR_OR_ZERO(hipcie->reset_gpio); + if (ret) { + dev_err(dev, "unable to request reset gpio: %d\n", ret); + return ret; + } + + ret = gpiod_set_consumer_name(hipcie->reset_gpio, + "PCIe device power control"); + if (ret) { + dev_err(dev, "unable to set reset gpio name: %d\n", ret); + return ret; } hipcie->aux_clk = devm_clk_get(dev, "aux"); From patchwork Tue Sep 6 20:43:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12968166 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F67CC54EE9 for ; Tue, 6 Sep 2022 20:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229496AbiIFUnK (ORCPT ); Tue, 6 Sep 2022 16:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230215AbiIFUnI (ORCPT ); Tue, 6 Sep 2022 16:43:08 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 566A08B9AF; Tue, 6 Sep 2022 13:43:07 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso2990940pjq.1; Tue, 06 Sep 2022 13:43:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=LGZJeMOU/kTBjQcVTon7M5VthpZd4oM1G5QflDMIOBQ=; b=fD3UBHqC6pgBLZfaZsrdOXw+33kE9SoUOutYUEl6EUeEKwU8uoJvvGbhLsC9ZC4e4u 0Y72dgEnu4HpKjNzFM3O8kGnGm+WN6QCCToLiWPk6uM6URU2PYDWIhrMfn1YVfJ6S8MY KyMKtm8ZoaX5Ss1aEdckR1fIF2r+LrAguDdfUh9wT/SIlNsHlMwGGJHuipHHotRSZUkb klDE+f/hG9BmSqiEUtONiiTU3lRxr8DIpKq2kvRSsU1eTW/A5BgnGjAt0u28k7Uwsw7w jd8zM0pjCBJoTCsTNl76FjtCoIYFSvNcnbJzH3VfECWqijdDFkTM1Eihyi3AHBbe+UFO 4weA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=LGZJeMOU/kTBjQcVTon7M5VthpZd4oM1G5QflDMIOBQ=; b=Etc1bI9PYnf2CRJrTiwlFXNGck1RF4XaGjxLBppftpkQPVELnW5Iu+bjOOB+VWFGry big+A/AL+1bmGbUOYOKCSG7eXiVUQvbBYMfycRym28lUv4qWq7VOfmgQT2DnapfhZyZK 71gRpgCLY7EgzVfKfhPi8duEZzEgC/sZhgVbLYaH1B00PRBDwki4/XcigmmQ/9Zw1iW7 oICfqJ3hazTfAwfxZsykqTTzr/k8oGRdnpoU/YC4s/5LIKVXDyMLa7SrxBhbexcHuLxL RPM8nPtGc7rzdWOpW7XNT56v8EcaZH8p+IB9VnzS0qBRx/w8wJoOZ5UU2ykVXcmKJoUd vksQ== X-Gm-Message-State: ACgBeo1mG96d4IhcYFCQ1sBn8bNrTYY3bot4spZs6hlY2Fabh3S6a5Q9 dpSc116k0b+LbPKIAJbkDCs= X-Google-Smtp-Source: AA6agR4W+ESDz7rOE+2SCpKsgNzs+jF9w7UKtzuT+jaPk9C2uuxmgps98PDHB3sT8kR+kQkn0cKNLw== X-Received: by 2002:a17:90b:254b:b0:200:a860:5bf9 with SMTP id nw11-20020a17090b254b00b00200a8605bf9mr3695228pjb.176.1662496986681; Tue, 06 Sep 2022 13:43:06 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:abc4:5d24:5a73:a96b]) by smtp.gmail.com with ESMTPSA id u3-20020a170902e80300b0016c57657977sm10359961plg.41.2022.09.06.13.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 13:43:06 -0700 (PDT) From: Dmitry Torokhov To: Shawn Guo , Lorenzo Pieralisi , Thomas Petazzoni , =?utf-8?q?Pali_Roh=C3=A1r?= , Bjorn Helgaas Cc: Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Linus Walleij , Bartosz Golaszewski , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] PCI: mvebu: switch to using gpiod API Date: Tue, 6 Sep 2022 13:43:01 -0700 Message-Id: <20220906204301.3736813-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220906204301.3736813-1-dmitry.torokhov@gmail.com> References: <20220906204301.3736813-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of of_get_named_gpio_flags() which I want to make private to gpiolib. Signed-off-by: Dmitry Torokhov Reported-by: kernel test robot --- drivers/pci/controller/pci-mvebu.c | 48 +++++++++--------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c index 1ced73726a26..a54beb8f611c 100644 --- a/drivers/pci/controller/pci-mvebu.c +++ b/drivers/pci/controller/pci-mvebu.c @@ -11,14 +11,13 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include #include #include @@ -1261,9 +1260,8 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, struct mvebu_pcie_port *port, struct device_node *child) { struct device *dev = &pcie->pdev->dev; - enum of_gpio_flags flags; u32 slot_power_limit; - int reset_gpio, ret; + int ret; u32 num_lanes; port->pcie = pcie; @@ -1327,40 +1325,22 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, port->name, child); } - reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags); - if (reset_gpio == -EPROBE_DEFER) { - ret = reset_gpio; + port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset", + port->name); + if (!port->reset_name) { + ret = -ENOMEM; goto err; } - if (gpio_is_valid(reset_gpio)) { - unsigned long gpio_flags; - - port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset", - port->name); - if (!port->reset_name) { - ret = -ENOMEM; + port->reset_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(child), + "reset", GPIOD_OUT_HIGH, + port->name); + ret = PTR_ERR_OR_ZERO(port->reset_gpio); + if (ret) { + if (ret != -ENOENT) goto err; - } - - if (flags & OF_GPIO_ACTIVE_LOW) { - dev_info(dev, "%pOF: reset gpio is active low\n", - child); - gpio_flags = GPIOF_ACTIVE_LOW | - GPIOF_OUT_INIT_LOW; - } else { - gpio_flags = GPIOF_OUT_INIT_HIGH; - } - - ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags, - port->reset_name); - if (ret) { - if (ret == -EPROBE_DEFER) - goto err; - goto skip; - } - - port->reset_gpio = gpio_to_desc(reset_gpio); + /* reset gpio is optional */ + port->reset_gpio = NULL; } slot_power_limit = of_pci_get_slot_power_limit(child,