Skip to content

Commit 7c7e53e

Browse files
shimodayLorenzo Pieralisi
authored andcommitted
PCI: rcar: Fix missing MACCTLR register setting in initialization sequence
The R-Car Gen2/3 manual - available at: https://www.renesas.com/eu/en/products/microcontrollers-microprocessors/rz/rzg/rzg1m.html#documents "RZ/G Series User's Manual: Hardware" section strictly enforces the MACCTLR inizialization value - 39.3.1 - "Initial Setting of PCI Express": "Be sure to write the initial value (= H'80FF 0000) to MACCTLR before enabling PCIETCTLR.CFINIT". To avoid unexpected behavior and to match the SW initialization sequence guidelines, this patch programs the MACCTLR with the correct value. Note that the MACCTLR.SPCHG bit in the MACCTLR register description reports that "Only writing 1 is valid and writing 0 is invalid" but this "invalid" has to be interpreted as a write-ignore aka "ignored", not "prohibited". Reported-by: Eugeniu Rosca <[email protected]> Fixes: c25da47 ("PCI: rcar: Add Renesas R-Car PCIe driver") Fixes: be20bbc ("PCI: rcar: Add the initialization of PCIe link in resume_noirq()") Signed-off-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Cc: <[email protected]> # v5.2+
1 parent 767c784 commit 7c7e53e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/pci/controller/pcie-rcar.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@
9191
#define LINK_SPEED_2_5GTS (1 << 16)
9292
#define LINK_SPEED_5_0GTS (2 << 16)
9393
#define MACCTLR 0x011058
94+
#define MACCTLR_NFTS_MASK GENMASK(23, 16) /* The name is from SH7786 */
9495
#define SPEED_CHANGE BIT(24)
9596
#define SCRAMBLE_DISABLE BIT(27)
97+
#define LTSMDIS BIT(31)
98+
#define MACCTLR_INIT_VAL (LTSMDIS | MACCTLR_NFTS_MASK)
9699
#define PMSR 0x01105c
97100
#define MACS2R 0x011078
98101
#define MACCGSPSETR 0x011084
@@ -613,6 +616,8 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie)
613616
if (IS_ENABLED(CONFIG_PCI_MSI))
614617
rcar_pci_write_reg(pcie, 0x801f0000, PCIEMSITXR);
615618

619+
rcar_pci_write_reg(pcie, MACCTLR_INIT_VAL, MACCTLR);
620+
616621
/* Finish initialization - establish a PCI Express link */
617622
rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR);
618623

@@ -1235,6 +1240,7 @@ static int rcar_pcie_resume_noirq(struct device *dev)
12351240
return 0;
12361241

12371242
/* Re-establish the PCIe link */
1243+
rcar_pci_write_reg(pcie, MACCTLR_INIT_VAL, MACCTLR);
12381244
rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR);
12391245
return rcar_pcie_wait_for_dl(pcie);
12401246
}

0 commit comments

Comments
 (0)