Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309041
b: refs/heads/master
c: 6015a85
h: refs/heads/master
i:
  309039: 73820ba
v: v3
  • Loading branch information
Gabor Juhos authored and Ralf Baechle committed May 15, 2012
1 parent d6b5de5 commit e07f7c9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 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: 64adb6bb62bee11ad04c2f9c3c797799e329c351
refs/heads/master: 6015a856f16ccf33e9f83643d04c2e15be2384eb
36 changes: 35 additions & 1 deletion trunk/arch/mips/pci/pci-ar724x.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@
*/

#include <linux/pci.h>
#include <asm/mach-ath79/ath79.h>
#include <asm/mach-ath79/pci.h>

#define AR724X_PCI_CFG_BASE 0x14000000
#define AR724X_PCI_CFG_SIZE 0x1000
#define AR724X_PCI_MEM_BASE 0x10000000
#define AR724X_PCI_MEM_SIZE 0x08000000

#define AR7240_BAR0_WAR_VALUE 0xffff

static DEFINE_SPINLOCK(ar724x_pci_lock);
static void __iomem *ar724x_pci_devcfg_base;

static u32 ar724x_pci_bar0_value;
static bool ar724x_pci_bar0_is_cached;

static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
int size, uint32_t *value)
{
Expand Down Expand Up @@ -56,7 +62,14 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
}

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

if (where == PCI_BASE_ADDRESS_0 && size == 4 &&
ar724x_pci_bar0_is_cached) {
/* use the cached value */
*value = ar724x_pci_bar0_value;
} else {
*value = data;
}

return PCIBIOS_SUCCESSFUL;
}
Expand All @@ -72,6 +85,27 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
if (devfn)
return PCIBIOS_DEVICE_NOT_FOUND;

if (soc_is_ar7240() && where == PCI_BASE_ADDRESS_0 && size == 4) {
if (value != 0xffffffff) {
/*
* WAR for a hw issue. If the BAR0 register of the
* device is set to the proper base address, the
* memory space of the device is not accessible.
*
* Cache the intended value so it can be read back,
* and write a SoC specific constant value to the
* BAR0 register in order to make the device memory
* accessible.
*/
ar724x_pci_bar0_is_cached = true;
ar724x_pci_bar0_value = value;

value = AR7240_BAR0_WAR_VALUE;
} else {
ar724x_pci_bar0_is_cached = false;
}
}

base = ar724x_pci_devcfg_base;

spin_lock_irqsave(&ar724x_pci_lock, flags);
Expand Down

0 comments on commit e07f7c9

Please sign in to comment.