From: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
Sergey Ryazanov <ryazanov.s.a@gmail.com>
Cc: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
Tobias Wolf <dev-NTEO@vplace.de>,
stable@vger.kernel.org
Subject: [PATCH v2 1/8] MIPS: pci-rt2880: fix slot 0 configuration
Date: Tue, 13 Apr 2021 20:12:33 -0700 [thread overview]
Message-ID: <20210414031240.313852-2-ilya.lipnitskiy@gmail.com> (raw)
In-Reply-To: <20210414031240.313852-1-ilya.lipnitskiy@gmail.com>
pci_fixup_irqs() used to call pcibios_map_irq on every PCI device, which
for RT2880 included bus 0 slot 0. After pci_fixup_irqs() got removed,
only slots/funcs with devices attached would be called. While arguably
the right thing, that left no chance for this driver to ever initialize
slot 0, effectively bricking PCI and USB on RT2880 devices such as the
Belkin F5D8235-4 v1.
Slot 0 configuration needs to happen after PCI bus enumeration, but
before any device at slot 0x11 (func 0 or 1) is talked to. That was
determined empirically by testing on a Belkin F5D8235-4 v1 device. A
minimal BAR 0 config write followed by read, then setting slot 0
PCI_COMMAND to MASTER | IO | MEMORY is all that seems to be required for
proper functionality.
Tested by ensuring that full- and high-speed USB devices get enumerated
on the Belkin F5D8235-4 v1 (with an out of tree DTS file from OpenWrt).
Fixes: 04c81c7293df ("MIPS: PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks")
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Tobias Wolf <dev-NTEO@vplace.de>
Cc: <stable@vger.kernel.org> # v4.14+
---
arch/mips/pci/pci-rt2880.c | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/arch/mips/pci/pci-rt2880.c b/arch/mips/pci/pci-rt2880.c
index e1f12e398136..f1538d2be89e 100644
--- a/arch/mips/pci/pci-rt2880.c
+++ b/arch/mips/pci/pci-rt2880.c
@@ -180,7 +180,6 @@ static inline void rt2880_pci_write_u32(unsigned long reg, u32 val)
int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
{
- u16 cmd;
int irq = -1;
if (dev->bus->number != 0)
@@ -188,8 +187,6 @@ int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
switch (PCI_SLOT(dev->devfn)) {
case 0x00:
- rt2880_pci_write_u32(PCI_BASE_ADDRESS_0, 0x08000000);
- (void) rt2880_pci_read_u32(PCI_BASE_ADDRESS_0);
break;
case 0x11:
irq = RT288X_CPU_IRQ_PCI;
@@ -201,16 +198,6 @@ int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
break;
}
- pci_write_config_byte((struct pci_dev *) dev,
- PCI_CACHE_LINE_SIZE, 0x14);
- pci_write_config_byte((struct pci_dev *) dev, PCI_LATENCY_TIMER, 0xFF);
- pci_read_config_word((struct pci_dev *) dev, PCI_COMMAND, &cmd);
- cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
- PCI_COMMAND_INVALIDATE | PCI_COMMAND_FAST_BACK |
- PCI_COMMAND_SERR | PCI_COMMAND_WAIT | PCI_COMMAND_PARITY;
- pci_write_config_word((struct pci_dev *) dev, PCI_COMMAND, cmd);
- pci_write_config_byte((struct pci_dev *) dev, PCI_INTERRUPT_LINE,
- dev->irq);
return irq;
}
@@ -251,6 +238,30 @@ static int rt288x_pci_probe(struct platform_device *pdev)
int pcibios_plat_dev_init(struct pci_dev *dev)
{
+ static bool slot0_init;
+
+ /*
+ * Nobody seems to initialize slot 0, but this platform requires it, so
+ * do it once when some other slot is being enabled. The PCI subsystem
+ * should configure other slots properly, so no need to do anything
+ * special for those.
+ */
+ if (!slot0_init && dev->bus->number == 0) {
+ u16 cmd;
+ u32 bar0;
+
+ slot0_init = true;
+
+ pci_bus_write_config_dword(dev->bus, 0, PCI_BASE_ADDRESS_0,
+ 0x08000000);
+ pci_bus_read_config_dword(dev->bus, 0, PCI_BASE_ADDRESS_0,
+ &bar0);
+
+ pci_bus_read_config_word(dev->bus, 0, PCI_COMMAND, &cmd);
+ cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
+ pci_bus_write_config_word(dev->bus, 0, PCI_COMMAND, cmd);
+ }
+
return 0;
}
--
2.31.1
next prev parent reply other threads:[~2021-04-14 3:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 3:12 [PATCH v2 0/8] MIPS: fixes for PCI legacy drivers (rt2880, rt3883) Ilya Lipnitskiy
2021-04-14 3:12 ` Ilya Lipnitskiy [this message]
2021-04-14 3:12 ` [PATCH v2 2/8] MIPS: pci-rt2880: remove unneeded locks Ilya Lipnitskiy
2021-04-15 8:07 ` Sergey Ryazanov
2021-04-14 3:12 ` [PATCH v2 3/8] MIPS: pci-rt3883: trivial: remove unused variable Ilya Lipnitskiy
2021-04-14 3:12 ` [PATCH v2 4/8] MIPS: pci-rt3883: more accurate DT error messages Ilya Lipnitskiy
2021-04-14 3:12 ` [PATCH v2 5/8] MIPS: pci-legacy: stop using of_pci_range_to_resource Ilya Lipnitskiy
2021-04-16 16:00 ` Liviu Dudau
2021-04-14 3:12 ` [PATCH v2 6/8] MIPS: pci-legacy: remove redundant info messages Ilya Lipnitskiy
2021-04-14 3:12 ` [PATCH v2 7/8] MIPS: pci-legacy: remove busn_resource field Ilya Lipnitskiy
2021-04-14 3:12 ` [PATCH v2 8/8] MIPS: pci-legacy: use generic pci_enable_resources Ilya Lipnitskiy
2021-04-20 5:23 ` Guenter Roeck
2021-04-20 6:39 ` [PATCH] MIPS: pci-legacy: revert "use generic pci_enable_resources" Ilya Lipnitskiy
2021-04-20 22:56 ` Guenter Roeck
2021-04-21 12:02 ` Thomas Bogendoerfer
2021-04-16 7:22 ` [PATCH v2 0/8] MIPS: fixes for PCI legacy drivers (rt2880, rt3883) Thomas Bogendoerfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210414031240.313852-2-ilya.lipnitskiy@gmail.com \
--to=ilya.lipnitskiy@gmail.com \
--cc=dev-NTEO@vplace.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=ryazanov.s.a@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®