Skip to content

Commit 8d18563

Browse files
Stanimir Varbanovgregkh
authored andcommitted
PCI: brcmstb: Reuse pcie_cfg_data structure
[ Upstream commit 10dbeda ] Instead of copying fields from the pcie_cfg_data structure to brcm_pcie, reference it directly. Signed-off-by: Stanimir Varbanov <svarbanov@suse.de> Reviewed-by: Florian Fainelil <florian.fainelli@broadcom.com> Reviewed-by: Jim Quinlan <james.quinlan@broadcom.com> Tested-by: Ivan T. Ivanov <iivanov@suse.de> Link: https://lore.kernel.org/r/20250224083559.47645-6-svarbanov@suse.de [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Stable-dep-of: 9583f9d ("PCI: brcmstb: Fix disabling L0s capability") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ebdbe19 commit 8d18563

1 file changed

Lines changed: 32 additions & 40 deletions

File tree

drivers/pci/controller/pcie-brcmstb.c

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@
191191
#define SSC_STATUS_PLL_LOCK_MASK 0x800
192192
#define PCIE_BRCM_MAX_MEMC 3
193193

194-
#define IDX_ADDR(pcie) ((pcie)->reg_offsets[EXT_CFG_INDEX])
195-
#define DATA_ADDR(pcie) ((pcie)->reg_offsets[EXT_CFG_DATA])
196-
#define PCIE_RGR1_SW_INIT_1(pcie) ((pcie)->reg_offsets[RGR1_SW_INIT_1])
197-
#define HARD_DEBUG(pcie) ((pcie)->reg_offsets[PCIE_HARD_DEBUG])
198-
#define INTR2_CPU_BASE(pcie) ((pcie)->reg_offsets[PCIE_INTR2_CPU_BASE])
194+
#define IDX_ADDR(pcie) ((pcie)->cfg->offsets[EXT_CFG_INDEX])
195+
#define DATA_ADDR(pcie) ((pcie)->cfg->offsets[EXT_CFG_DATA])
196+
#define PCIE_RGR1_SW_INIT_1(pcie) ((pcie)->cfg->offsets[RGR1_SW_INIT_1])
197+
#define HARD_DEBUG(pcie) ((pcie)->cfg->offsets[PCIE_HARD_DEBUG])
198+
#define INTR2_CPU_BASE(pcie) ((pcie)->cfg->offsets[PCIE_INTR2_CPU_BASE])
199199

200200
/* Rescal registers */
201201
#define PCIE_DVT_PMU_PCIE_PHY_CTRL 0xc700
@@ -276,26 +276,21 @@ struct brcm_pcie {
276276
int gen;
277277
u64 msi_target_addr;
278278
struct brcm_msi *msi;
279-
const int *reg_offsets;
280-
enum pcie_soc_base soc_base;
281279
struct reset_control *rescal;
282280
struct reset_control *perst_reset;
283281
struct reset_control *bridge_reset;
284282
struct reset_control *swinit_reset;
285283
int num_memc;
286284
u64 memc_size[PCIE_BRCM_MAX_MEMC];
287285
u32 hw_rev;
288-
int (*perst_set)(struct brcm_pcie *pcie, u32 val);
289-
int (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val);
290286
struct subdev_regulators *sr;
291287
bool ep_wakeup_capable;
292-
bool has_phy;
293-
u8 num_inbound_wins;
288+
const struct pcie_cfg_data *cfg;
294289
};
295290

296291
static inline bool is_bmips(const struct brcm_pcie *pcie)
297292
{
298-
return pcie->soc_base == BCM7435 || pcie->soc_base == BCM7425;
293+
return pcie->cfg->soc_base == BCM7435 || pcie->cfg->soc_base == BCM7425;
299294
}
300295

301296
/*
@@ -855,7 +850,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
855850
* security considerations, and is not implemented in our modern
856851
* SoCs.
857852
*/
858-
if (pcie->soc_base != BCM7712)
853+
if (pcie->cfg->soc_base != BCM7712)
859854
add_inbound_win(b++, &n, 0, 0, 0);
860855

861856
resource_list_for_each_entry(entry, &bridge->dma_ranges) {
@@ -872,10 +867,10 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
872867
* That being said, each BARs size must still be a power of
873868
* two.
874869
*/
875-
if (pcie->soc_base == BCM7712)
870+
if (pcie->cfg->soc_base == BCM7712)
876871
add_inbound_win(b++, &n, size, cpu_start, pcie_start);
877872

878-
if (n > pcie->num_inbound_wins)
873+
if (n > pcie->cfg->num_inbound_wins)
879874
break;
880875
}
881876

@@ -889,7 +884,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie,
889884
* that enables multiple memory controllers. As such, it can return
890885
* now w/o doing special configuration.
891886
*/
892-
if (pcie->soc_base == BCM7712)
887+
if (pcie->cfg->soc_base == BCM7712)
893888
return n;
894889

895890
ret = of_property_read_variable_u64_array(pcie->np, "brcm,scb-sizes", pcie->memc_size, 1,
@@ -1012,7 +1007,7 @@ static void set_inbound_win_registers(struct brcm_pcie *pcie,
10121007
* 7712:
10131008
* All of their BARs need to be set.
10141009
*/
1015-
if (pcie->soc_base == BCM7712) {
1010+
if (pcie->cfg->soc_base == BCM7712) {
10161011
/* BUS remap register settings */
10171012
reg_offset = brcm_ubus_reg_offset(i);
10181013
tmp = lower_32_bits(cpu_addr) & ~0xfff;
@@ -1036,23 +1031,23 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
10361031
int memc, ret;
10371032

10381033
/* Reset the bridge */
1039-
ret = pcie->bridge_sw_init_set(pcie, 1);
1034+
ret = pcie->cfg->bridge_sw_init_set(pcie, 1);
10401035
if (ret)
10411036
return ret;
10421037

10431038
/* Ensure that PERST# is asserted; some bootloaders may deassert it. */
1044-
if (pcie->soc_base == BCM2711) {
1045-
ret = pcie->perst_set(pcie, 1);
1039+
if (pcie->cfg->soc_base == BCM2711) {
1040+
ret = pcie->cfg->perst_set(pcie, 1);
10461041
if (ret) {
1047-
pcie->bridge_sw_init_set(pcie, 0);
1042+
pcie->cfg->bridge_sw_init_set(pcie, 0);
10481043
return ret;
10491044
}
10501045
}
10511046

10521047
usleep_range(100, 200);
10531048

10541049
/* Take the bridge out of reset */
1055-
ret = pcie->bridge_sw_init_set(pcie, 0);
1050+
ret = pcie->cfg->bridge_sw_init_set(pcie, 0);
10561051
if (ret)
10571052
return ret;
10581053

@@ -1072,9 +1067,9 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
10721067
*/
10731068
if (is_bmips(pcie))
10741069
burst = 0x1; /* 256 bytes */
1075-
else if (pcie->soc_base == BCM2711)
1070+
else if (pcie->cfg->soc_base == BCM2711)
10761071
burst = 0x0; /* 128 bytes */
1077-
else if (pcie->soc_base == BCM7278)
1072+
else if (pcie->cfg->soc_base == BCM7278)
10781073
burst = 0x3; /* 512 bytes */
10791074
else
10801075
burst = 0x2; /* 512 bytes */
@@ -1199,7 +1194,7 @@ static void brcm_extend_rbus_timeout(struct brcm_pcie *pcie)
11991194
u32 timeout_us = 4000000; /* 4 seconds, our setting for L1SS */
12001195

12011196
/* 7712 does not have this (RGR1) timer */
1202-
if (pcie->soc_base == BCM7712)
1197+
if (pcie->cfg->soc_base == BCM7712)
12031198
return;
12041199

12051200
/* Each unit in timeout register is 1/216,000,000 seconds */
@@ -1281,7 +1276,7 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)
12811276
brcm_pcie_set_gen(pcie, pcie->gen);
12821277

12831278
/* Unassert the fundamental reset */
1284-
ret = pcie->perst_set(pcie, 0);
1279+
ret = pcie->cfg->perst_set(pcie, 0);
12851280
if (ret)
12861281
return ret;
12871282

@@ -1465,12 +1460,12 @@ static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start)
14651460

14661461
static inline int brcm_phy_start(struct brcm_pcie *pcie)
14671462
{
1468-
return pcie->has_phy ? brcm_phy_cntl(pcie, 1) : 0;
1463+
return pcie->cfg->has_phy ? brcm_phy_cntl(pcie, 1) : 0;
14691464
}
14701465

14711466
static inline int brcm_phy_stop(struct brcm_pcie *pcie)
14721467
{
1473-
return pcie->has_phy ? brcm_phy_cntl(pcie, 0) : 0;
1468+
return pcie->cfg->has_phy ? brcm_phy_cntl(pcie, 0) : 0;
14741469
}
14751470

14761471
static int brcm_pcie_turn_off(struct brcm_pcie *pcie)
@@ -1481,7 +1476,7 @@ static int brcm_pcie_turn_off(struct brcm_pcie *pcie)
14811476
if (brcm_pcie_link_up(pcie))
14821477
brcm_pcie_enter_l23(pcie);
14831478
/* Assert fundamental reset */
1484-
ret = pcie->perst_set(pcie, 1);
1479+
ret = pcie->cfg->perst_set(pcie, 1);
14851480
if (ret)
14861481
return ret;
14871482

@@ -1496,7 +1491,7 @@ static int brcm_pcie_turn_off(struct brcm_pcie *pcie)
14961491
writel(tmp, base + HARD_DEBUG(pcie));
14971492

14981493
/* Shutdown PCIe bridge */
1499-
ret = pcie->bridge_sw_init_set(pcie, 1);
1494+
ret = pcie->cfg->bridge_sw_init_set(pcie, 1);
15001495

15011496
return ret;
15021497
}
@@ -1584,7 +1579,7 @@ static int brcm_pcie_resume_noirq(struct device *dev)
15841579
goto err_reset;
15851580

15861581
/* Take bridge out of reset so we can access the SERDES reg */
1587-
pcie->bridge_sw_init_set(pcie, 0);
1582+
pcie->cfg->bridge_sw_init_set(pcie, 0);
15881583

15891584
/* SERDES_IDDQ = 0 */
15901585
tmp = readl(base + HARD_DEBUG(pcie));
@@ -1805,12 +1800,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
18051800
pcie = pci_host_bridge_priv(bridge);
18061801
pcie->dev = &pdev->dev;
18071802
pcie->np = np;
1808-
pcie->reg_offsets = data->offsets;
1809-
pcie->soc_base = data->soc_base;
1810-
pcie->perst_set = data->perst_set;
1811-
pcie->bridge_sw_init_set = data->bridge_sw_init_set;
1812-
pcie->has_phy = data->has_phy;
1813-
pcie->num_inbound_wins = data->num_inbound_wins;
1803+
pcie->cfg = data;
18141804

18151805
pcie->base = devm_platform_ioremap_resource(pdev, 0);
18161806
if (IS_ERR(pcie->base))
@@ -1845,7 +1835,7 @@ static int brcm_pcie_probe(struct platform_device *pdev)
18451835
if (ret)
18461836
return dev_err_probe(&pdev->dev, ret, "could not enable clock\n");
18471837

1848-
pcie->bridge_sw_init_set(pcie, 0);
1838+
pcie->cfg->bridge_sw_init_set(pcie, 0);
18491839

18501840
if (pcie->swinit_reset) {
18511841
ret = reset_control_assert(pcie->swinit_reset);
@@ -1884,7 +1874,8 @@ static int brcm_pcie_probe(struct platform_device *pdev)
18841874
goto fail;
18851875

18861876
pcie->hw_rev = readl(pcie->base + PCIE_MISC_REVISION);
1887-
if (pcie->soc_base == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) {
1877+
if (pcie->cfg->soc_base == BCM4908 &&
1878+
pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) {
18881879
dev_err(pcie->dev, "hardware revision with unsupported PERST# setup\n");
18891880
ret = -ENODEV;
18901881
goto fail;
@@ -1904,7 +1895,8 @@ static int brcm_pcie_probe(struct platform_device *pdev)
19041895
}
19051896
}
19061897

1907-
bridge->ops = pcie->soc_base == BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops;
1898+
bridge->ops = pcie->cfg->soc_base == BCM7425 ?
1899+
&brcm7425_pcie_ops : &brcm_pcie_ops;
19081900
bridge->sysdata = pcie;
19091901

19101902
platform_set_drvdata(pdev, pcie);

0 commit comments

Comments
 (0)