Commit 8656c276 authored by Ivan Kokshaysky's avatar Ivan Kokshaysky Committed by Linus Torvalds

[PATCH] alpha: pci_ops update

Tested on CIA (sparse config space) and Irongate (dense config space);
other platforms should work as they are similar to these two.

Access config space directly on rx164.
parent 83d936cb
...@@ -90,11 +90,11 @@ ...@@ -90,11 +90,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned long *pci_addr, unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
unsigned long addr; unsigned long addr;
u8 bus = bus_dev->number; u8 bus = pbus->number;
DBGC(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x," DBGC(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x,"
" pci_addr=0x%p, type1=0x%p)\n", " pci_addr=0x%p, type1=0x%p)\n",
...@@ -272,8 +272,8 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1) ...@@ -272,8 +272,8 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1)
} }
static int static int
apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where,
u8 *value) int size, u32 *value)
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
unsigned char type1; unsigned char type1;
...@@ -283,27 +283,16 @@ apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, ...@@ -283,27 +283,16 @@ apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { mask = (size - 1) * 8;
case 1: shift = (where & 3) * 8;
mask = 0x00;
shift = (where & 3) * 8;
break;
case 2:
mask = 0x08;
shift = (where & 3) * 8;
break;
case 4:
mask = 0x18;
shift = 0;
break;
}
addr = (pci_addr << 5) + mask + APECS_CONF; addr = (pci_addr << 5) + mask + APECS_CONF;
*value = conf_read(addr, type1) >> (shift); *value = conf_read(addr, type1) >> (shift);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
apecs_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) apecs_write_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 value)
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
unsigned char type1; unsigned char type1;
...@@ -312,17 +301,7 @@ apecs_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, ...@@ -312,17 +301,7 @@ apecs_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { mask = (size - 1) * 8;
case 1:
mask = 0x00;
break;
case 2:
mask = 0x08;
break;
case 4:
mask = 0x18;
break;
}
addr = (pci_addr << 5) + mask + APECS_CONF; addr = (pci_addr << 5) + mask + APECS_CONF;
conf_write(addr, value << ((where & 3) * 8), type1); conf_write(addr, value << ((where & 3) * 8), type1);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
......
...@@ -219,22 +219,9 @@ cia_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, ...@@ -219,22 +219,9 @@ cia_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { mask = (size - 1) * 8;
case 1: shift = (where & 3) * 8;
mask = 0x00; addr = (pci_addr << 5) + mask + CIA_CONF;
shift = (where & 3) * 8;
break;
case 2:
mask = 0x08;
shift = (where & 3) * 8;
break;
case 4:
mase = 0x18;
shift = 0;
break;
}
addr = (pci_addr << 5) + 0x18 + CIA_CONF;
*value = conf_read(addr, type1) >> (shift); *value = conf_read(addr, type1) >> (shift);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
...@@ -250,18 +237,7 @@ cia_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, ...@@ -250,18 +237,7 @@ cia_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { mask = (size - 1) * 8;
case 1:
mask = 0x00;
break;
case 2:
mask = 0x08;
break;
case 4:
mase = 0x18;
break;
}
addr = (pci_addr << 5) + mask + CIA_CONF; addr = (pci_addr << 5) + mask + CIA_CONF;
conf_write(addr, value << ((where & 3) * 8), type1); conf_write(addr, value << ((where & 3) * 8), type1);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
......
...@@ -83,11 +83,11 @@ ...@@ -83,11 +83,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned long *pci_addr, unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
unsigned long addr; unsigned long addr;
u8 bus = bus_dev->number; u8 bus = pbus->number;
DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, " DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, "
"pci_addr=0x%p, type1=0x%p)\n", "pci_addr=0x%p, type1=0x%p)\n",
...@@ -113,7 +113,18 @@ irongate_read_config(struct pci_bus *bus, unsigned int devfn, int where, ...@@ -113,7 +113,18 @@ irongate_read_config(struct pci_bus *bus, unsigned int devfn, int where,
if (mk_conf_addr(bus, devfn, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldbu(*(vucp)addr); switch (size) {
case 1:
*value = __kernel_ldbu(*(vucp)addr);
break;
case 2:
*value = __kernel_ldwu(*(vusp)addr);
break;
case 4:
*value = *(vuip)addr;
break;
}
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
...@@ -127,13 +138,27 @@ irongate_write_config(struct pci_bus *bus, unsigned int devfn, int where, ...@@ -127,13 +138,27 @@ irongate_write_config(struct pci_bus *bus, unsigned int devfn, int where,
if (mk_conf_addr(bus, devfn, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stb(value, *(vucp)addr); switch (size) {
mb(); case 1:
__kernel_ldbu(*(vucp)addr); __kernel_stb(value, *(vucp)addr);
mb();
__kernel_ldbu(*(vucp)addr);
break;
case 2:
__kernel_stw(value, *(vusp)addr);
mb();
__kernel_ldwu(*(vusp)addr);
break;
case 4:
*(vuip)addr = value;
mb();
*(vuip)addr;
break;
}
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
struct pci_ops irongate_pci_ops = struct pci_ops irongate_pci_ops =
{ {
.read = irongate_read_config, .read = irongate_read_config,
......
...@@ -99,11 +99,11 @@ ...@@ -99,11 +99,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned long *pci_addr) unsigned long *pci_addr)
{ {
unsigned long addr; unsigned long addr;
u8 bus = bus_dev->number; u8 bus = pbus->number;
if (bus == 0) { if (bus == 0) {
int device = device_fn >> 3; int device = device_fn >> 3;
...@@ -204,32 +204,20 @@ lca_read_config(struct pci_bus *bus, unsigned int devfn, int where, ...@@ -204,32 +204,20 @@ lca_read_config(struct pci_bus *bus, unsigned int devfn, int where,
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
long mask; long mask;
int shift int shift;
if (mk_conf_addr(bus, devfn, dev, where, &pci_addr)) if (mk_conf_addr(bus, devfn, where, &pci_addr))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { shift = (where & 3) * 8;
case 1: mask = (size - 1) * 8;
shift = (where & 3) * 8;
mask = 0x00;
break;
case 2:
shift = (where & 3) * 8;
mask = 0x08
break;
case 4:
shift = 0;
mask = 0x18
break;
}
addr = (pci_addr << 5) + mask + LCA_CONF; addr = (pci_addr << 5) + mask + LCA_CONF;
*value = conf_read(addr) >> (shift); *value = conf_read(addr) >> (shift);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
lca_write_config(struct pci_bus *dev, unsigned int devfn, int where, int size, lca_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
u32 value) u32 value)
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
...@@ -238,17 +226,7 @@ lca_write_config(struct pci_bus *dev, unsigned int devfn, int where, int size, ...@@ -238,17 +226,7 @@ lca_write_config(struct pci_bus *dev, unsigned int devfn, int where, int size,
if (mk_conf_addr(bus, devfn, where, &pci_addr)) if (mk_conf_addr(bus, devfn, where, &pci_addr))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { mask = (size - 1) * 8;
case 1:
mask = 0x00;
break;
case 2:
mask = 0x08
break;
case 4:
mask = 0x18
break;
}
addr = (pci_addr << 5) + mask + LCA_CONF; addr = (pci_addr << 5) + mask + LCA_CONF;
conf_write(addr, value << ((where & 3) * 8)); conf_write(addr, value << ((where & 3) * 8));
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
......
...@@ -171,11 +171,11 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1, ...@@ -171,11 +171,11 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1,
} }
static int static int
mk_conf_addr(struct pci_dev *dev, int where, struct pci_controller *hose, mk_conf_addr(struct pci_bus *pbus, unsigned int devfn, int where,
unsigned long *pci_addr, unsigned char *type1) struct pci_controller *hose, unsigned long *pci_addr,
unsigned char *type1)
{ {
u8 bus = dev->bus->number; u8 bus = pbus->number;
u8 devfn = dev->devfn;
unsigned long addr; unsigned long addr;
DBG_CFG(("mk_conf_addr(bus=%d,devfn=0x%x,hose=%d,where=0x%x," DBG_CFG(("mk_conf_addr(bus=%d,devfn=0x%x,hose=%d,where=0x%x,"
...@@ -185,7 +185,7 @@ mk_conf_addr(struct pci_dev *dev, int where, struct pci_controller *hose, ...@@ -185,7 +185,7 @@ mk_conf_addr(struct pci_dev *dev, int where, struct pci_controller *hose,
/* Type 1 configuration cycle for *ALL* busses. */ /* Type 1 configuration cycle for *ALL* busses. */
*type1 = 1; *type1 = 1;
if (dev->bus->number == hose->first_busno) if (bus == hose->first_busno)
bus = 0; bus = 0;
addr = (bus << 16) | (devfn << 8) | (where); addr = (bus << 16) | (devfn << 8) | (where);
addr <<= 5; /* swizzle for SPARSE */ addr <<= 5; /* swizzle for SPARSE */
...@@ -197,94 +197,53 @@ mk_conf_addr(struct pci_dev *dev, int where, struct pci_controller *hose, ...@@ -197,94 +197,53 @@ mk_conf_addr(struct pci_dev *dev, int where, struct pci_controller *hose,
} }
static int static int
mcpcia_read_config_byte(struct pci_dev *dev, int where, u8 *value) mcpcia_read_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *value)
{ {
struct pci_controller *hose = dev->sysdata; struct pci_controller *hose = bus->sysdata;
unsigned long addr, w; unsigned long addr, w;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, hose, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, hose, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
addr |= 0x00; addr |= (size - 1) * 8;
w = conf_read(addr, type1, hose); w = conf_read(addr, type1, hose);
*value = __kernel_extbl(w, where & 3); switch (size) {
return PCIBIOS_SUCCESSFUL; case 1:
} *value = __kernel_extbl(w, where & 3);
break;
static int case 2:
mcpcia_read_config_word(struct pci_dev *dev, int where, u16 *value) *value = __kernel_extwl(w, where & 3);
{ break;
struct pci_controller *hose = dev->sysdata; case 4:
unsigned long addr, w; *value = w;
unsigned char type1; break;
}
if (mk_conf_addr(dev, where, hose, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
addr |= 0x08;
w = conf_read(addr, type1, hose);
*value = __kernel_extwl(w, where & 3);
return PCIBIOS_SUCCESSFUL;
}
static int
mcpcia_read_config_dword(struct pci_dev *dev, int where, u32 *value)
{
struct pci_controller *hose = dev->sysdata;
unsigned long addr;
unsigned char type1;
if (mk_conf_addr(dev, where, hose, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
addr |= 0x18;
*value = conf_read(addr, type1, hose);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
mcpcia_write_config(struct pci_dev *dev, int where, u32 value, long mask) mcpcia_write_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 value)
{ {
struct pci_controller *hose = dev->sysdata; struct pci_controller *hose = bus->sysdata;
unsigned long addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, hose, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, hose, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
addr |= mask; addr |= (size - 1) * 8;
value = __kernel_insql(value, where & 3); value = __kernel_insql(value, where & 3);
conf_write(addr, value, type1, hose); conf_write(addr, value, type1, hose);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int
mcpcia_write_config_byte(struct pci_dev *dev, int where, u8 value)
{
return mcpcia_write_config(dev, where, value, 0x00);
}
static int
mcpcia_write_config_word(struct pci_dev *dev, int where, u16 value)
{
return mcpcia_write_config(dev, where, value, 0x08);
}
static int
mcpcia_write_config_dword(struct pci_dev *dev, int where, u32 value)
{
return mcpcia_write_config(dev, where, value, 0x18);
}
struct pci_ops mcpcia_pci_ops = struct pci_ops mcpcia_pci_ops =
{ {
read_byte: mcpcia_read_config_byte, .read = mcpcia_read_config,
read_word: mcpcia_read_config_word, .write = mcpcia_write_config,
read_dword: mcpcia_read_config_dword,
write_byte: mcpcia_write_config_byte,
write_word: mcpcia_write_config_word,
write_dword: mcpcia_write_config_dword
}; };
void void
......
...@@ -65,10 +65,10 @@ ...@@ -65,10 +65,10 @@
*/ */
static int static int
mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned long *pci_addr, u8 *type1) unsigned long *pci_addr, u8 *type1)
{ {
u8 bus = bus_dev->number; u8 bus = pbus->number;
*type1 = (bus == 0) ? 0 : 1; *type1 = (bus == 0) ? 0 : 1;
*pci_addr = (bus << 16) | (device_fn << 8) | (where) | *pci_addr = (bus << 16) | (device_fn << 8) | (where) |
...@@ -85,13 +85,24 @@ static int ...@@ -85,13 +85,24 @@ static int
polaris_read_config(struct pci_bus *bus, unsigned int devfn, int where, polaris_read_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *value) int size, u32 *value)
{ {
unsigned long pci_addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldbu(*(vucp)pci_addr); switch (size) {
case 1:
*value = __kernel_ldbu(*(vucp)addr);
break;
case 2:
*value = __kernel_ldwu(*(vusp)addr);
break;
case 4:
*value = *(vuip)addr;
break;
}
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
...@@ -100,15 +111,30 @@ static int ...@@ -100,15 +111,30 @@ static int
polaris_write_config(struct pci_bus *bus, unsigned int devfn, int where, polaris_write_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 value) int size, u32 value)
{ {
unsigned long pci_addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stb(value, *(vucp)pci_addr); switch (size) {
mb(); case 1:
__kernel_ldbu(*(vucp)pci_addr); __kernel_stb(value, *(vucp)addr);
mb();
__kernel_ldbu(*(vucp)addr);
break;
case 2:
__kernel_stw(value, *(vusp)addr);
mb();
__kernel_ldwu(*(vusp)addr);
break;
case 4:
*(vuip)addr = value;
mb();
*(vuip)addr;
break;
}
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
......
...@@ -89,11 +89,11 @@ ...@@ -89,11 +89,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned long *pci_addr, unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
unsigned long addr; unsigned long addr;
u8 bus = bus_dev->number; u8 bus = pbus->number;
DBG(("mk_conf_addr(bus=%d, dfn=0x%x, where=0x%x," DBG(("mk_conf_addr(bus=%d, dfn=0x%x, where=0x%x,"
" addr=0x%lx, type1=0x%x)\n", " addr=0x%lx, type1=0x%x)\n",
...@@ -248,20 +248,8 @@ t2_read_config(struct pci_bus *bus, unsigned int devfn, int where, ...@@ -248,20 +248,8 @@ t2_read_config(struct pci_bus *bus, unsigned int devfn, int where,
if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { mask = (size - 1) * 8;
case 1: shift = (where & 3) * 8;
mask = 0x00;
shift = (where & 3) * 8;
break;
case 2:
mask = 0x08;
shift = (where & 3) * 8;
break;
case 4:
mask = 0x18;
shift = 0;
break;
}
addr = (pci_addr << 5) + mask + T2_CONF; addr = (pci_addr << 5) + mask + T2_CONF;
*value = conf_read(addr, type1) >> (shift); *value = conf_read(addr, type1) >> (shift);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
...@@ -275,20 +263,10 @@ t2_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, ...@@ -275,20 +263,10 @@ t2_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
unsigned char type1; unsigned char type1;
long mask; long mask;
if (mk_conf_addr(dev, where, &pci_addr, &type1)) if (mk_conf_addr(bus, devfn, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) { mask = (size - 1) * 8;
case 1:
mask = 0x00;
break;
case 2:
mask = 0x08;
break;
case 4:
mask = 0x18;
break;
}
addr = (pci_addr << 5) + mask + T2_CONF; addr = (pci_addr << 5) + mask + T2_CONF;
conf_write(addr, value << ((where & 3) * 8), type1); conf_write(addr, value << ((where & 3) * 8), type1);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
......
...@@ -82,19 +82,18 @@ static struct ...@@ -82,19 +82,18 @@ static struct
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
struct pci_controller *hose = dev->sysdata; struct pci_controller *hose = pbus->sysdata;
unsigned long addr; unsigned long addr;
u8 bus = dev->bus->number; u8 bus = pbus->number;
u8 device_fn = dev->devfn;
DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, " DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, "
"pci_addr=0x%p, type1=0x%p)\n", "pci_addr=0x%p, type1=0x%p)\n",
bus, device_fn, where, pci_addr, type1)); bus, device_fn, where, pci_addr, type1));
if (hose->first_busno == dev->bus->number) if (hose->first_busno == bus)
bus = 0; bus = 0;
*type1 = (bus != 0); *type1 = (bus != 0);
...@@ -106,98 +105,66 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, ...@@ -106,98 +105,66 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr,
return 0; return 0;
} }
static int
titan_read_config_byte(struct pci_dev *dev, int where, u8 *value)
{
unsigned long addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldbu(*(vucp)addr);
return PCIBIOS_SUCCESSFUL;
}
static int
titan_read_config_word(struct pci_dev *dev, int where, u16 *value)
{
unsigned long addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldwu(*(vusp)addr);
return PCIBIOS_SUCCESSFUL;
}
static int static int
titan_read_config_dword(struct pci_dev *dev, int where, u32 *value) titan_read_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *value)
{ {
unsigned long addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
*value = *(vuip)addr; switch (size) {
return PCIBIOS_SUCCESSFUL; case 1:
} *value = __kernel_ldbu(*(vucp)addr);
break;
static int case 2:
titan_write_config_byte(struct pci_dev *dev, int where, u8 value) *value = __kernel_ldwu(*(vusp)addr);
{ break;
unsigned long addr; case 4:
unsigned char type1; *value = *(vuip)addr;
break;
if (mk_conf_addr(dev, where, &addr, &type1)) }
return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stb(value, *(vucp)addr);
mb();
__kernel_ldbu(*(vucp)addr);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
titan_write_config_word(struct pci_dev *dev, int where, u16 value) titan_write_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 value)
{ {
unsigned long addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stw(value, *(vusp)addr); switch (size) {
mb(); case 1:
__kernel_ldwu(*(vusp)addr); __kernel_stb(value, *(vucp)addr);
return PCIBIOS_SUCCESSFUL; mb();
} __kernel_ldbu(*(vucp)addr);
break;
static int case 2:
titan_write_config_dword(struct pci_dev *dev, int where, u32 value) __kernel_stw(value, *(vusp)addr);
{ mb();
unsigned long addr; __kernel_ldwu(*(vusp)addr);
unsigned char type1; break;
case 4:
if (mk_conf_addr(dev, where, &addr, &type1)) *(vuip)addr = value;
return PCIBIOS_DEVICE_NOT_FOUND; mb();
*(vuip)addr;
break;
}
*(vuip)addr = value;
mb();
*(vuip)addr;
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
struct pci_ops titan_pci_ops = struct pci_ops titan_pci_ops =
{ {
read_byte: titan_read_config_byte, .read = titan_read_config,
read_word: titan_read_config_word, .write = titan_write_config,
read_dword: titan_read_config_dword,
write_byte: titan_write_config_byte,
write_word: titan_write_config_word,
write_dword: titan_write_config_dword
}; };
......
...@@ -89,19 +89,18 @@ static struct ...@@ -89,19 +89,18 @@ static struct
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
struct pci_controller *hose = dev->sysdata; struct pci_controller *hose = pbus->sysdata;
unsigned long addr; unsigned long addr;
u8 bus = dev->bus->number; u8 bus = pbus->number;
u8 device_fn = dev->devfn;
DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, " DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, "
"pci_addr=0x%p, type1=0x%p)\n", "pci_addr=0x%p, type1=0x%p)\n",
bus, device_fn, where, pci_addr, type1)); bus, device_fn, where, pci_addr, type1));
if (hose->first_busno == dev->bus->number) if (hose->first_busno == bus)
bus = 0; bus = 0;
*type1 = (bus != 0); *type1 = (bus != 0);
...@@ -114,97 +113,65 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, ...@@ -114,97 +113,65 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr,
} }
static int static int
tsunami_read_config_byte(struct pci_dev *dev, int where, u8 *value) tsunami_read_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *value)
{ {
unsigned long addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldbu(*(vucp)addr); switch (size) {
return PCIBIOS_SUCCESSFUL; case 1:
} *value = __kernel_ldbu(*(vucp)addr);
break;
static int case 2:
tsunami_read_config_word(struct pci_dev *dev, int where, u16 *value) *value = __kernel_ldwu(*(vusp)addr);
{ break;
unsigned long addr; case 4:
unsigned char type1; *value = *(vuip)addr;
break;
if (mk_conf_addr(dev, where, &addr, &type1)) }
return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldwu(*(vusp)addr);
return PCIBIOS_SUCCESSFUL;
}
static int
tsunami_read_config_dword(struct pci_dev *dev, int where, u32 *value)
{
unsigned long addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
*value = *(vuip)addr;
return PCIBIOS_SUCCESSFUL;
}
static int
tsunami_write_config_byte(struct pci_dev *dev, int where, u8 value)
{
unsigned long addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stb(value, *(vucp)addr);
mb();
__kernel_ldbu(*(vucp)addr);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
tsunami_write_config_word(struct pci_dev *dev, int where, u16 value) tsunami_write_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 value)
{ {
unsigned long addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stw(value, *(vusp)addr); switch (size) {
mb(); case 1:
__kernel_ldwu(*(vusp)addr); __kernel_stb(value, *(vucp)addr);
return PCIBIOS_SUCCESSFUL; mb();
} __kernel_ldbu(*(vucp)addr);
break;
static int case 2:
tsunami_write_config_dword(struct pci_dev *dev, int where, u32 value) __kernel_stw(value, *(vusp)addr);
{ mb();
unsigned long addr; __kernel_ldwu(*(vusp)addr);
unsigned char type1; break;
case 4:
if (mk_conf_addr(dev, where, &addr, &type1)) *(vuip)addr = value;
return PCIBIOS_DEVICE_NOT_FOUND; mb();
*(vuip)addr;
break;
}
*(vuip)addr = value;
mb();
*(vuip)addr;
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
struct pci_ops tsunami_pci_ops = struct pci_ops tsunami_pci_ops =
{ {
read_byte: tsunami_read_config_byte, .read = tsunami_read_config,
read_word: tsunami_read_config_word, .write = tsunami_write_config,
read_dword: tsunami_read_config_dword,
write_byte: tsunami_write_config_byte,
write_word: tsunami_write_config_word,
write_dword: tsunami_write_config_dword
}; };
void void
......
...@@ -357,19 +357,18 @@ wildfire_pci_tbi(struct pci_controller *hose, dma_addr_t start, dma_addr_t end) ...@@ -357,19 +357,18 @@ wildfire_pci_tbi(struct pci_controller *hose, dma_addr_t start, dma_addr_t end)
} }
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
struct pci_controller *hose = dev->sysdata; struct pci_controller *hose = pbus->sysdata;
unsigned long addr; unsigned long addr;
u8 bus = dev->bus->number; u8 bus = pbus->number;
u8 device_fn = dev->devfn;
DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, " DBG_CFG(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, "
"pci_addr=0x%p, type1=0x%p)\n", "pci_addr=0x%p, type1=0x%p)\n",
bus, device_fn, where, pci_addr, type1)); bus, device_fn, where, pci_addr, type1));
if (hose->first_busno == dev->bus->number) if (hose->first_busno == bus)
bus = 0; bus = 0;
*type1 = (bus != 0); *type1 = (bus != 0);
...@@ -382,97 +381,65 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, ...@@ -382,97 +381,65 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr,
} }
static int static int
wildfire_read_config_byte(struct pci_dev *dev, int where, u8 *value) wildfire_read_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *value)
{ {
unsigned long addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldbu(*(vucp)addr); switch (size) {
return PCIBIOS_SUCCESSFUL; case 1:
} *value = __kernel_ldbu(*(vucp)addr);
break;
static int case 2:
wildfire_read_config_word(struct pci_dev *dev, int where, u16 *value) *value = __kernel_ldwu(*(vusp)addr);
{ break;
unsigned long addr; case 4:
unsigned char type1; *value = *(vuip)addr;
break;
if (mk_conf_addr(dev, where, &addr, &type1)) }
return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldwu(*(vusp)addr);
return PCIBIOS_SUCCESSFUL;
}
static int
wildfire_read_config_dword(struct pci_dev *dev, int where, u32 *value)
{
unsigned long addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
*value = *(vuip)addr;
return PCIBIOS_SUCCESSFUL;
}
static int
wildfire_write_config_byte(struct pci_dev *dev, int where, u8 value)
{
unsigned long addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stb(value, *(vucp)addr);
mb();
__kernel_ldbu(*(vucp)addr);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
wildfire_write_config_word(struct pci_dev *dev, int where, u16 value) wildfire_write_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 value)
{ {
unsigned long addr; unsigned long addr;
unsigned char type1; unsigned char type1;
if (mk_conf_addr(dev, where, &addr, &type1)) if (mk_conf_addr(bus, devfn, where, &addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stw(value, *(vusp)addr); switch (size) {
mb(); case 1:
__kernel_ldwu(*(vusp)addr); __kernel_stb(value, *(vucp)addr);
return PCIBIOS_SUCCESSFUL; mb();
} __kernel_ldbu(*(vucp)addr);
break;
static int case 2:
wildfire_write_config_dword(struct pci_dev *dev, int where, u32 value) __kernel_stw(value, *(vusp)addr);
{ mb();
unsigned long addr; __kernel_ldwu(*(vusp)addr);
unsigned char type1; break;
case 4:
if (mk_conf_addr(dev, where, &addr, &type1)) *(vuip)addr = value;
return PCIBIOS_DEVICE_NOT_FOUND; mb();
*(vuip)addr;
break;
}
*(vuip)addr = value;
mb();
*(vuip)addr;
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
struct pci_ops wildfire_pci_ops = struct pci_ops wildfire_pci_ops =
{ {
read_byte: wildfire_read_config_byte, .read = wildfire_read_config,
read_word: wildfire_read_config_word, .write = wildfire_write_config,
read_dword: wildfire_read_config_dword,
write_byte: wildfire_write_config_byte,
write_word: wildfire_write_config_word,
write_dword: wildfire_write_config_dword
}; };
#if DEBUG_DUMP_REGS #if DEBUG_DUMP_REGS
......
...@@ -35,16 +35,15 @@ ...@@ -35,16 +35,15 @@
/* Note mask bit is true for ENABLED irqs. */ /* Note mask bit is true for ENABLED irqs. */
static unsigned long cached_irq_mask; static unsigned long cached_irq_mask;
/* Bus 0, Device 0. Nothing else matters, since we invoke the
POLARIS routines directly. */
static struct pci_dev rx164_system;
static inline void static inline void
rx164_update_irq_hw(unsigned long mask) rx164_update_irq_hw(unsigned long mask)
{ {
unsigned int temp; volatile unsigned int *irq_mask;
polaris_write_config_dword(&rx164_system, 0x74, mask);
polaris_read_config_dword(&rx164_system, 0x74, &temp); irq_mask = (void *)(POLARIS_DENSE_CONFIG_BASE + 0x74);
*irq_mask = mask;
mb();
*irq_mask;
} }
static inline void static inline void
...@@ -86,14 +85,14 @@ static struct hw_interrupt_type rx164_irq_type = { ...@@ -86,14 +85,14 @@ static struct hw_interrupt_type rx164_irq_type = {
static void static void
rx164_device_interrupt(unsigned long vector, struct pt_regs *regs) rx164_device_interrupt(unsigned long vector, struct pt_regs *regs)
{ {
unsigned int temp;
unsigned long pld; unsigned long pld;
volatile unsigned int *dirr;
long i; long i;
/* Read the interrupt summary register. On Polaris, this is /* Read the interrupt summary register. On Polaris, this is
the DIRR register in PCI config space (offset 0x84). */ the DIRR register in PCI config space (offset 0x84). */
polaris_read_config_dword(&rx164_system, 0x84, &temp); dirr = (void *)(POLARIS_DENSE_CONFIG_BASE + 0x84);
pld = temp; pld = *dirr;
/* /*
* Now for every possible bit set, work through them and call * Now for every possible bit set, work through them and call
......
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