PCI: dwc: Clean up DWC PCIe register macros
Subsystems (16)
cover PCI: dwc: Clean up DWC PCIe register macros
This series cleans up the DWC PCIe controller register macros to better match the Synopsys DesignWare PCIe Controller Reference Manual, and removes an unused set of iATU unroll register definitions.
Patch 1 renames various register and field macros, dropping redundant PCIE_ prefixes and using documented base names. Field macros are renamed consistently so their register association is clear. No functional change intended.
Patch 2 removes the unused PCIE_ATU_UNR_* macros. These have no remaining users now that the driver uses the ATU_* macros and ATU_UNROLL_BASE() for unrolled iATU register access.
The series was build-tested with defconfig and allmodconfig.
---
Changes in v2:
- Rename Port Link Control register to PORT_LINK_CTRL instead of PORT_LINK_CTRL_OFF, as suggested by Bjorn. The _OFF suffix is ambiguous and unnecessary.
- Extend the cleanup to more DWC PCIe register macros, dropping the redundant PCIE_ prefix and using documented base names, such as PORT_FORCE_LINK, PORT_AFAC, PORT_LANE_SKEW, TIMER_CTRL_MAX_FUNC_NUM, PORT_LINK_DEBUG0/1, LINK_WIDTH_SPEED_CTRL, GEN3_CTRL, GEN3_EQ_CTRL, MULTI_LANE_CTRL, MISC_CONTROL_1, MSIX_DOORBELL, and the ATU_* registers.
- Include the register name in field macros, e.g. PORT_LINK_CTRL_DLE, PORT_LINK_CTRL_FLM, PORT_LINK_CTRL_LC_*.
- Fix PORT_AFAC L1 field names (PORT_AFAC_L1_*).
- Unify COHERENCY_CTRL1/2/3 and RAS_DES_EVENT_COUNTER_* naming.
- Drop the _OFF suffix from MISC_CONTROL_1.
- Add a patch to remove unused PCIE_ATU_UNR_* definitions.
v1:
https://patchwork.kernel.org/project/linux-pci/patch/[email protected]/
---
Hans Zhang (2):
PCI: dwc: Align register macros with Synopsys documentation
PCI: dwc: Remove unused PCIE_ATU_UNR_* register definitions
drivers/pci/controller/dwc/pci-imx6.c | 26 +- drivers/pci/controller/dwc/pci-keystone.c | 4 +- .../pci/controller/dwc/pcie-designware-ep.c | 10 +- .../pci/controller/dwc/pcie-designware-host.c | 18 +- drivers/pci/controller/dwc/pcie-designware.c | 176 +++++------ drivers/pci/controller/dwc/pcie-designware.h | 275 +++++++++--------- drivers/pci/controller/dwc/pcie-fu740.c | 6 +- drivers/pci/controller/dwc/pcie-nxp-s32g.c | 18 +- drivers/pci/controller/dwc/pcie-qcom-common.c | 28 +- drivers/pci/controller/dwc/pcie-qcom.c | 6 +- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 26 +- .../pci/controller/dwc/pcie-tegra194-acpi.c | 22 +- drivers/pci/controller/dwc/pcie-tegra194.c | 86 +++--- drivers/pci/controller/dwc/pcie-ultrarisc.c | 10 +- 14 files changed, 349 insertions(+), 362 deletions(-)
base-commit: 08df884136f1c1197bab2a27814404fd329d9aac
Signature · 7 lines
2.34.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
PATCH 1/2 PCI: dwc: Align register macros with Synopsys documentation
The DWC PCIe register and field macros are inconsistently named and often do not match the Synopsys DesignWare PCIe Controller Reference Manual. This makes it harder to cross-reference the code with the documentation when debugging or maintaining the driver.
As suggested during review, do not add an "_OFF" suffix to the Port Link Control register: the suffix is ambiguous (offset vs. off) and unnecessary. Use PORT_LINK_CTRL, and include the register name in its field macros, e.g. PORT_LINK_CTRL_DLE, PORT_LINK_CTRL_FLM, and PORT_LINK_CTRL_LC_*.
Align other DWC PCIe controller-internal register macros in the same spirit by dropping the redundant PCIE_ prefix and using the documented base names, such as PORT_FORCE_LINK, PORT_AFAC, PORT_LANE_SKEW, TIMER_CTRL_MAX_FUNC_NUM, PORT_LINK_DEBUG0/1, LINK_WIDTH_SPEED_CTRL, GEN3_CTRL, GEN3_EQ_CTRL, MULTI_LANE_CTRL, MISC_CONTROL_1, MSIX_DOORBELL, and the ATU_* registers. Field macros are renamed consistently so their register association is clear.
This improves code maintainability and eases future reference to the controller manual.
No functional change intended.
--- drivers/pci/controller/dwc/pci-imx6.c | 26 +- drivers/pci/controller/dwc/pci-keystone.c | 4 +- .../pci/controller/dwc/pcie-designware-ep.c | 10 +- .../pci/controller/dwc/pcie-designware-host.c | 18 +- drivers/pci/controller/dwc/pcie-designware.c | 176 ++++++------ drivers/pci/controller/dwc/pcie-designware.h | 263 +++++++++--------- drivers/pci/controller/dwc/pcie-fu740.c | 6 +- drivers/pci/controller/dwc/pcie-nxp-s32g.c | 18 +- drivers/pci/controller/dwc/pcie-qcom-common.c | 28 +- drivers/pci/controller/dwc/pcie-qcom.c | 6 +- drivers/pci/controller/dwc/pcie-rcar-gen4.c | 26 +- .../pci/controller/dwc/pcie-tegra194-acpi.c | 22 +- drivers/pci/controller/dwc/pcie-tegra194.c | 86 +++--- drivers/pci/controller/dwc/pcie-ultrarisc.c | 10 +- 14 files changed, 349 insertions(+), 350 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +13 -13
@@ -955,9 +955,9 @@ static int imx_pcie_wait_for_speed_change(struct imx_pcie *imx_pcie)unsigned int retries;for (retries =0 ; retries <200 ; retries++) { - tmp =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); + tmp =dw_pcie_readl_dbi (pci,LINK_WIDTH_SPEED_CTRL );/* Test if the speed change finished. */ -if (!(tmp &PORT_LOGIC_SPEED_CHANGE )) +if (!(tmp &SPEED_CHANGE ))return 0 ;usleep_range (100 ,1000 ); }
@@ -1040,9 +1040,9 @@ static int imx_pcie_start_link(struct dw_pcie *pci)* Start Directed Speed Change so the best possible * speed both link partners support can be negotiated. */ - tmp =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); - tmp |=PORT_LOGIC_SPEED_CHANGE ; -dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , tmp); + tmp =dw_pcie_readl_dbi (pci,LINK_WIDTH_SPEED_CTRL ); + tmp |=SPEED_CHANGE ; +dw_pcie_writel_dbi (pci,LINK_WIDTH_SPEED_CTRL , tmp);dw_pcie_dbi_ro_wr_dis (pci); ret =imx_pcie_wait_for_speed_change (imx_pcie);
@@ -1058,8 +1058,8 @@ static int imx_pcie_start_link(struct dw_pcie *pci) err_reset_phy:dev_dbg (dev,"PHY DEBUG_R0=0x%08x DEBUG_R1=0x%08x\n" , -dw_pcie_readl_dbi (pci,PCIE_PORT_DEBUG0 ), -dw_pcie_readl_dbi (pci,PCIE_PORT_DEBUG1 )); +dw_pcie_readl_dbi (pci,PORT_LINK_DEBUG0 ), +dw_pcie_readl_dbi (pci,PORT_LINK_DEBUG1 ));imx_pcie_reset_phy (imx_pcie);return 0 ; }
@@ -1498,18 +1498,18 @@ static void imx_pcie_host_post_init(struct dw_pcie_rp *pp)/* * ERR051586: Compliance with 8GT/s Receiver Impedance ECN * -* The default value of GEN3_RELATED_OFF[GEN3_ZRXDC_NONCOMPL] +* The default value of GEN3_CTRL[GEN3_ZRXDC_NONCOMPL] * is 1 which makes receiver non-compliant with the ZRX-DC * parameter for 2.5 GT/s when operating at 8 GT/s or higher. * It causes unnecessary timeout in L1. * -* Workaround: Program GEN3_RELATED_OFF[GEN3_ZRXDC_NONCOMPL] +* Workaround: Program GEN3_CTRL[GEN3_ZRXDC_NONCOMPL] * to 0. */ dw_pcie_dbi_ro_wr_en (pci); - val =dw_pcie_readl_dbi (pci,GEN3_RELATED_OFF ); - val &= ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL ; -dw_pcie_writel_dbi (pci,GEN3_RELATED_OFF , val); + val =dw_pcie_readl_dbi (pci,GEN3_CTRL ); + val &= ~GEN3_CTRL_GEN3_ZRXDC_NONCOMPL ; +dw_pcie_writel_dbi (pci,GEN3_CTRL , val);dw_pcie_dbi_ro_wr_dis (pci); }
@@ -1521,7 +1521,7 @@ static void imx_pcie_host_post_init(struct dw_pcie_rp *pp) }/* -* In old DWC implementations, PCIE_ATU_INHIBIT_PAYLOAD in iATU Ctrl2 +* In old DWC implementations, ATU_INHIBIT_PAYLOAD in iATU Ctrl2 * register is reserved, so the generic DWC implementation of sending the * PME_Turn_Off message using a dummy MMIO write cannot be used. */
drivers/pci/controller/dwc/pci-keystone.c +2 -2
@@ -497,8 +497,8 @@ static bool ks_pcie_link_up(struct dw_pcie *pci) {u32 val; - val =dw_pcie_readl_dbi (pci,PCIE_PORT_DEBUG0 ); -return (val &PORT_LOGIC_LTSSM_STATE_MASK ) ==PORT_LOGIC_LTSSM_STATE_L0 ; + val =dw_pcie_readl_dbi (pci,PORT_LINK_DEBUG0 ); +return (val &PORT_LINK_DEBUG0_LTSSM_MASK ) ==DW_PCIE_LTSSM_L0 ; }static void ks_pcie_stop_link (struct dw_pcie *pci)
drivers/pci/controller/dwc/pcie-designware-ep.c +5 -5
@@ -163,7 +163,7 @@ static void dw_pcie_ep_clear_ib_maps(struct dw_pcie_ep *ep, u8 func_no, enum pci/* Tear down the BAR Match Mode mapping, if any. */ if (ep_func->bar_to_atu[bar]) { atu_index = ep_func->bar_to_atu[bar] -1 ; -dw_pcie_disable_atu (pci,PCIE_ATU_REGION_DIR_IB , atu_index); +dw_pcie_disable_atu (pci,ATU_REGION_DIR_IB , atu_index);clear_bit (atu_index, ep->ib_window_map); ep_func->bar_to_atu[bar] =0 ;return ;
@@ -177,7 +177,7 @@ static void dw_pcie_ep_clear_ib_maps(struct dw_pcie_ep *ep, u8 func_no, enum pciif (!indexes)return ;for (i =0 ; i < num; i++) { -dw_pcie_disable_atu (pci,PCIE_ATU_REGION_DIR_IB , indexes[i]); +dw_pcie_disable_atu (pci,ATU_REGION_DIR_IB , indexes[i]);clear_bit (indexes[i], ep->ib_window_map); }devm_kfree (dev, indexes);
@@ -647,7 +647,7 @@ static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,return ; ep->outbound_addr[atu_index] =0 ; -dw_pcie_disable_atu (pci,PCIE_ATU_REGION_DIR_OB , atu_index); +dw_pcie_disable_atu (pci,ATU_REGION_DIR_OB , atu_index);clear_bit (atu_index, ep->ob_window_map); }
@@ -1077,10 +1077,10 @@ int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no,if (!ep_func || !ep_func->msix_cap)return -EINVAL ; - msg_data = (func_no <<PCIE_MSIX_DOORBELL_PF_SHIFT ) | + msg_data = (func_no <<MSIX_DOORBELL_PF_SHIFT ) | (interrupt_num -1 ); -dw_pcie_writel_dbi (pci,PCIE_MSIX_DOORBELL , msg_data); +dw_pcie_writel_dbi (pci,MSIX_DOORBELL , msg_data);return 0 ; }
drivers/pci/controller/dwc/pcie-designware-host.c +9 -9
@@ -440,7 +440,7 @@ static int dw_pcie_config_ecam_iatu(struct dw_pcie_rp *pp) atu.parent_bus_addr = pp->cfg0_base +SZ_1M ;/* 1MiB is to cover 1 (bus) * 32 (devices) * 8 (functions) */ atu.size =SZ_1M ; - atu.ctrl2 =PCIE_ATU_CFG_SHIFT_MODE_ENABLE ; + atu.ctrl2 =ATU_CFG_SHIFT_MODE_ENABLE ; ret =dw_pcie_prog_outbound_atu (pci, &atu);if (ret)return ret;
@@ -455,7 +455,7 @@ static int dw_pcie_config_ecam_iatu(struct dw_pcie_rp *pp) atu.type =PCIE_TLP_TYPE_CFG1_RDWR ; atu.parent_bus_addr = pp->cfg0_base +SZ_2M ; atu.size = (SZ_1M * bus_range_max) -SZ_2M ; - atu.ctrl2 =PCIE_ATU_CFG_SHIFT_MODE_ENABLE ; + atu.ctrl2 =ATU_CFG_SHIFT_MODE_ENABLE ;return dw_pcie_prog_outbound_atu (pci, &atu); }
@@ -747,8 +747,8 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus,if (!dw_pcie_link_up (pci))return NULL ; - busdev =PCIE_ATU_BUS (bus->number) |PCIE_ATU_DEV (PCI_SLOT (devfn)) | -PCIE_ATU_FUNC (PCI_FUNC (devfn)); + busdev =ATU_BUS (bus->number) |ATU_DEV (PCI_SLOT (devfn)) | +ATU_FUNC (PCI_FUNC (devfn));if (pci_is_root_bus (bus->parent)) type =PCIE_TLP_TYPE_CFG0_RDWR ;
@@ -884,10 +884,10 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)* the MEM/IO (dma-)ranges setups. */ for (i =0 ; i < pci->num_ob_windows; i++) -dw_pcie_disable_atu (pci,PCIE_ATU_REGION_DIR_OB , i); +dw_pcie_disable_atu (pci,ATU_REGION_DIR_OB , i);for (i =0 ; i < pci->num_ib_windows; i++) -dw_pcie_disable_atu (pci,PCIE_ATU_REGION_DIR_IB , i); +dw_pcie_disable_atu (pci,ATU_REGION_DIR_IB , i);/* * NOTE: For outbound address translation, outbound iATU at index 0 is
@@ -1165,9 +1165,9 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp)/* Program correct class for RC */ dw_pcie_writew_dbi (pci,PCI_CLASS_DEVICE ,PCI_CLASS_BRIDGE_PCI ); - val =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); - val |=PORT_LOGIC_SPEED_CHANGE ; -dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , val); + val =dw_pcie_readl_dbi (pci,LINK_WIDTH_SPEED_CTRL ); + val |=SPEED_CHANGE ; +dw_pcie_writel_dbi (pci,LINK_WIDTH_SPEED_CTRL , val);dw_pcie_dbi_ro_wr_dis (pci);
drivers/pci/controller/dwc/pcie-designware.c +88 -88
372 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-designware.h +131 -132
323 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-fu740.c +3 -3
@@ -215,9 +215,9 @@ static int fu740_pcie_start_link(struct dw_pcie *pci) tmp |= orig;dw_pcie_writel_dbi (pci, cap_exp +PCI_EXP_LNKCAP , tmp); - tmp =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); - tmp |=PORT_LOGIC_SPEED_CHANGE ; -dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , tmp); + tmp =dw_pcie_readl_dbi (pci,LINK_WIDTH_SPEED_CTRL ); + tmp |=SPEED_CHANGE ; +dw_pcie_writel_dbi (pci,LINK_WIDTH_SPEED_CTRL , tmp); ret =dw_pcie_wait_for_link (pci);if (ret) {
drivers/pci/controller/dwc/pcie-nxp-s32g.c +9 -9
@@ -107,7 +107,7 @@ static void s32g_pcie_reset_mstr_ace(struct dw_pcie *pci)u32 ddr_base_high =upper_32_bits (S32G_MEMORY_BOUNDARY_ADDR );dw_pcie_dbi_ro_wr_en (pci); -dw_pcie_writel_dbi (pci,COHERENCY_CONTROL_3_OFF ,0x0 ); +dw_pcie_writel_dbi (pci,COHERENCY_CTRL3 ,0x0 );/* * Ncore is a cache-coherent interconnect module that enables the
@@ -125,9 +125,9 @@ static void s32g_pcie_reset_mstr_ace(struct dw_pcie *pci)* Define the start of DDR as seen by Linux as this boundary between * "memory" and "peripherals", with peripherals being below. */ -dw_pcie_writel_dbi (pci,COHERENCY_CONTROL_1_OFF , +dw_pcie_writel_dbi (pci,COHERENCY_CTRL1 , (ddr_base_low &CFG_MEMTYPE_BOUNDARY_LOW_ADDR_MASK )); -dw_pcie_writel_dbi (pci,COHERENCY_CONTROL_2_OFF , ddr_base_high); +dw_pcie_writel_dbi (pci,COHERENCY_CTRL2 , ddr_base_high);dw_pcie_dbi_ro_wr_dis (pci); }
@@ -154,13 +154,13 @@ static int s32g_init_pcie_controller(struct dw_pcie_rp *pp)dw_pcie_dbi_ro_wr_en (pci); - val =dw_pcie_readl_dbi (pci,PCIE_PORT_FORCE ); - val |=PORT_FORCE_DO_DESKEW_FOR_SRIS ; -dw_pcie_writel_dbi (pci,PCIE_PORT_FORCE , val); + val =dw_pcie_readl_dbi (pci,PORT_FORCE_LINK ); + val |=PORT_FORCE_LINK_DDFS ; +dw_pcie_writel_dbi (pci,PORT_FORCE_LINK , val); - val =dw_pcie_readl_dbi (pci,GEN3_RELATED_OFF ); - val |=GEN3_RELATED_OFF_EQ_PHASE_2_3 ; -dw_pcie_writel_dbi (pci,GEN3_RELATED_OFF , val); + val =dw_pcie_readl_dbi (pci,GEN3_CTRL ); + val |=GEN3_CTRL_EQ_PHASE_2_3 ; +dw_pcie_writel_dbi (pci,GEN3_CTRL , val);dw_pcie_dbi_ro_wr_dis (pci);
drivers/pci/controller/dwc/pcie-qcom-common.c +14 -14
@@ -15,9 +15,9 @@ void qcom_pcie_common_set_equalization(struct dw_pcie *pci)u16 speed;/* -* GEN3_RELATED_OFF register is repurposed to apply equalization +* GEN3_CTRL register is repurposed to apply equalization * settings at various data transmission rates through registers namely -* GEN3_EQ_*. The RATE_SHADOW_SEL bit field of GEN3_RELATED_OFF +* GEN3_EQ_*. The RATE_SHADOW_SEL bit field of GEN3_CTRL * determines the data rate for which these equalization settings are * applied. */
@@ -28,25 +28,25 @@ void qcom_pcie_common_set_equalization(struct dw_pcie *pci)break ; } - reg =dw_pcie_readl_dbi (pci,GEN3_RELATED_OFF ); - reg &= ~GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL ; -FIELD_MODIFY (GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK , ®, + reg =dw_pcie_readl_dbi (pci,GEN3_CTRL ); + reg &= ~GEN3_CTRL_GEN3_ZRXDC_NONCOMPL ; +FIELD_MODIFY (GEN3_CTRL_RATE_SHADOW_SEL_MASK , ®, speed -PCIE_SPEED_8_0GT ); -dw_pcie_writel_dbi (pci,GEN3_RELATED_OFF , reg); +dw_pcie_writel_dbi (pci,GEN3_CTRL , reg); - reg =dw_pcie_readl_dbi (pci,GEN3_EQ_FB_MODE_DIR_CHANGE_OFF ); + reg =dw_pcie_readl_dbi (pci,GEN3_EQ_FB_MODE_DIR_CHANGE );FIELD_MODIFY (GEN3_EQ_FMDC_T_MIN_PHASE23 , ®,0x1 );FIELD_MODIFY (GEN3_EQ_FMDC_N_EVALS , ®,0xd );FIELD_MODIFY (GEN3_EQ_FMDC_MAX_PRE_CURSOR_DELTA , ®,0x5 );FIELD_MODIFY (GEN3_EQ_FMDC_MAX_POST_CURSOR_DELTA , ®,0x5 ); -dw_pcie_writel_dbi (pci,GEN3_EQ_FB_MODE_DIR_CHANGE_OFF , reg); +dw_pcie_writel_dbi (pci,GEN3_EQ_FB_MODE_DIR_CHANGE , reg); - reg =dw_pcie_readl_dbi (pci,GEN3_EQ_CONTROL_OFF ); - reg &= ~(GEN3_EQ_CONTROL_OFF_FB_MODE | -GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE | -GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL | -GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC ); -dw_pcie_writel_dbi (pci,GEN3_EQ_CONTROL_OFF , reg); + reg =dw_pcie_readl_dbi (pci,GEN3_EQ_CTRL ); + reg &= ~(GEN3_EQ_CTRL_FB_MODE | +GEN3_EQ_CTRL_PHASE23_EXIT_MODE | +GEN3_EQ_CTRL_FOM_INC_INITIAL_EVAL | +GEN3_EQ_CTRL_PSET_REQ_VEC ); +dw_pcie_writel_dbi (pci,GEN3_EQ_CTRL , reg); } }EXPORT_SYMBOL_GPL (qcom_pcie_common_set_equalization);
drivers/pci/controller/dwc/pcie-qcom.c +3 -3
@@ -1295,9 +1295,9 @@ static int qcom_pcie_post_init_2_9_0(struct qcom_pcie *pcie)writel (DEVICE_TYPE_RC , pcie->parf +PARF_DEVICE_TYPE );writel (BYPASS |MSTR_AXI_CLK_EN |AHB_CLK_EN , pcie->parf +PARF_MHI_CLOCK_RESET_CTRL ); -writel (GEN3_RELATED_OFF_RXEQ_RGRDLESS_RXTS | -GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL , - pci->dbi_base +GEN3_RELATED_OFF ); +writel (GEN3_CTRL_RXEQ_RGRDLESS_RXTS | +GEN3_CTRL_GEN3_ZRXDC_NONCOMPL , + pci->dbi_base +GEN3_CTRL ); writel(MST_WAKEUP_EN | SLV_WAKEUP_EN | MSTR_ACLK_CGC_DIS | SLV_ACLK_CGC_DIS | CORE_CLK_CGC_DIS |
drivers/pci/controller/dwc/pcie-rcar-gen4.c +13 -13
@@ -122,17 +122,17 @@ static int rcar_gen4_pcie_speed_change(struct dw_pcie *dw)u32 val;int i; - val =dw_pcie_readl_dbi (dw,PCIE_LINK_WIDTH_SPEED_CONTROL ); - val &= ~PORT_LOGIC_SPEED_CHANGE ; -dw_pcie_writel_dbi (dw,PCIE_LINK_WIDTH_SPEED_CONTROL , val); + val =dw_pcie_readl_dbi (dw,LINK_WIDTH_SPEED_CTRL ); + val &= ~SPEED_CHANGE ; +dw_pcie_writel_dbi (dw,LINK_WIDTH_SPEED_CTRL , val); - val =dw_pcie_readl_dbi (dw,PCIE_LINK_WIDTH_SPEED_CONTROL ); - val |=PORT_LOGIC_SPEED_CHANGE ; -dw_pcie_writel_dbi (dw,PCIE_LINK_WIDTH_SPEED_CONTROL , val); + val =dw_pcie_readl_dbi (dw,LINK_WIDTH_SPEED_CTRL ); + val |=SPEED_CHANGE ; +dw_pcie_writel_dbi (dw,LINK_WIDTH_SPEED_CTRL , val);for (i =0 ; i <RCAR_NUM_SPEED_CHANGE_RETRIES ; i++) { - val =dw_pcie_readl_dbi (dw,PCIE_LINK_WIDTH_SPEED_CONTROL ); -if (!(val &PORT_LOGIC_SPEED_CHANGE )) + val =dw_pcie_readl_dbi (dw,LINK_WIDTH_SPEED_CTRL ); +if (!(val &SPEED_CHANGE ))return 0 ;usleep_range (10000 ,11000 ); }
@@ -688,11 +688,11 @@ static void rcar_gen4_pcie_additional_common_init(struct rcar_gen4_pcie *rcar)struct dw_pcie *dw = &rcar->dw;u32 val; - val =dw_pcie_readl_dbi (dw,PCIE_PORT_LANE_SKEW ); + val =dw_pcie_readl_dbi (dw,PORT_LANE_SKEW ); val &= ~PORT_LANE_SKEW_INSERT_MASK ;if (dw->num_lanes <4 ) val |=BIT (6 ); -dw_pcie_writel_dbi (dw,PCIE_PORT_LANE_SKEW , val); +dw_pcie_writel_dbi (dw,PORT_LANE_SKEW , val); val =readl (rcar->base +PCIEPWRMNGCTRL ); val |=APP_CLK_REQ_N |APP_CLK_PM_EN ;
@@ -803,9 +803,9 @@ static int rcar_gen4_pcie_ltssm_control(struct rcar_gen4_pcie *rcar, bool enablereturn 0 ; } - val =dw_pcie_readl_dbi (dw,PCIE_PORT_FORCE ); - val |=PORT_FORCE_DO_DESKEW_FOR_SRIS ; -dw_pcie_writel_dbi (dw,PCIE_PORT_FORCE , val); + val =dw_pcie_readl_dbi (dw,PORT_FORCE_LINK ); + val |=PORT_FORCE_LINK_DDFS ; +dw_pcie_writel_dbi (dw,PORT_FORCE_LINK , val); val =readl (rcar->base +PCIEMSR0 ); val |=APP_SRIS_MODE ;
drivers/pci/controller/dwc/pcie-tegra194-acpi.c +11 -11
@@ -39,8 +39,8 @@ static int tegra194_acpi_init(struct pci_config_window *cfg)static void atu_reg_write (struct tegra194_pcie_ecam *pcie_ecam,int index,u32 val,u32 reg) { -u32 offset =PCIE_ATU_UNROLL_BASE (PCIE_ATU_REGION_DIR_OB , index) + -PCIE_ATU_VIEWPORT_BASE ; +u32 offset =ATU_UNROLL_BASE (ATU_REGION_DIR_OB , index) + +ATU_VIEWPORT_BASE ;writel (val, pcie_ecam->iatu_base + offset + reg); }
@@ -50,17 +50,17 @@ static void program_outbound_atu(struct tegra194_pcie_ecam *pcie_ecam, u64 pci_addr, u64 size) {atu_reg_write (pcie_ecam ,index ,lower_32_bits (cpu_addr ), -PCIE_ATU_LOWER_BASE ); +ATU_LOWER_BASE );atu_reg_write (pcie_ecam, index,upper_32_bits (cpu_addr), -PCIE_ATU_UPPER_BASE ); +ATU_UPPER_BASE );atu_reg_write (pcie_ecam, index,lower_32_bits (pci_addr), -PCIE_ATU_LOWER_TARGET ); +ATU_LOWER_TARGET );atu_reg_write (pcie_ecam, index,lower_32_bits (cpu_addr + size -1 ), -PCIE_ATU_LIMIT ); +ATU_LIMIT );atu_reg_write (pcie_ecam, index,upper_32_bits (pci_addr), -PCIE_ATU_UPPER_TARGET ); -atu_reg_write (pcie_ecam, index, type,PCIE_ATU_REGION_CTRL1 ); -atu_reg_write (pcie_ecam, index,PCIE_ATU_ENABLE ,PCIE_ATU_REGION_CTRL2 ); +ATU_UPPER_TARGET ); +atu_reg_write (pcie_ecam, index, type,ATU_REGION_CTRL1 ); +atu_reg_write (pcie_ecam, index,ATU_ENABLE ,ATU_REGION_CTRL2 ); } static void __iomem *tegra194_map_bus(struct pci_bus *bus,
@@ -81,8 +81,8 @@ static void __iomem *tegra194_map_bus(struct pci_bus *bus,return NULL ; } - busdev =PCIE_ATU_BUS (bus->number) |PCIE_ATU_DEV (PCI_SLOT (devfn)) | -PCIE_ATU_FUNC (PCI_FUNC (devfn)); + busdev =ATU_BUS (bus->number) |ATU_DEV (PCI_SLOT (devfn)) | +ATU_FUNC (PCI_FUNC (devfn));if (bus->parent->number == cfg->busr.start) {if (PCI_SLOT (devfn) ==0 )
drivers/pci/controller/dwc/pcie-tegra194.c +43 -43
157 lines not on this page · raw message
drivers/pci/controller/dwc/pcie-ultrarisc.c +5 -5
@@ -52,18 +52,18 @@ static int ultrarisc_pcie_host_init(struct dw_pcie_rp *pp) val &= ~FAST_LINK_MODE ;dw_pcie_writel_dbi (pci,PCIE_CUS_CORE , val); - val =dw_pcie_readl_dbi (pci,PCIE_TIMER_CTRL_MAX_FUNC_NUM ); + val =dw_pcie_readl_dbi (pci,TIMER_CTRL_MAX_FUNC_NUM );FIELD_MODIFY (PORT_FLT_SF_MASK , &val,PORT_FLT_SF_VAL_64 ); -dw_pcie_writel_dbi (pci,PCIE_TIMER_CTRL_MAX_FUNC_NUM , val); +dw_pcie_writel_dbi (pci,TIMER_CTRL_MAX_FUNC_NUM , val); cap_exp =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); val =dw_pcie_readl_dbi (pci, cap_exp +PCI_EXP_LNKCTL2 );FIELD_MODIFY (PCI_EXP_LNKCTL2_TLS , &val,PCI_EXP_LNKCTL2_TLS_16_0GT );dw_pcie_writel_dbi (pci, cap_exp +PCI_EXP_LNKCTL2 , val); - val =dw_pcie_readl_dbi (pci,PCIE_PORT_FORCE ); -FIELD_MODIFY (PORT_LINK_NUM_MASK , &val,0 ); -dw_pcie_writel_dbi (pci,PCIE_PORT_FORCE , val); + val =dw_pcie_readl_dbi (pci,PORT_FORCE_LINK ); +FIELD_MODIFY (PORT_FORCE_LINK_NUM_MASK , &val,0 ); +dw_pcie_writel_dbi (pci,PORT_FORCE_LINK , val); val =dw_pcie_readl_dbi (pci, cap_exp +PCI_EXP_DEVCTL2 ); FIELD_MODIFY(PCI_EXP_DEVCTL2_COMP_TIMEOUT, &val,
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH 1/2] PCI: dwc: Align register macros with Synopsys documentation
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 lines
The DWC PCIe register and field macros are inconsistently named and often do not match the Synopsys DesignWare PCIe Controller Reference Manual. This makes it harder to cross-reference the code with the documentation when debugging or maintaining the driver.
As suggested during review, do not add an "
_OFF" suffix to the Port Link Control register: the suffix is ambiguous (offset vs. off) and unnecessary. UsePORT_LINK_CTRL, and include the register name in its field macros, e.g.PORT_LINK_CTRL_DLE,PORT_LINK_CTRL_FLM, and PORT_LINK_CTRL_LC_*.Align other DWC PCIe controller-internal register macros in the same spirit by dropping the redundant
PCIE_prefix and using the documented base names, such asPORT_FORCE_LINK,PORT_AFAC,PORT_LANE_SKEW,TIMER_CTRL_MAX_FUNC_NUM, PORT_LINK_DEBUG0/1,LINK_WIDTH_SPEED_CTRL,GEN3_CTRL,GEN3_EQ_CTRL,MULTI_LANE_CTRL,MISC_CONTROL_1,MSIX_DOORBELL, and the ATU_* registers. Field macros are renamed consistently so their register association is clear.
Quoted 8 lines
This improves code maintainability and eases future reference to the controller manual.
No functional change intended.
Co-developed-by Feizhou Yu <[email protected]>Signed-off-by Feizhou Yu <[email protected]>Signed-off-by Hans Zhang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Re: [PATCH 1/2] PCI: dwc: Align register macros with Synopsys documentation
In reply to Hans Zhangdrivers/pci/controller/dwc/pcie-designware.h line 88
Quoted 9 lines · Hans Zhang
The DWC PCIe register and field macros are inconsistently named and often do not match the Synopsys DesignWare PCIe Controller Reference Manual. This makes it harder to cross-reference the code with the documentation when debugging or maintaining the driver.
drivers/pci/controller/dwc/pcie-designware.h +4
-0+#define PORT_AFAC_L0S_ELS 24/* L0s Entrance Latency shift */ +#define PORT_AFAC_L0S_ELM GENMASK(26, 24)/* L0s Entrance Latency mask */ +#define PORT_AFAC_L1_ELS 27/* L1 Entrance Latency shift */ +#define PORT_AFAC_L1_ELM GENMASK(29, 27)/* L1 Entrance Latency mask */
Surely we don't need both the shift and the mask? Maybe a separate patch convert to FIELD_PREP()?
drivers/pci/controller/dwc/pcie-designware.h line 154
Quoted 2 lines
drivers/pci/controller/dwc/pcie-designware.h +2
-0+#define GEN3_CTRL_RATE_SHADOW_SEL_SHIFT 24/* Rate Shadow Select shift */ +#define GEN3_CTRL_RATE_SHADOW_SEL_MASK GENMASK(25, 24)/* Rate Shadow Select mask */
Ditto.
drivers/pci/controller/dwc/pcie-designware.h line 219
Quoted 2 lines
drivers/pci/controller/dwc/pcie-designware.h +2
-0+#define MSIX_DOORBELL 0x948 +#define MSIX_DOORBELL_PF_SHIFT 24
Probably would be better to define a mask so we have the position *and* the width.
drivers/pci/controller/dwc/pcie-tegra194.c static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event) · line 628
Quoted 10 lines
drivers/pci/controller/dwc/pcie-tegra194.c +1
-1@@ -621,15 +621,15 @@ static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event)u32 val; val =dw_pcie_readl_dbi (&pcie->pci, pcie->ras_des_cap + -PCIE_RAS_DES_EVENT_COUNTER_CONTROL ); +RAS_DES_EVENT_COUNTER_CONTROL ); val &= ~(EVENT_COUNTER_EVENT_SEL_MASK <<EVENT_COUNTER_EVENT_SEL_SHIFT ); val |=EVENT_COUNTER_GROUP_5 <<EVENT_COUNTER_GROUP_SEL_SHIFT ; val |= event <<EVENT_COUNTER_EVENT_SEL_SHIFT ; val |=EVENT_COUNTER_ENABLE_ALL <<EVENT_COUNTER_ENABLE_SHIFT ;
Probably a good chance to convert these to FIELD_PREP() etc. as well, maybe in a separate patch.
Re: [PATCH 1/2] PCI: dwc: Align register macros with Synopsys documentation
Quoted 6 lines · Bjorn Helgaas
Quoted 4 lines · Hans Zhang
The DWC PCIe register and field macros are inconsistently named and often do not match the Synopsys DesignWare PCIe Controller Reference Manual. This makes it harder to cross-reference the code with the documentation when debugging or maintaining the driver.
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.h line 88
Quoted 4 lines
drivers/pci/controller/dwc/pcie-designware.h +4
-0+#define PORT_AFAC_L0S_ELS 24/* L0s Entrance Latency shift */ +#define PORT_AFAC_L0S_ELM GENMASK(26, 24)/* L0s Entrance Latency mask */ +#define PORT_AFAC_L1_ELS 27/* L1 Entrance Latency shift */ +#define PORT_AFAC_L1_ELM GENMASK(29, 27)/* L1 Entrance Latency mask */ Surely we don't need both the shift and the mask? Maybe a separate patch convert to
FIELD_PREP()?
Oops, sorry, didn't notice that Mani had already applied these. This could be material for follow-on patches.
Quoted 24 lines
drivers/pci/controller/dwc/pcie-designware.h line 154
Quoted 2 lines
drivers/pci/controller/dwc/pcie-designware.h +2
-0+#define GEN3_CTRL_RATE_SHADOW_SEL_SHIFT 24/* Rate Shadow Select shift */ +#define GEN3_CTRL_RATE_SHADOW_SEL_MASK GENMASK(25, 24)/* Rate Shadow Select mask */ Ditto.
drivers/pci/controller/dwc/pcie-designware.h line 219
Quoted 2 lines
drivers/pci/controller/dwc/pcie-designware.h +2
-0+#define MSIX_DOORBELL 0x948 +#define MSIX_DOORBELL_PF_SHIFT 24Probably would be better to define a mask so we have the position *and* the width.
drivers/pci/controller/dwc/pcie-tegra194.c static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event) · line 628
Quoted 10 lines
drivers/pci/controller/dwc/pcie-tegra194.c +1
-1@@ -621,15 +621,15 @@ static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event)u32 val; val =dw_pcie_readl_dbi (&pcie->pci, pcie->ras_des_cap + -PCIE_RAS_DES_EVENT_COUNTER_CONTROL ); +RAS_DES_EVENT_COUNTER_CONTROL ); val &= ~(EVENT_COUNTER_EVENT_SEL_MASK <<EVENT_COUNTER_EVENT_SEL_SHIFT ); val |=EVENT_COUNTER_GROUP_5 <<EVENT_COUNTER_GROUP_SEL_SHIFT ; val |= event <<EVENT_COUNTER_EVENT_SEL_SHIFT ; val |=EVENT_COUNTER_ENABLE_ALL <<EVENT_COUNTER_ENABLE_SHIFT ;Probably a good chance to convert these to
FIELD_PREP()etc. as well, maybe in a separate patch.
Re: [PATCH 1/2] PCI: dwc: Align register macros with Synopsys documentation
Quoted 15 lines · Bjorn Helgaas
Quoted 6 lines · Bjorn Helgaas
Quoted 4 lines · Hans Zhang
The DWC PCIe register and field macros are inconsistently named and often do not match the Synopsys DesignWare PCIe Controller Reference Manual. This makes it harder to cross-reference the code with the documentation when debugging or maintaining the driver.
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.h line 88
Quoted 4 lines
drivers/pci/controller/dwc/pcie-designware.h +4
-0+#define PORT_AFAC_L0S_ELS 24/* L0s Entrance Latency shift */ +#define PORT_AFAC_L0S_ELM GENMASK(26, 24)/* L0s Entrance Latency mask */ +#define PORT_AFAC_L1_ELS 27/* L1 Entrance Latency shift */ +#define PORT_AFAC_L1_ELM GENMASK(29, 27)/* L1 Entrance Latency mask */ Surely we don't need both the shift and the mask? Maybe a separate patch convert to
FIELD_PREP()?
Quoted 2 lines
Oops, sorry, didn't notice that Mani had already applied these. This could be material for follow-on patches.
Hi Bjorn,
I will send a patch separately based on the branch controller/dwc.
Best regards,
Hans
Quoted 15 lines
Quoted 15 lines
drivers/pci/controller/dwc/pcie-designware.h line 154
Quoted 3 lines
drivers/pci/controller/dwc/pcie-designware.h +2
-0+#define GEN3_CTRL_RATE_SHADOW_SEL_SHIFT 24/* Rate Shadow Select shift */ +#define GEN3_CTRL_RATE_SHADOW_SEL_MASK GENMASK(25, 24)/* Rate Shadow Select mask */ Ditto.
drivers/pci/controller/dwc/pcie-designware.h line 219
Quoted 2 lines
drivers/pci/controller/dwc/pcie-designware.h +2
-0+#define MSIX_DOORBELL 0x948 +#define MSIX_DOORBELL_PF_SHIFT 24Probably would be better to define a mask so we have the position *and* the width.
Quoted 3 lines
(quoted diff) +0
-0@@ -621,15 +621,15 @@ static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event) u32 val;
Quoted 10 lines
Quoted 10 lines
drivers/pci/controller/dwc/pcie-tegra194.c static inline u32 event_counter_prog(struct tegra_pcie_dw *pcie, u32 event) · line 628
Quoted 7 lines
drivers/pci/controller/dwc/pcie-tegra194.c +1
-1val =dw_pcie_readl_dbi (&pcie->pci, pcie->ras_des_cap + -PCIE_RAS_DES_EVENT_COUNTER_CONTROL ); +RAS_DES_EVENT_COUNTER_CONTROL ); val &= ~(EVENT_COUNTER_EVENT_SEL_MASK <<EVENT_COUNTER_EVENT_SEL_SHIFT ); val |=EVENT_COUNTER_GROUP_5 <<EVENT_COUNTER_GROUP_SEL_SHIFT ; val |= event <<EVENT_COUNTER_EVENT_SEL_SHIFT ; val |=EVENT_COUNTER_ENABLE_ALL <<EVENT_COUNTER_ENABLE_SHIFT ;Probably a good chance to convert these to
FIELD_PREP()etc. as well, maybe in a separate patch.
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
PATCH 2/2 PCI: dwc: Remove unused PCIE_ATU_UNR_* register definitions
In reply to Hans ZhangThe PCIE_ATU_UNR_* macros are not used anywhere in the kernel. They were presumably intended for unrolled iATU register access, but the driver now uses the ATU_* macros and computes unrolled offsets via ATU_UNROLL_BASE().
Remove these unused definitions. No functional change intended.
--- drivers/pci/controller/dwc/pcie-designware.h | 12 ------------ 1 file changed, 12 deletions(-)
drivers/pci/controller/dwc/pcie-designware.h +0 -12
@@ -257,18 +257,6 @@#define MARGINING_MAXLANES GENMASK(20, 16)#define MARGINING_SAMPLE_RATE_TIMING GENMASK(13, 8)#define MARGINING_SAMPLE_RATE_VOLTAGE GENMASK(5, 0) -/* -* iATU Unroll-specific register definitions -* From 4.80 core version the address translation will be made by unroll -*/ -#define PCIE_ATU_UNR_REGION_CTRL1 0x00 -#define PCIE_ATU_UNR_REGION_CTRL2 0x04 -#define PCIE_ATU_UNR_LOWER_BASE 0x08 -#define PCIE_ATU_UNR_UPPER_BASE 0x0C -#define PCIE_ATU_UNR_LOWER_LIMIT 0x10 -#define PCIE_ATU_UNR_LOWER_TARGET 0x14 -#define PCIE_ATU_UNR_UPPER_TARGET 0x18 -#define PCIE_ATU_UNR_UPPER_LIMIT 0x20/* * RAS-DES register definitions
Signature · 7 lines
2.34.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
[email protected]
AI reviewRe: [PATCH 2/2] PCI: dwc: Remove unused PCIE_ATU_UNR_* register definitions
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
The PCIE_ATU_UNR_* macros are not used anywhere in the kernel. They were presumably intended for unrolled iATU register access, but the driver now uses the ATU_* macros and computes unrolled offsets via
ATU_UNROLL_BASE().Remove these unused definitions. No functional change intended.
Signed-off-by Hans Zhang <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Quoted 10 lines · Hans Zhang
This series cleans up the DWC PCIe controller register macros to better match the Synopsys DesignWare PCIe Controller Reference Manual, and removes an unused set of iATU unroll register definitions.
Patch 1 renames various register and field macros, dropping redundant
PCIE_prefixes and using documented base names. Field macros are renamed consistently so their register association is clear. No functional change intended.[...]
Applied, thanks!
[1/2] PCI: dwc: Align register macros with Synopsys documentation
commit: f29719b5064c07cec23c928055df302181374df5
[2/2] PCI: dwc: Remove unused PCIE_ATU_UNR_* register definitions
commit: 4996364a46e738cc455f5fa9b8b09f2f3348bcc9Best regards,
Signature · 1 line
மணிவண்ணன் சதாசிவம்