Skip to content

Commit 216f8e9

Browse files
Shmuel HazanLorenzo Pieralisi
authored andcommitted
PCI: mvebu: Setup BAR0 in order to fix MSI
According to the Armada XP datasheet, section 10.2.6: "in order for the device to do a write to the MSI doorbell address, it needs to write to a register in the internal registers space". As a result of the requirement above, without this patch, MSI won't function and therefore some devices won't operate properly without pci=nomsi. This requirement was not present at the time of writing this driver since the vendor u-boot always initializes all PCIe controllers (incl. BAR0 initialization) and for some time, the vendor u-boot was the only available bootloader for this driver's SoCs (e.g. A38x,A37x, etc). Tested on an Armada 385 board on mainline u-boot (2020.4), without u-boot PCI initialization and the following PCIe devices: - Wilocity Wil6200 rev 2 (wil6210) - Qualcomm Atheros QCA6174 (ath10k_pci) Both failed to get a response from the device after loading the firmware and seem to operate properly with this patch. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Shmuel Hazan <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Acked-by: Thomas Petazzoni <[email protected]>
1 parent b3a9e3b commit 216f8e9

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/pci/controller/pci-mvebu.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct mvebu_pcie_port {
105105
struct mvebu_pcie_window memwin;
106106
struct mvebu_pcie_window iowin;
107107
u32 saved_pcie_stat;
108+
struct resource regs;
108109
};
109110

110111
static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg)
@@ -149,7 +150,9 @@ static void mvebu_pcie_set_local_dev_nr(struct mvebu_pcie_port *port, int nr)
149150

150151
/*
151152
* Setup PCIE BARs and Address Decode Wins:
152-
* BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks
153+
* BAR[0] -> internal registers (needed for MSI)
154+
* BAR[1] -> covers all DRAM banks
155+
* BAR[2] -> Disabled
153156
* WIN[0-3] -> DRAM bank[0-3]
154157
*/
155158
static void mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
@@ -203,6 +206,12 @@ static void mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
203206
mvebu_writel(port, 0, PCIE_BAR_HI_OFF(1));
204207
mvebu_writel(port, ((size - 1) & 0xffff0000) | 1,
205208
PCIE_BAR_CTRL_OFF(1));
209+
210+
/*
211+
* Point BAR[0] to the device's internal registers.
212+
*/
213+
mvebu_writel(port, round_down(port->regs.start, SZ_1M), PCIE_BAR_LO_OFF(0));
214+
mvebu_writel(port, 0, PCIE_BAR_HI_OFF(0));
206215
}
207216

208217
static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
@@ -708,14 +717,13 @@ static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev,
708717
struct device_node *np,
709718
struct mvebu_pcie_port *port)
710719
{
711-
struct resource regs;
712720
int ret = 0;
713721

714-
ret = of_address_to_resource(np, 0, &regs);
722+
ret = of_address_to_resource(np, 0, &port->regs);
715723
if (ret)
716724
return (void __iomem *)ERR_PTR(ret);
717725

718-
return devm_ioremap_resource(&pdev->dev, &regs);
726+
return devm_ioremap_resource(&pdev->dev, &port->regs);
719727
}
720728

721729
#define DT_FLAGS_TO_TYPE(flags) (((flags) >> 24) & 0x03)

0 commit comments

Comments
 (0)