bcm27xx: update 6.1 patches to latest version
[openwrt/staging/dangole.git] / target / linux / bcm27xx / patches-6.1 / 950-1075-drivers-mmc-sdhci-add-SPURIOUS_INT_RESP-quirk.patch
1 From 4d2261fe86ce08bbee3c000718000e9f86593d88 Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Wed, 8 Nov 2023 11:52:16 +0000
4 Subject: [PATCH] drivers: mmc: sdhci: add SPURIOUS_INT_RESP quirk
5
6 Certain controllers (dwc-mshc) generate timeout conditions separately to
7 command-completion conditions, where the end result is interrupts are
8 separated in time depending on the current SDCLK frequency.
9
10 This causes spurious interrupts if SDCLK is slow compared to the CPU's
11 ability to process and return from interrupt. This occurs during card
12 probe with an empty slot where all commands that would generate a
13 response time out.
14
15 Add a quirk to squelch command response interrupts when a command
16 timeout interrupt is received.
17
18 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
19 ---
20 drivers/mmc/host/sdhci.c | 11 +++++++++++
21 drivers/mmc/host/sdhci.h | 3 +++
22 2 files changed, 14 insertions(+)
23
24 --- a/drivers/mmc/host/sdhci.c
25 +++ b/drivers/mmc/host/sdhci.c
26 @@ -1728,6 +1728,12 @@ static bool sdhci_send_command(struct sd
27 if (host->use_external_dma)
28 sdhci_external_dma_pre_transfer(host, cmd);
29
30 + if (host->quirks2 & SDHCI_QUIRK2_SPURIOUS_INT_RESP) {
31 + host->ier |= SDHCI_INT_RESPONSE;
32 + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
33 + sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
34 + }
35 +
36 sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
37
38 return true;
39 @@ -3330,6 +3336,11 @@ static void sdhci_cmd_irq(struct sdhci_h
40 if (intmask & SDHCI_INT_TIMEOUT) {
41 host->cmd->error = -ETIMEDOUT;
42 sdhci_err_stats_inc(host, CMD_TIMEOUT);
43 + if (host->quirks2 & SDHCI_QUIRK2_SPURIOUS_INT_RESP) {
44 + host->ier &= ~SDHCI_INT_RESPONSE;
45 + sdhci_writel(host, host->ier, SDHCI_INT_ENABLE);
46 + sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE);
47 + }
48 } else {
49 host->cmd->error = -EILSEQ;
50 if (!mmc_op_tuning(host->cmd->opcode))
51 --- a/drivers/mmc/host/sdhci.h
52 +++ b/drivers/mmc/host/sdhci.h
53 @@ -486,6 +486,9 @@ struct sdhci_host {
54 #define SDHCI_QUIRK2_NO_SDR50 (1<<20)
55 #define SDHCI_QUIRK2_NO_SDR104 (1<<21)
56
57 +/* Command timeouts may generate a trailing INT_RESPONSE later */
58 +#define SDHCI_QUIRK2_SPURIOUS_INT_RESP (1<<31)
59 +
60 int irq; /* Device IRQ */
61 void __iomem *ioaddr; /* Mapped address */
62 phys_addr_t mapbase; /* physical address base */