Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp161525yba; Tue, 23 Apr 2019 21:58:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrhc61Ee31EJjs1x1OhKe38Bl1qRAcmHWUpOm/tYBxPr2W9UHaeNobNgAWEpdjDtigqbFR X-Received: by 2002:a17:902:2b88:: with SMTP id l8mr30176618plb.262.1556081910097; Tue, 23 Apr 2019 21:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556081910; cv=none; d=google.com; s=arc-20160816; b=MzGIlVUUj8bLkVkSnlGnWU/IXTvQcNQYIunI4GfiWPS3mzrqOore3C3ZGKPoFXl+4S LFDpVMeVJs533uemOwe95QvP7VU2baNSHoFNkn3aE0g6cmEGVU1MhnX3rhXG+VIsHKak Om4RbGc8p3+Fq8TiCEcUrtaQaGob8ABjrfYxP62QVQf52Y77dSAXDCBG2Bv/J2wnTTEo qpKNt4PgCYKyYFUqKxv1P1KwQYPC/4ReGtBzcCIHu/+ObLhiD6hC7OBetRTy6+GkMmE0 0W74mjHzWz9FFdNfUvLo5+2et4ZuMuebfnNhrXldo1NLShlrHsAt/wLh8hZ6E0XvtKiM BFgw== 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; bh=aOYO14lSh5IPNA+8mvkCDlrk5n8QX+wicRYvOQYS18w=; b=CNd2eX3ptwC2a1e/iwoOcoN11nnQ8JpKWj3F40fbsXlkq7PEdzk7zOPaYwFamdngmT fcSBE9H4HW4ycJVYT2vEtHLqqZ3meYcv+SDCk11QpfDta6t8dn88ii4jhS54DW7VqKN9 j8lNDkp8X3y/lLuUsnEpdIHhhlbmm8nVwhPeZGRzO7vJjRc/3X6LaNJN8blEWCg5idUP ayNS6zg8ZAuYPoY1egYBudyhggfxGTXQJe1/RLNN6XbjQZLhLYmSlQ40QqWQpnjvSFMO fYKOjfiWaLHAO+XjXC8AmgNLQC6kvFo4zBsCOvs5ktZj2b4yPZ/oFw3DfTuL6XaXKHmx ehuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si11491621pgd.223.2019.04.23.21.58.14; Tue, 23 Apr 2019 21:58:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729156AbfDXE5V (ORCPT + 99 others); Wed, 24 Apr 2019 00:57:21 -0400 Received: from mga05.intel.com ([192.55.52.43]:50503 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbfDXE5U (ORCPT ); Wed, 24 Apr 2019 00:57:20 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2019 21:57:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,388,1549958400"; d="scan'208";a="340242633" Received: from lftan-mobl.gar.corp.intel.com (HELO ubuntu) ([10.226.248.116]) by fmsmga005.fm.intel.com with SMTP; 23 Apr 2019 21:57:17 -0700 Received: by ubuntu (sSMTP sendmail emulation); Wed, 24 Apr 2019 12:57:16 +0800 From: Ley Foon Tan To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, lftan.linux@gmail.com, Ley Foon Tan Subject: [PATCH] PCI: altera: Allow building as module Date: Wed, 24 Apr 2019 12:57:14 +0800 Message-Id: <1556081835-12921-1-git-send-email-ley.foon.tan@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Altera PCIe Rootport IP is a soft IP and is only available after FPGA image is programmed. Make driver modulable to support use case FPGA image is programmed after kernel is booted. User proram FPGA image in kernel then only load PCIe driver module. Signed-off-by: Ley Foon Tan --- drivers/pci/controller/Kconfig | 2 +- drivers/pci/controller/pcie-altera.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index 6012f3059acd..4b550f9cdd56 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -174,7 +174,7 @@ config PCIE_IPROC_MSI PCIe controller config PCIE_ALTERA - bool "Altera PCIe controller" + tristate "Altera PCIe controller" depends on ARM || NIOS2 || ARM64 || COMPILE_TEST help Say Y here if you want to enable PCIe controller support on Altera diff --git a/drivers/pci/controller/pcie-altera.c b/drivers/pci/controller/pcie-altera.c index 27edcebd1726..6c86bc69ace8 100644 --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -705,6 +706,13 @@ static int altera_pcie_init_irq_domain(struct altera_pcie *pcie) return 0; } +static int altera_pcie_irq_teardown(struct altera_pcie *pcie) +{ + irq_set_chained_handler_and_data(pcie->irq, NULL, NULL); + irq_domain_remove(pcie->irq_domain); + irq_dispose_mapping(pcie->irq); +} + static int altera_pcie_parse_dt(struct altera_pcie *pcie) { struct device *dev = &pcie->pdev->dev; @@ -798,6 +806,7 @@ static int altera_pcie_probe(struct platform_device *pdev) pcie = pci_host_bridge_priv(bridge); pcie->pdev = pdev; + platform_set_drvdata(pdev, pcie); match = of_match_device(altera_pcie_of_match, &pdev->dev); if (!match) @@ -855,13 +864,28 @@ static int altera_pcie_probe(struct platform_device *pdev) return ret; } +static int altera_pcie_remove(struct platform_device *pdev) +{ + struct altera_pcie *pcie = platform_get_drvdata(pdev); + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); + + pci_stop_root_bus(bridge->bus); + pci_remove_root_bus(bridge->bus); + pci_free_resource_list(&pcie->resources); + altera_pcie_irq_teardown(pcie); + + return 0; +} + static struct platform_driver altera_pcie_driver = { .probe = altera_pcie_probe, + .remove = altera_pcie_remove, .driver = { .name = "altera-pcie", .of_match_table = altera_pcie_of_match, - .suppress_bind_attrs = true, }, }; -builtin_platform_driver(altera_pcie_driver); +MODULE_DEVICE_TABLE(of, altera_pcie_of_match); +module_platform_driver(altera_pcie_driver); +MODULE_LICENSE("GPL v2"); -- 2.19.0