Skip to content

Commit 951b7cc

Browse files
bjorn-helgaasUlf Hansson
authored andcommitted
mmc: sdhci-pci-gli: Use PCI AER definitions, not hard-coded values
015c9cb ("mmc: sdhci-pci-gli: GL9750: Mask the replay timer timeout of AER") added PCI_GLI_9750_CORRERR_MASK, the offset of the AER Capability in config space, and PCI_GLI_9750_CORRERR_MASK_REPLAY_TIMER_TIMEOUT, the Replay Timer Timeout bit in the AER Correctable Error Status register. Use pci_find_ext_capability() to locate the AER Capability and use the existing PCI_ERR_COR_REP_TIMER definition to mask the bit. This removes a little bit of unnecessarily device-specific code and makes AER-related things more greppable. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/20240327214831.1544595-2-helgaas@kernel.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 0eed7b4 commit 951b7cc

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

drivers/mmc/host/sdhci-pci-gli.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
#define PCI_GLI_9750_PM_CTRL 0xFC
2929
#define PCI_GLI_9750_PM_STATE GENMASK(1, 0)
3030

31-
#define PCI_GLI_9750_CORRERR_MASK 0x214
32-
#define PCI_GLI_9750_CORRERR_MASK_REPLAY_TIMER_TIMEOUT BIT(12)
33-
3431
#define SDHCI_GLI_9750_CFG2 0x848
3532
#define SDHCI_GLI_9750_CFG2_L1DLY GENMASK(28, 24)
3633
#define GLI_9750_CFG2_L1DLY_VALUE 0x1F
@@ -155,9 +152,6 @@
155152
#define PCI_GLI_9755_PM_CTRL 0xFC
156153
#define PCI_GLI_9755_PM_STATE GENMASK(1, 0)
157154

158-
#define PCI_GLI_9755_CORRERR_MASK 0x214
159-
#define PCI_GLI_9755_CORRERR_MASK_REPLAY_TIMER_TIMEOUT BIT(12)
160-
161155
#define SDHCI_GLI_9767_GM_BURST_SIZE 0x510
162156
#define SDHCI_GLI_9767_GM_BURST_SIZE_AXI_ALWAYS_SET BIT(8)
163157

@@ -547,6 +541,7 @@ static void gl9750_hw_setting(struct sdhci_host *host)
547541
{
548542
struct sdhci_pci_slot *slot = sdhci_priv(host);
549543
struct pci_dev *pdev;
544+
int aer;
550545
u32 value;
551546

552547
pdev = slot->chip->pdev;
@@ -568,9 +563,12 @@ static void gl9750_hw_setting(struct sdhci_host *host)
568563
pci_write_config_dword(pdev, PCI_GLI_9750_PM_CTRL, value);
569564

570565
/* mask the replay timer timeout of AER */
571-
pci_read_config_dword(pdev, PCI_GLI_9750_CORRERR_MASK, &value);
572-
value |= PCI_GLI_9750_CORRERR_MASK_REPLAY_TIMER_TIMEOUT;
573-
pci_write_config_dword(pdev, PCI_GLI_9750_CORRERR_MASK, value);
566+
aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
567+
if (aer) {
568+
pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value);
569+
value |= PCI_ERR_COR_REP_TIMER;
570+
pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value);
571+
}
574572

575573
gl9750_wt_off(host);
576574
}
@@ -745,6 +743,7 @@ static void sdhci_gl9755_set_clock(struct sdhci_host *host, unsigned int clock)
745743
static void gl9755_hw_setting(struct sdhci_pci_slot *slot)
746744
{
747745
struct pci_dev *pdev = slot->chip->pdev;
746+
int aer;
748747
u32 value;
749748

750749
gl9755_wt_on(pdev);
@@ -782,9 +781,12 @@ static void gl9755_hw_setting(struct sdhci_pci_slot *slot)
782781
pci_write_config_dword(pdev, PCI_GLI_9755_PM_CTRL, value);
783782

784783
/* mask the replay timer timeout of AER */
785-
pci_read_config_dword(pdev, PCI_GLI_9755_CORRERR_MASK, &value);
786-
value |= PCI_GLI_9755_CORRERR_MASK_REPLAY_TIMER_TIMEOUT;
787-
pci_write_config_dword(pdev, PCI_GLI_9755_CORRERR_MASK, value);
784+
aer = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
785+
if (aer) {
786+
pci_read_config_dword(pdev, aer + PCI_ERR_COR_MASK, &value);
787+
value |= PCI_ERR_COR_REP_TIMER;
788+
pci_write_config_dword(pdev, aer + PCI_ERR_COR_MASK, value);
789+
}
788790

789791
gl9755_wt_off(pdev);
790792
}

0 commit comments

Comments
 (0)