Skip to content

Commit df5dd33

Browse files
committed
Merge branch 'pci/controller/qcom'
- Use devm_clk_bulk_get_all() to get all the clocks from DT to avoid writing out all the clock names (Manivannan Sadhasivam) - Add DT binding and driver support for the SA8775P SoC (Mrinmay Sarkar) - Refactor dw_pcie_edma_find_chip() to enable adding support for Hyper DMA (HDMA) (Manivannan Sadhasivam) - Enable drivers to supply the eDMA channel count since some can't auto detect this (Manivannan Sadhasivam) - Add HDMA support for the SA8775P SoC (Mrinmay Sarkar) - Override the SA8775P NO_SNOOP default to avoid possible memory corruption (Mrinmay Sarkar) - Make sure resources are disabled during PERST# assertion, even if the link is already disabled (Manivannan Sadhasivam) - Vote for the CPU-PCIe ICC (interconnect) path to ensure it stays active even if other drivers don't vote for it (Krishna chaitanya chundru) - Add Operating Performance Points (OPP) to scale performance state based on aggregate link bandwidth to improve SoC power efficiency (Krishna chaitanya chundru) - Return failure instead of success if dev_pm_opp_find_freq_floor() fails (Dan Carpenter) - Avoid an error pointer dereference if dev_pm_opp_find_freq_exact() fails (Dan Carpenter) - Prevent use of uninitialized data in qcom_pcie_suspend_noirq() (Dan Carpenter) * pci/controller/qcom: PCI: qcom: Prevent use of uninitialized data in qcom_pcie_suspend_noirq() PCI: qcom: Prevent potential error pointer dereference PCI: qcom: Fix missing error code in qcom_pcie_probe() PCI: qcom: Add OPP support to scale performance PCI: Bring the PCIe speed to MBps logic to new pcie_dev_speed_mbps() PCI: qcom: Add ICC bandwidth vote for CPU to PCIe path PCI: qcom-ep: Disable resources unconditionally during PERST# assert PCI: qcom-ep: Override NO_SNOOP attribute for SA8775P EP PCI: qcom: Override NO_SNOOP attribute for SA8775P RC PCI: epf-mhi: Enable HDMA for SA8775P SoC PCI: qcom-ep: Add HDMA support for SA8775P SoC PCI: dwc: Pass the eDMA mapping format flag directly from glue drivers PCI: dwc: Skip finding eDMA channels count for HDMA platforms PCI: dwc: Refactor dw_pcie_edma_find_chip() API PCI: qcom-ep: Add support for SA8775P SOC dt-bindings: PCI: qcom-ep: Add support for SA8775P SoC PCI: qcom: Use devm_clk_bulk_get_all() API
2 parents 325b9a3 + 044b45b commit df5dd33

File tree

9 files changed

+376
-188
lines changed

9 files changed

+376
-188
lines changed

Documentation/devicetree/bindings/pci/qcom,pcie-ep.yaml

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,41 @@ properties:
1313
compatible:
1414
oneOf:
1515
- enum:
16+
- qcom,sa8775p-pcie-ep
1617
- qcom,sdx55-pcie-ep
1718
- qcom,sm8450-pcie-ep
1819
- items:
1920
- const: qcom,sdx65-pcie-ep
2021
- const: qcom,sdx55-pcie-ep
2122

2223
reg:
24+
minItems: 6
2325
items:
2426
- description: Qualcomm-specific PARF configuration registers
2527
- description: DesignWare PCIe registers
2628
- description: External local bus interface registers
2729
- description: Address Translation Unit (ATU) registers
2830
- description: Memory region used to map remote RC address space
2931
- description: BAR memory region
32+
- description: DMA register space
3033

3134
reg-names:
35+
minItems: 6
3236
items:
3337
- const: parf
3438
- const: dbi
3539
- const: elbi
3640
- const: atu
3741
- const: addr_space
3842
- const: mmio
43+
- const: dma
3944

4045
clocks:
41-
minItems: 7
46+
minItems: 5
4247
maxItems: 8
4348

4449
clock-names:
45-
minItems: 7
50+
minItems: 5
4651
maxItems: 8
4752

4853
qcom,perst-regs:
@@ -57,14 +62,18 @@ properties:
5762
- description: Perst separation enable offset
5863

5964
interrupts:
65+
minItems: 2
6066
items:
6167
- description: PCIe Global interrupt
6268
- description: PCIe Doorbell interrupt
69+
- description: DMA interrupt
6370

6471
interrupt-names:
72+
minItems: 2
6573
items:
6674
- const: global
6775
- const: doorbell
76+
- const: dma
6877

6978
reset-gpios:
7079
description: GPIO used as PERST# input signal
@@ -125,6 +134,10 @@ allOf:
125134
- qcom,sdx55-pcie-ep
126135
then:
127136
properties:
137+
reg:
138+
maxItems: 6
139+
reg-names:
140+
maxItems: 6
128141
clocks:
129142
items:
130143
- description: PCIe Auxiliary clock
@@ -143,6 +156,10 @@ allOf:
143156
- const: slave_q2a
144157
- const: sleep
145158
- const: ref
159+
interrupts:
160+
maxItems: 2
161+
interrupt-names:
162+
maxItems: 2
146163

147164
- if:
148165
properties:
@@ -152,6 +169,10 @@ allOf:
152169
- qcom,sm8450-pcie-ep
153170
then:
154171
properties:
172+
reg:
173+
maxItems: 6
174+
reg-names:
175+
maxItems: 6
155176
clocks:
156177
items:
157178
- description: PCIe Auxiliary clock
@@ -172,6 +193,45 @@ allOf:
172193
- const: ref
173194
- const: ddrss_sf_tbu
174195
- const: aggre_noc_axi
196+
interrupts:
197+
maxItems: 2
198+
interrupt-names:
199+
maxItems: 2
200+
201+
- if:
202+
properties:
203+
compatible:
204+
contains:
205+
enum:
206+
- qcom,sa8775p-pcie-ep
207+
then:
208+
properties:
209+
reg:
210+
minItems: 7
211+
maxItems: 7
212+
reg-names:
213+
minItems: 7
214+
maxItems: 7
215+
clocks:
216+
items:
217+
- description: PCIe Auxiliary clock
218+
- description: PCIe CFG AHB clock
219+
- description: PCIe Master AXI clock
220+
- description: PCIe Slave AXI clock
221+
- description: PCIe Slave Q2A AXI clock
222+
clock-names:
223+
items:
224+
- const: aux
225+
- const: cfg
226+
- const: bus_master
227+
- const: bus_slave
228+
- const: slave_q2a
229+
interrupts:
230+
minItems: 3
231+
maxItems: 3
232+
interrupt-names:
233+
minItems: 3
234+
maxItems: 3
175235

176236
unevaluatedProperties: false
177237

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

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -870,30 +870,40 @@ static struct dw_edma_plat_ops dw_pcie_edma_ops = {
870870
.irq_vector = dw_pcie_edma_irq_vector,
871871
};
872872

873-
static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
873+
static void dw_pcie_edma_init_data(struct dw_pcie *pci)
874+
{
875+
pci->edma.dev = pci->dev;
876+
877+
if (!pci->edma.ops)
878+
pci->edma.ops = &dw_pcie_edma_ops;
879+
880+
pci->edma.flags |= DW_EDMA_CHIP_LOCAL;
881+
}
882+
883+
static int dw_pcie_edma_find_mf(struct dw_pcie *pci)
874884
{
875885
u32 val;
876886

887+
/*
888+
* Bail out finding the mapping format if it is already set by the glue
889+
* driver. Also ensure that the edma.reg_base is pointing to a valid
890+
* memory region.
891+
*/
892+
if (pci->edma.mf != EDMA_MF_EDMA_LEGACY)
893+
return pci->edma.reg_base ? 0 : -ENODEV;
894+
877895
/*
878896
* Indirect eDMA CSRs access has been completely removed since v5.40a
879897
* thus no space is now reserved for the eDMA channels viewport and
880898
* former DMA CTRL register is no longer fixed to FFs.
881-
*
882-
* Note that Renesas R-Car S4-8's PCIe controllers for unknown reason
883-
* have zeros in the eDMA CTRL register even though the HW-manual
884-
* explicitly states there must FFs if the unrolled mapping is enabled.
885-
* For such cases the low-level drivers are supposed to manually
886-
* activate the unrolled mapping to bypass the auto-detection procedure.
887899
*/
888-
if (dw_pcie_ver_is_ge(pci, 540A) || dw_pcie_cap_is(pci, EDMA_UNROLL))
900+
if (dw_pcie_ver_is_ge(pci, 540A))
889901
val = 0xFFFFFFFF;
890902
else
891903
val = dw_pcie_readl_dbi(pci, PCIE_DMA_VIEWPORT_BASE + PCIE_DMA_CTRL);
892904

893905
if (val == 0xFFFFFFFF && pci->edma.reg_base) {
894906
pci->edma.mf = EDMA_MF_EDMA_UNROLL;
895-
896-
val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL);
897907
} else if (val != 0xFFFFFFFF) {
898908
pci->edma.mf = EDMA_MF_EDMA_LEGACY;
899909

@@ -902,15 +912,25 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
902912
return -ENODEV;
903913
}
904914

905-
pci->edma.dev = pci->dev;
915+
return 0;
916+
}
906917

907-
if (!pci->edma.ops)
908-
pci->edma.ops = &dw_pcie_edma_ops;
918+
static int dw_pcie_edma_find_channels(struct dw_pcie *pci)
919+
{
920+
u32 val;
909921

910-
pci->edma.flags |= DW_EDMA_CHIP_LOCAL;
922+
/*
923+
* Autodetect the read/write channels count only for non-HDMA platforms.
924+
* HDMA platforms with native CSR mapping doesn't support autodetect,
925+
* so the glue drivers should've passed the valid count already. If not,
926+
* the below sanity check will catch it.
927+
*/
928+
if (pci->edma.mf != EDMA_MF_HDMA_NATIVE) {
929+
val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL);
911930

912-
pci->edma.ll_wr_cnt = FIELD_GET(PCIE_DMA_NUM_WR_CHAN, val);
913-
pci->edma.ll_rd_cnt = FIELD_GET(PCIE_DMA_NUM_RD_CHAN, val);
931+
pci->edma.ll_wr_cnt = FIELD_GET(PCIE_DMA_NUM_WR_CHAN, val);
932+
pci->edma.ll_rd_cnt = FIELD_GET(PCIE_DMA_NUM_RD_CHAN, val);
933+
}
914934

915935
/* Sanity check the channels count if the mapping was incorrect */
916936
if (!pci->edma.ll_wr_cnt || pci->edma.ll_wr_cnt > EDMA_MAX_WR_CH ||
@@ -920,6 +940,19 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
920940
return 0;
921941
}
922942

943+
static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
944+
{
945+
int ret;
946+
947+
dw_pcie_edma_init_data(pci);
948+
949+
ret = dw_pcie_edma_find_mf(pci);
950+
if (ret)
951+
return ret;
952+
953+
return dw_pcie_edma_find_channels(pci);
954+
}
955+
923956
static int dw_pcie_edma_irq_verify(struct dw_pcie *pci)
924957
{
925958
struct platform_device *pdev = to_platform_device(pci->dev);

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@
5151

5252
/* DWC PCIe controller capabilities */
5353
#define DW_PCIE_CAP_REQ_RES 0
54-
#define DW_PCIE_CAP_EDMA_UNROLL 1
55-
#define DW_PCIE_CAP_IATU_UNROLL 2
56-
#define DW_PCIE_CAP_CDM_CHECK 3
54+
#define DW_PCIE_CAP_IATU_UNROLL 1
55+
#define DW_PCIE_CAP_CDM_CHECK 2
5756

5857
#define dw_pcie_cap_is(_pci, _cap) \
5958
test_bit(DW_PCIE_CAP_ ## _cap, &(_pci)->caps)

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

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define PARF_DBI_BASE_ADDR_HI 0x354
4848
#define PARF_SLV_ADDR_SPACE_SIZE 0x358
4949
#define PARF_SLV_ADDR_SPACE_SIZE_HI 0x35c
50+
#define PARF_NO_SNOOP_OVERIDE 0x3d4
5051
#define PARF_ATU_BASE_ADDR 0x634
5152
#define PARF_ATU_BASE_ADDR_HI 0x638
5253
#define PARF_SRIS_MODE 0x644
@@ -86,6 +87,10 @@
8687
#define PARF_DEBUG_INT_CFG_BUS_MASTER_EN BIT(2)
8788
#define PARF_DEBUG_INT_RADM_PM_TURNOFF BIT(3)
8889

90+
/* PARF_NO_SNOOP_OVERIDE register fields */
91+
#define WR_NO_SNOOP_OVERIDE_EN BIT(1)
92+
#define RD_NO_SNOOP_OVERIDE_EN BIT(3)
93+
8994
/* PARF_DEVICE_TYPE register fields */
9095
#define PARF_DEVICE_TYPE_EP 0x0
9196

@@ -149,6 +154,16 @@ enum qcom_pcie_ep_link_status {
149154
QCOM_PCIE_EP_LINK_DOWN,
150155
};
151156

157+
/**
158+
* struct qcom_pcie_ep_cfg - Per SoC config struct
159+
* @hdma_support: HDMA support on this SoC
160+
* @override_no_snoop: Override NO_SNOOP attribute in TLP to enable cache snooping
161+
*/
162+
struct qcom_pcie_ep_cfg {
163+
bool hdma_support;
164+
bool override_no_snoop;
165+
};
166+
152167
/**
153168
* struct qcom_pcie_ep - Qualcomm PCIe Endpoint Controller
154169
* @pci: Designware PCIe controller struct
@@ -167,6 +182,7 @@ enum qcom_pcie_ep_link_status {
167182
* @num_clks: PCIe clocks count
168183
* @perst_en: Flag for PERST enable
169184
* @perst_sep_en: Flag for PERST separation enable
185+
* @cfg: PCIe EP config struct
170186
* @link_status: PCIe Link status
171187
* @global_irq: Qualcomm PCIe specific Global IRQ
172188
* @perst_irq: PERST# IRQ
@@ -194,6 +210,7 @@ struct qcom_pcie_ep {
194210
u32 perst_en;
195211
u32 perst_sep_en;
196212

213+
const struct qcom_pcie_ep_cfg *cfg;
197214
enum qcom_pcie_ep_link_status link_status;
198215
int global_irq;
199216
int perst_irq;
@@ -489,6 +506,10 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)
489506
val |= BIT(8);
490507
writel_relaxed(val, pcie_ep->parf + PARF_LTSSM);
491508

509+
if (pcie_ep->cfg && pcie_ep->cfg->override_no_snoop)
510+
writel_relaxed(WR_NO_SNOOP_OVERIDE_EN | RD_NO_SNOOP_OVERIDE_EN,
511+
pcie_ep->parf + PARF_NO_SNOOP_OVERIDE);
512+
492513
return 0;
493514

494515
err_disable_resources:
@@ -500,12 +521,6 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)
500521
static void qcom_pcie_perst_assert(struct dw_pcie *pci)
501522
{
502523
struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci);
503-
struct device *dev = pci->dev;
504-
505-
if (pcie_ep->link_status == QCOM_PCIE_EP_LINK_DISABLED) {
506-
dev_dbg(dev, "Link is already disabled\n");
507-
return;
508-
}
509524

510525
pci_epc_deinit_notify(pci->ep.epc);
511526
dw_pcie_ep_cleanup(&pci->ep);
@@ -817,6 +832,14 @@ static int qcom_pcie_ep_probe(struct platform_device *pdev)
817832
pcie_ep->pci.ops = &pci_ops;
818833
pcie_ep->pci.ep.ops = &pci_ep_ops;
819834
pcie_ep->pci.edma.nr_irqs = 1;
835+
836+
pcie_ep->cfg = of_device_get_match_data(dev);
837+
if (pcie_ep->cfg && pcie_ep->cfg->hdma_support) {
838+
pcie_ep->pci.edma.ll_wr_cnt = 8;
839+
pcie_ep->pci.edma.ll_rd_cnt = 8;
840+
pcie_ep->pci.edma.mf = EDMA_MF_HDMA_NATIVE;
841+
}
842+
820843
platform_set_drvdata(pdev, pcie_ep);
821844

822845
ret = qcom_pcie_ep_get_resources(pdev, pcie_ep);
@@ -875,7 +898,13 @@ static void qcom_pcie_ep_remove(struct platform_device *pdev)
875898
qcom_pcie_disable_resources(pcie_ep);
876899
}
877900

901+
static const struct qcom_pcie_ep_cfg cfg_1_34_0 = {
902+
.hdma_support = true,
903+
.override_no_snoop = true,
904+
};
905+
878906
static const struct of_device_id qcom_pcie_ep_match[] = {
907+
{ .compatible = "qcom,sa8775p-pcie-ep", .data = &cfg_1_34_0},
879908
{ .compatible = "qcom,sdx55-pcie-ep", },
880909
{ .compatible = "qcom,sm8450-pcie-ep", },
881910
{ }

0 commit comments

Comments
 (0)