From patchwork Tue Mar 28 15:42:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9650017 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 BDF8F60113 for ; Tue, 28 Mar 2017 15:44:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0ABD283C9 for ; Tue, 28 Mar 2017 15:44:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5038283E8; Tue, 28 Mar 2017 15:44:04 +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=unavailable 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 50B7C283FF for ; Tue, 28 Mar 2017 15:44:04 +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=qRRHXBJwk3xsgkCyantTBtsm7Eu/6RnY5J2jrkR9i5k=; b=qUW1q9wB1IIxU/IGZ/3OU0epH8 fdByfigUNg8Kp6FN06/PnEFlVMoOGsRTitCpY/BsKznX2i1wwnUgZtXiM11fa4JnnQ5zqtpdPY2+I k6lgtPGMoQqYGOEKF/vN1Q4gion0Gvzpv21x37CsiDKohW7PDMcy+tYHLloNDpBD0dGthNw3a61Qk dWcR1pSfxpKgVq3relg2LMk3PkYxKLV4D2TXqdNyZeWAcyXrt1bHPDeWWzdYH1r4pG04+N+PE4uqH GgqhFQxP/neKDKiIwy7YSr8OgQNGhHRFtiOQz7RZI01VVJBGT9xVQmdtBRXU+/+mXxmPn7PUiyHLk WDvH18jg==; 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 1cstHu-0005My-OU; Tue, 28 Mar 2017 15:44:02 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cstHK-0004Yb-VD for linux-arm-kernel@lists.infradead.org; Tue, 28 Mar 2017 15:43:31 +0000 Received: by mail-pg0-x242.google.com with SMTP id o123so19503014pga.1 for ; Tue, 28 Mar 2017 08:43:06 -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=oyeASCgHViqQ8dIW4tIGwuKMGiLzv4gZDGttbK3sijU=; b=Mj5y+VIUKAFQrSrHWm1cicxFBUO0AJvwp6sz2S6SpTHSLVQ90ERO0+w0M/I6TN7/Y+ HCFMkrhu0i8DyTKhjbU06Mn4TivOiGxBoTNIfsC5g+8puMc3CifZNKGBjR/Z1B0eNciO Y7odZjGkmB9faKDK3/E2AWmcNHg/BGNdQzr/BIHWbzfzABl633nEbw1H7NnjB4vPnyah LUPM5yG+FjoJkmmgcL4kJUdoo/MDYZ/bmY+JgzHgx2iLGplYgTGrDa30EcsqFLDI4i+5 8aNHuK7LUFNCnbVOO6+4qstxcwMUcC4qDkaHSFLX7oQ+B9YcrnaPdwse9zfMxcHFs7Y+ ODBQ== 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=oyeASCgHViqQ8dIW4tIGwuKMGiLzv4gZDGttbK3sijU=; b=bdgv8wGHzeKFMGEX42HKOjo7dFUCIhyS3z6KluYOW2brsEYZaH6hI7ATb8rF/IPriG HXwxUADkuP9uvL06+xS2NauUK7y9ZGTWRbIgwC7J6Sn0opGpK1Af5fxuwNVh0BLRaQYb zfgeXwyniO9MlgUqDr/+N8RC2z023HfHaYkkm1KixHUY3XJLN/4IcCR4ujs8uwsTDlSn m8gJa0W5HEvDrUAdX3osa2fbM/pzAfbKuhEEA5V4PZOJ6TE2L2qM3A9N93W+kXQuMAd2 HAyCnoao4oplVZ4msn+zi8niH9gnlVTzM9QxyYCp90RM0hh/eSjgWtN9slJECikXvTGZ +5DQ== X-Gm-Message-State: AFeK/H0oMibm+7VD0G3sGIgbCj6RJfB/2fuqa7Kl5OR6tsBMYfZZWq17mccgFUHri6H76Q== X-Received: by 10.84.150.131 with SMTP id h3mr10167341plh.38.1490715786097; Tue, 28 Mar 2017 08:43:06 -0700 (PDT) Received: from squirtle.lan (c-73-19-0-61.hsd1.wa.comcast.net. [73.19.0.61]) by smtp.gmail.com with ESMTPSA id e16sm8238865pfb.102.2017.03.28.08.43.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 08:43:05 -0700 (PDT) From: Andrey Smirnov To: Bjorn Helgaas Subject: [PATCH v8 2/4] PCI: imx6: Allow probe deferal by reset GPIO Date: Tue, 28 Mar 2017 08:42:50 -0700 Message-Id: <20170328154252.6902-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170328154252.6902-1-andrew.smirnov@gmail.com> References: <20170328154252.6902-1-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170328_084327_179740_B1056961 X-CRM114-Status: GOOD ( 16.16 ) 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: Dong Aisheng , Andrey Smirnov , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Fabio Estevam , 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: Fabio Estevam Cc: Dong Aisheng Cc: linux-pci@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Lucas Stach Signed-off-by: Andrey Smirnov --- drivers/pci/dwc/pci-imx6.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/pci/dwc/pci-imx6.c b/drivers/pci/dwc/pci-imx6.c index e0c36d6..64de9bb 100644 --- a/drivers/pci/dwc/pci-imx6.c +++ b/drivers/pci/dwc/pci-imx6.c @@ -595,8 +595,8 @@ static struct dw_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 dw_pcie *pci = imx6_pcie->pci; struct pcie_port *pp = &pci->pp; @@ -636,7 +636,7 @@ static const struct dw_pcie_ops dw_pcie_ops = { .link_up = imx6_pcie_link_up, }; -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 dw_pcie *pci; @@ -660,10 +660,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); pci->dbi_base = devm_ioremap_resource(dev, dbi_base); if (IS_ERR(pci->dbi_base)) @@ -683,6 +679,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 */ @@ -796,11 +794,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);