From patchwork Wed Jan 8 05:01:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minghuan Lian X-Patchwork-Id: 3451611 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7067CC02DC for ; Wed, 8 Jan 2014 05:02:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1DE4F2010E for ; Wed, 8 Jan 2014 05:02:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 092A5200D5 for ; Wed, 8 Jan 2014 05:01:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751456AbaAHFB6 (ORCPT ); Wed, 8 Jan 2014 00:01:58 -0500 Received: from co1ehsobe003.messaging.microsoft.com ([216.32.180.186]:44591 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751104AbaAHFB5 (ORCPT ); Wed, 8 Jan 2014 00:01:57 -0500 Received: from mail137-co1-R.bigfish.com (10.243.78.230) by CO1EHSOBE017.bigfish.com (10.243.66.80) with Microsoft SMTP Server id 14.1.225.22; Wed, 8 Jan 2014 05:01:57 +0000 Received: from mail137-co1 (localhost [127.0.0.1]) by mail137-co1-R.bigfish.com (Postfix) with ESMTP id 1D9E480013D; Wed, 8 Jan 2014 05:01:57 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: -1 X-BigFish: VS-1(zz154dIzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah1fc6hzz1de098h17326ah8275bh8275dh1de097h186068hz2dh2a8h839he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h2327h2336h1155h) Received: from mail137-co1 (localhost.localdomain [127.0.0.1]) by mail137-co1 (MessageSwitch) id 1389157314999248_16996; Wed, 8 Jan 2014 05:01:54 +0000 (UTC) Received: from CO1EHSMHS002.bigfish.com (unknown [10.243.78.252]) by mail137-co1.bigfish.com (Postfix) with ESMTP id E4F242A01DB; Wed, 8 Jan 2014 05:01:54 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS002.bigfish.com (10.243.66.12) with Microsoft SMTP Server (TLS) id 14.16.227.3; Wed, 8 Jan 2014 05:01:54 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.3.158.2; Wed, 8 Jan 2014 05:01:53 +0000 Received: from lmh.ap.freescale.net (lmh.ap.freescale.net [10.193.20.65]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s0851V2I018463; Tue, 7 Jan 2014 22:01:51 -0700 From: Minghuan Lian To: CC: Zang Roy-R61911 , Scott Wood , Kumar Gala , Bjorn Helgaas , , Minghuan Lian Subject: [PATCH 07/12][v4] pci: fsl: port PCI platform driver Date: Wed, 8 Jan 2014 13:01:58 +0800 Message-ID: <1389157323-3088-7-git-send-email-Minghuan.Lian@freescale.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1389157323-3088-1-git-send-email-Minghuan.Lian@freescale.com> References: <1389157323-3088-1-git-send-email-Minghuan.Lian@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, UNRESOLVED_TEMPLATE 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 1. The patch ports FSL PCI platform driver. probe function initialize fsl_pci and register it to architecture PCI system, remove function removes fsl_pci from architecture PCI system. fsl_arch_pci_sys_register() and fsl_arch_pci_sys_remove() should be implemented in architecture-specific driver to provide register/remove functionality. 2. Remove architecture-specific header and unnecessary header. 3. Change Kconfig and Makefile to support FSL PCI common driver Signed-off-by: Minghuan Lian --- change log: v4: no change v1-v3: Derived from http://patchwork.ozlabs.org/patch/278965/ Based on upstream master. Based on the discussion of RFC version here http://patchwork.ozlabs.org/patch/274487/ arch/powerpc/Kconfig | 1 + drivers/pci/host/Kconfig | 10 +++++++++ drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-fsl-common.c | 43 +++++++++++++++++++++++++++++++-------- include/linux/fsl/pci-common.h | 6 ++++++ 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b44b52c..c708d80 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -694,6 +694,7 @@ config FSL_SOC config FSL_PCI bool + select PCI_FSL_COMMON if FSL_SOC_BOOKE || PPC_86xx select PPC_INDIRECT_PCI select PCI_QUIRKS diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index 47d46c6..290afaa 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig @@ -33,4 +33,14 @@ config PCI_RCAR_GEN2 There are 3 internal PCI controllers available with a single built-in EHCI/OHCI host controller present on each one. +config PCI_FSL_COMMON + bool "Common driver for Freescale PCI/PCIe controller" + depends on FSL_SOC_BOOKE || PPC_86xx + help + This driver provides common support for PCI/PCIE controller + on Freescale embedded processors 85xx/86xx/QorIQ/Layerscape. + Additional drivers must be enabled in order to provide some + architecture-dependent functions and register the controller + to PCI subsystem. + endmenu diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile index 13fb333..1f8de80 100644 --- a/drivers/pci/host/Makefile +++ b/drivers/pci/host/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_PCI_IMX6) += pci-imx6.o obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o +obj-$(CONFIG_PCI_FSL_COMMON) += pci-fsl-common.o diff --git a/drivers/pci/host/pci-fsl-common.c b/drivers/pci/host/pci-fsl-common.c index 7184ac7..d608550 100644 --- a/drivers/pci/host/pci-fsl-common.c +++ b/drivers/pci/host/pci-fsl-common.c @@ -16,16 +16,12 @@ */ #include #include -#include -#include #include -#include #include #include -#include -#include #include #include +#include #include #include @@ -665,12 +661,40 @@ static const struct of_device_id pci_ids[] = { static int fsl_pci_probe(struct platform_device *pdev) { int ret; - struct device_node *node; + struct fsl_pci *pci; - node = pdev->dev.of_node; - ret = fsl_add_bridge(pdev, fsl_pci_primary == node); + if (!of_device_is_available(pdev->dev.of_node)) { + dev_dbg(&pdev->dev, "disabled\n"); + return -ENODEV; + } + + pci = devm_kzalloc(&pdev->dev, sizeof(*pci), GFP_KERNEL); + if (!pci) { + dev_err(&pdev->dev, "no memory for fsl_pci\n"); + return -ENOMEM; + } + + ret = fsl_pci_setup(pdev, pci); + if (ret) + return ret; + + ret = fsl_arch_pci_sys_register(pci); + if (ret) { + dev_err(&pdev->dev, "failed to register pcie to Arch\n"); + return ret; + } + + return 0; +} + +static int fsl_pci_remove(struct platform_device *pdev) +{ + struct fsl_pci *pci = platform_get_drvdata(pdev); + + if (!pci) + return -ENODEV; - mpc85xx_pci_err_probe(pdev); + fsl_arch_pci_sys_remove(pci); return 0; } @@ -714,6 +738,7 @@ static struct platform_driver fsl_pci_driver = { .of_match_table = pci_ids, }, .probe = fsl_pci_probe, + .remove = fsl_pci_remove, }; static int __init fsl_pci_init(void) diff --git a/include/linux/fsl/pci-common.h b/include/linux/fsl/pci-common.h index 02bcf5b..8d33354 100644 --- a/include/linux/fsl/pci-common.h +++ b/include/linux/fsl/pci-common.h @@ -166,5 +166,11 @@ extern struct pci_bus *fsl_arch_fake_pci_bus(struct fsl_pci *pci, int busnr); /* Return PCI64 DMA offset */ u64 fsl_arch_pci64_dma_offset(void); +/* Register PCI/PCIe controller to architecture system */ +extern int fsl_arch_pci_sys_register(struct fsl_pci *pci); + +/* Remove PCI/PCIe controller from architecture system */ +extern void fsl_arch_pci_sys_remove(struct fsl_pci *pci); + #endif /* __PCI_COMMON_H */ #endif /* __KERNEL__ */