Skip to content

Commit e72f42e

Browse files
P33Mpelwell
authored andcommitted
mmc: use downstream DT property to modify CQE and/or SD CQ behaviour
Implement a tristate-style option for "supports-cqe". If the property is absent or zero, disable CQ completely. For 1, enable CQ unconditionally for eMMC cards, and known-good SD cards. For 2, enable for eMMC cards, and all SD cards that are not known-bad. The sdhci-brcmstb driver needs to know about the tristate as its probe sequence would otherwise override a disable in mmc_of_parse(). Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
1 parent eb4d8ff commit e72f42e

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

drivers/mmc/core/host.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ EXPORT_SYMBOL(mmc_of_parse_clk_phase);
275275
int mmc_of_parse(struct mmc_host *host)
276276
{
277277
struct device *dev = host->parent;
278-
u32 bus_width, drv_type, cd_debounce_delay_ms;
278+
u32 bus_width, drv_type, cd_debounce_delay_ms, cq_allow;
279279
int ret;
280280

281281
if (!dev || !dev_fwnode(dev))
@@ -410,6 +410,15 @@ int mmc_of_parse(struct mmc_host *host)
410410
host->caps2 &= ~(MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V |
411411
MMC_CAP2_HS400_ES);
412412

413+
cq_allow = 0;
414+
/*
415+
* Downstream property - if a u32 and 2 instead of a bool,
416+
* trust most A2 SD cards claiming CQ support.
417+
*/
418+
device_property_read_u32(dev, "supports-cqe", &cq_allow);
419+
if (cq_allow == 2)
420+
host->caps2 |= MMC_CAP2_SD_CQE_PERMISSIVE;
421+
413422
/* Must be after "non-removable" check */
414423
if (device_property_read_u32(dev, "fixed-emmc-driver-type", &drv_type) == 0) {
415424
if (host->caps & MMC_CAP_NONREMOVABLE)

drivers/mmc/core/sd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,8 +1506,8 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
15061506
goto free_card;
15071507
}
15081508

1509-
/* Disallow command queueing on unvetted cards */
1510-
if (!mmc_card_working_sd_cq(card))
1509+
/* Disallow command queueing on unvetted cards unless overridden */
1510+
if (!(host->caps2 & MMC_CAP2_SD_CQE_PERMISSIVE) && !mmc_card_working_sd_cq(card))
15111511
card->ext_csd.cmdq_support = false;
15121512

15131513
/* Enable command queueing if supported */

drivers/mmc/host/sdhci-brcmstb.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
511511
struct sdhci_pltfm_host *pltfm_host;
512512
const struct of_device_id *match;
513513
struct sdhci_brcmstb_priv *priv;
514-
u32 actual_clock_mhz;
514+
u32 actual_clock_mhz, cqe;
515515
struct sdhci_host *host;
516516
struct resource *iomem;
517517
bool no_pinctrl = false;
@@ -540,7 +540,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
540540
pltfm_host->clk = clk;
541541

542542
priv = sdhci_pltfm_priv(pltfm_host);
543-
if (device_property_read_bool(&pdev->dev, "supports-cqe")) {
543+
cqe = 0;
544+
device_property_read_u32(&pdev->dev, "supports-cqe", &cqe);
545+
if (cqe > 0) {
544546
priv->flags |= BRCMSTB_PRIV_FLAGS_HAS_CQE;
545547
match_priv->ops->irq = sdhci_brcmstb_cqhci_irq;
546548
}

include/linux/mmc/host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ struct mmc_host {
427427
#define MMC_CAP2_CRYPTO 0
428428
#endif
429429
#define MMC_CAP2_ALT_GPT_TEGRA (1 << 28) /* Host with eMMC that has GPT entry at a non-standard location */
430+
#define MMC_CAP2_SD_CQE_PERMISSIVE (1 << 31) /* Ignore allow-list for CQ capable SD card detection */
430431

431432
int fixed_drv_type; /* fixed driver type for non-removable media */
432433

0 commit comments

Comments
 (0)