Skip to contentSkip to conversation

mmc: tmio/sdhi: add support for custom MASK_ALL

PATCH In review Wolfram Sang 3 participants 9 messages Feb 23, 2021 – Mar 4, 2021

Subsystems (2)
lore
Share & tools
lore

Wolfram Sang

author maintainer
#0 lore raw

cover mmc: tmio/sdhi: add support for custom MASK_ALL

Here is a small series to ensure SDHI Gen2+ will use its custom MASK_ALL value all the time.

Please let me know what you think.

Happy hacking,

Wolfram

Wolfram Sang (2):
mmc: tmio: support custom irq masks
mmc: renesas_sdhi: use custom mask for TMIO_MASK_ALL

 drivers/mmc/host/renesas_sdhi_core.c | 3 ++-
 drivers/mmc/host/tmio_mmc.h          | 3 ++-
 drivers/mmc/host/tmio_mmc_core.c     | 8 +++++---
 3 files changed, 9 insertions(+), 5 deletions(-)
Signature · 1 line
2.30.0
author maintainer
#1 lore raw

PATCH 1/2 mmc: tmio: support custom irq masks

SDHI Gen2+ has a different value for TMIO_MASK_ALL, so add a member to support that. If the member is not used, the previous default value is applied.

---
 drivers/mmc/host/tmio_mmc.h      | 1 +
 drivers/mmc/host/tmio_mmc_core.c | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/host/tmio_mmc.h +1 -0
index 2d1db9396d4a..7d5201d6a006 100644
@@ -164,6 +164,7 @@ struct tmio_mmc_host {
 	u32			sdio_irq_mask;
 	unsigned int		clk_cache;
 	u32			sdcard_irq_setbit_mask;
+	u32			sdcard_irq_mask_all;
 
 	spinlock_t		lock;		/* protect host private data */
 	unsigned long		last_req_ts;
drivers/mmc/host/tmio_mmc_core.c +5 -3
index 0e7a2faa5238..eca767dcabba 100644
@@ -1175,7 +1175,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
 	tmio_mmc_reset(_host);
 
 	_host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
-	tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
+	if (!_host->sdcard_irq_mask_all)
+		_host->sdcard_irq_mask_all = TMIO_MASK_ALL;
+	tmio_mmc_disable_mmc_irqs(_host, _host->sdcard_irq_mask_all);
 
 	if (_host->native_hotplug)
 		tmio_mmc_enable_mmc_irqs(_host,
@@ -1229,7 +1231,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 	cancel_work_sync(&host->done);
 	cancel_delayed_work_sync(&host->delayed_reset_work);
 	tmio_mmc_release_dma(host);
-	tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
+	tmio_mmc_disable_mmc_irqs(host, host->sdcard_irq_mask_all);
 
 	if (host->native_hotplug)
 		pm_runtime_put_noidle(&pdev->dev);
@@ -1259,7 +1261,7 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)
 {
 	struct tmio_mmc_host *host = dev_get_drvdata(dev);
 
-	tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
+	tmio_mmc_disable_mmc_irqs(host, host->sdcard_irq_mask_all);
 
 	if (host->clk_cache)
 		host->set_clock(host, 0);
Signature · 1 line
2.30.0
Reviewed-by Tested-by on v1 1/2
#2 lore raw

RE: [PATCH 1/2] mmc: tmio: support custom irq masks

Hi Wolfram-san,

Quoted 7 lines

From: Wolfram Sang, Sent: Tuesday, February 23, 2021 7:08 PM

SDHI Gen2+ has a different value for TMIO_MASK_ALL, so add a member to support that. If the member is not used, the previous default value is applied.

Thank you for the patch!

And, I tested on my environment (r8a77951-salvator-xs.dts) and I didn't observe any regression, so,

Best regards,
Yoshihiro Shimoda

#3 lore raw

Re: [PATCH 1/2] mmc: tmio: support custom irq masks

In reply to Wolfram Sang
Quoted 6 lines · Wolfram Sang

SDHI Gen2+ has a different value for TMIO_MASK_ALL, so add a member to support that. If the member is not used, the previous default value is applied.

Applied for next, thanks!

To be clear, I am awaiting a v2 of patch 2/2.

Kind regards
Uffe

Quoted 53 lines
---
 drivers/mmc/host/tmio_mmc.h      | 1 +
 drivers/mmc/host/tmio_mmc_core.c | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/host/tmio_mmc.h +1 -0
index 2d1db9396d4a..7d5201d6a006 100644
@@ -164,6 +164,7 @@ struct tmio_mmc_host {
        u32                     sdio_irq_mask;
        unsigned int            clk_cache;
        u32                     sdcard_irq_setbit_mask;
+       u32                     sdcard_irq_mask_all;
 
        spinlock_t              lock;           /* protect host private data */
        unsigned long           last_req_ts;
drivers/mmc/host/tmio_mmc_core.c +5 -4
index 0e7a2faa5238..eca767dcabba 100644
@@ -1175,7 +1175,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host)
        tmio_mmc_reset(_host);
 
        _host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
-       tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
+       if (!_host->sdcard_irq_mask_all)
+               _host->sdcard_irq_mask_all = TMIO_MASK_ALL;
+       tmio_mmc_disable_mmc_irqs(_host, _host->sdcard_irq_mask_all);
 
        if (_host->native_hotplug)
                tmio_mmc_enable_mmc_irqs(_host,
@@ -1229,7 +1231,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
        cancel_work_sync(&host->done);
        cancel_delayed_work_sync(&host->delayed_reset_work);
        tmio_mmc_release_dma(host);
-       tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
+       tmio_mmc_disable_mmc_irqs(host, host->sdcard_irq_mask_all);
 
        if (host->native_hotplug)
                pm_runtime_put_noidle(&pdev->dev);
@@ -1259,7 +1261,7 @@ int tmio_mmc_host_runtime_suspend(struct device *dev)
 {
        struct tmio_mmc_host *host = dev_get_drvdata(dev);
 
-       tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
+       tmio_mmc_disable_mmc_irqs(host, host->sdcard_irq_mask_all);
 
        if (host->clk_cache)
                host->set_clock(host, 0);
--

2.30.0

author maintainer
#4 lore raw

Re: [PATCH 1/2] mmc: tmio: support custom irq masks

Quoted 2 lines

To be clear, I am awaiting a v2 of patch 2/2.

Thanks for the heads up! Just sent.

#5 lore raw

Re: [PATCH 1/2] mmc: tmio: support custom irq masks

Quoted 5 lines · Wolfram Sang
Quoted 3 lines

To be clear, I am awaiting a v2 of patch 2/2.

Thanks for the heads up! Just sent.

V2 patch applied (could find the email in my inbox, but the patch was picked up by the patchtracker, weird).

In any case, thanks and kind regards
Uffe

author maintainer
#6 lore raw

PATCH 2/2 mmc: renesas_sdhi: use custom mask for TMIO_MASK_ALL

In reply to Wolfram Sang

Populate the new member for custom mask values to make sure this value is applied whenever needed. Also, rename the define holding the value because this is not only about initialization anymore.

---
 drivers/mmc/host/renesas_sdhi_core.c | 3 ++-
 drivers/mmc/host/tmio_mmc.h          | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/renesas_sdhi_core.c +2 -1
index a1de5c431f07..734442dacdfa 100644
@@ -582,7 +582,7 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host)
 			       sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
 	}
 
-	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_INIT_RCAR2);
+	sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_ALL_RCAR2);
 
 	if (sd_ctrl_read16(host, CTL_VERSION) >= SDHI_VER_GEN3_SD) {
 		val = sd_ctrl_read16(host, CTL_SD_MEM_CARD_OPT);
@@ -1043,6 +1043,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
 		host->ops.start_signal_voltage_switch =
 			renesas_sdhi_start_signal_voltage_switch;
 		host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27;
+		host->sdcard_irq_mask_all = TMIO_MASK_ALL_RCAR2;
 		host->reset = renesas_sdhi_reset;
 	}
 
drivers/mmc/host/tmio_mmc.h +1 -1
index 7d5201d6a006..3b242f2e2c98 100644
@@ -100,7 +100,7 @@
 
 /* Define some IRQ masks */
 /* This is the mask used at reset by the chip */
-#define TMIO_MASK_INIT_RCAR2	0x8b7f031d /* Initial value for R-Car Gen2+ */
+#define TMIO_MASK_ALL_RCAR2	0x8b7f031d /* Initial value for R-Car Gen2+ */
 #define TMIO_MASK_ALL           0x837f031d
 #define TMIO_MASK_READOP  (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND)
 #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND)
Signature · 1 line
2.30.0
Reviewed-by Tested-by on v1 2/2
#7 lore raw

RE: [PATCH 2/2] mmc: renesas_sdhi: use custom mask for TMIO_MASK_ALL

Hi Wolfram-san,

Thank you for the patch!

Quoted 1 line

From: Wolfram Sang, Sent: Tuesday, February 23, 2021 7:09 PM

<snip>

drivers/mmc/host/tmio_mmc.h line 103

Quoted 10 lines
drivers/mmc/host/tmio_mmc.h +1 -1
index 7d5201d6a006..3b242f2e2c98 100644
@@ -100,7 +100,7 @@
 
 /* Define some IRQ masks */
 /* This is the mask used at reset by the chip */
-#define TMIO_MASK_INIT_RCAR2	0x8b7f031d /* Initial value for R-Car Gen2+ */
+#define TMIO_MASK_ALL_RCAR2	0x8b7f031d /* Initial value for R-Car Gen2+ */

nit: Perhaps, we also have to change the comment "Initial value"?

Anyway,

And, I tested on my environment (r8a77951-salvator-xs.dts) and I didn't observe any regression, so,

Best regards,
Yoshihiro Shimoda

author maintainer
#8 lore raw

Re: [PATCH 2/2] mmc: renesas_sdhi: use custom mask for TMIO_MASK_ALL

Quoted 5 lines

drivers/mmc/host/tmio_mmc.h line 103

Quoted 3 lines
drivers/mmc/host/tmio_mmc.h +1 -1
-#define TMIO_MASK_INIT_RCAR2	0x8b7f031d /* Initial value for R-Car Gen2+ */
+#define TMIO_MASK_ALL_RCAR2	0x8b7f031d /* Initial value for R-Car Gen2+ */

nit: Perhaps, we also have to change the comment "Initial value"?

Good point, I will fix it. Thank you!