Skip to content

Commit d45736b

Browse files
Shashank Babu Chinta Venkatakwilczynski
authored andcommitted
PCI: qcom: Add equalization settings for 16.0 GT/s
During high data transmission rates such as 16.0 GT/s, there is an increased risk of signal loss due to poor channel quality and interference. This can impact receiver's ability to capture signals accurately. Hence, as signal compensation is achieved through appropriate lane equalization, apply lane equalization settings at both transmitter and receiver which results in an increase in the PCIe signal strength. While at it, modify the pcie-tegra194 driver to make use of the common GEN3_EQ_CONTROL_OFF definitions in pcie-designware.h. Link: https://lore.kernel.org/linux-pci/[email protected] Tested-by: Johan Hovold <[email protected]> Signed-off-by: Shashank Babu Chinta Venkata <[email protected]> [mani: dropped the code refactoring and minor changes] Signed-off-by: Manivannan Sadhasivam <[email protected]> [kwilczynski: commit log] Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Johan Hovold <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 19a69cb commit d45736b

File tree

9 files changed

+97
-13
lines changed

9 files changed

+97
-13
lines changed

MAINTAINERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2728,7 +2728,7 @@ F: drivers/iommu/msm*
27282728
F: drivers/mfd/ssbi.c
27292729
F: drivers/mmc/host/mmci_qcom*
27302730
F: drivers/mmc/host/sdhci-msm.c
2731-
F: drivers/pci/controller/dwc/pcie-qcom.c
2731+
F: drivers/pci/controller/dwc/pcie-qcom*
27322732
F: drivers/phy/qualcomm/
27332733
F: drivers/power/*/msm*
27342734
F: drivers/reset/reset-qcom-*
@@ -17754,6 +17754,7 @@ M: Manivannan Sadhasivam <[email protected]>
1775417754
1775517755
1775617756
S: Maintained
17757+
F: drivers/pci/controller/dwc/pcie-qcom-common.c
1775717758
F: drivers/pci/controller/dwc/pcie-qcom.c
1775817759

1775917760
PCIE DRIVER FOR ROCKCHIP
@@ -17790,6 +17791,7 @@ L: [email protected]
1779017791
1779117792
S: Maintained
1779217793
F: Documentation/devicetree/bindings/pci/qcom,pcie-ep.yaml
17794+
F: drivers/pci/controller/dwc/pcie-qcom-common.c
1779317795
F: drivers/pci/controller/dwc/pcie-qcom-ep.c
1779417796

1779517797
PCMCIA SUBSYSTEM

drivers/pci/controller/dwc/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,16 @@ config PCIE_DW_PLAT_EP
265265
order to enable device-specific features PCI_DW_PLAT_EP must be
266266
selected.
267267

268+
config PCIE_QCOM_COMMON
269+
bool
270+
268271
config PCIE_QCOM
269272
bool "Qualcomm PCIe controller (host mode)"
270273
depends on OF && (ARCH_QCOM || COMPILE_TEST)
271274
depends on PCI_MSI
272275
select PCIE_DW_HOST
273276
select CRC8
277+
select PCIE_QCOM_COMMON
274278
help
275279
Say Y here to enable PCIe controller support on Qualcomm SoCs. The
276280
PCIe controller uses the DesignWare core plus Qualcomm-specific
@@ -281,6 +285,7 @@ config PCIE_QCOM_EP
281285
depends on OF && (ARCH_QCOM || COMPILE_TEST)
282286
depends on PCI_ENDPOINT
283287
select PCIE_DW_EP
288+
select PCIE_QCOM_COMMON
284289
help
285290
Say Y here to enable support for the PCIe controllers on Qualcomm SoCs
286291
to work in endpoint mode. The PCIe controller uses the DesignWare core

drivers/pci/controller/dwc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o
1212
obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone.o
1313
obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o
1414
obj-$(CONFIG_PCI_LAYERSCAPE_EP) += pci-layerscape-ep.o
15+
obj-$(CONFIG_PCIE_QCOM_COMMON) += pcie-qcom-common.o
1516
obj-$(CONFIG_PCIE_QCOM) += pcie-qcom.o
1617
obj-$(CONFIG_PCIE_QCOM_EP) += pcie-qcom-ep.o
1718
obj-$(CONFIG_PCIE_ARMADA_8K) += pcie-armada8k.o

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@
125125
#define GEN3_RELATED_OFF_GEN3_EQ_DISABLE BIT(16)
126126
#define GEN3_RELATED_OFF_RATE_SHADOW_SEL_SHIFT 24
127127
#define GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK GENMASK(25, 24)
128+
#define GEN3_RELATED_OFF_RATE_SHADOW_SEL_16_0GT 0x1
129+
130+
#define GEN3_EQ_CONTROL_OFF 0x8A8
131+
#define GEN3_EQ_CONTROL_OFF_FB_MODE GENMASK(3, 0)
132+
#define GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE BIT(4)
133+
#define GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC GENMASK(23, 8)
134+
#define GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL BIT(24)
135+
136+
#define GEN3_EQ_FB_MODE_DIR_CHANGE_OFF 0x8AC
137+
#define GEN3_EQ_FMDC_T_MIN_PHASE23 GENMASK(4, 0)
138+
#define GEN3_EQ_FMDC_N_EVALS GENMASK(9, 5)
139+
#define GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA GENMASK(13, 10)
140+
#define GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA GENMASK(17, 14)
128141

129142
#define PCIE_PORT_MULTI_LANE_CTRL 0x8C0
130143
#define PORT_MLTI_UPCFG_SUPPORT BIT(7)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
*/
5+
6+
#include <linux/pci.h>
7+
8+
#include "pcie-designware.h"
9+
#include "pcie-qcom-common.h"
10+
11+
void qcom_pcie_common_set_16gt_equalization(struct dw_pcie *pci)
12+
{
13+
u32 reg;
14+
15+
/*
16+
* GEN3_RELATED_OFF register is repurposed to apply equalization
17+
* settings at various data transmission rates through registers namely
18+
* GEN3_EQ_*. The RATE_SHADOW_SEL bit field of GEN3_RELATED_OFF
19+
* determines the data rate for which these equalization settings are
20+
* applied.
21+
*/
22+
reg = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
23+
reg &= ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL;
24+
reg &= ~GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK;
25+
reg |= FIELD_PREP(GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK,
26+
GEN3_RELATED_OFF_RATE_SHADOW_SEL_16_0GT);
27+
dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, reg);
28+
29+
reg = dw_pcie_readl_dbi(pci, GEN3_EQ_FB_MODE_DIR_CHANGE_OFF);
30+
reg &= ~(GEN3_EQ_FMDC_T_MIN_PHASE23 |
31+
GEN3_EQ_FMDC_N_EVALS |
32+
GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA |
33+
GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA);
34+
reg |= FIELD_PREP(GEN3_EQ_FMDC_T_MIN_PHASE23, 0x1) |
35+
FIELD_PREP(GEN3_EQ_FMDC_N_EVALS, 0xd) |
36+
FIELD_PREP(GEN3_EQ_FMDC_MAX_PRE_CUSROR_DELTA, 0x5) |
37+
FIELD_PREP(GEN3_EQ_FMDC_MAX_POST_CUSROR_DELTA, 0x5);
38+
dw_pcie_writel_dbi(pci, GEN3_EQ_FB_MODE_DIR_CHANGE_OFF, reg);
39+
40+
reg = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
41+
reg &= ~(GEN3_EQ_CONTROL_OFF_FB_MODE |
42+
GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE |
43+
GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL |
44+
GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC);
45+
dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, reg);
46+
}
47+
EXPORT_SYMBOL_GPL(qcom_pcie_common_set_16gt_equalization);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
*/
5+
6+
#ifndef _PCIE_QCOM_COMMON_H
7+
#define _PCIE_QCOM_COMMON_H
8+
9+
struct dw_pcie;
10+
11+
void qcom_pcie_common_set_16gt_equalization(struct dw_pcie *pci);
12+
13+
#endif

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "../../pci.h"
2727
#include "pcie-designware.h"
28+
#include "pcie-qcom-common.h"
2829

2930
/* PARF registers */
3031
#define PARF_SYS_CTRL 0x00
@@ -486,6 +487,9 @@ static int qcom_pcie_perst_deassert(struct dw_pcie *pci)
486487
goto err_disable_resources;
487488
}
488489

490+
if (pcie_link_speed[pci->max_link_speed] == PCIE_SPEED_16_0GT)
491+
qcom_pcie_common_set_16gt_equalization(pci);
492+
489493
/*
490494
* The physical address of the MMIO region which is exposed as the BAR
491495
* should be written to MHI BASE registers.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#include "../../pci.h"
3737
#include "pcie-designware.h"
38+
#include "pcie-qcom-common.h"
3839

3940
/* PARF registers */
4041
#define PARF_SYS_CTRL 0x00
@@ -295,6 +296,9 @@ static int qcom_pcie_start_link(struct dw_pcie *pci)
295296
{
296297
struct qcom_pcie *pcie = to_qcom_pcie(pci);
297298

299+
if (pcie_link_speed[pci->max_link_speed] == PCIE_SPEED_16_0GT)
300+
qcom_pcie_common_set_16gt_equalization(pci);
301+
298302
/* Enable Link Training state machine */
299303
if (pcie->cfg->ops->ltssm_enable)
300304
pcie->cfg->ops->ltssm_enable(pcie);

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,6 @@
177177
#define N_FTS_VAL 52
178178
#define FTS_VAL 52
179179

180-
#define GEN3_EQ_CONTROL_OFF 0x8a8
181-
#define GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_SHIFT 8
182-
#define GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_MASK GENMASK(23, 8)
183-
#define GEN3_EQ_CONTROL_OFF_FB_MODE_MASK GENMASK(3, 0)
184-
185180
#define PORT_LOGIC_AMBA_ERROR_RESPONSE_DEFAULT 0x8D0
186181
#define AMBA_ERROR_RESPONSE_CRS_SHIFT 3
187182
#define AMBA_ERROR_RESPONSE_CRS_MASK GENMASK(1, 0)
@@ -861,9 +856,9 @@ static void config_gen3_gen4_eq_presets(struct tegra_pcie_dw *pcie)
861856
dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
862857

863858
val = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
864-
val &= ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_MASK;
865-
val |= (0x3ff << GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_SHIFT);
866-
val &= ~GEN3_EQ_CONTROL_OFF_FB_MODE_MASK;
859+
val &= ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC;
860+
val |= FIELD_PREP(GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC, 0x3ff);
861+
val &= ~GEN3_EQ_CONTROL_OFF_FB_MODE;
867862
dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, val);
868863

869864
val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);
@@ -872,10 +867,10 @@ static void config_gen3_gen4_eq_presets(struct tegra_pcie_dw *pcie)
872867
dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
873868

874869
val = dw_pcie_readl_dbi(pci, GEN3_EQ_CONTROL_OFF);
875-
val &= ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_MASK;
876-
val |= (pcie->of_data->gen4_preset_vec <<
877-
GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC_SHIFT);
878-
val &= ~GEN3_EQ_CONTROL_OFF_FB_MODE_MASK;
870+
val &= ~GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC;
871+
val |= FIELD_PREP(GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC,
872+
pcie->of_data->gen4_preset_vec);
873+
val &= ~GEN3_EQ_CONTROL_OFF_FB_MODE;
879874
dw_pcie_writel_dbi(pci, GEN3_EQ_CONTROL_OFF, val);
880875

881876
val = dw_pcie_readl_dbi(pci, GEN3_RELATED_OFF);

0 commit comments

Comments
 (0)