Skip to content

Commit f587775

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: mvebu: Set PCI Bridge Class Code to PCI Bridge
The default value of Class Code of this bridge corresponds to a Memory controller, though. This is probably relict from the past when old Marvell/Galileo PCI-based controllers were used as standalone PCI device for connecting SDRAM or workaround for PCs with broken BIOS. Details are in commit 36de23a ("MIPS: Cobalt: Explain GT64111 early PCI fixup"). Change the Class Code to correspond to a PCI Bridge. Add comment explaining this change. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]>
1 parent df08ac0 commit f587775

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/pci/controller/pci-mvebu.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
214214

215215
static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
216216
{
217-
u32 ctrl, cmd, mask;
217+
u32 ctrl, cmd, dev_rev, mask;
218218

219219
/* Setup PCIe controller to Root Complex mode. */
220220
ctrl = mvebu_readl(port, PCIE_CTRL_OFF);
@@ -226,6 +226,32 @@ static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
226226
cmd &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
227227
mvebu_writel(port, cmd, PCIE_CMD_OFF);
228228

229+
/*
230+
* Change Class Code of PCI Bridge device to PCI Bridge (0x6004)
231+
* because default value is Memory controller (0x5080).
232+
*
233+
* Note that this mvebu PCI Bridge does not have compliant Type 1
234+
* Configuration Space. Header Type is reported as Type 0 and it
235+
* has format of Type 0 config space.
236+
*
237+
* Moreover Type 0 BAR registers (ranges 0x10 - 0x28 and 0x30 - 0x34)
238+
* have the same format in Marvell's specification as in PCIe
239+
* specification, but their meaning is totally different and they do
240+
* different things: they are aliased into internal mvebu registers
241+
* (e.g. PCIE_BAR_LO_OFF) and these should not be changed or
242+
* reconfigured by pci device drivers.
243+
*
244+
* Therefore driver uses emulation of PCI Bridge which emulates
245+
* access to configuration space via internal mvebu registers or
246+
* emulated configuration buffer. Driver access these PCI Bridge
247+
* directly for simplification, but these registers can be accessed
248+
* also via standard mvebu way for accessing PCI config space.
249+
*/
250+
dev_rev = mvebu_readl(port, PCIE_DEV_REV_OFF);
251+
dev_rev &= ~0xffffff00;
252+
dev_rev |= (PCI_CLASS_BRIDGE_PCI << 8) << 8;
253+
mvebu_writel(port, dev_rev, PCIE_DEV_REV_OFF);
254+
229255
/* Point PCIe unit MBUS decode windows to DRAM space. */
230256
mvebu_pcie_setup_wins(port);
231257

0 commit comments

Comments
 (0)