From patchwork Tue Aug 12 16:26:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 35300 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 97B10203C5 for ; Tue, 12 Aug 2014 16:43:13 +0000 (UTC) Received: by mail-oi0-f70.google.com with SMTP id u20sf40538952oif.1 for ; Tue, 12 Aug 2014 09:43:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=65UPi75/ZvRL5G4//LemfbBelWawGXqCkO2Y7mf2u3E=; b=FvR/vgwIOGB1bV4GymjRubupD8oR0YE22Zn/yGPmvVkV2ipBJSRLI8rylnp1JIX84R EZe6O3UqSlnjxILrUQ7rNFYiwPfJbDkKzrPTGwH3UqnVfRCI8bbiay/dnsgqj4yGzUa8 oVVx9PXzHxhaxqW1gpl9f4DiNLdlIYJzhiQCVwx26QBg1g9NgoY6fjzMpXZ/SEffTT3Z SUVsNiiyWLYcN2+QdnnwbcpAn0eVCaO4hNxOx0vJr8fl0thipEuWGSh/5gzAdUuuM54P oRLJDzorDS4HTftqv/RAPfKSldSGnov0xA39mF14OqQ28wiLziJu3fNL+HqSOHGriYPC Jhng== X-Gm-Message-State: ALoCoQkfAk94WETixV/NWz0D7K0/1P2pznW+w4jt0FvDmPHmRaEfv9HYDTRxLEs//vsm96ukxXIE X-Received: by 10.42.97.138 with SMTP id o10mr569627icn.33.1407861793163; Tue, 12 Aug 2014 09:43:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.176 with SMTP id t45ls204768qgt.60.gmail; Tue, 12 Aug 2014 09:43:13 -0700 (PDT) X-Received: by 10.220.116.196 with SMTP id n4mr5155885vcq.6.1407861793014; Tue, 12 Aug 2014 09:43:13 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id xs2si8546222vdc.22.2014.08.12.09.43.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 09:43:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so13750551vcb.13 for ; Tue, 12 Aug 2014 09:43:12 -0700 (PDT) X-Received: by 10.52.3.40 with SMTP id 8mr24769746vdz.24.1407861792890; Tue, 12 Aug 2014 09:43:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp263788vcb; Tue, 12 Aug 2014 09:43:12 -0700 (PDT) X-Received: by 10.70.40.201 with SMTP id z9mr3122401pdk.55.1407861791540; Tue, 12 Aug 2014 09:43:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ev6si16457530pac.56.2014.08.12.09.43.10 for ; Tue, 12 Aug 2014 09:43:11 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753966AbaHLQnI (ORCPT + 26 others); Tue, 12 Aug 2014 12:43:08 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:51326 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753791AbaHLQnE (ORCPT ); Tue, 12 Aug 2014 12:43:04 -0400 Received: from e106497-lin.cambridge.arm.com (e106497-lin.cambridge.arm.com [10.1.195.53]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id s7CGQ0GL026972; Tue, 12 Aug 2014 17:26:01 +0100 From: Liviu Dudau To: Bjorn Helgaas , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Arnd Bergmann , Russell King , Tanmay Inamdar , Grant Likely , Sinan Kaya , Jingoo Han , Kukjin Kim , Suravee Suthikulanit , linux-pci Cc: LKML , LAKML Subject: [PATCH v9] arm64: Add architectural support for PCIe Date: Tue, 12 Aug 2014 17:26:00 +0100 Message-Id: <1407860760-25252-2-git-send-email-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1407860760-25252-1-git-send-email-Liviu.Dudau@arm.com> References: <1407860760-25252-1-git-send-email-Liviu.Dudau@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: liviu.dudau@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use the generic PCI domain and host bridge functions to provide support for PCI Express on arm64. Signed-off-by: Liviu Dudau [Generic PCI domain support] Signed-off-by: Catalin Marinas --- arch/arm64/Kconfig | 22 +++++++++++++++++++- arch/arm64/include/asm/Kbuild | 1 + arch/arm64/include/asm/io.h | 3 ++- arch/arm64/include/asm/pci.h | 37 +++++++++++++++++++++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/pci.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/include/asm/pci.h create mode 100644 arch/arm64/kernel/pci.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 839f48c..30832d9 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -76,7 +76,7 @@ config MMU def_bool y config NO_IOPORT_MAP - def_bool y + def_bool y if !PCI config STACKTRACE_SUPPORT def_bool y @@ -151,6 +151,26 @@ menu "Bus support" config ARM_AMBA bool +config PCI + bool "PCI support" + help + This feature enables support for PCIe bus system. If you say Y + here, the kernel will include drivers and infrastructure code + to support PCIe bus devices. + +config PCI_DOMAINS + def_bool PCI + +config PCI_DOMAINS_GENERIC + def_bool PCI + +config PCI_SYSCALL + def_bool PCI + +source "drivers/pci/Kconfig" +source "drivers/pci/pcie/Kconfig" +source "drivers/pci/hotplug/Kconfig" + endmenu menu "Kernel Features" diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild index 0b3fcf8..07cb417 100644 --- a/arch/arm64/include/asm/Kbuild +++ b/arch/arm64/include/asm/Kbuild @@ -29,6 +29,7 @@ generic-y += mman.h generic-y += msgbuf.h generic-y += mutex.h generic-y += pci.h +generic-y += pci-bridge.h generic-y += poll.h generic-y += preempt.h generic-y += resource.h diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index e0ecdcf..dc34039 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -121,7 +121,8 @@ static inline u64 __raw_readq(const volatile void __iomem *addr) /* * I/O port access primitives. */ -#define IO_SPACE_LIMIT 0xffff +#define arch_has_dev_port() (1) +#define IO_SPACE_LIMIT 0x1ffffff #define PCI_IOBASE ((void __iomem *)(MODULES_VADDR - SZ_32M)) static inline u8 inb(unsigned long addr) diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h new file mode 100644 index 0000000..872ba93 --- /dev/null +++ b/arch/arm64/include/asm/pci.h @@ -0,0 +1,37 @@ +#ifndef __ASM_PCI_H +#define __ASM_PCI_H +#ifdef __KERNEL__ + +#include +#include +#include + +#include +#include +#include + +#define PCIBIOS_MIN_IO 0x1000 +#define PCIBIOS_MIN_MEM 0 + +/* + * Set to 1 if the kernel should re-assign all PCI bus numbers + */ +#define pcibios_assign_all_busses() \ + (pci_has_flag(PCI_REASSIGN_ALL_BUS)) + +/* + * PCI address space differs from physical memory address space + */ +#define PCI_DMA_BUS_IS_PHYS (0) + +extern int isa_dma_bridge_buggy; + +#ifdef CONFIG_PCI +static inline int pci_proc_domain(struct pci_bus *bus) +{ + return 1; +} +#endif /* CONFIG_PCI */ + +#endif /* __KERNEL__ */ +#endif /* __ASM_PCI_H */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index cdaedad..36b117a 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,6 +29,7 @@ arm64-obj-$(CONFIG_ARM64_CPU_SUSPEND) += sleep.o suspend.o arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o arm64-obj-$(CONFIG_KGDB) += kgdb.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o +arm64-obj-$(CONFIG_PCI) += pci.o obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c new file mode 100644 index 0000000..fe99049 --- /dev/null +++ b/arch/arm64/kernel/pci.c @@ -0,0 +1,48 @@ +/* + * Code borrowed from powerpc/kernel/pci-common.c + * + * Copyright (C) 2003 Anton Blanchard , IBM + * Copyright (C) 2014 ARM Ltd. + * + * 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 +#include +#include +#include +#include +#include +#include + +#include + +/* + * Called after each bus is probed, but before its children are examined + */ +void pcibios_fixup_bus(struct pci_bus *bus) +{ + /* nothing to do, expected to be removed in the future */ +} + +/* + * We don't have to worry about legacy ISA devices, so nothing to do here + */ +resource_size_t pcibios_align_resource(void *data, const struct resource *res, + resource_size_t size, resource_size_t align) +{ + return res->start; +} + +#ifdef CONFIG_PCI_DOMAINS_GENERIC +void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) +{ + int domain = of_pci_get_domain_nr(parent->of_node, true); + + if (domain >= 0) + bus->domain_nr = domain; +} +#endif