Commit b6706ef1 authored by Magnus Damm's avatar Magnus Damm Committed by Paul Mundt

sh: hook in struct pci_channel in sysdata

Store a struct pci_channel pointer in bus->sysdata. This makes whatever
struct pci_channel assigned to a bus available for sh4_pci_read() and
sh4_pci_write(). We also modify PCIBIOS_MIN_IO and PCIBIOS_MIN_MEM to
use bus->sysdata - this to gives us support for multiple pci channels.
Signed-off-by: default avatarMagnus Damm <damm@igel.co.jp>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 710fa3c8
...@@ -26,6 +26,7 @@ static DEFINE_SPINLOCK(sh4_pci_lock); ...@@ -26,6 +26,7 @@ static DEFINE_SPINLOCK(sh4_pci_lock);
static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn, static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn,
int where, int size, u32 *val) int where, int size, u32 *val)
{ {
struct pci_channel *chan = bus->sysdata;
unsigned long flags; unsigned long flags;
u32 data; u32 data;
...@@ -34,8 +35,8 @@ static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn, ...@@ -34,8 +35,8 @@ static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn,
* so we must do byte alignment by hand * so we must do byte alignment by hand
*/ */
spin_lock_irqsave(&sh4_pci_lock, flags); spin_lock_irqsave(&sh4_pci_lock, flags);
pci_write_reg(NULL, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR); pci_write_reg(chan, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR);
data = pci_read_reg(NULL, SH4_PCIPDR); data = pci_read_reg(chan, SH4_PCIPDR);
spin_unlock_irqrestore(&sh4_pci_lock, flags); spin_unlock_irqrestore(&sh4_pci_lock, flags);
switch (size) { switch (size) {
...@@ -63,13 +64,14 @@ static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn, ...@@ -63,13 +64,14 @@ static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn,
static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn, static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn,
int where, int size, u32 val) int where, int size, u32 val)
{ {
struct pci_channel *chan = bus->sysdata;
unsigned long flags; unsigned long flags;
int shift; int shift;
u32 data; u32 data;
spin_lock_irqsave(&sh4_pci_lock, flags); spin_lock_irqsave(&sh4_pci_lock, flags);
pci_write_reg(NULL, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR); pci_write_reg(chan, CONFIG_CMD(bus, devfn, where), SH4_PCIPAR);
data = pci_read_reg(NULL, SH4_PCIPDR); data = pci_read_reg(chan, SH4_PCIPDR);
spin_unlock_irqrestore(&sh4_pci_lock, flags); spin_unlock_irqrestore(&sh4_pci_lock, flags);
switch (size) { switch (size) {
...@@ -90,7 +92,7 @@ static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn, ...@@ -90,7 +92,7 @@ static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn,
return PCIBIOS_FUNC_NOT_SUPPORTED; return PCIBIOS_FUNC_NOT_SUPPORTED;
} }
pci_write_reg(NULL, data, SH4_PCIPDR); pci_write_reg(chan, data, SH4_PCIPDR);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
......
...@@ -67,6 +67,7 @@ static struct pci_dev *fake_pci_dev(struct pci_channel *hose, ...@@ -67,6 +67,7 @@ static struct pci_dev *fake_pci_dev(struct pci_channel *hose,
dev.devfn = devfn; dev.devfn = devfn;
bus.number = busnr; bus.number = busnr;
bus.ops = hose->pci_ops; bus.ops = hose->pci_ops;
bus.sysdata = hose;
if(busnr != top_bus) if(busnr != top_bus)
/* Fake a parent bus structure. */ /* Fake a parent bus structure. */
......
...@@ -31,8 +31,10 @@ struct pci_channel { ...@@ -31,8 +31,10 @@ struct pci_channel {
*/ */
extern struct pci_channel board_pci_channels[]; extern struct pci_channel board_pci_channels[];
#define PCIBIOS_MIN_IO board_pci_channels->io_resource->start /* ugly as hell, but makes drivers/pci/setup-res.c compile and work */
#define PCIBIOS_MIN_MEM board_pci_channels->mem_resource->start #define __PCI_CHAN(bus) ((struct pci_channel *)bus->sysdata)
#define PCIBIOS_MIN_IO __PCI_CHAN(bus)->io_resource->start
#define PCIBIOS_MIN_MEM __PCI_CHAN(bus)->mem_resource->start
/* /*
* I/O routine helpers * I/O routine helpers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment