From patchwork Tue Mar 14 15:18:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9623721 X-Patchwork-Delegate: bhelgaas@google.com 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 0053E604CC for ; Tue, 14 Mar 2017 15:19:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6A572859F for ; Tue, 14 Mar 2017 15:19:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB1D2285A4; Tue, 14 Mar 2017 15:19:45 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E6D32859F for ; Tue, 14 Mar 2017 15:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752154AbdCNPTb (ORCPT ); Tue, 14 Mar 2017 11:19:31 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:36473 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752650AbdCNPSi (ORCPT ); Tue, 14 Mar 2017 11:18:38 -0400 Received: by mail-pg0-f67.google.com with SMTP id m5so749416pgk.3; Tue, 14 Mar 2017 08:18:37 -0700 (PDT) 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=IQAElJh+gHuH7JMAgsRGMzu7WYCYN/OMDoSBFWd1mgU=; b=QSpkjj9B3CLVDomLSnCJAzEFvdNvMzNhwv5XyOCcANVo0IOB3gywzs7gbvLEIj52MK N7a8f3r22hDjIGQ1eX0Zj03kyJXj7RQxtMi8kp06OrnJox3Max/yGRgu2/aXtkOklf3n /7VdCtCbqhmYz4OYOSMEdQ4rDT7Ue4QyUZLpN6zJISMrcqadjCW9TBO/uzWALIN2ZtRG LyrjxcfhW7XfmC7c47UIUV8oQEEHgycvqaWjutOmFWXdM2NY0VWrWrDQrov9gvTSiW7c fJvKXbGg1T3YE60CYVpKXoT6OTWnfoMIAl5KdzOgRuJ61if0x2oL0HYNPug/HB1QkjzD d1HA== 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=IQAElJh+gHuH7JMAgsRGMzu7WYCYN/OMDoSBFWd1mgU=; b=G78Xb5Nrnb9mzQHM9lUF3lO91LJ0o2PcHMtzvciYOUXp03DEfYPPxG2kRW94V6pYy/ lEoVSwyxI6jY/i5eIL2eFRgA/vCFrzw/Z0mFkEQyNLPVG2aVw9XGXP610eweq7jbBU8w c4xz7mwp9a4JCOOWSin2VeTsFjsWm5SjlJ/67P0/Qec6QvcjyWuuozGG+8zZrNcYca1w dCLlqO7gKtwHqMVjoku6KD8cegl75sjWBJV0CA4JTggTCV60sbP+8nRLiwvXW0VlsCX7 d1xO9N7fxGqitdwvTGtubIUHAvTdbq6zr1Pc55kniqRZ0xViaczx+dmp1kgHIU/hwf9c 1ppA== X-Gm-Message-State: AMke39nUd17MZNad7OxNDaC8JoZphH04nr+E4fRbJZG4AkcruXs9zjygBp/SE0uv3mCO2Q== X-Received: by 10.99.177.6 with SMTP id r6mr43582349pgf.61.1489504716865; Tue, 14 Mar 2017 08:18:36 -0700 (PDT) Received: from squirtle.lan ([2601:602:9400:8377:f0f2:a63b:2597:b3d9]) by smtp.gmail.com with ESMTPSA id m6sm39248277pfm.22.2017.03.14.08.18.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 08:18:36 -0700 (PDT) From: Andrey Smirnov To: linux-pci@vger.kernel.org Cc: Andrey Smirnov , yurovsky@gmail.com, Lucas Stach , Bjorn Helgaas , Fabio Estevam , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/4] PCI: imx6: Allow probe deferal by reset GPIO Date: Tue, 14 Mar 2017 08:18:27 -0700 Message-Id: <20170314151827.31248-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170314151827.31248-1-andrew.smirnov@gmail.com> References: <20170314151827.31248-1-andrew.smirnov@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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 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);