Skip to content

Commit c766624

Browse files
r-vigneshUlf Hansson
authored andcommitted
drivers: mmc: sdhci_am654: Add the quirk to set TESTCD bit
The ARASAN MMC controller on Keystone 3 class of devices need the SDCD line to be connected for proper functioning. Similar to the issue pointed out in sdhci-of-arasan.c driver, commit 3794c54 ("mmc: sdhci-of-arasan: Set controller to test mode when no CD bit"). In cases where this can't be connected, add a quirk to force the controller into test mode and set the TESTCD bit. Use the flag "ti,fails-without-test-cd", to implement this above quirk when required. Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com> Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Link: https://lore.kernel.org/r/20220425063120.10135-3-a-govindraju@ti.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 7a05874 commit c766624

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

drivers/mmc/host/sdhci_am654.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ struct sdhci_am654_data {
147147
int drv_strength;
148148
int strb_sel;
149149
u32 flags;
150+
u32 quirks;
151+
152+
#define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
150153
};
151154

152155
struct sdhci_am654_driver_data {
@@ -369,6 +372,21 @@ static void sdhci_am654_write_b(struct sdhci_host *host, u8 val, int reg)
369372
}
370373
}
371374

375+
static void sdhci_am654_reset(struct sdhci_host *host, u8 mask)
376+
{
377+
u8 ctrl;
378+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
379+
struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
380+
381+
sdhci_reset(host, mask);
382+
383+
if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_FORCE_CDTEST) {
384+
ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
385+
ctrl |= SDHCI_CTRL_CDTEST_INS | SDHCI_CTRL_CDTEST_EN;
386+
sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
387+
}
388+
}
389+
372390
static int sdhci_am654_execute_tuning(struct mmc_host *mmc, u32 opcode)
373391
{
374392
struct sdhci_host *host = mmc_priv(mmc);
@@ -500,7 +518,7 @@ static struct sdhci_ops sdhci_j721e_4bit_ops = {
500518
.set_clock = sdhci_j721e_4bit_set_clock,
501519
.write_b = sdhci_am654_write_b,
502520
.irq = sdhci_am654_cqhci_irq,
503-
.reset = sdhci_reset,
521+
.reset = sdhci_am654_reset,
504522
};
505523

506524
static const struct sdhci_pltfm_data sdhci_j721e_4bit_pdata = {
@@ -719,6 +737,9 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
719737
device_property_read_u32(dev, "ti,clkbuf-sel",
720738
&sdhci_am654->clkbuf_sel);
721739

740+
if (device_property_read_bool(dev, "ti,fails-without-test-cd"))
741+
sdhci_am654->quirks |= SDHCI_AM654_QUIRK_FORCE_CDTEST;
742+
722743
sdhci_get_of_property(pdev);
723744

724745
return 0;

0 commit comments

Comments
 (0)