linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mmc: add and use helpers mmc_regulator_enable/disable_vqmmc
@ 2023-03-11 22:38 Heiner Kallweit
  2023-03-11 22:39 ` [PATCH 1/2] mmc: core: add " Heiner Kallweit
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Heiner Kallweit @ 2023-03-11 22:38 UTC (permalink / raw)
  To: Ulf Hansson, Martin Blumenstingl, Jerome Brunet, Kevin Hilman,
	Neil Armstrong
  Cc: linux-mmc@vger.kernel.org, open list:ARM/Amlogic Meson...,
	linux-arm-kernel@lists.infradead.org

There's a number of drivers (e.g. dw_mmc, meson-gx, mmci, sunxi) using
the same mechanism and a private flag vqmmc_enabled to deal with
enabling/disabling the vqmmc regulator.

Move this to the core and create new helpers mmc_regulator_enable_vqmmc
and mmc_regulator_disable_vqmmc. Make meson-gx the first user of the
new helpers.

Heiner Kallweit (2):
  mmc: core: add helpers mmc_regulator_enable/disable_vqmmc
  mmc: meson-gx: use new helpers mmc_regulator_enable/disable_vqmmc

 drivers/mmc/core/regulator.c    | 41 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/meson-gx-mmc.c | 18 ++-------------
 include/linux/mmc/host.h        |  3 +++
 3 files changed, 46 insertions(+), 16 deletions(-)

-- 
2.39.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] mmc: core: add helpers mmc_regulator_enable/disable_vqmmc
  2023-03-11 22:38 [PATCH 0/2] mmc: add and use helpers mmc_regulator_enable/disable_vqmmc Heiner Kallweit
@ 2023-03-11 22:39 ` Heiner Kallweit
  2023-03-12 20:28   ` Martin Blumenstingl
  2023-03-11 22:41 ` [PATCH 2/2] mmc: meson-gx: use new " Heiner Kallweit
  2023-03-23 12:12 ` [PATCH 0/2] mmc: add and use " Ulf Hansson
  2 siblings, 1 reply; 6+ messages in thread
From: Heiner Kallweit @ 2023-03-11 22:39 UTC (permalink / raw)
  To: Ulf Hansson, Martin Blumenstingl, Jerome Brunet, Kevin Hilman,
	Neil Armstrong
  Cc: linux-mmc@vger.kernel.org, open list:ARM/Amlogic Meson...,
	linux-arm-kernel@lists.infradead.org

There's a number of drivers (e.g. dw_mmc, meson-gx, mmci, sunxi) using
the same mechanism and a private flag vqmmc_enabled to deal with
enabling/disabling the vqmmc regulator.

Move this to the core and create new helpers mmc_regulator_enable_vqmmc
and mmc_regulator_disable_vqmmc.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/mmc/core/regulator.c | 41 ++++++++++++++++++++++++++++++++++++
 include/linux/mmc/host.h     |  3 +++
 2 files changed, 44 insertions(+)

diff --git a/drivers/mmc/core/regulator.c b/drivers/mmc/core/regulator.c
index 4fad81cd5..005247a49 100644
--- a/drivers/mmc/core/regulator.c
+++ b/drivers/mmc/core/regulator.c
@@ -274,3 +274,44 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
 	return 0;
 }
 EXPORT_SYMBOL_GPL(mmc_regulator_get_supply);
+
+/**
+ * mmc_regulator_enable_vqmmc - enable VQMMC regulator for a host
+ * @mmc: the host to regulate
+ *
+ * Returns 0 or errno. Enables the regulator for vqmmc.
+ * Keeps track of the enable status for ensuring that calls to
+ * regulator_enable/disable are balanced.
+ */
+int mmc_regulator_enable_vqmmc(struct mmc_host *mmc)
+{
+	int ret = 0;
+
+	if (!IS_ERR(mmc->supply.vqmmc) && !mmc->vqmmc_enabled) {
+		ret = regulator_enable(mmc->supply.vqmmc);
+		if (ret < 0)
+			dev_err(mmc_dev(mmc), "enabling vqmmc regulator failed\n");
+		else
+			mmc->vqmmc_enabled = true;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(mmc_regulator_enable_vqmmc);
+
+/**
+ * mmc_regulator_disable_vqmmc - disable VQMMC regulator for a host
+ * @mmc: the host to regulate
+ *
+ * Returns 0 or errno. Disables the regulator for vqmmc.
+ * Keeps track of the enable status for ensuring that calls to
+ * regulator_enable/disable are balanced.
+ */
+void mmc_regulator_disable_vqmmc(struct mmc_host *mmc)
+{
+	if (!IS_ERR(mmc->supply.vqmmc) && mmc->vqmmc_enabled) {
+		regulator_disable(mmc->supply.vqmmc);
+		mmc->vqmmc_enabled = false;
+	}
+}
+EXPORT_SYMBOL_GPL(mmc_regulator_disable_vqmmc);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 812e6b583..461d15438 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -450,6 +450,7 @@ struct mmc_host {
 	unsigned int		retune_paused:1; /* re-tuning is temporarily disabled */
 	unsigned int		retune_crc_disable:1; /* don't trigger retune upon crc */
 	unsigned int		can_dma_map_merge:1; /* merging can be used */
+	unsigned int		vqmmc_enabled:1; /* vqmmc regulator is enabled */
 
 	int			rescan_disable;	/* disable card detection */
 	int			rescan_entered;	/* used with nonremovable devices */
@@ -598,6 +599,8 @@ static inline int mmc_regulator_set_vqmmc(struct mmc_host *mmc,
 #endif
 
 int mmc_regulator_get_supply(struct mmc_host *mmc);
+int mmc_regulator_enable_vqmmc(struct mmc_host *mmc);
+void mmc_regulator_disable_vqmmc(struct mmc_host *mmc);
 
 static inline int mmc_card_is_removable(struct mmc_host *host)
 {
-- 
2.39.2



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] mmc: meson-gx: use new helpers mmc_regulator_enable/disable_vqmmc
  2023-03-11 22:38 [PATCH 0/2] mmc: add and use helpers mmc_regulator_enable/disable_vqmmc Heiner Kallweit
  2023-03-11 22:39 ` [PATCH 1/2] mmc: core: add " Heiner Kallweit
@ 2023-03-11 22:41 ` Heiner Kallweit
  2023-03-12 20:28   ` Martin Blumenstingl
  2023-03-23 12:12 ` [PATCH 0/2] mmc: add and use " Ulf Hansson
  2 siblings, 1 reply; 6+ messages in thread
From: Heiner Kallweit @ 2023-03-11 22:41 UTC (permalink / raw)
  To: Ulf Hansson, Martin Blumenstingl, Jerome Brunet, Kevin Hilman,
	Neil Armstrong
  Cc: linux-mmc@vger.kernel.org, open list:ARM/Amlogic Meson...,
	linux-arm-kernel@lists.infradead.org

Use new helpers mmc_regulator_enable/disable_vqmmc to simplify
the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/mmc/host/meson-gx-mmc.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index 28e04dc4e..b8514d9d5 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -174,7 +174,6 @@ struct meson_host {
 
 	int irq;
 
-	bool vqmmc_enabled;
 	bool needs_pre_post_req;
 
 	spinlock_t lock;
@@ -605,11 +604,7 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	switch (ios->power_mode) {
 	case MMC_POWER_OFF:
 		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
-
-		if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) {
-			regulator_disable(mmc->supply.vqmmc);
-			host->vqmmc_enabled = false;
-		}
+		mmc_regulator_disable_vqmmc(mmc);
 
 		break;
 
@@ -619,15 +614,7 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		break;
 
 	case MMC_POWER_ON:
-		if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) {
-			int ret = regulator_enable(mmc->supply.vqmmc);
-
-			if (ret < 0)
-				dev_err(host->dev,
-					"failed to enable vqmmc regulator\n");
-			else
-				host->vqmmc_enabled = true;
-		}
+		mmc_regulator_enable_vqmmc(mmc);
 
 		break;
 	}
@@ -1179,7 +1166,6 @@ static int meson_mmc_probe(struct platform_device *pdev)
 					"amlogic,dram-access-quirk");
 
 	/* Get regulators and the supported OCR mask */
-	host->vqmmc_enabled = false;
 	ret = mmc_regulator_get_supply(mmc);
 	if (ret)
 		return ret;
-- 
2.39.2



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mmc: core: add helpers mmc_regulator_enable/disable_vqmmc
  2023-03-11 22:39 ` [PATCH 1/2] mmc: core: add " Heiner Kallweit
@ 2023-03-12 20:28   ` Martin Blumenstingl
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2023-03-12 20:28 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Ulf Hansson, Jerome Brunet, Kevin Hilman, Neil Armstrong,
	linux-mmc@vger.kernel.org, open list:ARM/Amlogic Meson...,
	linux-arm-kernel@lists.infradead.org

On Sat, Mar 11, 2023 at 11:41 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> There's a number of drivers (e.g. dw_mmc, meson-gx, mmci, sunxi) using
> the same mechanism and a private flag vqmmc_enabled to deal with
> enabling/disabling the vqmmc regulator.
>
> Move this to the core and create new helpers mmc_regulator_enable_vqmmc
> and mmc_regulator_disable_vqmmc.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] mmc: meson-gx: use new helpers mmc_regulator_enable/disable_vqmmc
  2023-03-11 22:41 ` [PATCH 2/2] mmc: meson-gx: use new " Heiner Kallweit
@ 2023-03-12 20:28   ` Martin Blumenstingl
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Blumenstingl @ 2023-03-12 20:28 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Ulf Hansson, Jerome Brunet, Kevin Hilman, Neil Armstrong,
	linux-mmc@vger.kernel.org, open list:ARM/Amlogic Meson...,
	linux-arm-kernel@lists.infradead.org

On Sat, Mar 11, 2023 at 11:41 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> Use new helpers mmc_regulator_enable/disable_vqmmc to simplify
> the code.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] mmc: add and use helpers mmc_regulator_enable/disable_vqmmc
  2023-03-11 22:38 [PATCH 0/2] mmc: add and use helpers mmc_regulator_enable/disable_vqmmc Heiner Kallweit
  2023-03-11 22:39 ` [PATCH 1/2] mmc: core: add " Heiner Kallweit
  2023-03-11 22:41 ` [PATCH 2/2] mmc: meson-gx: use new " Heiner Kallweit
@ 2023-03-23 12:12 ` Ulf Hansson
  2 siblings, 0 replies; 6+ messages in thread
From: Ulf Hansson @ 2023-03-23 12:12 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Martin Blumenstingl, Jerome Brunet, Kevin Hilman, Neil Armstrong,
	linux-mmc@vger.kernel.org, open list:ARM/Amlogic Meson...,
	linux-arm-kernel@lists.infradead.org

On Sat, 11 Mar 2023 at 23:38, Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> There's a number of drivers (e.g. dw_mmc, meson-gx, mmci, sunxi) using
> the same mechanism and a private flag vqmmc_enabled to deal with
> enabling/disabling the vqmmc regulator.
>
> Move this to the core and create new helpers mmc_regulator_enable_vqmmc
> and mmc_regulator_disable_vqmmc. Make meson-gx the first user of the
> new helpers.
>
> Heiner Kallweit (2):
>   mmc: core: add helpers mmc_regulator_enable/disable_vqmmc
>   mmc: meson-gx: use new helpers mmc_regulator_enable/disable_vqmmc
>
>  drivers/mmc/core/regulator.c    | 41 +++++++++++++++++++++++++++++++++
>  drivers/mmc/host/meson-gx-mmc.c | 18 ++-------------
>  include/linux/mmc/host.h        |  3 +++
>  3 files changed, 46 insertions(+), 16 deletions(-)
>

Applied for next, thanks!

Kind regards
Uffe

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-23 12:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-11 22:38 [PATCH 0/2] mmc: add and use helpers mmc_regulator_enable/disable_vqmmc Heiner Kallweit
2023-03-11 22:39 ` [PATCH 1/2] mmc: core: add " Heiner Kallweit
2023-03-12 20:28   ` Martin Blumenstingl
2023-03-11 22:41 ` [PATCH 2/2] mmc: meson-gx: use new " Heiner Kallweit
2023-03-12 20:28   ` Martin Blumenstingl
2023-03-23 12:12 ` [PATCH 0/2] mmc: add and use " Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).