From patchwork Tue Sep 22 07:19:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ley Foon Tan X-Patchwork-Id: 7235311 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6762BBEEC1 for ; Tue, 22 Sep 2015 07:19:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E67E2081B for ; Tue, 22 Sep 2015 07:19:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7C12207C1 for ; Tue, 22 Sep 2015 07:19:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757360AbbIVHTt (ORCPT ); Tue, 22 Sep 2015 03:19:49 -0400 Received: from mail-by2on0056.outbound.protection.outlook.com ([207.46.100.56]:39376 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756627AbbIVHTn (ORCPT ); Tue, 22 Sep 2015 03:19:43 -0400 Received: from CH1PR03CA009.namprd03.prod.outlook.com (10.255.156.154) by BY2PR03MB042.namprd03.prod.outlook.com (10.255.241.146) with Microsoft SMTP Server (TLS) id 15.1.274.16; Tue, 22 Sep 2015 07:19:40 +0000 Received: from BN1AFFO11FD052.protection.gbl (10.255.156.132) by CH1PR03CA009.outlook.office365.com (10.255.156.154) with Microsoft SMTP Server (TLS) id 15.1.274.16 via Frontend Transport; Tue, 22 Sep 2015 07:19:40 +0000 Authentication-Results: spf=softfail (sender IP is 66.35.236.227) smtp.mailfrom=altera.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=altera.com; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning altera.com discourages use of 66.35.236.227 as permitted sender) Received: from sj-itexedge03.altera.priv.altera.com (66.35.236.227) by BN1AFFO11FD052.mail.protection.outlook.com (10.58.53.67) with Microsoft SMTP Server (TLS) id 15.1.274.4 via Frontend Transport; Tue, 22 Sep 2015 07:19:39 +0000 Received: from sj-mail01.altera.com (137.57.1.6) by webmail.altera.com (66.35.236.227) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 22 Sep 2015 00:19:07 -0700 Received: from leyfoon-vm (pg-lftan-l.altera.com [137.57.103.123]) by sj-mail01.altera.com (8.13.7+Sun/8.13.7) with SMTP id t8M7JYKx027111; Tue, 22 Sep 2015 00:19:35 -0700 (PDT) Received: by leyfoon-vm (sSMTP sendmail emulation); Tue, 22 Sep 2015 15:19:33 +0800 From: Ley Foon Tan To: Bjorn Helgaas CC: , , , Ley Foon Tan , Subject: [PATCH 1/2] nios2: Add architectural support for PCIe Date: Tue, 22 Sep 2015 15:19:26 +0800 Message-ID: <1442906367-10935-2-git-send-email-lftan@altera.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1442906367-10935-1-git-send-email-lftan@altera.com> References: <1442906367-10935-1-git-send-email-lftan@altera.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD052; 1:cUAoZECdQdvxaQiiU0l+oWBw4665RasjFAYspGR8seie5bT2QUHRe33SkMvtNtpPUu+mnRmnkj8D2UUo1cGjxXtyK7PmdPZmlZBDwJbPSD8A7PD5hZxkSVWQvZn0o+TP4h2v9//OSywJrZ74SJgYVhCh3/QN9wAlbVHJsFDtPvYj7CFMUGS6plJzIezPZMRm8vSP52OwcF2AyTdYwCLe7RmJ9T6C2lzTxpjzrFNnHccF7/SCWCKjJFCZ25f6EelczLB65K48EVQ8drxfADT+ZsrjKJC4gKAfCZBkZezdvRBGEr/5ZyQ6r6k61H7Yy5Ud5gE7QIIjEGrlHuLfIRMjTe0lTL927GcPscJc42wv0+YIktTQMKiZ1NaqHzji9roD X-Forefront-Antispam-Report: CIP:66.35.236.227; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(189002)(199003)(62966003)(110136002)(5003940100001)(4001540100001)(575784001)(68736005)(92566002)(46102003)(105596002)(86362001)(15975445007)(87936001)(5001860100001)(5001960100002)(97736004)(77156002)(33646002)(64706001)(47776003)(81156007)(189998001)(5001830100001)(36756003)(5007970100001)(2950100001)(106466001)(48376002)(50466002)(11100500001)(42186005)(50986999)(19580395003)(19580405001)(50226001)(6806004)(229853001)(76176999)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB042; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB042; 2:S4oFEgwOph/0JHa7mtFRSsLIOn/+oM+nu0sVyEQK+fw8kUp2ulTfPsKOt79BxlQi1Ygxvg7gUcnxyTf3JVgvi26f9AhUbVNiRcF9WkBfhn1ZF3O7VM3T3FJwo3g4Av8UBATJE1ZhvFlYdi9X0NphuxkP+an8ZHpDTQcxUJo2lvA=; 3:9/DWEWD5NM+2c3Sth7njdIB20Rb9CHGu2vJi8240NFg2UCh6hOUUWcrwrNCHpsEDWU1frZ6zuJoIV3CXf1pRzNMB6FYumTiFVqYzSQDNEUZg/AKK89b9SEFTJLx8pbS062ZVVBu67Hr9HeNJU4gJigSV+aPG88dN27ooYugdUgp+SJytb202EEJgS709k1ZxxhoXvu2f0ZKjMK8TZqclkqNG+h0mqeGsD5ZMTX+4ZAk=; 25:vddFN6NFBBwWsDitYgDKu+mE4+waRLUtNEBqwnXtrx8OVFvMv861muAC4Y/mwEpnMgzJ6/khSK5JpVDnlbgriYBU+82X/vULb302/XyNvTITE3zshKg6OeBo6rM+a5uOiH108V5jXg36YEcTJtYt1Vpp4rl4rRCK0EFVc7EjJchK0oYQo42O5rgpwXmlYiSd79T2e9isrRsMPepBN/ZmWG2pKWOPDwP3DNhh7o7qswRMgCN8KAU/sRUo3yewoebrdWFpO8DPntb4u865bcgq3Q==; 20:GeMQfP2ODoH7WU7JVBg9xAtsLkJYfJOwKOT/XCHHF6mUEx9YO2gnoL0el0hnz/QcBeBiJo2HFrP8uIPsKEPm5k157P7zAoWYYzOZgB4nMiqWgM/LVON7HePrgwc7NQ1HxkknUsViCrxFrx8nI1qNm+bhsxFH87Mz3gIE6iPV7Yc= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB042; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401041)(8121501046)(520078)(5005006)(3002001); SRVR:BY2PR03MB042; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB042; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB042; 4:IuZE5F3fqh4sXPNLrI149FxY3w3F7yLSyDsOH2OXRqFa+0DpBSLdhkd4tA3/pFzSE+BAoAnG0NaNRUkUYhDvlHKT74MVIqBmCBCKdvZ56IZGBPsldFBAwEClQCwQlTqaus1UHzXZo0y97WWNvYJ7KPa6TqgG7nfuWq/XM52SAMCwbZsDGieJUI2e4420cwbvU8vbtbgMbUS7e8nsBUplWjOAdX52Ff3G0WfWy7Mv5BHOCw2sNJT8clA908n8JuYNkId+Xl/JrIbfgyDu/ViS75gVejKDw8CIWBLLROfS4PDvVeBbOZA+sxglazSjzqVoutkR4Y/eSY+fxD63WtDLtcI1r9JGq7x4XazlYHZwWrU= X-Forefront-PRVS: 0707248B64 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB042; 23:kGoLfGS7QNeEFVlHYgJIqeRl5PNCeXZ+K06dvhcc9L?= =?us-ascii?Q?3j3VByrmJf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S0xuFdKTcmI12Ze?= =?us-ascii?Q?SnoOtYy0KRJwr7FZF+R0WZPq9BFKyOOJ0gOv9E0fgz04SHEQZSogEP96FOyc?= =?us-ascii?Q?l7j1KEhA9gS5ERd7uzrpmL567bG0ahzaijB2RNIdEMy6ePRqU0+KvURvCa7a?= =?us-ascii?Q?WMXpj0nAPA0bLdoDA6PCGGrLrKdBDjakigIScwGF+erNfa9hcD+d0NJ3P0Yf?= =?us-ascii?Q?bYdeCjbHQrcbQ/cEMbCRR2uWcG1kxyc0tLQIU/dqJqFxSpifdjeA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB042; 5:GtGh3E8pbvREZOb7aHvilX5/HGAJv2eBIXCapolg5tzX3H7FnolvLM+ySb5rIHDOpyMK72T3B2Kwc4xPukmgM20gZAkrYJbFLqAAyzB9VU50qfxp5JTEZCKUbrbOkoS5irVRJbbMbP30nVpqJo6kEQ==; 24:XZlouzDi+lBBo6HHFGua4qNLMPNWd07n2vVEbw1S4mcvMgdgeuK9QFDekoVi2XLPudxbclhNH2H4RWuwjL64QNj03CrDUhvSulz5xZ1sZUg=; 20:uvKUqKNukzccOykNKPGOumV5m2PdM13SIattHFT9SauazasFOIaOxZ/WRjcX6n7xb7gAFocAXvmit8HlJOCajFfQD/PejYZa5/sRFmwmVaoZFIHol7PfjoO0ObgO/fbJo2AVcsuCyJdWuyO5M2BGM3jpoqviG6GoMmfi3EuOMQA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2015 07:19:39.6726 (UTC) X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fbd72e03-d4a5-4110-adce-614d51f2077a; Ip=[66.35.236.227]; Helo=[sj-itexedge03.altera.priv.altera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB042 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 This patch add pcie support on nios2 platform. Signed-off-by: Ley Foon Tan --- arch/nios2/Kconfig | 24 +++++++++++++++++++++ arch/nios2/include/asm/Kbuild | 2 +- arch/nios2/include/asm/io.h | 11 +++++++++- arch/nios2/include/asm/pci.h | 50 +++++++++++++++++++++++++++++++++++++++++++ arch/nios2/kernel/Makefile | 1 + arch/nios2/kernel/pci.c | 33 ++++++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 arch/nios2/include/asm/pci.h create mode 100644 arch/nios2/kernel/pci.c diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 4375554..9e0a291 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -11,6 +11,7 @@ config NIOS2 select HAVE_ARCH_KGDB select IRQ_DOMAIN select MODULES_USE_ELF_RELA + select MIGHT_HAVE_PCI select OF select OF_EARLY_FLATTREE select SOC_BUS @@ -194,6 +195,29 @@ config NIOS2_IO_REGION_BASE endmenu +menu "Bus support" +config PCI + bool "PCI support" + select GENERIC_PCI_IOMAP + 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" + +endmenu + menu "Executable file formats" source "fs/Kconfig.binfmt" diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild index 914864e..8b928ba 100644 --- a/arch/nios2/include/asm/Kbuild +++ b/arch/nios2/include/asm/Kbuild @@ -34,8 +34,8 @@ generic-y += mm-arch-hooks.h generic-y += mman.h generic-y += module.h generic-y += msgbuf.h +generic-y += msi.h generic-y += param.h -generic-y += pci.h generic-y += percpu.h generic-y += poll.h generic-y += posix_types.h diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h index c5a62da..74ba082 100644 --- a/arch/nios2/include/asm/io.h +++ b/arch/nios2/include/asm/io.h @@ -14,7 +14,7 @@ #include #include -/* PCI is not supported in nios2, set this to 0. */ +/* PCI I/O space is not supported, set this to 0. */ #define IO_SPACE_LIMIT 0 #define readb_relaxed(addr) readb(addr) @@ -45,6 +45,15 @@ static inline void iounmap(void __iomem *addr) __iounmap(addr); } +static inline void __iomem *ioport_map(unsigned long port, unsigned int nr) +{ + return NULL; +} + +static inline void ioport_unmap(void __iomem *p) +{ +} + #define ioremap_wc ioremap_nocache #define ioremap_wt ioremap_nocache diff --git a/arch/nios2/include/asm/pci.h b/arch/nios2/include/asm/pci.h new file mode 100644 index 0000000..f2cba05 --- /dev/null +++ b/arch/nios2/include/asm/pci.h @@ -0,0 +1,50 @@ +/* Copyright Altera Corporation (C) 2015. All rights reserved. + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#ifndef _ASM_NIOS2_PCI_H +#define _ASM_NIOS2_PCI_H + +#ifdef __KERNEL__ +#include + +#include +#include +#include + +#define PCIBIOS_MIN_IO 0UL +#define PCIBIOS_MIN_MEM 0UL + +/* + * 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)) + +#ifdef CONFIG_PCI +extern int isa_dma_bridge_buggy; +#else +#define isa_dma_bridge_buggy (0) +#endif + +#ifdef CONFIG_PCI_DOMAINS +static inline int pci_proc_domain(struct pci_bus *bus) +{ + return pci_domain_nr(bus); +} +#endif /* CONFIG_PCI_DOMAINS */ + +#endif /* __KERNEL__ */ + +#endif diff --git a/arch/nios2/kernel/Makefile b/arch/nios2/kernel/Makefile index 1aae257..bb1ef81 100644 --- a/arch/nios2/kernel/Makefile +++ b/arch/nios2/kernel/Makefile @@ -10,6 +10,7 @@ obj-y += entry.o obj-y += insnemu.o obj-y += irq.o obj-y += nios2_ksyms.o +obj-y += pci.o obj-y += process.o obj-y += prom.o obj-y += ptrace.o diff --git a/arch/nios2/kernel/pci.c b/arch/nios2/kernel/pci.c new file mode 100644 index 0000000..d28aed7 --- /dev/null +++ b/arch/nios2/kernel/pci.c @@ -0,0 +1,33 @@ +/* Copyright Altera Corporation (C) 2015. All rights reserved. + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#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; +}