linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Jesse Barnes <jbarnes@virtuousgeek.org>, Greg KH <greg@kroah.com>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	linux-usb@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/4] x86, pci: add dummy pci device for early stage
Date: Mon, 10 Jan 2011 16:55:28 -0800	[thread overview]
Message-ID: <4D2BAA80.7060803@kernel.org> (raw)
In-Reply-To: <4D2BA8FE.9090204@kernel.org>


So we can pass pci_dev *dev to reuse some generic pci functions.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/include/asm/pci-direct.h |    2 +
 arch/x86/pci/early.c              |   75 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+)

Index: linux-2.6/arch/x86/include/asm/pci-direct.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/pci-direct.h
+++ linux-2.6/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 */
Index: linux-2.6/arch/x86/pci/early.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/early.c
+++ linux-2.6/arch/x86/pci/early.c
@@ -109,3 +109,78 @@ 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 = devfn >> 3;
+	func = devfn & 7;
+	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 = devfn >> 3;
+	func = devfn & 7;
+	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_device_init_name[8];
+static __initdata struct pci_dev pci_early_dev = {
+	.bus = &pci_early_bus,
+};
+
+__init struct pci_dev *get_early_pci_dev(int num, int slot, int func)
+{
+	struct pci_dev *pdev;
+
+	pdev = &pci_early_dev;
+	pdev->devfn = (slot<<3) | (func & 7);
+	pdev->bus->number = num;
+	sprintf(pci_device_init_name, "%02x:%02x.%01x", num, slot, func);
+	pdev->dev.init_name = pci_device_init_name;
+
+	return pdev;
+}

  parent reply	other threads:[~2011-01-11  0:55 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-09 19:58 [PATCH 0/3] x86, usb, pci: Disable usb legacy support early Yinghai Lu
2011-01-10  8:43 ` [PATCH -v2 0/4] " Yinghai Lu
2011-01-11  0:49   ` [PATCH -v3 " Yinghai Lu
2011-01-11  0:55     ` [PATCH -v3 1/4] pci, usb: Make usb handoff func all take base remapping Yinghai Lu
2011-01-11  1:07       ` Greg KH
2011-01-11  1:20         ` Yinghai Lu
2011-01-11  3:37           ` Greg KH
2011-01-11  5:21           ` Benjamin Herrenschmidt
2011-01-11  6:34             ` Yinghai Lu
2011-01-11  7:37               ` Benjamin Herrenschmidt
2011-01-11  9:21                 ` Yinghai Lu
2011-01-11 13:56                   ` Greg KH
2011-01-11 17:39                     ` Konrad Rzeszutek Wilk
2011-01-12  1:06                     ` [RFC PATCH] x86: Add safe_udelay() and safe_msleep() Yinghai Lu
2011-01-12  2:32                       ` Benjamin Herrenschmidt
2011-01-12  5:07                         ` Greg KH
2011-01-13 22:21                         ` Yinghai Lu
2011-01-13 22:44                           ` Greg KH
2011-01-13 22:52                             ` Thomas Gleixner
2011-01-13 23:02                               ` Greg KH
2011-01-13 23:04                               ` Yinghai Lu
2011-01-13 23:31                                 ` Thomas Gleixner
2011-01-14 22:42                                   ` Yinghai Lu
2011-01-13 23:48                                 ` Greg KH
2011-01-14  0:31                                   ` Yinghai Lu
2011-01-14  0:40                                     ` Benjamin Herrenschmidt
2011-01-14  1:00                                       ` Yinghai Lu
2011-01-14 14:46                                         ` Christoph Lameter
2011-01-14  0:44                                     ` Greg KH
2011-01-14  1:12                                       ` Yinghai Lu
2011-01-14 14:50                                         ` Christoph Lameter
2011-01-14 21:22                                           ` [PATCH] x86: set percpu cpu0 lpj to default Yinghai Lu
2011-01-14 21:28                                             ` Christoph Lameter
2011-01-15 13:09                                               ` Tejun Heo
2011-01-16  2:32                                                 ` Yinghai Lu
2011-01-14 22:16                                             ` Greg KH
2011-01-14 22:29                                               ` Yinghai Lu
2011-01-11  5:18       ` [PATCH -v3 1/4] pci, usb: Make usb handoff func all take base remapping Benjamin Herrenschmidt
2011-01-11  0:55     ` [PATCH 2/4] x86: early_quirk check all dev/func in domain 0 Yinghai Lu
2011-01-11  1:09       ` Greg KH
2011-01-11  1:46         ` Yinghai Lu
2011-01-11  3:38           ` Greg KH
2011-01-11  3:39           ` Greg KH
2011-01-11  0:55     ` Yinghai Lu [this message]
2011-01-11  0:55     ` [PATCH -v3 4/4] x86: usb handoff in early_quirk Yinghai Lu
2011-01-11  1:08       ` Greg KH
2011-01-11  1:41         ` Yinghai Lu
2011-01-11  1:07     ` [PATCH -v3 0/4] x86, usb, pci: Disable usb legacy support early Greg KH
2011-01-11  1:25       ` Yinghai Lu
2011-01-11  3:35         ` Greg KH
     [not found] ` <4D2AC584.6010004@kernel.org>
2011-01-10  8:43   ` [PATCH -v2 1/4] pci, usb: Seperate usb handoff func to another file Yinghai Lu
2011-01-10  8:44   ` [PATCH 2/4] x86: early_quirk check all dev/func in domain 0 Yinghai Lu
2011-01-10  8:44   ` [PATCH 3/4] x86, pci: add dummy pci device for early stage Yinghai Lu
2011-01-10  8:44   ` [PATCH v2 4/4] x86: usb handoff in early_quirk Yinghai Lu
2011-01-10 15:57 ` [PATCH 0/3] x86, usb, pci: Disable usb legacy support early Greg KH
2011-01-10 18:27   ` Jesse Barnes
2011-01-10 20:10     ` Yinghai Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D2BAA80.7060803@kernel.org \
    --to=yinghai@kernel.org \
    --cc=benh@kernel.crashing.org \
    --cc=greg@kroah.com \
    --cc=hpa@zytor.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).