Skip to contentSkip to conversation

mmc: mediatek: add optional reset property

PATCH In review Wenbin Mei 4 participants 11 messages Aug 14, 2020 – Aug 28, 2020

Subsystems (5)
lore
Share & tools
lore

Wenbin Mei

author
#0 lore raw

v5 cover mmc: mediatek: add optional reset property

Wenbin Mei (3):
mmc: dt-bindings: Add resets/reset-names for Mediatek MMC bindings
arm64: dts: mt7622: add reset node for mmc device
mmc: mediatek: add optional module reset property

 Documentation/devicetree/bindings/mmc/mtk-sd.txt |  2 ++
 arch/arm64/boot/dts/mediatek/mt7622.dtsi         |  2 ++
 drivers/mmc/host/mtk-sd.c                        | 13 +++++++++++++
 3 files changed, 17 insertions(+)

--
2.18.0

author
#1 lore raw

PATCH v5 1/3 mmc: dt-bindings: Add resets/reset-names for Mediatek MMC bindings

Add description for resets/reset-names.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")
---
 Documentation/devicetree/bindings/mmc/mtk-sd.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mmc/mtk-sd.txt +2 -0
index 8a532f4453f2..09aecec47003 100644
@@ -49,6 +49,8 @@ Optional properties:
 		     error caused by stop clock(fifo full)
 		     Valid range = [0:0x7]. if not present, default value is 0.
 		     applied to compatible "mediatek,mt2701-mmc".
+- resets: Phandle and reset specifier pair to softreset line of MSDC IP.
+- reset-names: Should be "hrst".
 
 Examples:
 mmc0: mmc@11230000 {
Signature · 1 line
2.18.0
author
#4 lore raw

PATCH v5 2/3 arm64: dts: mt7622: add reset node for mmc device

In reply to Wenbin Mei

This commit adds reset node for mmc device.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")
---
 arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622.dtsi +2 -0
index 1a39e0ef776b..5b9ec032ce8d 100644
@@ -686,6 +686,8 @@
 		clocks = <&pericfg CLK_PERI_MSDC30_0_PD>,
 			 <&topckgen CLK_TOP_MSDC50_0_SEL>;
 		clock-names = "source", "hclk";
+		resets = <&pericfg MT7622_PERI_MSDC0_SW_RST>;
+		reset-names = "hrst";
 		status = "disabled";
 	};
 
Signature · 1 line
2.18.0
author
#8 lore raw

PATCH v5 3/3 mmc: mediatek: add optional module reset property

In reply to Wenbin Mei

This patch fixs eMMC-Access on mt7622/Bpi-64. Before we got these Errors on mounting eMMC ion R64:

[   48.664925] blk_update_request: I/O error, dev mmcblk0, sector 204800 op 0x1:(WRITE)
flags 0x800 phys_seg 1 prio class 0
[   48.676019] Buffer I/O error on dev mmcblk0p1, logical block 0, lost sync page write

This patch adds a optional reset management for msdc. Sometimes the bootloader does not bring msdc register to default state, so need reset the msdc controller.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")
---
 drivers/mmc/host/mtk-sd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/host/mtk-sd.c +13 -0
index 39e7fc54c438..fc97d5bf3a20 100644
@@ -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>
@@ -434,6 +435,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 = {
@@ -1516,6 +1518,12 @@ static void msdc_init_hw(struct msdc_host *host)
 	u32 val;
 	u32 tune_reg = host->dev_comp->pad_tune_reg;
 
+	if (host->reset) {
+		reset_control_assert(host->reset);
+		usleep_range(10, 50);
+		reset_control_deassert(host->reset);
+	}
+
 	/* Configure to MMC/SD mode, clock free running */
 	sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_MODE | MSDC_CFG_CKPDN);
 
@@ -2273,6 +2281,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
 	if (IS_ERR(host->src_clk_cg))
 		host->src_clk_cg = NULL;
 
+	host->reset = devm_reset_control_get_optional_exclusive(&pdev->dev,
+								"hrst");
+	if (IS_ERR(host->reset))
+		return PTR_ERR(host->reset);
+
 	host->irq = platform_get_irq(pdev, 0);
 	if (host->irq < 0) {
 		ret = -EINVAL;
Signature · 1 line
2.18.0
maintainer Reviewed-by on v5 1/3
#2 lore raw

Re: [v5,1/3] mmc: dt-bindings: Add resets/reset-names for Mediatek MMC bindings

In reply to Wenbin Mei
Quoted 6 lines · Wenbin Mei

Add description for resets/reset-names.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")
Quoted 9 lines
---
 Documentation/devicetree/bindings/mmc/mtk-sd.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mmc/mtk-sd.txt +0 -0
index 8a532f4453f2..09aecec47003 100644

Documentation/devicetree/bindings/mmc/mtk-sd.txt Optional properties: · line 56

Quoted 8 lines
Documentation/devicetree/bindings/mmc/mtk-sd.txt +2 -0
@@ -49,6 +49,8 @@ Optional properties:
 		     error caused by stop clock(fifo full)
 		     Valid range = [0:0x7]. if not present, default value is 0.
 		     applied to compatible "mediatek,mt2701-mmc".
+- resets: Phandle and reset specifier pair to softreset line of MSDC IP.
+- reset-names: Should be "hrst".
 
 Examples:
 mmc0: mmc@11230000 {

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

maintainer Reviewed-by on v5 3/3
#9 lore raw

Re: [v5,3/3] mmc: mediatek: add optional module reset property

In reply to Wenbin Mei
Quoted 6 lines · Wenbin Mei

This patch fixs eMMC-Access on mt7622/Bpi-64. Before we got these Errors on mounting eMMC ion R64:

[   48.664925] blk_update_request: I/O error, dev mmcblk0, sector 204800 op 0x1:(WRITE)
flags 0x800 phys_seg 1 prio class 0
[   48.676019] Buffer I/O error on dev mmcblk0p1, logical block 0, lost sync page write
Quoted 8 lines

This patch adds a optional reset management for msdc. Sometimes the bootloader does not bring msdc register to default state, so need reset the msdc controller.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")
Quoted 40 lines
---
 drivers/mmc/host/mtk-sd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/host/mtk-sd.c +8 -0
index 39e7fc54c438..fc97d5bf3a20 100644
@@ -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>
@@ -434,6 +435,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 = {
@@ -1516,6 +1518,12 @@ static void msdc_init_hw(struct msdc_host *host)
 	u32 val;
 	u32 tune_reg = host->dev_comp->pad_tune_reg;
 
+	if (host->reset) {
+		reset_control_assert(host->reset);
+		usleep_range(10, 50);
+		reset_control_deassert(host->reset);
+	}
+
 	/* Configure to MMC/SD mode, clock free running */
 	sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_MODE | MSDC_CFG_CKPDN);
 
@@ -2273,6 +2281,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
 	if (IS_ERR(host->src_clk_cg))

drivers/mmc/host/mtk-sd.c static int msdc_drv_probe(struct platform_device *pdev) · line 2291

Quoted 10 lines
drivers/mmc/host/mtk-sd.c +5 -0
 		host->src_clk_cg = NULL;
 
+	host->reset = devm_reset_control_get_optional_exclusive(&pdev->dev,
+								"hrst");
+	if (IS_ERR(host->reset))
+		return PTR_ERR(host->reset);
+
 	host->irq = platform_get_irq(pdev, 0);
 	if (host->irq < 0) {
 		ret = -EINVAL;

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#10 lore raw

Re: [v5,3/3] mmc: mediatek: add optional module reset property

In reply to Wenbin Mei
Quoted 11 lines · Wenbin Mei

This patch fixs eMMC-Access on mt7622/Bpi-64. Before we got these Errors on mounting eMMC ion R64:

[   48.664925] blk_update_request: I/O error, dev mmcblk0, sector 204800 op 0x1:(WRITE)
flags 0x800 phys_seg 1 prio class 0
[   48.676019] Buffer I/O error on dev mmcblk0p1, logical block 0, lost sync page write

This patch adds a optional reset management for msdc. Sometimes the bootloader does not bring msdc register to default state, so need reset the msdc controller.

Quoted 5 lines
Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")

Applied for fixes, but needed to resolve a conflict when applying, thanks!

Quoted 17 lines
---
 drivers/mmc/host/mtk-sd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/host/mtk-sd.c +1 -0
index 39e7fc54c438..fc97d5bf3a20 100644
@@ -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>

drivers/mmc/host/mtk-sd.c struct msdc_host { · line 438

Quoted 4 lines
drivers/mmc/host/mtk-sd.c +1 -0
@@ -434,6 +435,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;

I moved this a couple of lines above, since this conflicts with later changes for mtk-sd.

[...]

Kind regards
Uffe

#5 lore raw

Re: [v5,2/3] arm64: dts: mt7622: add reset node for mmc device

In reply to Wenbin Mei
Quoted 7 lines · Wenbin Mei

This commit adds reset node for mmc device.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")

I can pick this for my fixes branch, together with the other changes, however deferring that until Matthias acks it.

Kind regards
Uffe

Quoted 19 lines
---
 arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622.dtsi +2 -1
index 1a39e0ef776b..5b9ec032ce8d 100644
@@ -686,6 +686,8 @@
                clocks = <&pericfg CLK_PERI_MSDC30_0_PD>,
                         <&topckgen CLK_TOP_MSDC50_0_SEL>;
                clock-names = "source", "hclk";
+               resets = <&pericfg MT7622_PERI_MSDC0_SW_RST>;
+               reset-names = "hrst";
                status = "disabled";
        };
 
--

2.18.0

#3 lore raw

Re: [v5,1/3] mmc: dt-bindings: Add resets/reset-names for Mediatek MMC bindings

In reply to Wenbin Mei
Quoted 7 lines · Wenbin Mei

Add description for resets/reset-names.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")

Applied for fixes, thanks!

Kind regards
Uffe

Quoted 19 lines
---
 Documentation/devicetree/bindings/mmc/mtk-sd.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mmc/mtk-sd.txt +2 -1
index 8a532f4453f2..09aecec47003 100644
@@ -49,6 +49,8 @@ Optional properties:
                     error caused by stop clock(fifo full)
                     Valid range = [0:0x7]. if not present, default value is 0.
                     applied to compatible "mediatek,mt2701-mmc".
+- resets: Phandle and reset specifier pair to softreset line of MSDC IP.
+- reset-names: Should be "hrst".
 
 Examples:
 mmc0: mmc@11230000 {
--

2.18.0

maintainer Acked-by
#6 lore raw

Re: [v5,2/3] arm64: dts: mt7622: add reset node for mmc device

In reply to Ulf Hansson
Quoted 11 lines · Ulf Hansson
Quoted 7 lines · Wenbin Mei

This commit adds reset node for mmc device.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")

I can pick this for my fixes branch, together with the other changes, however deferring that until Matthias acks it.

My understanding is, that this will land also in v5.9-rc[3,4], correct?

Regards,
Matthias

Quoted 23 lines

Kind regards
Uffe

Quoted 17 lines
---
  arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 ++
  1 file changed, 2 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622.dtsi +2 -0
index 1a39e0ef776b..5b9ec032ce8d 100644
@@ -686,6 +686,8 @@
                 clocks = <&pericfg CLK_PERI_MSDC30_0_PD>,
                          <&topckgen CLK_TOP_MSDC50_0_SEL>;
                 clock-names = "source", "hclk";
+               resets = <&pericfg MT7622_PERI_MSDC0_SW_RST>;
+               reset-names = "hrst";
                 status = "disabled";
         };
 
Quoted 2 lines
Quoted 2 lines

--
2.18.0

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#7 lore raw

Re: [v5,2/3] arm64: dts: mt7622: add reset node for mmc device

Quoted 13 lines · Matthias Brugger
Quoted 9 lines · Ulf Hansson
Quoted 7 lines · Wenbin Mei

This commit adds reset node for mmc device.

Cc <[email protected]> # v5.4+
Fixes 966580ad236e ("mmc: mediatek: add support for MT7622 SoC")
Quoted 6 lines
Quoted 2 lines

I can pick this for my fixes branch, together with the other changes, however deferring that until Matthias acks it.

My understanding is, that this will land also in v5.9-rc[3,4], correct?

Correct.

Applied for fixes, thanks!

[...]

Kind regards
Uffe