Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309040
b: refs/heads/master
c: 64adb6b
h: refs/heads/master
v: v3
  • Loading branch information
Gabor Juhos authored and Ralf Baechle committed May 15, 2012
1 parent 73820ba commit d6b5de5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ffdce4668234a113e767edd27aa1331903959106
refs/heads/master: 64adb6bb62bee11ad04c2f9c3c797799e329c351
52 changes: 26 additions & 26 deletions trunk/arch/mips/pci/pci-ar724x.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,32 @@ static void __iomem *ar724x_pci_devcfg_base;
static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
int size, uint32_t *value)
{
unsigned long flags, addr, tval, mask;
unsigned long flags;
void __iomem *base;
u32 data;

if (devfn)
return PCIBIOS_DEVICE_NOT_FOUND;

base = ar724x_pci_devcfg_base;

spin_lock_irqsave(&ar724x_pci_lock, flags);
data = __raw_readl(base + (where & ~3));

switch (size) {
case 1:
addr = where & ~3;
mask = 0xff000000 >> ((where % 4) * 8);
tval = __raw_readl(base + addr);
tval = tval & ~mask;
*value = (tval >> ((4 - (where % 4))*8));
if (where & 1)
data >>= 8;
if (where & 2)
data >>= 16;
data &= 0xff;
break;
case 2:
addr = where & ~3;
mask = 0xffff0000 >> ((where % 4)*8);
tval = __raw_readl(base + addr);
tval = tval & ~mask;
*value = (tval >> ((4 - (where % 4))*8));
if (where & 2)
data >>= 16;
data &= 0xffff;
break;
case 4:
*value = __raw_readl(base + where);
break;
default:
spin_unlock_irqrestore(&ar724x_pci_lock, flags);
Expand All @@ -57,49 +56,50 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
}

spin_unlock_irqrestore(&ar724x_pci_lock, flags);
*value = data;

return PCIBIOS_SUCCESSFUL;
}

static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
int size, uint32_t value)
{
unsigned long flags, tval, addr, mask;
unsigned long flags;
void __iomem *base;
u32 data;
int s;

if (devfn)
return PCIBIOS_DEVICE_NOT_FOUND;

base = ar724x_pci_devcfg_base;

spin_lock_irqsave(&ar724x_pci_lock, flags);
data = __raw_readl(base + (where & ~3));

switch (size) {
case 1:
addr = where & ~3;
mask = 0xff000000 >> ((where % 4)*8);
tval = __raw_readl(base + addr);
tval = tval & ~mask;
tval |= (value << ((4 - (where % 4))*8)) & mask;
__raw_writel(tval, base + addr);
s = ((where & 3) * 8);
data &= ~(0xff << s);
data |= ((value & 0xff) << s);
break;
case 2:
addr = where & ~3;
mask = 0xffff0000 >> ((where % 4)*8);
tval = __raw_readl(base + addr);
tval = tval & ~mask;
tval |= (value << ((4 - (where % 4))*8)) & mask;
__raw_writel(tval, base + addr);
s = ((where & 2) * 8);
data &= ~(0xffff << s);
data |= ((value & 0xffff) << s);
break;
case 4:
__raw_writel(value, (base + where));
data = value;
break;
default:
spin_unlock_irqrestore(&ar724x_pci_lock, flags);

return PCIBIOS_BAD_REGISTER_NUMBER;
}

__raw_writel(data, base + (where & ~3));
/* flush write */
__raw_readl(base + (where & ~3));
spin_unlock_irqrestore(&ar724x_pci_lock, flags);

return PCIBIOS_SUCCESSFUL;
Expand Down

0 comments on commit d6b5de5

Please sign in to comment.