PCI: dwc: Add support for configuring lane equalization presets
Subsystems (6)
cover PCI: dwc: Add support for configuring lane equalization presets
PCIe equalization presets are predefined settings used to optimize signal integrity by compensating for signal loss and distortion in high-speed data transmission.
As per PCIe spec 6.0.1 revision section 8.3.3.3 & 4.2.4 for data rates of 8.0 GT/s, 16.0 GT/s, 32.0 GT/s, and 64.0 GT/s, there is a way to configure lane equalization presets for each lane to enhance the PCIe link reliability. Each preset value represents a different combination of pre-shoot and de-emphasis values. For each data rate, different registers are defined: for 8.0 GT/s, registers are defined in section 7.7.3.4; for 16.0 GT/s, in section 7.7.5.9, etc. The 8.0 GT/s rate has an extra receiver preset hint, requiring 16 bits per lane, while the remaining data rates use 8 bits per lane.
Based on the number of lanes and the supported data rate, read the device tree property and stores in the presets structure.
Based upon the lane width and supported data rate update lane equalization registers.
This patch depends on the this dt binding pull request: https://github.com/devicetree-org/dt-schema/pull/146
---
Krishna chaitanya chundru (4):
arm64: dts: qcom: x1e80100: Add PCIe lane equalization preset properties
PCI: of: Add API to retrieve equalization presets from device tree
PCI: dwc: Improve handling of PCIe lane configuration
PCI: dwc: Add support for configuring lane equalization presets
arch/arm64/boot/dts/qcom/x1e80100.dtsi | 8 +++ drivers/pci/controller/dwc/pcie-designware-host.c | 42 +++++++++++++++ drivers/pci/controller/dwc/pcie-designware.c | 14 ++++- drivers/pci/controller/dwc/pcie-designware.h | 4 ++ drivers/pci/of.c | 62 +++++++++++++++++++++++ drivers/pci/pci.h | 17 ++++++- include/uapi/linux/pci_regs.h | 3 ++ 7 files changed, 147 insertions(+), 3 deletions(-)
---
base-commit: 81983758430957d9a5cb3333fe324fd70cf63e7e
change-id: 20241030-presets-ec11a3e44ab3
Best regards,
Signature · 1 line
Krishna chaitanya chundru <[email protected]>
PATCH 1/4 arm64: dts: qcom: x1e80100: Add PCIe lane equalization preset properties
Add PCIe lane equalization preset properties for 8 GT/s and 16 GT/s data rates used in lane equalization procedure.
--- arch/arm64/boot/dts/qcom/x1e80100.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm64/boot/dts/qcom/x1e80100.dtsi +8 -0
@@ -2993,6 +2993,10 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, phys = <&pcie6a_phy>; phy-names = "pciephy"; + eq-presets-8gts = /bits/ 16 <0x5555 0x5555>; + + eq-presets-16gts = /bits/ 8 <0x55 0x55>; + status = "disabled"; };
@@ -3115,6 +3119,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, phys = <&pcie5_phy>; phy-names = "pciephy"; + eq-presets-8gts = /bits/ 16 <0x5555 0x5555>; + status = "disabled"; };
@@ -3235,6 +3241,8 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, phys = <&pcie4_phy>; phy-names = "pciephy"; + eq-presets-8gts = /bits/ 16 <0x5555 0x5555>; + status = "disabled"; pcie4_port0: pcie@0 {
Signature · 1 line
2.34.1
Re: [PATCH 1/4] arm64: dts: qcom: x1e80100: Add PCIe lane equalization preset properties
Quoted 13 lines · Krishna chaitanya chundru
Add PCIe lane equalization preset properties for 8 GT/s and 16 GT/s data rates used in lane equalization procedure.
Signed-off-by Krishna chaitanya chundru <[email protected]>--- arch/arm64/boot/dts/qcom/x1e80100.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)arch/arm64/boot/dts/qcom/x1e80100.dtsi +0
-0
arch/arm64/boot/dts/qcom/x1e80100.dtsi &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, · line 2996
Quoted 4 lines
arch/arm64/boot/dts/qcom/x1e80100.dtsi +1
-0@@ -2993,6 +2993,10 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, phys = <&pcie6a_phy>; phy-names = "pciephy"; + eq-presets-8gts = /bits/ 16 <0x5555 0x5555>;
If we make all of these presets u8 arrays, we can use the:
property = [0xff 0xff 0xff 0xff];
syntax
Konrad
Re: [PATCH 1/4] arm64: dts: qcom: x1e80100: Add PCIe lane equalization preset properties
Quoted 21 lines · Konrad Dybcio
Quoted 13 lines · Krishna chaitanya chundru
Add PCIe lane equalization preset properties for 8 GT/s and 16 GT/s data rates used in lane equalization procedure.
Signed-off-by Krishna chaitanya chundru <[email protected]>--- arch/arm64/boot/dts/qcom/x1e80100.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)arch/arm64/boot/dts/qcom/x1e80100.dtsi +0
-0arch/arm64/boot/dts/qcom/x1e80100.dtsi &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, · line 2996
Quoted 4 lines
arch/arm64/boot/dts/qcom/x1e80100.dtsi +1
-0@@ -2993,6 +2993,10 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, phys = <&pcie6a_phy>; phy-names = "pciephy"; + eq-presets-8gts = /bits/ 16 <0x5555 0x5555>;If we make all of these presets u8 arrays, we can use the:
Quoted 5 lines
property = [
0xff0xff0xff0xff];syntax
Konrad
we can't make the property as u8 as each index represents single lane and for 8 GT/s data rates each value needs 16bits. So for 8 GT/s we have to use u16 array only.
- Krishna Chaitanya.
Re: [PATCH 1/4] arm64: dts: qcom: x1e80100: Add PCIe lane equalization preset properties
Quoted 23 lines · Krishna Chaitanya Chundru
Quoted 20 lines · Konrad Dybcio
Quoted 13 lines · Krishna chaitanya chundru
Add PCIe lane equalization preset properties for 8 GT/s and 16 GT/s data rates used in lane equalization procedure.
Signed-off-by Krishna chaitanya chundru <[email protected]>---
arch/arm64/boot/dts/qcom/x1e80100.dtsi| 8 ++++++++1 file changed, 8 insertions(+)arch/arm64/boot/dts/qcom/x1e80100.dtsi +0
-0arch/arm64/boot/dts/qcom/x1e80100.dtsi &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, · line 2995
Quoted 3 lines
arch/arm64/boot/dts/qcom/x1e80100.dtsi +0
-0@@ -2993,6 +2993,10 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, phys = <&pcie6a_phy>; phy-names = "pciephy"; + eq-presets-8gts = /bits/ 16 <0x5555 0x5555>;If we make all of these presets u8 arrays, we can use the:
Quoted 8 lines
Quoted 5 lines
property = [
0xff0xff0xff0xff];syntax
Konrad
we can't make the property as u8 as each index represents single lane and for 8 GT/s data rates each value needs 16bits. So for 8 GT/s we have to use u16 array only.
In patch 4 you write them one bit at at time anyway, you can split the u16 value into 2 bytes, which will save you on some ifs down the line.
Konrad
PATCH 2/4 PCI: of: Add API to retrieve equalization presets from device tree
In reply to Krishna chaitanya chundruPCIe equalization presets are predefined settings used to optimize signal integrity by compensating for signal loss and distortion in high-speed data transmission.
As per PCIe spec 6.0.1 revision section 8.3.3.3 & 4.2.4 for data rates of 8.0 GT/s, 16.0 GT/s, 32.0 GT/s, and 64.0 GT/s, there is a way to configure lane equalization presets for each lane to enhance the PCIe link reliability. Each preset value represents a different combination of pre-shoot and de-emphasis values. For each data rate, different registers are defined: for 8.0 GT/s, registers are defined in section 7.7.3.4; for 16.0 GT/s, in section 7.7.5.9, etc. The 8.0 GT/s rate has an extra receiver preset hint, requiring 16 bits per lane, while the remaining data rates use 8 bits per lane.
Based on the number of lanes and the supported data rate, this function reads the device tree property and stores in the presets structure.
--- drivers/pci/of.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 17 +++++++++++++-- 2 files changed, 77 insertions(+), 2 deletions(-)
drivers/pci/of.c +62 -0
@@ -826,3 +826,65 @@ u32 of_pci_get_slot_power_limit(struct device_node *node,return slot_power_limit_mw; }EXPORT_SYMBOL_GPL (of_pci_get_slot_power_limit); + +int of_pci_get_equalization_presets (struct device *dev, +struct pci_eq_presets *presets, +int num_lanes) +{ +int ret; + +if (of_property_present (dev->of_node,"eq-presets-8gts" )) { + presets->eq_presets_8gts =devm_kzalloc (dev,sizeof (u16) * num_lanes,GFP_KERNEL ); +if (!presets->eq_presets_8gts) +return -ENOMEM ; + + ret =of_property_read_u16_array (dev->of_node,"eq-presets-8gts" , + presets->eq_presets_8gts, num_lanes); +if (ret) { +dev_err (dev,"Error reading eq-presets-8gts %d\n" , ret); +return ret; + } + } + +if (of_property_present (dev->of_node,"eq-presets-16gts" )) { + presets->eq_presets_16gts =devm_kzalloc (dev,sizeof (u8) * num_lanes,GFP_KERNEL ); +if (!presets->eq_presets_16gts) +return -ENOMEM ; + + ret =of_property_read_u8_array (dev->of_node,"eq-presets-16gts" , + presets->eq_presets_16gts, num_lanes); +if (ret) { +dev_err (dev,"Error reading eq-presets-16gts %d\n" , ret); +return ret; + } + } + +if (of_property_present (dev->of_node,"eq-presets-32gts" )) { + presets->eq_presets_32gts =devm_kzalloc (dev,sizeof (u8) * num_lanes,GFP_KERNEL ); +if (!presets->eq_presets_32gts) +return -ENOMEM ; + + ret =of_property_read_u8_array (dev->of_node,"eq-presets-32gts" , + presets->eq_presets_32gts, num_lanes); +if (ret) { +dev_err (dev,"Error reading eq-presets-32gts %d\n" , ret); +return ret; + } + } + +if (of_property_present (dev->of_node,"eq-presets-64gts" )) { + presets->eq_presets_64gts =devm_kzalloc (dev,sizeof (u8) * num_lanes,GFP_KERNEL ); +if (!presets->eq_presets_64gts) +return -ENOMEM ; + + ret =of_property_read_u8_array (dev->of_node,"eq-presets-64gts" , + presets->eq_presets_64gts, num_lanes); +if (ret) { +dev_err (dev,"Error reading eq-presets-64gts %d\n" , ret); +return ret; + } + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (of_pci_get_equalization_presets);
drivers/pci/pci.h +15 -2
@@ -731,7 +731,12 @@ static inline u64 pci_rebar_size_to_bytes(int size) }struct device_node ; - +struct pci_eq_presets { +u16 *eq_presets_8gts; +u8 *eq_presets_16gts; +u8 *eq_presets_32gts; +u8 *eq_presets_64gts; +};#ifdef CONFIG_OF int of_pci_parse_bus_range (struct device_node *node,struct resource *res);int of_get_pci_domain_nr (struct device_node *node);
@@ -746,7 +751,9 @@ void pci_set_bus_of_node(struct pci_bus *bus);void pci_release_bus_of_node (struct pci_bus *bus);int devm_of_pci_bridge_init (struct device *dev,struct pci_host_bridge *bridge); - +int of_pci_get_equalization_presets (struct device *dev, +struct pci_eq_presets *presets, +int num_lanes);#else static inline int of_pci_parse_bus_range (struct device_node *node,struct resource *res)
@@ -793,6 +800,12 @@ static inline int devm_of_pci_bridge_init(struct device *dev, struct pci_host_br return 0; } +static int of_pci_get_equalization_presets (struct device *dev, +struct pci_eq_presets *presets, +int num_lanes) +{ +return 0 ; +}#endif /* CONFIG_OF */ struct of_changeset ;
Signature · 1 line
2.34.1
Re: [PATCH 2/4] PCI: of: Add API to retrieve equalization presets from device tree
Quoted 31 lines · Krishna chaitanya chundru
PCIe equalization presets are predefined settings used to optimize signal integrity by compensating for signal loss and distortion in high-speed data transmission.
As per PCIe spec 6.0.1 revision section 8.3.3.3 & 4.2.4 for data rates of 8.0 GT/s, 16.0 GT/s, 32.0 GT/s, and 64.0 GT/s, there is a way to configure lane equalization presets for each lane to enhance the PCIe link reliability. Each preset value represents a different combination of pre-shoot and de-emphasis values. For each data rate, different registers are defined: for 8.0 GT/s, registers are defined in section 7.7.3.4; for 16.0 GT/s, in section 7.7.5.9, etc. The 8.0 GT/s rate has an extra receiver preset hint, requiring 16 bits per lane, while the remaining data rates use 8 bits per lane.
Based on the number of lanes and the supported data rate, this function reads the device tree property and stores in the presets structure.
Signed-off-by Krishna chaitanya chundru <[email protected]>--- drivers/pci/of.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 17 +++++++++++++-- 2 files changed, 77 insertions(+), 2 deletions(-)drivers/pci/of.c +0
-0@@ -826,3 +826,65 @@ u32 of_pci_get_slot_power_limit(struct device_node *node,return slot_power_limit_mw; }EXPORT_SYMBOL_GPL (of_pci_get_slot_power_limit);
drivers/pci/of.c u32 of_pci_get_slot_power_limit(struct device_node *node, · line 838
Quoted 10 lines
drivers/pci/of.c +10
-0+ +int of_pci_get_equalization_presets (struct device *dev, +struct pci_eq_presets *presets, +int num_lanes) +{ +int ret; + +if (of_property_present (dev->of_node,"eq-presets-8gts" )) { + presets->eq_presets_8gts =devm_kzalloc (dev,sizeof (u16) * num_lanes,GFP_KERNEL ); +if (!presets->eq_presets_8gts)
If you make this an array with enum indices, you can make a for loop and read "eq-presets-%ugts", (8 << i)
Konrad
Re: [PATCH 2/4] PCI: of: Add API to retrieve equalization presets from device tree
Quoted 46 lines · Konrad Dybcio
Quoted 31 lines · Krishna chaitanya chundru
PCIe equalization presets are predefined settings used to optimize signal integrity by compensating for signal loss and distortion in high-speed data transmission.
As per PCIe spec 6.0.1 revision section 8.3.3.3 & 4.2.4 for data rates of 8.0 GT/s, 16.0 GT/s, 32.0 GT/s, and 64.0 GT/s, there is a way to configure lane equalization presets for each lane to enhance the PCIe link reliability. Each preset value represents a different combination of pre-shoot and de-emphasis values. For each data rate, different registers are defined: for 8.0 GT/s, registers are defined in section 7.7.3.4; for 16.0 GT/s, in section 7.7.5.9, etc. The 8.0 GT/s rate has an extra receiver preset hint, requiring 16 bits per lane, while the remaining data rates use 8 bits per lane.
Based on the number of lanes and the supported data rate, this function reads the device tree property and stores in the presets structure.
Signed-off-by Krishna chaitanya chundru <[email protected]>--- drivers/pci/of.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.h | 17 +++++++++++++-- 2 files changed, 77 insertions(+), 2 deletions(-)drivers/pci/of.c +0
-0@@ -826,3 +826,65 @@ u32 of_pci_get_slot_power_limit(struct device_node *node,return slot_power_limit_mw; }EXPORT_SYMBOL_GPL (of_pci_get_slot_power_limit);drivers/pci/of.c u32 of_pci_get_slot_power_limit(struct device_node *node, · line 838
Quoted 10 lines
drivers/pci/of.c +10
-0+ +int of_pci_get_equalization_presets (struct device *dev, +struct pci_eq_presets *presets, +int num_lanes) +{ +int ret; + +if (of_property_present (dev->of_node,"eq-presets-8gts" )) { + presets->eq_presets_8gts =devm_kzalloc (dev,sizeof (u16) * num_lanes,GFP_KERNEL ); +if (!presets->eq_presets_8gts)If you make this an array with enum indices, you can make a for loop and read "eq-presets-%ugts", (8 << i)
Quoted 1 line
Konrad
as "eq-presets-8gts" is u16 array and other properties are u8 array. I will use as it is for "eq-presets-8gts", but for remaining properties I will use for loop as suggested by you.
- Krishna Chaitanya.
kernel test robot
build botRe: [PATCH 2/4] PCI: of: Add API to retrieve equalization presets from device tree
In reply to Krishna chaitanya chundrukernel test robot noticed the following build warnings:
Hi Krishna,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 81983758430957d9a5cb3333fe324fd70cf63e7e]
url: https://github.com/intel-lab-lkp/linux/commits/Krishna-chaitanya-chundru/arm64-dts-qcom-x1e80100-Add-PCIe-lane-equalization-preset-properties/20241117-000950 base: 81983758430957d9a5cb3333fe324fd70cf63e7e patch link: https://lore.kernel.org/r/20241116-presets-v1-2-878a837a4fee%40quicinc.com patch subject: [PATCH 2/4] PCI: of: Add API to retrieve equalization presets from device tree config: i386-buildonly-randconfig-005-20241117 (https://download.01.org/0day-ci/archive/20241117/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241117/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/pci/controller/dwc/pcie-designware.c:23:
>> drivers/pci/controller/dwc/../../pci.h:803:12: warning: 'of_pci_get_equalization_presets' defined but not used [-Wunused-function]
803 | static int of_pci_get_equalization_presets(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/of_pci_get_equalization_presets +803 drivers/pci/controller/dwc/../../pci.h
802
> 803 static int of_pci_get_equalization_presets(struct device *dev,
804 struct pci_eq_presets *presets,
805 int num_lanes)
806 {
807 return 0;
808 }
809 #endif /* CONFIG_OF */
810
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 2/4] PCI: of: Add API to retrieve equalization presets from device tree
In reply to Krishna chaitanya chundrukernel test robot noticed the following build warnings:
Hi Krishna,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 81983758430957d9a5cb3333fe324fd70cf63e7e]
url: https://github.com/intel-lab-lkp/linux/commits/Krishna-chaitanya-chundru/arm64-dts-qcom-x1e80100-Add-PCIe-lane-equalization-preset-properties/20241117-000950 base: 81983758430957d9a5cb3333fe324fd70cf63e7e patch link: https://lore.kernel.org/r/20241116-presets-v1-2-878a837a4fee%40quicinc.com patch subject: [PATCH 2/4] PCI: of: Add API to retrieve equalization presets from device tree config: parisc-defconfig (https://download.01.org/0day-ci/archive/20241117/[email protected]/config) compiler: hppa-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241117/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from drivers/pci/access.c:8:
>> drivers/pci/pci.h:803:12: warning: 'of_pci_get_equalization_presets' defined but not used [-Wunused-function]
803 | static int of_pci_get_equalization_presets(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from drivers/pci/msi/pcidev_msi.c:5:
>> drivers/pci/msi/../pci.h:803:12: warning: 'of_pci_get_equalization_presets' defined but not used [-Wunused-function]
803 | static int of_pci_get_equalization_presets(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from drivers/pci/pcie/aspm.c:27:
>> drivers/pci/pcie/../pci.h:803:12: warning: 'of_pci_get_equalization_presets' defined but not used [-Wunused-function]
803 | static int of_pci_get_equalization_presets(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/of_pci_get_equalization_presets +803 drivers/pci/pci.h
802
> 803 static int of_pci_get_equalization_presets(struct device *dev,
804 struct pci_eq_presets *presets,
805 int num_lanes)
806 {
807 return 0;
808 }
809 #endif /* CONFIG_OF */
810
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 3/4 PCI: dwc: Improve handling of PCIe lane configuration
In reply to Krishna chaitanya chundruCurrently even if the number of lanes hardware supports is equal to the number lanes provided in the devicetree, the driver is trying to configure again the maximum number of lanes which is not needed.
Update number of lanes only when it is not equal to hardware capability.
And also if the num-lanes property is not present in the devicetree update the num_lanes with the maximum hardware supports.
Introduce dw_pcie_link_get_max_link_width() to get the maximum lane width the hardware supports.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 3 +++ drivers/pci/controller/dwc/pcie-designware.c | 14 +++++++++++++- drivers/pci/controller/dwc/pcie-designware.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware-host.c +3 -0
@@ -504,6 +504,9 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)dw_pcie_iatu_detect (pci); +if (pci->num_lanes <1 ) + pci->num_lanes =dw_pcie_link_get_max_link_width (pci); +/* * Allocate the resource for MSG TLP before programming the iATU * outbound window in dw_pcie_setup_rc(). Since the allocation depends
drivers/pci/controller/dwc/pcie-designware.c +13 -1
@@ -736,6 +736,16 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci) } +int dw_pcie_link_get_max_link_width (struct dw_pcie *pci) +{ +u32 lnkcap; +u8 cap; + + cap =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); + lnkcap =dw_pcie_readl_dbi (pci, cap +PCI_EXP_LNKCAP ); +return FIELD_GET (PCI_EXP_LNKCAP_MLW , lnkcap); +} +static void dw_pcie_link_set_max_link_width (struct dw_pcie *pci,u32 num_lanes) {u32 lnkcap, lwsc, plc;
@@ -1069,6 +1079,7 @@ void dw_pcie_edma_remove(struct dw_pcie *pci)void dw_pcie_setup (struct dw_pcie *pci) { +int num_lanes =dw_pcie_link_get_max_link_width (pci);u32 val;dw_pcie_link_set_max_speed (pci);
@@ -1102,5 +1113,6 @@ void dw_pcie_setup(struct dw_pcie *pci) val |=PORT_LINK_DLL_LINK_EN ;dw_pcie_writel_dbi (pci,PCIE_PORT_LINK_CONTROL , val); -dw_pcie_link_set_max_link_width (pci, pci->num_lanes); +if (num_lanes != pci->num_lanes) +dw_pcie_link_set_max_link_width (pci, pci->num_lanes); }
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -486,6 +486,7 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val);int dw_pcie_link_up (struct dw_pcie *pci);void dw_pcie_upconfig_setup (struct dw_pcie *pci);int dw_pcie_wait_for_link (struct dw_pcie *pci); +int dw_pcie_link_get_max_link_width (struct dw_pcie *pci);int dw_pcie_prog_outbound_atu (struct dw_pcie *pci,const struct dw_pcie_ob_atu_cfg *atu); int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int type,
Signature · 1 line
2.34.1
PATCH 4/4 PCI: dwc: Add support for configuring lane equalization presets
In reply to Krishna chaitanya chundruPCIe equalization presets are predefined settings used to optimize signal integrity by compensating for signal loss and distortion in high-speed data transmission.
Based upon the number of lanes and the data rate supported, read the devicetree property and write it in to the lane equalization control registers.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 39 +++++++++++++++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 3 ++ include/uapi/linux/pci_regs.h | 3 ++ 3 files changed, 45 insertions(+)
drivers/pci/controller/dwc/pcie-designware-host.c +39 -0
@@ -507,6 +507,10 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)if (pci->num_lanes <1 ) pci->num_lanes =dw_pcie_link_get_max_link_width (pci); + ret =of_pci_get_equalization_presets (dev, &pp->presets, pci->num_lanes); +if (ret) + goto err_free_msi; +/* * Allocate the resource for MSG TLP before programming the iATU * outbound window in dw_pcie_setup_rc(). Since the allocation depends
@@ -802,6 +806,40 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)return 0 ; } +static void dw_pcie_program_presets (struct dw_pcie *pci,u8 cap_id,u8 lane_eq_offset, +u8 lane_reg_size,u8 *presets,u8 num_lanes) +{ +u32 cap; +int i; + + cap =dw_pcie_find_ext_capability (pci, cap_id); +if (!cap) +return ; + +/* +* Write preset values to the registers byte-by-byte for the given +* number of lanes and register size. +*/ +for (i =0 ; i < num_lanes * lane_reg_size; i++) +dw_pcie_writeb_dbi (pci, cap + lane_eq_offset + i, presets[i]); +} + +static void dw_pcie_config_presets (struct dw_pcie_rp *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +enum pci_bus_speed speed = pcie_link_speed[pci->max_link_speed]; + +/* For data rate of 8 GT/S each lane equalization control is 16bits wide */ +if (speed >=PCIE_SPEED_8_0GT && pp->presets.eq_presets_8gts) +dw_pcie_program_presets (pci,PCI_EXT_CAP_ID_SECPCI ,PCI_SECPCI_LE_CTRL , +0x2 , (u8 *)pp->presets.eq_presets_8gts, pci->num_lanes); + +/* For data rate of 16 GT/S each lane equalization control is 8bits wide */ +if (speed >=PCIE_SPEED_16_0GT && pp->presets.eq_presets_16gts) +dw_pcie_program_presets (pci,PCI_EXT_CAP_ID_PL_16GT ,PCI_PL_16GT_LE_CTRL , +0x1 , pp->presets.eq_presets_16gts, pci->num_lanes); +} +int dw_pcie_setup_rc (struct dw_pcie_rp *pp) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);
@@ -855,6 +893,7 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp)PCI_COMMAND_MASTER |PCI_COMMAND_SERR ;dw_pcie_writel_dbi (pci,PCI_COMMAND , val); +dw_pcie_config_presets (pp);/* * If the platform provides its own child bus config accesses, it means * the platform uses its own address translation component rather than
drivers/pci/controller/dwc/pcie-designware.h +3 -0
@@ -25,6 +25,8 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> +#include "../../pci.h" +/* DWC PCIe IP-core versions (native support since v4.70a) */ #define DW_PCIE_VER_365A 0x3336352a#define DW_PCIE_VER_460A 0x3436302a
@@ -379,6 +381,7 @@ struct dw_pcie_rp {bool use_atu_msg;int msg_atu_index;struct resource *msg_res; +struct pci_eq_presets presets; };struct dw_pcie_ep_ops {
include/uapi/linux/pci_regs.h +3 -0
@@ -1118,6 +1118,9 @@#define PCI_DLF_CAP 0x04/* Capabilities Register */ #define PCI_DLF_EXCHANGE_ENABLE 0x80000000/* Data Link Feature Exchange Enable */ +/* Secondary PCIe Capability 8.0 GT/s */ +#define PCI_SECPCI_LE_CTRL 0x0c/* Lane Equalization Control Register */ +/* Physical Layer 16.0 GT/s */ #define PCI_PL_16GT_LE_CTRL 0x20/* Lane Equalization Control Register */ #define PCI_PL_16GT_LE_CTRL_DSP_TX_PRESET_MASK 0x0000000F
Signature · 1 line
2.34.1