Commit 00ed5b65 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] PCI: alpha pci_ops changes

pci_ops update for most of the alpha ports.
parent df5dbe8e
...@@ -90,12 +90,11 @@ ...@@ -90,12 +90,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
unsigned long addr; unsigned long addr;
u8 bus = dev->bus->number; u8 bus = bus_dev->number;
u8 device_fn = dev->devfn;
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",
...@@ -273,87 +272,66 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1) ...@@ -273,87 +272,66 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1)
} }
static int static int
apecs_read_config_byte(struct pci_dev *dev, int where, u8 *value) apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
u8 *value)
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
unsigned char type1; unsigned char type1;
long mask;
int shift;
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;
addr = (pci_addr << 5) + 0x00 + APECS_CONF; switch (size) {
*value = conf_read(addr, type1) >> ((where & 3) * 8); case 1:
return PCIBIOS_SUCCESSFUL; mask = 0x00;
} shift = (where & 3) * 8;
break;
static int case 2:
apecs_read_config_word(struct pci_dev *dev, int where, u16 *value) mask = 0x08;
{ shift = (where & 3) * 8;
unsigned long addr, pci_addr; break;
unsigned char type1; case 4:
mask = 0x18;
if (mk_conf_addr(dev, where, &pci_addr, &type1)) shift = 0;
return PCIBIOS_DEVICE_NOT_FOUND; break;
}
addr = (pci_addr << 5) + 0x08 + APECS_CONF; addr = (pci_addr << 5) + mask + APECS_CONF;
*value = conf_read(addr, type1) >> ((where & 3) * 8); *value = conf_read(addr, type1) >> (shift);
return PCIBIOS_SUCCESSFUL;
}
static int
apecs_read_config_dword(struct pci_dev *dev, int where, u32 *value)
{
unsigned long addr, pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
addr = (pci_addr << 5) + 0x18 + APECS_CONF;
*value = conf_read(addr, type1);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
apecs_write_config(struct pci_dev *dev, int where, u32 value, long mask) 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;
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) {
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;
} }
static int
apecs_write_config_byte(struct pci_dev *dev, int where, u8 value)
{
return apecs_write_config(dev, where, value, 0x00);
}
static int
apecs_write_config_word(struct pci_dev *dev, int where, u16 value)
{
return apecs_write_config(dev, where, value, 0x08);
}
static int
apecs_write_config_dword(struct pci_dev *dev, int where, u32 value)
{
return apecs_write_config(dev, where, value, 0x18);
}
struct pci_ops apecs_pci_ops = struct pci_ops apecs_pci_ops =
{ {
read_byte: apecs_read_config_byte, .read = apecs_read_config,
read_word: apecs_read_config_word, .write = apecs_write_config,
read_dword: apecs_read_config_dword,
write_byte: apecs_write_config_byte,
write_word: apecs_write_config_word,
write_dword: apecs_write_config_dword
}; };
void void
......
...@@ -89,11 +89,10 @@ ...@@ -89,11 +89,10 @@
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
u8 bus = dev->bus->number; u8 bus = bus_dev->number;
u8 device_fn = dev->devfn;
*type1 = (bus != 0); *type1 = (bus != 0);
*pci_addr = (bus << 16) | (device_fn << 8) | where; *pci_addr = (bus << 16) | (device_fn << 8) | where;
...@@ -208,88 +207,70 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1) ...@@ -208,88 +207,70 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1)
DBGC(("done\n")); DBGC(("done\n"));
} }
static int
cia_read_config_byte(struct pci_dev *dev, int where, u8 *value)
{
unsigned long addr, pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
addr = (pci_addr << 5) + 0x00 + CIA_CONF;
*value = conf_read(addr, type1) >> ((where & 3) * 8);
return PCIBIOS_SUCCESSFUL;
}
static int static int
cia_read_config_word(struct pci_dev *dev, int where, u16 *value) cia_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size,
u32 *value)
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
long mask;
unsigned char type1; unsigned char type1;
int shift;
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;
addr = (pci_addr << 5) + 0x08 + CIA_CONF; switch (size) {
*value = conf_read(addr, type1) >> ((where & 3) * 8); case 1:
return PCIBIOS_SUCCESSFUL; mask = 0x00;
} shift = (where & 3) * 8;
break;
static int case 2:
cia_read_config_dword(struct pci_dev *dev, int where, u32 *value) mask = 0x08;
{ shift = (where & 3) * 8;
unsigned long addr, pci_addr; break;
unsigned char type1; case 4:
mase = 0x18;
if (mk_conf_addr(dev, where, &pci_addr, &type1)) shift = 0;
return PCIBIOS_DEVICE_NOT_FOUND; break;
}
addr = (pci_addr << 5) + 0x18 + CIA_CONF; addr = (pci_addr << 5) + 0x18 + CIA_CONF;
*value = conf_read(addr, type1); *value = conf_read(addr, type1) >> (shift);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
cia_write_config(struct pci_dev *dev, int where, u32 value, long mask) cia_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;
long mask;
unsigned char type1; unsigned char type1;
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) {
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;
} }
static int
cia_write_config_byte(struct pci_dev *dev, int where, u8 value)
{
return cia_write_config(dev, where, value, 0x00);
}
static int
cia_write_config_word(struct pci_dev *dev, int where, u16 value)
{
return cia_write_config(dev, where, value, 0x08);
}
static int
cia_write_config_dword(struct pci_dev *dev, int where, u32 value)
{
return cia_write_config(dev, where, value, 0x18);
}
struct pci_ops cia_pci_ops = struct pci_ops cia_pci_ops =
{ {
read_byte: cia_read_config_byte, .read = cia_read_config,
read_word: cia_read_config_word, .write = cia_write_config,
read_dword: cia_read_config_dword,
write_byte: cia_write_config_byte,
write_word: cia_write_config_word,
write_dword: cia_write_config_dword
}; };
/* /*
......
...@@ -83,12 +83,11 @@ ...@@ -83,12 +83,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
unsigned long addr; unsigned long addr;
u8 bus = dev->bus->number; u8 bus = bus_dev->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",
...@@ -105,12 +104,13 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, ...@@ -105,12 +104,13 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr,
} }
static int static int
irongate_read_config_byte(struct pci_dev *dev, int where, u8 *value) irongate_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); *value = __kernel_ldbu(*(vucp)addr);
...@@ -118,38 +118,13 @@ irongate_read_config_byte(struct pci_dev *dev, int where, u8 *value) ...@@ -118,38 +118,13 @@ irongate_read_config_byte(struct pci_dev *dev, int where, u8 *value)
} }
static int static int
irongate_read_config_word(struct pci_dev *dev, int where, u16 *value) irongate_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;
*value = __kernel_ldwu(*(vusp)addr);
return PCIBIOS_SUCCESSFUL;
}
static int
irongate_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
irongate_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; return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stb(value, *(vucp)addr); __kernel_stb(value, *(vucp)addr);
...@@ -158,45 +133,11 @@ irongate_write_config_byte(struct pci_dev *dev, int where, u8 value) ...@@ -158,45 +133,11 @@ irongate_write_config_byte(struct pci_dev *dev, int where, u8 value)
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int
irongate_write_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;
__kernel_stw(value, *(vusp)addr);
mb();
__kernel_ldwu(*(vusp)addr);
return PCIBIOS_SUCCESSFUL;
}
static int
irongate_write_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;
*(vuip)addr = value;
mb();
*(vuip)addr;
return PCIBIOS_SUCCESSFUL;
}
struct pci_ops irongate_pci_ops = struct pci_ops irongate_pci_ops =
{ {
read_byte: irongate_read_config_byte, .read = irongate_read_config,
read_word: irongate_read_config_word, .write = irongate_write_config,
read_dword: irongate_read_config_dword,
write_byte: irongate_write_config_byte,
write_word: irongate_write_config_word,
write_dword: irongate_write_config_dword
}; };
#ifdef DEBUG_IRONGATE #ifdef DEBUG_IRONGATE
......
...@@ -99,11 +99,11 @@ ...@@ -99,11 +99,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr) mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
unsigned long *pci_addr)
{ {
unsigned long addr; unsigned long addr;
u8 bus = dev->bus->number; u8 bus = bus_dev->number;
u8 device_fn = dev->devfn;
if (bus == 0) { if (bus == 0) {
int device = device_fn >> 3; int device = device_fn >> 3;
...@@ -199,83 +199,65 @@ conf_write(unsigned long addr, unsigned int value) ...@@ -199,83 +199,65 @@ conf_write(unsigned long addr, unsigned int value)
} }
static int static int
lca_read_config_byte(struct pci_dev *dev, int where, u8 *value) lca_read_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *value)
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
long mask;
int shift
if (mk_conf_addr(dev, where, &pci_addr)) if (mk_conf_addr(bus, devfn, dev, where, &pci_addr))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
addr = (pci_addr << 5) + 0x00 + LCA_CONF; switch (size) {
*value = conf_read(addr) >> ((where & 3) * 8); case 1:
return PCIBIOS_SUCCESSFUL; shift = (where & 3) * 8;
} mask = 0x00;
break;
static int case 2:
lca_read_config_word(struct pci_dev *dev, int where, u16 *value) shift = (where & 3) * 8;
{ mask = 0x08
unsigned long addr, pci_addr; break;
case 4:
if (mk_conf_addr(dev, where, &pci_addr)) shift = 0;
return PCIBIOS_DEVICE_NOT_FOUND; mask = 0x18
break;
addr = (pci_addr << 5) + 0x08 + LCA_CONF; }
*value = conf_read(addr) >> ((where & 3) * 8); addr = (pci_addr << 5) + mask + LCA_CONF;
return PCIBIOS_SUCCESSFUL; *value = conf_read(addr) >> (shift);
}
static int
lca_read_config_dword(struct pci_dev *dev, int where, u32 *value)
{
unsigned long addr, pci_addr;
if (mk_conf_addr(dev, where, &pci_addr))
return PCIBIOS_DEVICE_NOT_FOUND;
addr = (pci_addr << 5) + 0x18 + LCA_CONF;
*value = conf_read(addr);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
lca_write_config(struct pci_dev *dev, int where, u32 value, long mask) lca_write_config(struct pci_bus *dev, unsigned int devfn, int where, int size,
u32 value)
{ {
unsigned long addr, pci_addr; unsigned long addr, pci_addr;
long mask;
if (mk_conf_addr(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) {
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;
} }
static int
lca_write_config_byte(struct pci_dev *dev, int where, u8 value)
{
return lca_write_config(dev, where, value, 0x00);
}
static int
lca_write_config_word(struct pci_dev *dev, int where, u16 value)
{
return lca_write_config(dev, where, value, 0x08);
}
static int
lca_write_config_dword(struct pci_dev *dev, int where, u32 value)
{
return lca_write_config(dev, where, value, 0x18);
}
struct pci_ops lca_pci_ops = struct pci_ops lca_pci_ops =
{ {
read_byte: lca_read_config_byte, .read = lca_read_config,
read_word: lca_read_config_word, .write = lca_write_config,
read_dword: lca_read_config_dword,
write_byte: lca_write_config_byte,
write_word: lca_write_config_word,
write_dword: lca_write_config_dword
}; };
void void
......
...@@ -65,10 +65,10 @@ ...@@ -65,10 +65,10 @@
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, u8 *type1) mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
unsigned long *pci_addr, u8 *type1)
{ {
u8 bus = dev->bus->number; u8 bus = bus_dev->number;
u8 device_fn = dev->devfn;
*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) |
...@@ -82,51 +82,28 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, u8 *type1) ...@@ -82,51 +82,28 @@ mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, u8 *type1)
} }
static int static int
polaris_read_config_byte(struct pci_dev *dev, int where, u8 *value) polaris_read_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 *value)
{ {
unsigned long pci_addr; unsigned long pci_addr;
unsigned char type1; unsigned char type1;
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;
*value = __kernel_ldbu(*(vucp)pci_addr); *value = __kernel_ldbu(*(vucp)pci_addr);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int
polaris_read_config_word(struct pci_dev *dev, int where, u16 *value)
{
unsigned long pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
*value = __kernel_ldwu(*(vusp)pci_addr);
return PCIBIOS_SUCCESSFUL;
}
int
polaris_read_config_dword(struct pci_dev *dev, int where, u32 *value)
{
unsigned long pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
*value = *(vuip)pci_addr;
return PCIBIOS_SUCCESSFUL;
}
static int static int
polaris_write_config_byte(struct pci_dev *dev, int where, u8 value) polaris_write_config(struct pci_bus *bus, unsigned int devfn, int where,
int size, u32 value)
{ {
unsigned long pci_addr; unsigned long pci_addr;
unsigned char type1; unsigned char type1;
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;
__kernel_stb(value, *(vucp)pci_addr); __kernel_stb(value, *(vucp)pci_addr);
...@@ -135,44 +112,10 @@ polaris_write_config_byte(struct pci_dev *dev, int where, u8 value) ...@@ -135,44 +112,10 @@ polaris_write_config_byte(struct pci_dev *dev, int where, u8 value)
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int
polaris_write_config_word(struct pci_dev *dev, int where, u16 value)
{
unsigned long pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
__kernel_stw(value, *(vusp)pci_addr);
mb();
__kernel_ldwu(*(vusp)pci_addr);
return PCIBIOS_SUCCESSFUL;
}
int
polaris_write_config_dword(struct pci_dev *dev, int where, u32 value)
{
unsigned long pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
*(vuip)pci_addr = value;
mb();
*(vuip)pci_addr;
return PCIBIOS_SUCCESSFUL;
}
struct pci_ops polaris_pci_ops = struct pci_ops polaris_pci_ops =
{ {
read_byte: polaris_read_config_byte, .read = polaris_read_config,
read_word: polaris_read_config_word, .write = polaris_write_config,
read_dword: polaris_read_config_dword,
write_byte: polaris_write_config_byte,
write_word: polaris_write_config_word,
write_dword: polaris_write_config_dword
}; };
void __init void __init
......
...@@ -89,12 +89,11 @@ ...@@ -89,12 +89,11 @@
*/ */
static int static int
mk_conf_addr(struct pci_dev *dev, int where, unsigned long *pci_addr, mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
unsigned char *type1) unsigned long *pci_addr, unsigned char *type1)
{ {
unsigned long addr; unsigned long addr;
u8 bus = dev->bus->number; u8 bus = bus_dev->number;
u8 device_fn = dev->devfn;
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",
...@@ -238,87 +237,67 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1) ...@@ -238,87 +237,67 @@ conf_write(unsigned long addr, unsigned int value, unsigned char type1)
} }
static int static int
t2_read_config_byte(struct pci_dev *dev, int where, u8 *value) t2_read_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;
int shift;
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;
addr = (pci_addr << 5) + 0x00 + T2_CONF;
*value = conf_read(addr, type1) >> ((where & 3) * 8);
return PCIBIOS_SUCCESSFUL;
}
static int
t2_read_config_word(struct pci_dev *dev, int where, u16 *value)
{
unsigned long addr, pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND;
addr = (pci_addr << 5) + 0x08 + T2_CONF;
*value = conf_read(addr, type1) >> ((where & 3) * 8);
return PCIBIOS_SUCCESSFUL;
}
static int
t2_read_config_dword(struct pci_dev *dev, int where, u32 *value)
{
unsigned long addr, pci_addr;
unsigned char type1;
if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
addr = (pci_addr << 5) + 0x18 + T2_CONF; switch (size) {
*value = conf_read(addr, type1); case 1:
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;
*value = conf_read(addr, type1) >> (shift);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
} }
static int static int
t2_write_config(struct pci_dev *dev, int where, u32 value, long mask) t2_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;
long mask;
if (mk_conf_addr(dev, where, &pci_addr, &type1)) if (mk_conf_addr(dev, where, &pci_addr, &type1))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
switch (size) {
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;
} }
static int
t2_write_config_byte(struct pci_dev *dev, int where, u8 value)
{
return t2_write_config(dev, where, value, 0x00);
}
static int
t2_write_config_word(struct pci_dev *dev, int where, u16 value)
{
return t2_write_config(dev, where, value, 0x08);
}
static int
t2_write_config_dword(struct pci_dev *dev, int where, u32 value)
{
return t2_write_config(dev, where, value, 0x18);
}
struct pci_ops t2_pci_ops = struct pci_ops t2_pci_ops =
{ {
read_byte: t2_read_config_byte, .read = t2_read_config,
read_word: t2_read_config_word, .write = t2_write_config,
read_dword: t2_read_config_dword,
write_byte: t2_write_config_byte,
write_word: t2_write_config_word,
write_dword: t2_write_config_dword
}; };
void __init void __init
......
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