f52171197724ac511842f75a8fd2de66526d51be
[openwrt/staging/ansuel.git] /
1 From 5c0f94088e0694220a2f0d8ad6e8216b50a80f2e Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Thu, 13 Jun 2024 15:01:02 +0100
4 Subject: [PATCH 1133/1145] drivers: mmc: sdhci-brcmstb: improve bcm2712 card
5 removal handling
6
7 If the controller is being reset, then the CQE needs to be reset as well.
8
9 For removable cards, CQHCI_SSC1 must specify a polling mode (CBC=0)
10 otherwise it's possible that the controller stops emitting periodic
11 CMD13s on card removal, without raising an error status interrupt.
12
13 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
14 ---
15 drivers/mmc/host/sdhci-brcmstb.c | 19 ++++++++++++++++---
16 1 file changed, 16 insertions(+), 3 deletions(-)
17
18 --- a/drivers/mmc/host/sdhci-brcmstb.c
19 +++ b/drivers/mmc/host/sdhci-brcmstb.c
20 @@ -365,8 +365,21 @@ static void sdhci_brcmstb_cqe_enable(str
21
22 sdhci_cqe_enable(mmc);
23
24 - /* Reset CMD13 polling timer back to eMMC specification default */
25 - cqhci_writel(cq_host, 0x00011000, CQHCI_SSC1);
26 + /*
27 + * The controller resets this register to a very short default interval
28 + * whenever CQHCI is disabled.
29 + *
30 + * For removable cards CBC needs to be clear or card removal can hang
31 + * the CQE. In polling mode, a CIT of 0x4000 "cycles" seems to produce the best
32 + * throughput.
33 + *
34 + * For nonremovable cards, the specification default of CBC=1 CIT=0x1000
35 + * suffices.
36 + */
37 + if (mmc->caps & MMC_CAP_NONREMOVABLE)
38 + cqhci_writel(cq_host, 0x00011000, CQHCI_SSC1);
39 + else
40 + cqhci_writel(cq_host, 0x00004000, CQHCI_SSC1);
41 }
42
43 static const struct cqhci_host_ops sdhci_brcmstb_cqhci_ops = {
44 @@ -386,7 +399,7 @@ static struct sdhci_ops sdhci_brcmstb_op
45 .set_clock = sdhci_bcm2712_set_clock,
46 .set_power = sdhci_brcmstb_set_power,
47 .set_bus_width = sdhci_set_bus_width,
48 - .reset = sdhci_reset,
49 + .reset = brcmstb_reset,
50 .set_uhs_signaling = sdhci_set_uhs_signaling,
51 .init_sd_express = bcm2712_init_sd_express,
52 };