Commit c198441a authored by Gabor Juhos's avatar Gabor Juhos Committed by Ralf Baechle

MIPS: ath79: use io-accessor macros in pci-ar724x.c

Signed-off-by: default avatarGabor Juhos <juhosg@openwrt.org>
Acked-by: default avatarRené Bolldorf <xsecute@googlemail.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/3491/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent d624bd3c
...@@ -11,19 +11,19 @@ ...@@ -11,19 +11,19 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <asm/mach-ath79/pci.h> #include <asm/mach-ath79/pci.h>
#define reg_read(_phys) (*(unsigned int *) KSEG1ADDR(_phys)) #define AR724X_PCI_CFG_BASE 0x14000000
#define reg_write(_phys, _val) ((*(unsigned int *) KSEG1ADDR(_phys)) = (_val)) #define AR724X_PCI_CFG_SIZE 0x1000
#define AR724X_PCI_DEV_BASE 0x14000000
#define AR724X_PCI_MEM_BASE 0x10000000 #define AR724X_PCI_MEM_BASE 0x10000000
#define AR724X_PCI_MEM_SIZE 0x08000000 #define AR724X_PCI_MEM_SIZE 0x08000000
static DEFINE_SPINLOCK(ar724x_pci_lock); static DEFINE_SPINLOCK(ar724x_pci_lock);
static void __iomem *ar724x_pci_devcfg_base;
static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
int size, uint32_t *value) int size, uint32_t *value)
{ {
unsigned long flags, addr, tval, mask; unsigned long flags, addr, tval, mask;
void __iomem *base;
if (devfn) if (devfn)
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
...@@ -31,25 +31,27 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, ...@@ -31,25 +31,27 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
if (where & (size - 1)) if (where & (size - 1))
return PCIBIOS_BAD_REGISTER_NUMBER; return PCIBIOS_BAD_REGISTER_NUMBER;
base = ar724x_pci_devcfg_base;
spin_lock_irqsave(&ar724x_pci_lock, flags); spin_lock_irqsave(&ar724x_pci_lock, flags);
switch (size) { switch (size) {
case 1: case 1:
addr = where & ~3; addr = where & ~3;
mask = 0xff000000 >> ((where % 4) * 8); mask = 0xff000000 >> ((where % 4) * 8);
tval = reg_read(AR724X_PCI_DEV_BASE + addr); tval = __raw_readl(base + addr);
tval = tval & ~mask; tval = tval & ~mask;
*value = (tval >> ((4 - (where % 4))*8)); *value = (tval >> ((4 - (where % 4))*8));
break; break;
case 2: case 2:
addr = where & ~3; addr = where & ~3;
mask = 0xffff0000 >> ((where % 4)*8); mask = 0xffff0000 >> ((where % 4)*8);
tval = reg_read(AR724X_PCI_DEV_BASE + addr); tval = __raw_readl(base + addr);
tval = tval & ~mask; tval = tval & ~mask;
*value = (tval >> ((4 - (where % 4))*8)); *value = (tval >> ((4 - (where % 4))*8));
break; break;
case 4: case 4:
*value = reg_read(AR724X_PCI_DEV_BASE + where); *value = __raw_readl(base + where);
break; break;
default: default:
spin_unlock_irqrestore(&ar724x_pci_lock, flags); spin_unlock_irqrestore(&ar724x_pci_lock, flags);
...@@ -66,6 +68,7 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, ...@@ -66,6 +68,7 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
int size, uint32_t value) int size, uint32_t value)
{ {
unsigned long flags, tval, addr, mask; unsigned long flags, tval, addr, mask;
void __iomem *base;
if (devfn) if (devfn)
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
...@@ -73,27 +76,29 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where, ...@@ -73,27 +76,29 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
if (where & (size - 1)) if (where & (size - 1))
return PCIBIOS_BAD_REGISTER_NUMBER; return PCIBIOS_BAD_REGISTER_NUMBER;
base = ar724x_pci_devcfg_base;
spin_lock_irqsave(&ar724x_pci_lock, flags); spin_lock_irqsave(&ar724x_pci_lock, flags);
switch (size) { switch (size) {
case 1: case 1:
addr = (AR724X_PCI_DEV_BASE + where) & ~3; addr = where & ~3;
mask = 0xff000000 >> ((where % 4)*8); mask = 0xff000000 >> ((where % 4)*8);
tval = reg_read(addr); tval = __raw_readl(base + addr);
tval = tval & ~mask; tval = tval & ~mask;
tval |= (value << ((4 - (where % 4))*8)) & mask; tval |= (value << ((4 - (where % 4))*8)) & mask;
reg_write(addr, tval); __raw_writel(tval, base + addr);
break; break;
case 2: case 2:
addr = (AR724X_PCI_DEV_BASE + where) & ~3; addr = where & ~3;
mask = 0xffff0000 >> ((where % 4)*8); mask = 0xffff0000 >> ((where % 4)*8);
tval = reg_read(addr); tval = __raw_readl(base + addr);
tval = tval & ~mask; tval = tval & ~mask;
tval |= (value << ((4 - (where % 4))*8)) & mask; tval |= (value << ((4 - (where % 4))*8)) & mask;
reg_write(addr, tval); __raw_writel(tval, base + addr);
break; break;
case 4: case 4:
reg_write((AR724X_PCI_DEV_BASE + where), value); __raw_writel(value, (base + where));
break; break;
default: default:
spin_unlock_irqrestore(&ar724x_pci_lock, flags); spin_unlock_irqrestore(&ar724x_pci_lock, flags);
...@@ -133,6 +138,11 @@ static struct pci_controller ar724x_pci_controller = { ...@@ -133,6 +138,11 @@ static struct pci_controller ar724x_pci_controller = {
int __init ar724x_pcibios_init(void) int __init ar724x_pcibios_init(void)
{ {
ar724x_pci_devcfg_base = ioremap(AR724X_PCI_CFG_BASE,
AR724X_PCI_CFG_SIZE);
if (ar724x_pci_devcfg_base == NULL)
return -ENOMEM;
register_pci_controller(&ar724x_pci_controller); register_pci_controller(&ar724x_pci_controller);
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
......
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