From patchwork Wed Oct 14 06:31:44 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: 7390761 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E05B29F37F for ; Wed, 14 Oct 2015 06:33:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D0AC620690 for ; Wed, 14 Oct 2015 06:33:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8722D206E8 for ; Wed, 14 Oct 2015 06:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752896AbbJNGdO (ORCPT ); Wed, 14 Oct 2015 02:33:14 -0400 Received: from mail-bn1bon0073.outbound.protection.outlook.com ([157.56.111.73]:6503 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752341AbbJNGcH (ORCPT ); Wed, 14 Oct 2015 02:32:07 -0400 Received: from CO2PR03CA0036.namprd03.prod.outlook.com (10.141.194.163) by BLUPR03MB310.namprd03.prod.outlook.com (10.141.48.25) with Microsoft SMTP Server (TLS) id 15.1.293.16; Wed, 14 Oct 2015 06:32:05 +0000 Received: from BN1AFFO11FD007.protection.gbl (2a01:111:f400:7c10::101) by CO2PR03CA0036.outlook.office365.com (2a01:111:e400:1414::35) with Microsoft SMTP Server (TLS) id 15.1.286.15 via Frontend Transport; Wed, 14 Oct 2015 06:32:05 +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 BN1AFFO11FD007.mail.protection.outlook.com (10.58.52.67) with Microsoft SMTP Server (TLS) id 15.1.293.9 via Frontend Transport; Wed, 14 Oct 2015 06:32:04 +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, 13 Oct 2015 23:31:40 -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 t9E6VukJ016083; Tue, 13 Oct 2015 23:31:57 -0700 (PDT) Received: by leyfoon-vm (sSMTP sendmail emulation); Wed, 14 Oct 2015 14:32:03 +0800 From: Ley Foon Tan To: Bjorn Helgaas , Arnd Bergmann CC: , , , Ley Foon Tan , Subject: [PATCH v2 4/4] nios2: Add architectural support for PCIe Date: Wed, 14 Oct 2015 14:31:44 +0800 Message-ID: <1444804304-5213-5-git-send-email-lftan@altera.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1444804304-5213-1-git-send-email-lftan@altera.com> References: <1444804304-5213-1-git-send-email-lftan@altera.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD007; 1:K5oJRKKrxrn8SqxYpzULB/UDtgQJpPNMvy8h5G+bTSOvtnV9Ob3U7G6EuwVlse2Nv2pPEAKnSG07bnEQI2ZV2lS2NO5mNF4caK67qtc7hC8eewapc9WVD02wCRajhYoZ4Xhh4ICzaIs3Q8KKv+NSLIjKvLDs3pfcBApgdYEGqQi5JVsVOKASL1yFCoM31Lv3KwcRL7W9fCznlkw6G/F4ia1PRDfHxTkOgswziqMNjjaDS09U7jEMPWLcJezomyJgIz6P3aRWPzJV9H5K+KqNFU+LEg1RZ737y7whSkLRIlcBGjmVmxE7jCCiJky6w3orIdoBRR6xKuUSyhltn8B4v42YF710y/8cOeWz3/TINEv5ZYyNsE8axgHuUjZdVdkg X-Forefront-Antispam-Report: CIP:66.35.236.227; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(199003)(189002)(50986999)(81156007)(50226001)(76176999)(86362001)(2950100001)(97736004)(5003940100001)(5008740100001)(189998001)(64706001)(47776003)(5001770100001)(5001960100002)(36756003)(87936001)(92566002)(6806005)(48376002)(11100500001)(106466001)(33646002)(50466002)(5007970100001)(19580405001)(105596002)(19580395003)(42186005)(46102003)(15975445007)(229853001)(7099028)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB310; H:sj-itexedge03.altera.priv.altera.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB310; 2:Aev5Bnho+N3GJzxpzAV+9VJdBNaIearW+UwytzG+juNMv2BY+lVqP4J1XpeQrGXFxb8Z8Ti8mygyU1jdrsY4225eTgxyZvwDXSl5We5riZpgR7tN/rO/Y2UGPJutoQJzytwDi5mSbefJ/NjgM7tsS5AlWYm8OmHl6xVY2XYPtx4=; 3:FPbXrpmFB/iQyE5TyYI++JAdabEnnHRVTnSgKdj4vsAFHNvj/ncJTGC5420UvaFj4qo8Mu62m7GBmmb0FZxkXxOwv4eZJOjHXnWuHQnw+xfNGiz4qHewCzUfqiwZlYOs8jqhoYyo99GiXr66KVCJHaHEgjgG9AJiWlLXSVE4BjIY07wKIsxk8bo6xDrnLgxoLE3cpSMcPdxeN1vEWiYepI570B9cyKYchb1p7zb9nMg=; 25:AFWvYC1qbWxgxDVOETpH9CDM98Y/FNgghcnqzu2i+22YgleK+bHorF7HTQWeOxBmh2qsjjXc12TX/4DnP6eq7B2RMHtYOWyVH1OzC7JSBoP2nGxZxgefMMD5/tJo6XJqtmSeud7d4ZcBtv+YtoUR0x5GlzM0tw3v2YSpbkixv22XfHx8u25I3E5xZlA7ScbnBn8ZV/s/sM8jyLUKjkXRdXdslUBrJRyDtVmMdCoYZy/GEQPfm7Ke6T1aQVav7jTXMV9cuLQOIS0sddo0oF/mjg==; 20:bLlXTICJczDVQAZJngZJK9lWE294YM5AViIBYFI6cTaIjlN2A6yKZJqpkIbiLEbUXgancaOPPj8cKw1pO8dYaoi7R8E/ZceFXLHu5ihpjjY0qGMzInnXnAxMSIlsMOLFT2jnidLcYdzKmNRUHRbAShOtKESSrrkXG6HJ+1QYzpM= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB310; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(80048183373757); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001); SRVR:BLUPR03MB310; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB310; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB310; 4:nJqG/yRQJ1sCukc43Dq4tfuJsiYPnQqbeCTufzghcv3LvJviAfSfArWM8kriO3fKSHruzEKTT7F5aPhptiH6aUZULmODLE17IE9uigzRDvkG6RWlPbQNBTdt8JXNpp8zT2oREep9HjnTJuS8Dz0Q2BUnmwuCoDyWaGA8mswl1mNs9HzoAusdlf5XzIRbmjV6UIFJReX9GzIodynpGZINd9/JPUf0M6mjrmDge51JQ7x4oa/uNt835NVxCSLrYZV+6g0M4k03QMP5LthEipxw773+BGFSdYntZi1jbFbXEsTpysBzTtbyubKECJSFW+RLHwkSP5okJfNwCuY3NUpuZU4MUelUIAQvNJ88gKDdKoE= X-Forefront-PRVS: 0729050452 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB310; 23:IiVBOuUAzHdoc38Uz+S642EW8YrMkJpFCYCYzOZPKi?= =?us-ascii?Q?sWLkyrxouUUsLjGwc2/2qaN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= =?us-ascii?Q?0v4ZVo8X6DXSGNoD/Dpmfshb4rcgLEi4dRgC9joGciLEWaJPRtOvQvka5QLa?= =?us-ascii?Q?axh61sf/8CFY6sPV/T2adlW2H9DXd7pscjP5Bt9UkVpw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB310; 5:2Qmh5pIUTLqILjsksodBSD4YZ85F98Xr7KbeDAzhO9vAA8qf0Hsg3VrPoQOSmXxrPU6tPmEp84gtNmfcSj2bQGMacFRvewxvjJ7JBfG4QaddVwE2Q3+exl/AtZ5tEUf1I2vM0TRfyUxKF6OAO2ovEA==; 24:PRXu3kBsHFlUSlq1ueIYk5nU9bTXBto45r5fVjXqN/xUeeK6lbHo349rE/jHZHUM99YS9ftAMmLQBp7BYBjltZQoXBIwYfzNCMY6J9pZgGQ=; 20:P1I1H2ZXR4ky1jvQD+iuHcOspxx1PgTzCSZDpo2ml0zUzvwF4nlvcTc49iODM+aZj8QbfHEGWdMSVyIp8d83MvRs/j+RP3gWEiKA3kBQIhE8/D4Wzb4+lXt/7WBrywY8LuOqP4+FqC+mVYka0v2+S6ZEhzP++3IXzmgTViv6qFg= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2015 06:32:04.1932 (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: BLUPR03MB310 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, T_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 This patch add pcie support on nios2 platform. Signed-off-by: Ley Foon Tan --- arch/nios2/Kconfig | 21 +++++++++++++++++++++ arch/nios2/include/asm/Kbuild | 1 + arch/nios2/include/asm/io.h | 12 ++++++++++-- arch/nios2/kernel/Makefile | 1 + arch/nios2/kernel/pci.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 arch/nios2/kernel/pci.c diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 4375554..bde323f 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,26 @@ 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 + +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 d63330e..a7cace1 100644 --- a/arch/nios2/include/asm/Kbuild +++ b/arch/nios2/include/asm/Kbuild @@ -34,6 +34,7 @@ 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 diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h index c5a62da..0ba8388 100644 --- a/arch/nios2/include/asm/io.h +++ b/arch/nios2/include/asm/io.h @@ -14,8 +14,7 @@ #include #include -/* PCI is not supported in nios2, set this to 0. */ -#define IO_SPACE_LIMIT 0 +#define IO_SPACE_LIMIT 0xffff #define readb_relaxed(addr) readb(addr) #define readw_relaxed(addr) readw(addr) @@ -45,6 +44,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/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; +}