Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 830aa6f

Browse files
jim2101024bjorn-helgaas
authored andcommitted
PCI: brcmstb: Split brcm_pcie_setup() into two funcs
We need to take some code in brcm_pcie_setup() and put it in a new function brcm_pcie_linkup(). In future commits the brcm_pcie_linkup() function will be called indirectly by pci_host_probe() as opposed to the host driver invoking it directly. Some code that was executed after the PCIe linkup is now placed so that it executes prior to linkup, since this code has to run prior to the invocation of pci_host_probe(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jim Quinlan <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent ea372f4 commit 830aa6f

File tree

1 file changed

+39
-26
lines changed

1 file changed

+39
-26
lines changed

drivers/pci/controller/pcie-brcmstb.c

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -872,16 +872,9 @@ static inline int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie,
872872

873873
static int brcm_pcie_setup(struct brcm_pcie *pcie)
874874
{
875-
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
876875
u64 rc_bar2_offset, rc_bar2_size;
877876
void __iomem *base = pcie->base;
878-
struct device *dev = pcie->dev;
879-
struct resource_entry *entry;
880-
bool ssc_good = false;
881-
struct resource *res;
882-
int num_out_wins = 0;
883-
u16 nlw, cls, lnksta;
884-
int i, ret, memc;
877+
int ret, memc;
885878
u32 tmp, burst, aspm_support;
886879

887880
/* Reset the bridge */
@@ -966,6 +959,40 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
966959
if (pcie->gen)
967960
brcm_pcie_set_gen(pcie, pcie->gen);
968961

962+
/* Don't advertise L0s capability if 'aspm-no-l0s' */
963+
aspm_support = PCIE_LINK_STATE_L1;
964+
if (!of_property_read_bool(pcie->np, "aspm-no-l0s"))
965+
aspm_support |= PCIE_LINK_STATE_L0S;
966+
tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
967+
u32p_replace_bits(&tmp, aspm_support,
968+
PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
969+
writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
970+
971+
/*
972+
* For config space accesses on the RC, show the right class for
973+
* a PCIe-PCIe bridge (the default setting is to be EP mode).
974+
*/
975+
tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3);
976+
u32p_replace_bits(&tmp, 0x060400,
977+
PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK);
978+
writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3);
979+
980+
return 0;
981+
}
982+
983+
static int brcm_pcie_linkup(struct brcm_pcie *pcie)
984+
{
985+
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
986+
struct device *dev = pcie->dev;
987+
void __iomem *base = pcie->base;
988+
struct resource_entry *entry;
989+
struct resource *res;
990+
int num_out_wins = 0;
991+
u16 nlw, cls, lnksta;
992+
bool ssc_good = false;
993+
u32 tmp;
994+
int ret, i;
995+
969996
/* Unassert the fundamental reset */
970997
pcie->perst_set(pcie, 0);
971998

@@ -1003,24 +1030,6 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
10031030
num_out_wins++;
10041031
}
10051032

1006-
/* Don't advertise L0s capability if 'aspm-no-l0s' */
1007-
aspm_support = PCIE_LINK_STATE_L1;
1008-
if (!of_property_read_bool(pcie->np, "aspm-no-l0s"))
1009-
aspm_support |= PCIE_LINK_STATE_L0S;
1010-
tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
1011-
u32p_replace_bits(&tmp, aspm_support,
1012-
PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
1013-
writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
1014-
1015-
/*
1016-
* For config space accesses on the RC, show the right class for
1017-
* a PCIe-PCIe bridge (the default setting is to be EP mode).
1018-
*/
1019-
tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3);
1020-
u32p_replace_bits(&tmp, 0x060400,
1021-
PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK);
1022-
writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3);
1023-
10241033
if (pcie->ssc) {
10251034
ret = brcm_pcie_set_ssc(pcie);
10261035
if (ret == 0)
@@ -1209,6 +1218,10 @@ static int brcm_pcie_resume(struct device *dev)
12091218
if (ret)
12101219
goto err_reset;
12111220

1221+
ret = brcm_pcie_linkup(pcie);
1222+
if (ret)
1223+
goto err_reset;
1224+
12121225
if (pcie->msi)
12131226
brcm_msi_set_regs(pcie->msi);
12141227

0 commit comments

Comments
 (0)