From patchwork Tue Nov 27 00:42:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takao Indoh X-Patchwork-Id: 1808171 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7C0D53FC54 for ; Tue, 27 Nov 2012 00:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757572Ab2K0Amk (ORCPT ); Mon, 26 Nov 2012 19:42:40 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:52109 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757568Ab2K0Amj (ORCPT ); Mon, 26 Nov 2012 19:42:39 -0500 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 57C8A3EE0B5; Tue, 27 Nov 2012 09:42:38 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 3A87045DE53; Tue, 27 Nov 2012 09:42:35 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 062C245DE51; Tue, 27 Nov 2012 09:42:35 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id BD27C1DB8041; Tue, 27 Nov 2012 09:42:34 +0900 (JST) Received: from m1001.s.css.fujitsu.com (m1001.s.css.fujitsu.com [10.240.81.139]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 6FF7D1DB8037; Tue, 27 Nov 2012 09:42:34 +0900 (JST) Received: from m1001.css.fujitsu.com (m1001 [127.0.0.1]) by m1001.s.css.fujitsu.com (Postfix) with ESMTP id 400936112F; Tue, 27 Nov 2012 09:42:34 +0900 (JST) Received: from tindoh.g01.fujitsu.local (tindoh.g01.fujitsu.local [10.124.101.134]) by m1001.s.css.fujitsu.com (Postfix) with ESMTP id A71B7611D3; Tue, 27 Nov 2012 09:42:33 +0900 (JST) X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 From: Takao Indoh To: linux-pci@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: tokunaga.keiich@jp.fujitsu.com, kexec@lists.infradead.org, hbabu@us.ibm.com, andi@firstfloor.org, ddutile@redhat.com, Takao Indoh , ishii.hironobu@jp.fujitsu.com, hpa@zytor.com, bhelgaas@google.com, tglx@linutronix.de, yinghai@kernel.org, mingo@redhat.com, vgoyal@redhat.com, khalid@gonehiking.org Message-Id: <20121127004154.3604.89729.sendpatchset@tindoh.g01.fujitsu.local> In-Reply-To: <20121127004144.3604.61708.sendpatchset@tindoh.g01.fujitsu.local> References: <20121127004144.3604.61708.sendpatchset@tindoh.g01.fujitsu.local> Subject: [PATCH v7 1/5] x86, pci: add dummy pci device for early stage Date: Tue, 27 Nov 2012 09:42:34 +0900 (JST) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org So we can pass pci_dev *dev to reuse some generic pci functions. The original patch was written by Yinghai Lu. Signed-off-by: Takao Indoh --- arch/x86/include/asm/pci-direct.h | 2 + arch/x86/pci/early.c | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/pci-direct.h b/arch/x86/include/asm/pci-direct.h index b1e7a45..b6360d3 100644 --- a/arch/x86/include/asm/pci-direct.h +++ b/arch/x86/include/asm/pci-direct.h @@ -18,4 +18,6 @@ extern int early_pci_allowed(void); extern unsigned int pci_early_dump_regs; extern void early_dump_pci_device(u8 bus, u8 slot, u8 func); extern void early_dump_pci_devices(void); + +struct pci_dev *get_early_pci_dev(int num, int slot, int func); #endif /* _ASM_X86_PCI_DIRECT_H */ diff --git a/arch/x86/pci/early.c b/arch/x86/pci/early.c index d1067d5..024def7 100644 --- a/arch/x86/pci/early.c +++ b/arch/x86/pci/early.c @@ -109,3 +109,77 @@ void early_dump_pci_devices(void) } } } + +static __init int +early_pci_read(struct pci_bus *bus, unsigned int devfn, int where, + int size, u32 *value) +{ + int num, slot, func; + + num = bus->number; + slot = PCI_SLOT(devfn); + func = PCI_FUNC(devfn); + switch (size) { + case 1: + *value = read_pci_config_byte(num, slot, func, where); + break; + case 2: + *value = read_pci_config_16(num, slot, func, where); + break; + case 4: + *value = read_pci_config(num, slot, func, where); + break; + } + + return 0; +} + +static __init int +early_pci_write(struct pci_bus *bus, unsigned int devfn, int where, + int size, u32 value) +{ + int num, slot, func; + + num = bus->number; + slot = PCI_SLOT(devfn); + func = PCI_FUNC(devfn); + switch (size) { + case 1: + write_pci_config_byte(num, slot, func, where, (u8)value); + break; + case 2: + write_pci_config_16(num, slot, func, where, (u16)value); + break; + case 4: + write_pci_config(num, slot, func, where, (u32)value); + break; + } + + return 0; +} + +static __initdata struct pci_ops pci_early_ops = { + .read = early_pci_read, + .write = early_pci_write, +}; +static __initdata struct pci_bus pci_early_bus = { + .ops = &pci_early_ops, +}; +static __initdata char pci_early_init_name[8]; +static __initdata struct pci_dev pci_early_dev; + +__init struct pci_dev *get_early_pci_dev(int num, int slot, int func) +{ + struct pci_dev *pdev; + + pdev = &pci_early_dev; + memset(pdev, 0, sizeof(*pdev)); + + pdev->bus = &pci_early_bus, + pdev->dev.init_name = pci_early_init_name; + pdev->bus->number = num; + pdev->devfn = PCI_DEVFN(slot, func); + sprintf((char *)pdev->dev.init_name, "%02x:%02x.%01x", num, slot, func); + + return pdev; +}