Skip to content

Commit 84fc1b2

Browse files
committed
mmc: sdhci-of-at91: add hw_reset callback
Add hardware reset callback that can reset an eMMC. This is only used in combination with specific DT property cap-mmc-hw-reset. It uses the MC1R register to enable and disable the reset pin. Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
1 parent 295b593 commit 84fc1b2

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

drivers/mmc/host/sdhci-of-at91.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#define SDMMC_MC1R 0x204
2727
#define SDMMC_MC1R_DDR BIT(3)
28+
#define SDMMC_MC1R_RSTN BIT(6)
2829
#define SDMMC_MC1R_FCD BIT(7)
2930
#define SDMMC_CACR 0x230
3031
#define SDMMC_CACR_CAPWREN BIT(0)
@@ -153,12 +154,31 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
153154
}
154155
}
155156

157+
static void sdhci_at91_hw_reset(struct sdhci_host *host)
158+
{
159+
u8 mc1r;
160+
161+
mc1r = readb(host->ioaddr + SDMMC_MC1R);
162+
163+
mc1r |= SDMMC_MC1R_RSTN;
164+
writeb(mc1r, host->ioaddr + SDMMC_MC1R);
165+
166+
udelay(10);
167+
168+
mc1r &= ~SDMMC_MC1R_RSTN;
169+
writeb(mc1r, host->ioaddr + SDMMC_MC1R);
170+
171+
/* JEDEC specifies a minimum of 200us for tRSCA (reset to command) */
172+
usleep_range(200, 500);
173+
}
174+
156175
static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
157176
.set_clock = sdhci_at91_set_clock,
158177
.set_bus_width = sdhci_set_bus_width,
159178
.reset = sdhci_at91_reset,
160179
.set_uhs_signaling = sdhci_at91_set_uhs_signaling,
161180
.set_power = sdhci_set_power_and_bus_voltage,
181+
.hw_reset = sdhci_at91_hw_reset,
162182
};
163183

164184
static const struct sdhci_pltfm_data sdhci_sama5d2_pdata = {

0 commit comments

Comments
 (0)