From patchwork Mon Feb 20 15:30:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9583089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA113604A0 for ; Mon, 20 Feb 2017 15:32:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BB3428434 for ; Mon, 20 Feb 2017 15:32:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 909A728477; Mon, 20 Feb 2017 15:32:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 41A6A28434 for ; Mon, 20 Feb 2017 15:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n31R6KeR9P7jZf5oxYepcG5EzHguZHy0fRdrYX4Lpuo=; b=PPzTz1sHBEF+IMMdNkqsH8RI7f 5AZqWe6RM3YBR+bqosUscV/JA2yHSOUq1WBszJ817/BfEXeoyD0SoP3C1t73qVzZlVc1DRKlduA8T t9CULQezya94RL6qyX66WmnS1mP1kel12cZmy3ZThhOEOlWnolADfRskclryBiTBzutAYqDLRs9Ud GFYBNW3CsZHWxWyQ+zmsUpLK8IJOoj5aVH+ndfYvHzkD53EY37UHYwCVaYMEni82m/IpCDo+gEIrh GQ6V2pgeOLNXZHsL8lxxGSjq7499LnM9GftWVNm8m6I7kEYDT8Uu835NK34kCDVekeV7Dme+K2ZVo FImhBlVw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cfpwg-0007Bm-2J; Mon, 20 Feb 2017 15:32:10 +0000 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cfpvX-0006cf-0D for linux-arm-kernel@lists.infradead.org; Mon, 20 Feb 2017 15:31:02 +0000 Received: by mail-pg0-x244.google.com with SMTP id s67so2788918pgb.1 for ; Mon, 20 Feb 2017 07:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N/RX2NDxIfdk5iAVhOAuvlfMvQVorpiMahRUad7mryc=; b=IyLuswRBvELMjLwgQSe51WPek8GAyQowBnxwcxI3b/ydBnzMi0OgG1zJpAJhUehQMa TTXQ2SxVVGydBPv8lHyHQLOUvUbrNEmKiX5GWV/QjZSwjstZst/DDXUu8pIwOrnOq0SW ciqbklYug511uoeBmK4ea1+QP70Kdmu95m4jgwUl87T3obWtNaqUqXASnupHbj8qoJoN LY5FO5EIL527oNXznErz0IQmnnO+DpeSgPkSoeftiW29mPXo8P/sdQpN5M0pmBBMU+LV nkTzT6rPn7Dh9f/n1WTgegzFwb3IpEXjQ8h8RBFVH5KRkPpk024tQDZ7LkfIeZjUks3b NCcw== 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:in-reply-to :references; bh=N/RX2NDxIfdk5iAVhOAuvlfMvQVorpiMahRUad7mryc=; b=jtE5JgEcWCQkOdTPiqdh/5zpF5fq/fAIgPZMs2IeXxldDlwfT0rotWyNa3Wb7Tnf6+ Po1dpWzqpMJayoPqUZvbEdRT2Hbx81bcCCF1mYSv5jZfRgIgzNMzjCmiURKUR4D5dPSx XF17PiTkSD8+4T540WqgpBh0pT+0j9m/rmaOvamto7TXfhYEJ3RFmZuQetuKhEtqWmGT zKj8UDlqgV9LROci7+fXTbN6AV13lpvOBKBSQvKBwYhQVHmjbhuh29lDqFShFDDkGKFB a4TiDD0ckbj9EKKU2sFtA/JSC1cyidEKzAgsfg940NWIA2qakABq9nwM86WvIbLNVGLC tWqw== X-Gm-Message-State: AMke39kGjc80CUQftIEpSk9fZzvl1EOIcimyUPlxR3FVrLzwdPrYg5HwvW+QIP/pwm8HAA== X-Received: by 10.98.89.21 with SMTP id n21mr26952624pfb.163.1487604638121; Mon, 20 Feb 2017 07:30:38 -0800 (PST) Received: from localhost.localdomain (c-73-19-0-61.hsd1.wa.comcast.net. [73.19.0.61]) by smtp.gmail.com with ESMTPSA id 67sm35815004pfd.120.2017.02.20.07.30.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Feb 2017 07:30:37 -0800 (PST) From: Andrey Smirnov To: linux-pci@vger.kernel.org Subject: [PATCH v5 4/4] PCI: imx6: Allow probe deferal by reset GPIO Date: Mon, 20 Feb 2017 07:30:25 -0800 Message-Id: <20170220153025.32096-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170220153025.32096-1-andrew.smirnov@gmail.com> References: <20170220153025.32096-1-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170220_073059_163548_30563AEC X-CRM114-Status: GOOD ( 15.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Smirnov , linux-kernel@vger.kernel.org, Fabio Estevam , Bjorn Helgaas , yurovsky@gmail.com, linux-arm-kernel@lists.infradead.org, Lucas Stach MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some designs implement reset GPIO via a GPIO expander connected to a peripheral bus. One such example would be i.MX7 Sabre board where said GPIO is provided by SPI shift register connected to a bitbanged SPI bus. In order to support such designs allow reset GPIO request to defer probing of the driver. Cc: yurovsky@gmail.com Cc: Lucas Stach Cc: Bjorn Helgaas Cc: Fabio Estevam Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Lucas Stach Signed-off-by: Andrey Smirnov --- drivers/pci/host/pci-imx6.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index 071251f3..fe832e7f 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -638,8 +638,8 @@ static struct pcie_host_ops imx6_pcie_host_ops = { .host_init = imx6_pcie_host_init, }; -static int __init imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, - struct platform_device *pdev) +static int imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, + struct platform_device *pdev) { struct pcie_port *pp = &imx6_pcie->pp; struct device *dev = pp->dev; @@ -674,7 +674,7 @@ static int __init imx6_add_pcie_port(struct imx6_pcie *imx6_pcie, return 0; } -static int __init imx6_pcie_probe(struct platform_device *pdev) +static int imx6_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct imx6_pcie *imx6_pcie; @@ -693,10 +693,6 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) imx6_pcie->variant = (enum imx6_pcie_variants)of_device_get_match_data(dev); - /* Added for PCI abort handling */ - hook_fault_code(16 + 6, imx6q_pcie_abort_handler, SIGBUS, 0, - "imprecise external abort"); - dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0); pp->dbi_base = devm_ioremap_resource(dev, dbi_base); if (IS_ERR(pp->dbi_base)) @@ -716,6 +712,8 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) dev_err(dev, "unable to get reset gpio\n"); return ret; } + } else if (imx6_pcie->reset_gpio == -EPROBE_DEFER) { + return imx6_pcie->reset_gpio; } /* Fetch clocks */ @@ -828,11 +826,22 @@ static struct platform_driver imx6_pcie_driver = { .name = "imx6q-pcie", .of_match_table = imx6_pcie_of_match, }, + .probe = imx6_pcie_probe, .shutdown = imx6_pcie_shutdown, }; static int __init imx6_pcie_init(void) { - return platform_driver_probe(&imx6_pcie_driver, imx6_pcie_probe); + /* + * Since probe() can be deferred we need to make sure that + * hook_fault_code is not called after __init memory is freed + * by kernel and since imx6q_pcie_abort_handler() is a no-op + * we can install the handler here without risking it + * accessing some unitialized driver state + */ + hook_fault_code(16 + 6, imx6q_pcie_abort_handler, SIGBUS, 0, + "imprecise external abort"); + + return platform_driver_register(&imx6_pcie_driver); } device_initcall(imx6_pcie_init);