From patchwork Fri Nov 7 13:27:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 5252641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 48CC89F3ED for ; Fri, 7 Nov 2014 13:31:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 782B1200F3 for ; Fri, 7 Nov 2014 13:31:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B4B520131 for ; Fri, 7 Nov 2014 13:31:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmjbM-00046V-58; Fri, 07 Nov 2014 13:29:20 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xmjai-0003kE-HA for linux-arm-kernel@lists.infradead.org; Fri, 07 Nov 2014 13:28:41 +0000 Received: by mail-wg0-f49.google.com with SMTP id x13so3704020wgg.36 for ; Fri, 07 Nov 2014 05:28:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7AXrXok6Q1kvmTjAYGj65Uw+4ZHkUGAq7bLI5H2ys70=; b=WCjRYh2W3FCtWabKEnheM8F7knLXrBqtP5CztvfRMauyUpu7uVE+bTgCDWDg8ePPPK ZU34evNzWTgZ1AukrIE+uEq3hg+EiVJvNBzEijuRwoxZevbkTDTbagR2KNyDvbtUDoRC FVtMAfMEvztBSETUavpLLPnj+KNgkmQdJ8JNOSTQhV5bz4q1VZxYaa9nh6d9LDXk2gBh o6HAlMOGhFk2xw9YZhW/E93x533j2n2svTHlW28SdNgUI62JIoTgtAjZ3bOtd/RUjf8M o2BUiDWqATnhEG2vrDu5v32gkhRePWOuc2bNavO4rDKI1RA9GXbmXnULM2dclonqIwHC gfKA== X-Gm-Message-State: ALoCoQnRe+kDZJZFd70jXPERlpn7YZ3EOUdNfjkkHHGnGDpQKU9NhG/KZDF6M1f+nj2pNi+vIU3Q X-Received: by 10.194.60.198 with SMTP id j6mr16423254wjr.30.1415366898290; Fri, 07 Nov 2014 05:28:18 -0800 (PST) Received: from tn-HP-4.semihalf.com ([80.82.22.190]) by mx.google.com with ESMTPSA id ce1sm11833490wjc.2.2014.11.07.05.28.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Nov 2014 05:28:17 -0800 (PST) From: Tomasz Nowicki To: catalin.marinas@arm.com, will.deacon@arm.com, bhelgaas@google.com, Liviu.Dudau@arm.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, rjw@rjwysocki.net Subject: [RFC PATCH 3/4] arm64, acpi, pci: Add arch specific functions for mmconfig driver. Date: Fri, 7 Nov 2014 14:27:55 +0100 Message-Id: <1415366876-30811-4-git-send-email-tomasz.nowicki@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415366876-30811-1-git-send-email-tomasz.nowicki@linaro.org> References: <1415366876-30811-1-git-send-email-tomasz.nowicki@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141107_052840_743292_6CF71FEA X-CRM114-Status: GOOD ( 14.88 ) X-Spam-Score: -0.7 (/) Cc: linaro-acpi@lists.linaro.org, linux-pci@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Tomasz Nowicki , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY 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 These calls allow to map/unmap PCI config space ranges (which are specified in MMCFG ACPI table). Signed-off-by: Tomasz Nowicki --- arch/arm64/Kconfig | 3 ++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/mmconfig.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 arch/arm64/kernel/mmconfig.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index aee6a60..f2bcb58 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -186,6 +186,9 @@ config PCI_DOMAINS_GENERIC config PCI_SYSCALL def_bool PCI +config PCI_MMCONFIG + def_bool PCI && ACPI + source "drivers/pci/Kconfig" source "drivers/pci/pcie/Kconfig" source "drivers/pci/hotplug/Kconfig" diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f48e3f7..ec576e6 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -32,6 +32,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o arm64-obj-$(CONFIG_PCI) += pci.o arm64-obj-$(CONFIG_ACPI) += acpi.o +arm64-obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/mmconfig.c b/arch/arm64/kernel/mmconfig.c new file mode 100644 index 0000000..b0ca0ec --- /dev/null +++ b/arch/arm64/kernel/mmconfig.c @@ -0,0 +1,69 @@ +/* + * mmconfig.c - Low-level direct PCI config space access via MMCONFIG + * + * This is an ARM64 version that allows the mmconfig space to be mapped. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + */ + +#include + +#define PREFIX "PCI: " + +static void __iomem *mcfg_ioremap(struct pci_mmcfg_region *cfg) +{ + void __iomem *addr; + u64 start, size; + int num_buses; + + start = cfg->address + PCI_MMCFG_BUS_OFFSET(cfg->start_bus); + num_buses = cfg->end_bus - cfg->start_bus + 1; + size = PCI_MMCFG_BUS_OFFSET(num_buses); + addr = ioremap_nocache(start, size); + if (addr) + addr -= PCI_MMCFG_BUS_OFFSET(cfg->start_bus); + return addr; +} + +int __init pci_mmcfg_arch_init(void) +{ + struct pci_mmcfg_region *cfg; + + list_for_each_entry(cfg, &pci_mmcfg_list, list) + if (pci_mmcfg_arch_map(cfg)) { + pci_mmcfg_arch_free(); + return 0; + } + + return 1; +} + +void __init pci_mmcfg_arch_free(void) +{ + struct pci_mmcfg_region *cfg; + + list_for_each_entry(cfg, &pci_mmcfg_list, list) + pci_mmcfg_arch_unmap(cfg); +} + +int pci_mmcfg_arch_map(struct pci_mmcfg_region *cfg) +{ + cfg->virt = mcfg_ioremap(cfg); + if (!cfg->virt) { + pr_err(PREFIX "can't map MMCONFIG at %pR\n", &cfg->res); + return -ENOMEM; + } + + return 0; +} + +void pci_mmcfg_arch_unmap(struct pci_mmcfg_region *cfg) +{ + if (cfg && cfg->virt) { + iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus)); + cfg->virt = NULL; + } +}