Skip to content

Commit c96992a

Browse files
PCI: dwc: Add support for ELBI resource mapping
External Local Bus Interface (ELBI) is an optional register space for all DWC IPs containing the vendor specific registers. There is no need for the vendor glue drivers to fetch and map the ELBI region separately. Hence, optionally fetch and map the resource from DT in the DWC core. This also warrants dropping the corresponding code from glue drivers. Hence, drop the ELBI resource fetch and map logic from glue drivers and convert them to use 'dw_pci::elbi_base'. Note that the pcie-qcom-ep driver used devm_pci_remap_cfg_resource() to map the ELBI resource previously. But it was a mistake since devm_pci_remap_cfg_resource() should only be used for mapping the PCIe config space region as it maps the region as Non-Posted. As ELBI is used to hold vendor specific registers, there is no need to map the region as Non-Posted. With this conversion, the region will get mapped as normal MMIO memory. Suggested-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Krishna Chaitanya Chundru <[email protected]> [mani: removed elbi override, converted glue drivers and reworded description] Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent af8df70 commit c96992a

File tree

5 files changed

+50
-52
lines changed

5 files changed

+50
-52
lines changed

drivers/pci/controller/dwc/pci-exynos.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454
struct exynos_pcie {
5555
struct dw_pcie pci;
56-
void __iomem *elbi_base;
5756
struct clk_bulk_data *clks;
5857
struct phy *phy;
5958
struct regulator_bulk_data supplies[2];
@@ -71,73 +70,78 @@ static u32 exynos_pcie_readl(void __iomem *base, u32 reg)
7170

7271
static void exynos_pcie_sideband_dbi_w_mode(struct exynos_pcie *ep, bool on)
7372
{
73+
struct dw_pcie *pci = &ep->pci;
7474
u32 val;
7575

76-
val = exynos_pcie_readl(ep->elbi_base, PCIE_ELBI_SLV_AWMISC);
76+
val = exynos_pcie_readl(pci->elbi_base, PCIE_ELBI_SLV_AWMISC);
7777
if (on)
7878
val |= PCIE_ELBI_SLV_DBI_ENABLE;
7979
else
8080
val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
81-
exynos_pcie_writel(ep->elbi_base, val, PCIE_ELBI_SLV_AWMISC);
81+
exynos_pcie_writel(pci->elbi_base, val, PCIE_ELBI_SLV_AWMISC);
8282
}
8383

8484
static void exynos_pcie_sideband_dbi_r_mode(struct exynos_pcie *ep, bool on)
8585
{
86+
struct dw_pcie *pci = &ep->pci;
8687
u32 val;
8788

88-
val = exynos_pcie_readl(ep->elbi_base, PCIE_ELBI_SLV_ARMISC);
89+
val = exynos_pcie_readl(pci->elbi_base, PCIE_ELBI_SLV_ARMISC);
8990
if (on)
9091
val |= PCIE_ELBI_SLV_DBI_ENABLE;
9192
else
9293
val &= ~PCIE_ELBI_SLV_DBI_ENABLE;
93-
exynos_pcie_writel(ep->elbi_base, val, PCIE_ELBI_SLV_ARMISC);
94+
exynos_pcie_writel(pci->elbi_base, val, PCIE_ELBI_SLV_ARMISC);
9495
}
9596

9697
static void exynos_pcie_assert_core_reset(struct exynos_pcie *ep)
9798
{
99+
struct dw_pcie *pci = &ep->pci;
98100
u32 val;
99101

100-
val = exynos_pcie_readl(ep->elbi_base, PCIE_CORE_RESET);
102+
val = exynos_pcie_readl(pci->elbi_base, PCIE_CORE_RESET);
101103
val &= ~PCIE_CORE_RESET_ENABLE;
102-
exynos_pcie_writel(ep->elbi_base, val, PCIE_CORE_RESET);
103-
exynos_pcie_writel(ep->elbi_base, 0, PCIE_STICKY_RESET);
104-
exynos_pcie_writel(ep->elbi_base, 0, PCIE_NONSTICKY_RESET);
104+
exynos_pcie_writel(pci->elbi_base, val, PCIE_CORE_RESET);
105+
exynos_pcie_writel(pci->elbi_base, 0, PCIE_STICKY_RESET);
106+
exynos_pcie_writel(pci->elbi_base, 0, PCIE_NONSTICKY_RESET);
105107
}
106108

107109
static void exynos_pcie_deassert_core_reset(struct exynos_pcie *ep)
108110
{
111+
struct dw_pcie *pci = &ep->pci;
109112
u32 val;
110113

111-
val = exynos_pcie_readl(ep->elbi_base, PCIE_CORE_RESET);
114+
val = exynos_pcie_readl(pci->elbi_base, PCIE_CORE_RESET);
112115
val |= PCIE_CORE_RESET_ENABLE;
113116

114-
exynos_pcie_writel(ep->elbi_base, val, PCIE_CORE_RESET);
115-
exynos_pcie_writel(ep->elbi_base, 1, PCIE_STICKY_RESET);
116-
exynos_pcie_writel(ep->elbi_base, 1, PCIE_NONSTICKY_RESET);
117-
exynos_pcie_writel(ep->elbi_base, 1, PCIE_APP_INIT_RESET);
118-
exynos_pcie_writel(ep->elbi_base, 0, PCIE_APP_INIT_RESET);
117+
exynos_pcie_writel(pci->elbi_base, val, PCIE_CORE_RESET);
118+
exynos_pcie_writel(pci->elbi_base, 1, PCIE_STICKY_RESET);
119+
exynos_pcie_writel(pci->elbi_base, 1, PCIE_NONSTICKY_RESET);
120+
exynos_pcie_writel(pci->elbi_base, 1, PCIE_APP_INIT_RESET);
121+
exynos_pcie_writel(pci->elbi_base, 0, PCIE_APP_INIT_RESET);
119122
}
120123

121124
static int exynos_pcie_start_link(struct dw_pcie *pci)
122125
{
123-
struct exynos_pcie *ep = to_exynos_pcie(pci);
124126
u32 val;
125127

126-
val = exynos_pcie_readl(ep->elbi_base, PCIE_SW_WAKE);
128+
val = exynos_pcie_readl(pci->elbi_base, PCIE_SW_WAKE);
127129
val &= ~PCIE_BUS_EN;
128-
exynos_pcie_writel(ep->elbi_base, val, PCIE_SW_WAKE);
130+
exynos_pcie_writel(pci->elbi_base, val, PCIE_SW_WAKE);
129131

130132
/* assert LTSSM enable */
131-
exynos_pcie_writel(ep->elbi_base, PCIE_ELBI_LTSSM_ENABLE,
133+
exynos_pcie_writel(pci->elbi_base, PCIE_ELBI_LTSSM_ENABLE,
132134
PCIE_APP_LTSSM_ENABLE);
133135
return 0;
134136
}
135137

136138
static void exynos_pcie_clear_irq_pulse(struct exynos_pcie *ep)
137139
{
138-
u32 val = exynos_pcie_readl(ep->elbi_base, PCIE_IRQ_PULSE);
140+
struct dw_pcie *pci = &ep->pci;
139141

140-
exynos_pcie_writel(ep->elbi_base, val, PCIE_IRQ_PULSE);
142+
u32 val = exynos_pcie_readl(pci->elbi_base, PCIE_IRQ_PULSE);
143+
144+
exynos_pcie_writel(pci->elbi_base, val, PCIE_IRQ_PULSE);
141145
}
142146

143147
static irqreturn_t exynos_pcie_irq_handler(int irq, void *arg)
@@ -150,12 +154,14 @@ static irqreturn_t exynos_pcie_irq_handler(int irq, void *arg)
150154

151155
static void exynos_pcie_enable_irq_pulse(struct exynos_pcie *ep)
152156
{
157+
struct dw_pcie *pci = &ep->pci;
158+
153159
u32 val = IRQ_INTA_ASSERT | IRQ_INTB_ASSERT |
154160
IRQ_INTC_ASSERT | IRQ_INTD_ASSERT;
155161

156-
exynos_pcie_writel(ep->elbi_base, val, PCIE_IRQ_EN_PULSE);
157-
exynos_pcie_writel(ep->elbi_base, 0, PCIE_IRQ_EN_LEVEL);
158-
exynos_pcie_writel(ep->elbi_base, 0, PCIE_IRQ_EN_SPECIAL);
162+
exynos_pcie_writel(pci->elbi_base, val, PCIE_IRQ_EN_PULSE);
163+
exynos_pcie_writel(pci->elbi_base, 0, PCIE_IRQ_EN_LEVEL);
164+
exynos_pcie_writel(pci->elbi_base, 0, PCIE_IRQ_EN_SPECIAL);
159165
}
160166

161167
static u32 exynos_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base,
@@ -211,8 +217,7 @@ static struct pci_ops exynos_pci_ops = {
211217

212218
static bool exynos_pcie_link_up(struct dw_pcie *pci)
213219
{
214-
struct exynos_pcie *ep = to_exynos_pcie(pci);
215-
u32 val = exynos_pcie_readl(ep->elbi_base, PCIE_ELBI_RDLH_LINKUP);
220+
u32 val = exynos_pcie_readl(pci->elbi_base, PCIE_ELBI_RDLH_LINKUP);
216221

217222
return val & PCIE_ELBI_XMLH_LINKUP;
218223
}
@@ -295,11 +300,6 @@ static int exynos_pcie_probe(struct platform_device *pdev)
295300
if (IS_ERR(ep->phy))
296301
return PTR_ERR(ep->phy);
297302

298-
/* External Local Bus interface (ELBI) registers */
299-
ep->elbi_base = devm_platform_ioremap_resource_byname(pdev, "elbi");
300-
if (IS_ERR(ep->elbi_base))
301-
return PTR_ERR(ep->elbi_base);
302-
303303
ret = devm_clk_bulk_get_all_enabled(dev, &ep->clks);
304304
if (ret < 0)
305305
return ret;

drivers/pci/controller/dwc/pcie-designware.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ int dw_pcie_get_resources(struct dw_pcie *pci)
167167
}
168168
}
169169

170+
/* ELBI is an optional resource */
171+
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
172+
if (res) {
173+
pci->elbi_base = devm_ioremap_resource(pci->dev, res);
174+
if (IS_ERR(pci->elbi_base))
175+
return PTR_ERR(pci->elbi_base);
176+
}
177+
170178
/* LLDD is supposed to manually switch the clocks and resets state */
171179
if (dw_pcie_cap_is(pci, REQ_RES)) {
172180
ret = dw_pcie_get_clocks(pci);

drivers/pci/controller/dwc/pcie-designware.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ struct dw_pcie {
491491
resource_size_t dbi_phys_addr;
492492
void __iomem *dbi_base2;
493493
void __iomem *atu_base;
494+
void __iomem *elbi_base;
494495
resource_size_t atu_phys_addr;
495496
size_t atu_size;
496497
resource_size_t parent_bus_offset;

drivers/pci/controller/dwc/pcie-qcom-ep.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ struct qcom_pcie_ep_cfg {
179179
* struct qcom_pcie_ep - Qualcomm PCIe Endpoint Controller
180180
* @pci: Designware PCIe controller struct
181181
* @parf: Qualcomm PCIe specific PARF register base
182-
* @elbi: Designware PCIe specific ELBI register base
183182
* @mmio: MMIO register base
184183
* @perst_map: PERST regmap
185184
* @mmio_res: MMIO region resource
@@ -202,7 +201,6 @@ struct qcom_pcie_ep {
202201
struct dw_pcie pci;
203202

204203
void __iomem *parf;
205-
void __iomem *elbi;
206204
void __iomem *mmio;
207205
struct regmap *perst_map;
208206
struct resource *mmio_res;
@@ -267,10 +265,9 @@ static void qcom_pcie_ep_configure_tcsr(struct qcom_pcie_ep *pcie_ep)
267265

268266
static bool qcom_pcie_dw_link_up(struct dw_pcie *pci)
269267
{
270-
struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci);
271268
u32 reg;
272269

273-
reg = readl_relaxed(pcie_ep->elbi + ELBI_SYS_STTS);
270+
reg = readl_relaxed(pci->elbi_base + ELBI_SYS_STTS);
274271

275272
return reg & XMLH_LINK_UP;
276273
}
@@ -294,16 +291,15 @@ static void qcom_pcie_dw_stop_link(struct dw_pcie *pci)
294291
static void qcom_pcie_dw_write_dbi2(struct dw_pcie *pci, void __iomem *base,
295292
u32 reg, size_t size, u32 val)
296293
{
297-
struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci);
298294
int ret;
299295

300-
writel(1, pcie_ep->elbi + ELBI_CS2_ENABLE);
296+
writel(1, pci->elbi_base + ELBI_CS2_ENABLE);
301297

302298
ret = dw_pcie_write(pci->dbi_base2 + reg, size, val);
303299
if (ret)
304300
dev_err(pci->dev, "Failed to write DBI2 register (0x%x): %d\n", reg, ret);
305301

306-
writel(0, pcie_ep->elbi + ELBI_CS2_ENABLE);
302+
writel(0, pci->elbi_base + ELBI_CS2_ENABLE);
307303
}
308304

309305
static void qcom_pcie_ep_icc_update(struct qcom_pcie_ep *pcie_ep)
@@ -583,11 +579,6 @@ static int qcom_pcie_ep_get_io_resources(struct platform_device *pdev,
583579
return PTR_ERR(pci->dbi_base);
584580
pci->dbi_base2 = pci->dbi_base;
585581

586-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi");
587-
pcie_ep->elbi = devm_pci_remap_cfg_resource(dev, res);
588-
if (IS_ERR(pcie_ep->elbi))
589-
return PTR_ERR(pcie_ep->elbi);
590-
591582
pcie_ep->mmio_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
592583
"mmio");
593584
if (!pcie_ep->mmio_res) {

drivers/pci/controller/dwc/pcie-qcom.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ struct qcom_pcie_port {
276276
struct qcom_pcie {
277277
struct dw_pcie *pci;
278278
void __iomem *parf; /* DT parf */
279-
void __iomem *elbi; /* DT elbi */
280279
void __iomem *mhi;
281280
union qcom_pcie_resources res;
282281
struct icc_path *icc_mem;
@@ -409,12 +408,17 @@ static void qcom_pcie_configure_dbi_atu_base(struct qcom_pcie *pcie)
409408

410409
static void qcom_pcie_2_1_0_ltssm_enable(struct qcom_pcie *pcie)
411410
{
411+
struct dw_pcie *pci = pcie->pci;
412412
u32 val;
413413

414+
if (!pci->elbi_base) {
415+
dev_err(pci->dev, "ELBI is not present\n");
416+
return;
417+
}
414418
/* enable link training */
415-
val = readl(pcie->elbi + ELBI_SYS_CTRL);
419+
val = readl(pci->elbi_base + ELBI_SYS_CTRL);
416420
val |= ELBI_SYS_CTRL_LT_ENABLE;
417-
writel(val, pcie->elbi + ELBI_SYS_CTRL);
421+
writel(val, pci->elbi_base + ELBI_SYS_CTRL);
418422
}
419423

420424
static int qcom_pcie_get_resources_2_1_0(struct qcom_pcie *pcie)
@@ -1847,12 +1851,6 @@ static int qcom_pcie_probe(struct platform_device *pdev)
18471851
goto err_pm_runtime_put;
18481852
}
18491853

1850-
pcie->elbi = devm_platform_ioremap_resource_byname(pdev, "elbi");
1851-
if (IS_ERR(pcie->elbi)) {
1852-
ret = PTR_ERR(pcie->elbi);
1853-
goto err_pm_runtime_put;
1854-
}
1855-
18561854
/* MHI region is optional */
18571855
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mhi");
18581856
if (res) {

0 commit comments

Comments
 (0)