|
9 | 9 | * Author: Vidya Sagar <[email protected]>
|
10 | 10 | */
|
11 | 11 |
|
| 12 | +#include <linux/bitfield.h> |
12 | 13 | #include <linux/clk.h>
|
13 | 14 | #include <linux/debugfs.h>
|
14 | 15 | #include <linux/delay.h>
|
@@ -346,8 +347,7 @@ static void apply_bad_link_workaround(struct dw_pcie_rp *pp)
|
346 | 347 | */
|
347 | 348 | val = dw_pcie_readw_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKSTA);
|
348 | 349 | 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); |
351 | 351 | if (pcie->init_link_width > current_link_width) {
|
352 | 352 | dev_warn(pci->dev, "PCIe link is bad, width reduced\n");
|
353 | 353 | 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)
|
760 | 760 |
|
761 | 761 | val_w = dw_pcie_readw_dbi(&pcie->pci, pcie->pcie_cap_base +
|
762 | 762 | 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); |
765 | 764 |
|
766 | 765 | val_w = dw_pcie_readw_dbi(&pcie->pci, pcie->pcie_cap_base +
|
767 | 766 | PCI_EXP_LNKCTL);
|
@@ -920,7 +919,7 @@ static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp)
|
920 | 919 | /* Configure Max lane width from DT */
|
921 | 920 | val = dw_pcie_readl_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKCAP);
|
922 | 921 | 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); |
924 | 923 | dw_pcie_writel_dbi(pci, pcie->pcie_cap_base + PCI_EXP_LNKCAP, val);
|
925 | 924 |
|
926 | 925 | /* Clear Slot Clock Configuration bit if SRNS configuration */
|
|
0 commit comments