Skip to content

Commit a07d249

Browse files
Mani-Sadhasivamkwilczynski
authored andcommitted
PCI: qcom-ep: Add dedicated callback for writing to DBI2 registers
The DWC core driver exposes the write_dbi2() callback for writing to the DBI2 registers in a vendor-specific way. On the Qcom EP platforms, the DBI_CS2 bit in the ELBI region needs to be asserted before writing to any DBI2 registers and deasserted once done. So, let's implement the callback for the Qcom PCIe EP driver so that the DBI2 writes are correctly handled in the hardware. Without this callback, the DBI2 register writes like BAR size won't go through and as a result, the default BAR size is set for all BARs. [kwilczynski: commit log, renamed function to match the DWC convention] Fixes: f55fee5 ("PCI: qcom-ep: Add Qualcomm PCIe Endpoint controller driver") Suggested-by: Serge Semin <[email protected]> Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Serge Semin <[email protected]> Cc: [email protected] # 5.16+
1 parent 0bb80ec commit a07d249

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123

124124
/* ELBI registers */
125125
#define ELBI_SYS_STTS 0x08
126+
#define ELBI_CS2_ENABLE 0xa4
126127

127128
/* DBI registers */
128129
#define DBI_CON_STATUS 0x44
@@ -263,6 +264,21 @@ static void qcom_pcie_dw_stop_link(struct dw_pcie *pci)
263264
disable_irq(pcie_ep->perst_irq);
264265
}
265266

267+
static void qcom_pcie_dw_write_dbi2(struct dw_pcie *pci, void __iomem *base,
268+
u32 reg, size_t size, u32 val)
269+
{
270+
struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci);
271+
int ret;
272+
273+
writel(1, pcie_ep->elbi + ELBI_CS2_ENABLE);
274+
275+
ret = dw_pcie_write(pci->dbi_base2 + reg, size, val);
276+
if (ret)
277+
dev_err(pci->dev, "Failed to write DBI2 register (0x%x): %d\n", reg, ret);
278+
279+
writel(0, pcie_ep->elbi + ELBI_CS2_ENABLE);
280+
}
281+
266282
static void qcom_pcie_ep_icc_update(struct qcom_pcie_ep *pcie_ep)
267283
{
268284
struct dw_pcie *pci = &pcie_ep->pci;
@@ -519,6 +535,7 @@ static const struct dw_pcie_ops pci_ops = {
519535
.link_up = qcom_pcie_dw_link_up,
520536
.start_link = qcom_pcie_dw_start_link,
521537
.stop_link = qcom_pcie_dw_stop_link,
538+
.write_dbi2 = qcom_pcie_dw_write_dbi2,
522539
};
523540

524541
static int qcom_pcie_ep_get_io_resources(struct platform_device *pdev,

0 commit comments

Comments
 (0)