Skip to content

Commit

Permalink
Add module reset before eMMC init
Browse files Browse the repository at this point in the history
  • Loading branch information
wenbinmei1 authored and frank-w committed May 30, 2020
1 parent 2d3e42d commit e9be744
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/arm64/boot/dts/mediatek/mt7622.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,8 @@
compatible = "mediatek,mt7622-mmc";
reg = <0 0x11230000 0 0x1000>;
interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_LOW>;
resets = <&pericfg MT7622_PERI_MSDC0_SW_RST>;
reset-names = "hrst";
clocks = <&pericfg CLK_PERI_MSDC30_0_PD>,
<&topckgen CLK_TOP_MSDC50_0_SEL>;
clock-names = "source", "hclk";
Expand Down
12 changes: 12 additions & 0 deletions drivers/mmc/host/mtk-sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/reset.h>

#include <linux/mmc/card.h>
#include <linux/mmc/core.h>
Expand Down Expand Up @@ -432,6 +433,7 @@ struct msdc_host {
struct msdc_save_para save_para; /* used when gate HCLK */
struct msdc_tune_para def_tune_para; /* default tune setting */
struct msdc_tune_para saved_tune_para; /* tune result of CMD21/CMD19 */
struct reset_control *reset;
};

static const struct mtk_mmc_compatible mt8135_compat = {
Expand Down Expand Up @@ -2208,6 +2210,10 @@ static int msdc_drv_probe(struct platform_device *pdev)
host->top_base = NULL;
}

host->reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "hrst");
if (PTR_ERR(host->reset) == -EPROBE_DEFER)
return PTR_ERR(host->reset);

ret = mmc_regulator_get_supply(mmc);
if (ret)
goto host_free;
Expand Down Expand Up @@ -2318,6 +2324,12 @@ static int msdc_drv_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, mmc);
msdc_ungate_clock(host);

if (!IS_ERR(host->reset)) {
reset_control_assert(host->reset);
usleep_range(10, 50);
reset_control_deassert(host->reset);
}
msdc_init_hw(host);

ret = devm_request_irq(&pdev->dev, host->irq, msdc_irq,
Expand Down

0 comments on commit e9be744

Please sign in to comment.