Skip to content

Commit e30a581

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 15fd6ee commit e30a581

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
@@ -272,7 +272,7 @@ EXPORT_SYMBOL(mmc_of_parse_clk_phase);
272272
int mmc_of_parse(struct mmc_host *host)
273273
{
274274
struct device *dev = host->parent;
275-
u32 bus_width, drv_type, cd_debounce_delay_ms;
275+
u32 bus_width, drv_type, cd_debounce_delay_ms, cq_allow;
276276
int ret;
277277

278278
if (!dev || !dev_fwnode(dev))
@@ -407,6 +407,15 @@ int mmc_of_parse(struct mmc_host *host)
407407
host->caps2 &= ~(MMC_CAP2_HS400_1_8V | MMC_CAP2_HS400_1_2V |
408408
MMC_CAP2_HS400_ES);
409409

410+
cq_allow = 0;
411+
/*
412+
* Downstream property - if a u32 and 2 instead of a bool,
413+
* trust most A2 SD cards claiming CQ support.
414+
*/
415+
device_property_read_u32(dev, "supports-cqe", &cq_allow);
416+
if (cq_allow == 2)
417+
host->caps2 |= MMC_CAP2_SD_CQE_PERMISSIVE;
418+
410419
/* Must be after "non-removable" check */
411420
if (device_property_read_u32(dev, "fixed-emmc-driver-type", &drv_type) == 0) {
412421
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
@@ -1501,8 +1501,8 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
15011501
goto free_card;
15021502
}
15031503

1504-
/* Disallow command queueing on unvetted cards */
1505-
if (!mmc_card_working_sd_cq(card))
1504+
/* Disallow command queueing on unvetted cards unless overridden */
1505+
if (!(host->caps2 & MMC_CAP2_SD_CQE_PERMISSIVE) && !mmc_card_working_sd_cq(card))
15061506
card->ext_csd.cmdq_support = false;
15071507

15081508
/* 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
@@ -571,7 +571,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
571571
struct sdhci_pltfm_host *pltfm_host;
572572
const struct of_device_id *match;
573573
struct sdhci_brcmstb_priv *priv;
574-
u32 actual_clock_mhz;
574+
u32 actual_clock_mhz, cqe;
575575
struct sdhci_host *host;
576576
struct resource *iomem;
577577
bool no_pinctrl = false;
@@ -600,7 +600,9 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)
600600
pltfm_host->clk = clk;
601601

602602
priv = sdhci_pltfm_priv(pltfm_host);
603-
if (device_property_read_bool(&pdev->dev, "supports-cqe")) {
603+
cqe = 0;
604+
device_property_read_u32(&pdev->dev, "supports-cqe", &cqe);
605+
if (cqe > 0) {
604606
priv->flags |= BRCMSTB_PRIV_FLAGS_HAS_CQE;
605607
match_priv->ops->irq = sdhci_brcmstb_cqhci_irq;
606608
}

include/linux/mmc/host.h

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

408409
int fixed_drv_type; /* fixed driver type for non-removable media */
409410

0 commit comments

Comments
 (0)