Date: Thu, 12 Apr 2012 22:38:11 -0700 From: Adrian Chadd <adrian.chadd@gmail.com> To: freebsd-mips@freebsd.org Subject: [ar71xx] PCI changes from ar71xx in openwrt Message-ID: <CAJ-VmokCQW_6pPAX9JgKmgWtiqU%2B2O_Nay%2BAbTQU_vNWT0zppw@mail.gmail.com>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hi,
I've noticed that the ar71xx PCI code in openwrt trunk is .. different.
Specifically, the "local" config stuff isn't handled in bus/slot/func
'0/0/0' - it's a different function.
This patch brings it in sync:
* break the local config writes into a new function, matching what Linux does;
* use that when doing the "PCI work around" during PCI bus attach;
* change that to a 4 byte write, rather than a 2 byte write, which
again matches what Linux does;
* change the pci read/write config to not treat 0/0/0 special and use
"local" read/write.
Any issues?
Adrian
[-- Attachment #2 --]
Index: ar71xx_pci.c
===================================================================
--- ar71xx_pci.c (revision 234157)
+++ ar71xx_pci.c (working copy)
@@ -207,17 +207,11 @@
dprintf("%s: tag (%x, %x, %x) reg %d(%d)\n", __func__, bus, slot,
func, reg, bytes);
- if ((bus == 0) && (slot == 0) && (func == 0)) {
- cmd = PCI_LCONF_CMD_READ | (reg & ~3);
- ATH_WRITE_REG(AR71XX_PCI_LCONF_CMD, cmd);
- data = ATH_READ_REG(AR71XX_PCI_LCONF_READ_DATA);
- } else {
- if (ar71xx_pci_conf_setup(bus, slot, func, reg, bytes,
- PCI_CONF_CMD_READ) == 0)
- data = ATH_READ_REG(AR71XX_PCI_CONF_READ_DATA);
- else
- data = -1;
- }
+ if (ar71xx_pci_conf_setup(bus, slot, func, reg, bytes,
+ PCI_CONF_CMD_READ) == 0)
+ data = ATH_READ_REG(AR71XX_PCI_CONF_READ_DATA);
+ else
+ data = -1;
/* get request bytes from 32-bit word */
data = (data >> shift) & mask;
@@ -228,26 +222,33 @@
}
static void
-ar71xx_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func,
- u_int reg, uint32_t data, int bytes)
+ar71xx_pci_local_write(device_t dev, uint32_t reg, uint32_t data, int bytes)
{
uint32_t cmd;
- dprintf("%s: tag (%x, %x, %x) reg %d(%d)\n", __func__, bus, slot,
+ dprintf("%s: local write reg %d(%d)\n", __func__, reg, bytes);
+
+ data = data << (8*(reg % 4));
+
+ cmd = PCI_LCONF_CMD_WRITE | (reg & ~3);
+ cmd |= (ar71xx_get_bytes_to_read(reg, bytes) << 20);
+ ATH_WRITE_REG(AR71XX_PCI_LCONF_CMD, cmd);
+ ATH_WRITE_REG(AR71XX_PCI_LCONF_WRITE_DATA, data);
+}
+
+static void
+ar71xx_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func,
+ u_int reg, uint32_t data, int bytes)
+{
+
+ dprintf("%s: tag (%x, %x, %x) reg %d(%d)\n", __func__, bus, slot,
func, reg, bytes);
data = data << (8*(reg % 4));
- if ((bus == 0) && (slot == 0) && (func == 0)) {
- cmd = PCI_LCONF_CMD_WRITE | (reg & ~3);
- cmd |= ar71xx_get_bytes_to_read(reg, bytes) << 20;
- ATH_WRITE_REG(AR71XX_PCI_LCONF_CMD, cmd);
- ATH_WRITE_REG(AR71XX_PCI_LCONF_WRITE_DATA, data);
- } else {
- if (ar71xx_pci_conf_setup(bus, slot, func, reg, bytes,
- PCI_CONF_CMD_WRITE) == 0)
- ATH_WRITE_REG(AR71XX_PCI_CONF_WRITE_DATA, data);
- }
+ if (ar71xx_pci_conf_setup(bus, slot, func, reg, bytes,
+ PCI_CONF_CMD_WRITE) == 0)
+ ATH_WRITE_REG(AR71XX_PCI_CONF_WRITE_DATA, data);
}
#ifdef AR71XX_ATH_EEPROM
@@ -389,10 +390,10 @@
ar71xx_pci_check_bus_error();
/* Fixup internal PCI bridge */
- ar71xx_pci_write_config(dev, 0, 0, 0, PCIR_COMMAND,
- PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN
+ ar71xx_pci_local_write(dev, PCIR_COMMAND,
+ PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN
| PCIM_CMD_SERRESPEN | PCIM_CMD_BACKTOBACK
- | PCIM_CMD_PERRESPEN | PCIM_CMD_MWRICEN, 2);
+ | PCIM_CMD_PERRESPEN | PCIM_CMD_MWRICEN, 4);
#ifdef AR71XX_ATH_EEPROM
/*
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-VmokCQW_6pPAX9JgKmgWtiqU%2B2O_Nay%2BAbTQU_vNWT0zppw>
