From patchwork Tue Jan 23 01:04:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 125469 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1458390ljf; Mon, 22 Jan 2018 17:05:00 -0800 (PST) X-Google-Smtp-Source: AH8x227Cyu2FZpLfp4nWo0RKOXY+Cfo+wnSb1OCE23dJhIqCKPY/eO+l3238cQ5MTyvuOPoglucV X-Received: by 10.107.142.2 with SMTP id q2mr1362504iod.21.1516669500827; Mon, 22 Jan 2018 17:05:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516669500; cv=none; d=google.com; s=arc-20160816; b=QeWeiIbgjugtq73Gxy06z8mc59rfCntl6y11l5yztwRqVko6UQHxcU1iUeVApSxh3Y k9BaK7LnXeQwH34LG8VvZvCH4nVb2hCbe3H3D69x2tZ3uyYG3paXNgQErNY9QyXW+X+R JvX6nehf2lEHaSD1UvCp+0LO8I+zh9AN7jSgMwb2JoiaGIS80qUuOfK+3Ng5aVyTghdQ K3XYTiLWsJrGePYEnMgBGS2sUvu3Ee5/MNjn26hXnSKVVXsF+AOpMxSpuQn016gLNUhN dn4Q9+JIMrEaMHCm07NZ9bWjx9DgyuuhVhMyIaJ5XDTzIJh8iMiFMpVBfCU0xk2Vugpi 8x1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=0N9+GeCikdLA4VQbUhIAm4tflh9NLh8q/6EGFkN3GLw=; b=zPX45THqdryUZ19h3SHqdmd3WAT8lFKcwc8wbb9qNrnb9gijM+BmW8/L6iytkSNxan LTtpHasz0gdwJP0seMIYRC3UUNu7BHz/DMHQ98ZalZ2LOjvhyAybDo5VcRnYhiHEiLny 5XgPmcmzaI0tqIyGhWA2YmVebHOxQf3wtdBumbn7bjgJOeDliOkm77+PU1c0HHZmMgub ggtb6viVURqCDnmBO6Mo2axoBEAjFbXK6v2ZLs0NERxVzu43CGNPKxJTFONFHTflP38/ biakR0bTsFRHM8TQvWNQAMr1gvJIx/+95wEZ4QGEqxQwOObYVvTn8fyL4/dTe7Qntm5u BkYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=h1vOnwlx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w79si14326561ioi.330.2018.01.22.17.05.00; Mon, 22 Jan 2018 17:05:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=h1vOnwlx; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751299AbeAWBE7 (ORCPT + 6 others); Mon, 22 Jan 2018 20:04:59 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:40443 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751253AbeAWBE6 (ORCPT ); Mon, 22 Jan 2018 20:04:58 -0500 Received: by mail-pg0-f68.google.com with SMTP id g16so8469028pgn.7 for ; Mon, 22 Jan 2018 17:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=uBCAP/x0+TDkyIyOWsAh4+jywEPNozMxMND/23Kb53U=; b=h1vOnwlxpuEEoZ7JCrVmap7gekPM/KeLWdvaurTVZ1NTIUnNvlMaxEggamFgWMigFN 0L9eix2QbmNbeBIR4lq+VQXDdv5bQEsw45V2ErIwG3x8QGz8cdeaLQjHIF8Mvy8efH2C 1B7txohI1v8qJl3KNXrwd/jpsW/G8iM5I/shQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uBCAP/x0+TDkyIyOWsAh4+jywEPNozMxMND/23Kb53U=; b=ZhhCgfqxGr+lhv1u+qLQagRwTzkhZLglWQ8nVVFLy9kvTKkqlYR8xLqXOuN17rHQU+ oIeyu6a/J9dW3n+7zvJsi81iSUWd74S28gnsyUw9c0jLAeX2u/t7pdr4T8WZNJAy+Uxq y0/Vb+87T8H7AP5mdacpMNSdbGO3TBBwMx191z66iNBsqfSYZrlHAY3mLh0FN5SS7MK9 a4E0Ko0ytlHI0rovcvz7eSBTQn/2B7IKpVIpTxOyZN0CwHtTljMkL5hblocRiHhrxZHL 6d4otk0gMuA69Hjg9HkoJMpsG9LfkuoOzySUyGHprk0w5qcKSqbwRC9Mq5jLKgoIUA2e NtyA== X-Gm-Message-State: AKwxytdZFeYMELfPb2y9lBca8rrFbbMAuNp97eOoEA/35WnTF/RhUoOl y0HWQUUpl0swPz4+uUdjJU03/g== X-Received: by 10.101.77.208 with SMTP id q16mr7651706pgt.395.1516669497705; Mon, 22 Jan 2018 17:04:57 -0800 (PST) Received: from localhost.localdomain ([45.56.152.94]) by smtp.gmail.com with ESMTPSA id o20sm19294694pgv.85.2018.01.22.17.04.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Jan 2018 17:04:56 -0800 (PST) From: Shawn Guo To: Bjorn Helgaas Cc: Rob Herring , linux-pci@vger.kernel.org, devicetree@vger.kernel.org, project-aspen-dev@linaro.org, Jianguo Sun , Shawn Guo Subject: [PATCH] PCI: histb: add power control GPIO for PCIe slot Date: Tue, 23 Jan 2018 09:04:37 +0800 Message-Id: <1516669477-20151-1-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Jianguo Sun Besides the GPIO for controlling reset, there is also possibly another GPIO for turning on/off the power of PCIe slot. Let's add the support for that with another optional device tree property 'power-gpios'. Signed-off-by: Jianguo Sun Signed-off-by: Shawn Guo --- .../bindings/pci/hisilicon-histb-pcie.txt | 1 + drivers/pci/dwc/pcie-histb.c | 28 +++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt b/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt index c84bc027930b..597397a048f8 100644 --- a/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt +++ b/Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt @@ -33,6 +33,7 @@ Required properties "bus": bus reset. Optional properties: +- power-gpios: The gpio to control the power of PCIe slot. - reset-gpios: The gpio to generate PCIe PERST# assert and deassert signal. - phys: List of phandle and phy mode specifier, should be 0. - phy-names: Must be "phy". diff --git a/drivers/pci/dwc/pcie-histb.c b/drivers/pci/dwc/pcie-histb.c index 33b01b734d7d..2a6b18619b25 100644 --- a/drivers/pci/dwc/pcie-histb.c +++ b/drivers/pci/dwc/pcie-histb.c @@ -63,6 +63,7 @@ struct histb_pcie { struct reset_control *sys_reset; struct reset_control *bus_reset; void __iomem *ctrl; + int power_gpio; int reset_gpio; }; @@ -230,6 +231,8 @@ static void histb_pcie_host_disable(struct histb_pcie *hipcie) if (gpio_is_valid(hipcie->reset_gpio)) gpio_set_value_cansleep(hipcie->reset_gpio, 0); + if (gpio_is_valid(hipcie->power_gpio)) + gpio_set_value_cansleep(hipcie->power_gpio, 0); } static int histb_pcie_host_enable(struct pcie_port *pp) @@ -240,8 +243,14 @@ static int histb_pcie_host_enable(struct pcie_port *pp) int ret; /* power on PCIe device if have */ - if (gpio_is_valid(hipcie->reset_gpio)) + if (gpio_is_valid(hipcie->power_gpio)) + gpio_set_value_cansleep(hipcie->power_gpio, 1); + + if (gpio_is_valid(hipcie->reset_gpio)) { + gpio_set_value_cansleep(hipcie->reset_gpio, 0); + mdelay(10); gpio_set_value_cansleep(hipcie->reset_gpio, 1); + } ret = clk_prepare_enable(hipcie->bus_clk); if (ret) { @@ -335,15 +344,28 @@ static int histb_pcie_probe(struct platform_device *pdev) return PTR_ERR(pci->dbi_base); } + hipcie->power_gpio = of_get_named_gpio_flags(np, + "power-gpios", 0, &of_flags); + if (of_flags & OF_GPIO_ACTIVE_LOW) + flag |= GPIOF_ACTIVE_LOW; + if (gpio_is_valid(hipcie->power_gpio)) { + ret = devm_gpio_request_one(dev, hipcie->power_gpio, + flag, "PCIe device power control"); + if (ret) { + dev_err(dev, "unable to request power gpio\n"); + return ret; + } + } + 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"); + flag, "PCIe device reset control"); if (ret) { - dev_err(dev, "unable to request gpio\n"); + dev_err(dev, "unable to request reset gpio\n"); return ret; } }