From patchwork Sat Oct 3 18:13:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 7322231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4C7939F302 for ; Sat, 3 Oct 2015 18:16:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 686FB20570 for ; Sat, 3 Oct 2015 18:16:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54DE62054B for ; Sat, 3 Oct 2015 18:16:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZiRKE-0004yY-HH; Sat, 03 Oct 2015 18:14:26 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZiRJl-0004RH-SO for linux-arm-kernel@lists.infradead.org; Sat, 03 Oct 2015 18:13:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References:In-Reply-To; bh=lebeA1DGjbK9h6GLvl0WUtrqcPKfB4gywrJDCCfe3Go=; b=MUQU6emW5ECvKikqY74PggT/cmLdnMNPpY3V/8A1/TNMHuwmsAjrxxrHERVsEPAqepJ5yxiPSmMCpRhuXA/+QZrCF7mUVmSXmNBXdRt6GxBknP1JJa8I+6UJi/JGlBTz5WjLILKjwB03I1bTCrH9BuMr4+wN03X+0Y8bnSmrg0A=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([2001:4d48:ad52:3201:222:68ff:fe15:37dd]:43244 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1ZiRJG-0005tK-BA; Sat, 03 Oct 2015 19:13:26 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1ZiRJC-0004J4-PY; Sat, 03 Oct 2015 19:13:22 +0100 In-Reply-To: <20151003181228.GI21513@n2100.arm.linux.org.uk> References: <20151003181228.GI21513@n2100.arm.linux.org.uk> From: Russell King To: Jason Cooper , Thomas Petazzoni Subject: [PATCH 6/9] pci: mvebu: use gpio_desc to carry around gpio MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sat, 03 Oct 2015 19:13:22 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151003_111358_304841_68D05220 X-CRM114-Status: GOOD ( 14.58 ) X-Spam-Score: -4.3 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use a gpio_desc to carry around the gpio, so we can then make use of the GPIOF_ACTIVE_LOW property rather than carrying that around as well. This also avoids needing to use gpio_is_valid() to check whether we have a GPIO; checking for a non-NULL descriptor is simpler. Signed-off-by: Russell King --- drivers/pci/host/pci-mvebu.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 7282bb06c7a8..ab619ee0ef49 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c @@ -119,8 +119,7 @@ struct mvebu_pcie_port { unsigned int io_target; unsigned int io_attr; struct clk *clk; - int reset_gpio; - int reset_active_low; + struct gpio_desc *reset_gpio; char *reset_name; struct mvebu_sw_pci_bridge bridge; struct device_node *dn; @@ -940,7 +939,7 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, { struct device *dev = &pcie->pdev->dev; enum of_gpio_flags flags; - int ret; + int reset_gpio, ret; port->pcie = pcie; @@ -980,15 +979,15 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, port->io_attr = -1; } - port->reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, - &flags); - if (port->reset_gpio == -EPROBE_DEFER) { - ret = port->reset_gpio; + reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags); + if (reset_gpio == -EPROBE_DEFER) { + ret = reset_gpio; goto err; } - if (gpio_is_valid(port->reset_gpio)) { - port->reset_active_low = flags & OF_GPIO_ACTIVE_LOW; + 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) { @@ -996,13 +995,24 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie, goto err; } - ret = devm_gpio_request_one(dev, port->reset_gpio, - GPIOF_DIR_OUT, port->reset_name); + if (flags & OF_GPIO_ACTIVE_LOW) { + dev_info(dev, "%s: reset gpio is active low\n", + of_node_full_name(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); } port->clk = of_clk_get_by_name(child, NULL); @@ -1104,15 +1114,14 @@ static int mvebu_pcie_probe(struct platform_device *pdev) if (!child) continue; - if (gpio_is_valid(port->reset_gpio)) { + if (port->reset_gpio) { u32 reset_udelay = 20000; of_property_read_u32(child, "reset-delay-us", &reset_udelay); - gpio_set_value_cansleep(port->reset_gpio, - !!port->reset_active_low); - msleep(reset_udelay/1000); + gpiod_set_value_cansleep(port->reset_gpio, 0); + msleep(reset_udelay / 1000); } ret = clk_prepare_enable(port->clk);