Skip to content

Commit 759574a

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: tegra194: Use FIELD_GET()/FIELD_PREP() with Link Width fields
Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of custom masking and shifting. Similarly, change custom code that misleadingly used PCI_EXP_LNKSTA_NLW_SHIFT to prepare value for PCI_EXP_LNKCAP write to use FIELD_PREP() with correct field define (PCI_EXP_LNKCAP_MLW). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]>
1 parent 0bb80ec commit 759574a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Author: Vidya Sagar <[email protected]>
1010
*/
1111

12+
#include <linux/bitfield.h>
1213
#include <linux/clk.h>
1314
#include <linux/debugfs.h>
1415
#include <linux/delay.h>
@@ -346,8 +347,7 @@ static void apply_bad_link_workaround(struct dw_pcie_rp *pp)
346347
*/
347348
val = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA);
348349
if (val & PCI_EXP_LNKSTA_LBMS) {
349-
current_link_width = (val & PCI_EXP_LNKSTA_NLW) >>
350-
PCI_EXP_LNKSTA_NLW_SHIFT;
350+
current_link_width = FIELD_GET(PCI_EXP_LNKSTA_NLW, val);
351351
if (pcie->init_link_width > current_link_width) {
352352
dev_warn(pci->dev, "PCIe link is bad, width reduced\n");
353353
val = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base +
@@ -760,8 +760,7 @@ static void tegra_pcie_enable_system_interrupts(struct dw_pcie_rp *pp)
760760

761761
val_w = dw_pcie_readw_dbi(&pcie->pci, pcie->pcie_cap_base +
762762
PCI_EXP_LNKSTA);
763-
pcie->init_link_width = (val_w & PCI_EXP_LNKSTA_NLW) >>
764-
PCI_EXP_LNKSTA_NLW_SHIFT;
763+
pcie->init_link_width = FIELD_GET(PCI_EXP_LNKSTA_NLW, val_w);
765764

766765
val_w = dw_pcie_readw_dbi(&pcie->pci, pcie->pcie_cap_base +
767766
PCI_EXP_LNKCTL);
@@ -920,7 +919,7 @@ static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp)
920919
/* Configure Max lane width from DT */
921920
val = dw_pcie_readl_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKCAP);
922921
val &= ~PCI_EXP_LNKCAP_MLW;
923-
val |= (pcie->num_lanes << PCI_EXP_LNKSTA_NLW_SHIFT);
922+
val |= FIELD_PREP(PCI_EXP_LNKCAP_MLW, pcie->num_lanes);
924923
dw_pcie_writel_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKCAP, val);
925924

926925
/* Clear Slot Clock Configuration bit if SRNS configuration */

0 commit comments

Comments
 (0)