All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: mvebu: Espressobin: Disable slot when emmc is not present
@ 2020-12-21 10:09 Pali Rohár
  2020-12-22 10:09 ` Stefan Roese
  0 siblings, 1 reply; 2+ messages in thread
From: Pali Rohár @ 2020-12-21 10:09 UTC (permalink / raw)
  To: u-boot

This change extends previous commit 061c6d1b238a ("arm: mvebu: Espressobin:
Detect presence of emmc at runtime") and when emmc is not present then emmc
is removed from U-Boot DM and corresponding slot is disabled. Therefore on
Espressobin board without soldered emmc, state of emmc hw should be same as
if emmc was disabled in DTS.

Signed-off-by: Pali Roh?r <pali@kernel.org>
---
 board/Marvell/mvebu_armada-37xx/board.c | 15 ++++++++++++---
 drivers/mmc/xenon_sdhci.c               | 19 +++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
index f67b04b78c..1b9e7520cc 100644
--- a/board/Marvell/mvebu_armada-37xx/board.c
+++ b/board/Marvell/mvebu_armada-37xx/board.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dm/device-internal.h>
 #include <env.h>
 #include <i2c.h>
 #include <init.h>
@@ -84,12 +85,10 @@ int board_init(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
+	struct udevice *dev;
 	struct mmc *mmc_dev;
 	bool ddr4, emmc;
 
-	if (env_get("fdtfile"))
-		return 0;
-
 	if (!of_machine_is_compatible("globalscale,espressobin"))
 		return 0;
 
@@ -101,6 +100,16 @@ int board_late_init(void)
 	mmc_dev = find_mmc_device(1);
 	emmc = (mmc_dev && mmc_init(mmc_dev) == 0);
 
+	/* if eMMC is not present then remove it from DM */
+	if (!emmc && mmc_dev) {
+		dev = mmc_dev->dev;
+		device_remove(dev, DM_REMOVE_NORMAL);
+		device_unbind(dev);
+	}
+
+	if (env_get("fdtfile"))
+		return 0;
+
 	if (ddr4 && emmc)
 		env_set("fdtfile", "marvell/armada-3720-espressobin-v7-emmc.dtb");
 	else if (ddr4)
diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c
index 6ce9d00d0a..da9882cbf6 100644
--- a/drivers/mmc/xenon_sdhci.c
+++ b/drivers/mmc/xenon_sdhci.c
@@ -350,6 +350,16 @@ static void xenon_mmc_enable_slot(struct sdhci_host *host, u8 slot)
 	sdhci_writel(host, var, SDHC_SYS_OP_CTRL);
 }
 
+/* Disable specific slot */
+static void xenon_mmc_disable_slot(struct sdhci_host *host, u8 slot)
+{
+	u32 var;
+
+	var = sdhci_readl(host, SDHC_SYS_OP_CTRL);
+	var &= ~(SLOT_MASK(slot) << SLOT_ENABLE_SHIFT);
+	sdhci_writel(host, var, SDHC_SYS_OP_CTRL);
+}
+
 /* Enable Parallel Transfer Mode */
 static void xenon_mmc_enable_parallel_tran(struct sdhci_host *host, u8 slot)
 {
@@ -515,6 +525,14 @@ static int xenon_sdhci_probe(struct udevice *dev)
 	return ret;
 }
 
+static int xenon_sdhci_remove(struct udevice *dev)
+{
+	struct sdhci_host *host = dev_get_priv(dev);
+
+	xenon_mmc_disable_slot(host, XENON_MMC_SLOT_ID_HYPERION);
+	return 0;
+}
+
 static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev)
 {
 	struct sdhci_host *host = dev_get_priv(dev);
@@ -564,6 +582,7 @@ U_BOOT_DRIVER(xenon_sdhci_drv) = {
 	.ops		= &sdhci_ops,
 	.bind		= xenon_sdhci_bind,
 	.probe		= xenon_sdhci_probe,
+	.remove		= xenon_sdhci_remove,
 	.priv_auto_alloc_size = sizeof(struct xenon_sdhci_priv),
 	.platdata_auto_alloc_size = sizeof(struct xenon_sdhci_plat),
 };
-- 
2.20.1

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

* [PATCH] arm: mvebu: Espressobin: Disable slot when emmc is not present
  2020-12-21 10:09 [PATCH] arm: mvebu: Espressobin: Disable slot when emmc is not present Pali Rohár
@ 2020-12-22 10:09 ` Stefan Roese
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2020-12-22 10:09 UTC (permalink / raw)
  To: u-boot

On 21.12.20 11:09, Pali Roh?r wrote:
> This change extends previous commit 061c6d1b238a ("arm: mvebu: Espressobin:
> Detect presence of emmc at runtime") and when emmc is not present then emmc
> is removed from U-Boot DM and corresponding slot is disabled. Therefore on
> Espressobin board without soldered emmc, state of emmc hw should be same as
> if emmc was disabled in DTS.
> 
> Signed-off-by: Pali Roh?r <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   board/Marvell/mvebu_armada-37xx/board.c | 15 ++++++++++++---
>   drivers/mmc/xenon_sdhci.c               | 19 +++++++++++++++++++
>   2 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/board/Marvell/mvebu_armada-37xx/board.c b/board/Marvell/mvebu_armada-37xx/board.c
> index f67b04b78c..1b9e7520cc 100644
> --- a/board/Marvell/mvebu_armada-37xx/board.c
> +++ b/board/Marvell/mvebu_armada-37xx/board.c
> @@ -5,6 +5,7 @@
>   
>   #include <common.h>
>   #include <dm.h>
> +#include <dm/device-internal.h>
>   #include <env.h>
>   #include <i2c.h>
>   #include <init.h>
> @@ -84,12 +85,10 @@ int board_init(void)
>   #ifdef CONFIG_BOARD_LATE_INIT
>   int board_late_init(void)
>   {
> +	struct udevice *dev;
>   	struct mmc *mmc_dev;
>   	bool ddr4, emmc;
>   
> -	if (env_get("fdtfile"))
> -		return 0;
> -
>   	if (!of_machine_is_compatible("globalscale,espressobin"))
>   		return 0;
>   
> @@ -101,6 +100,16 @@ int board_late_init(void)
>   	mmc_dev = find_mmc_device(1);
>   	emmc = (mmc_dev && mmc_init(mmc_dev) == 0);
>   
> +	/* if eMMC is not present then remove it from DM */
> +	if (!emmc && mmc_dev) {
> +		dev = mmc_dev->dev;
> +		device_remove(dev, DM_REMOVE_NORMAL);
> +		device_unbind(dev);
> +	}
> +
> +	if (env_get("fdtfile"))
> +		return 0;
> +
>   	if (ddr4 && emmc)
>   		env_set("fdtfile", "marvell/armada-3720-espressobin-v7-emmc.dtb");
>   	else if (ddr4)
> diff --git a/drivers/mmc/xenon_sdhci.c b/drivers/mmc/xenon_sdhci.c
> index 6ce9d00d0a..da9882cbf6 100644
> --- a/drivers/mmc/xenon_sdhci.c
> +++ b/drivers/mmc/xenon_sdhci.c
> @@ -350,6 +350,16 @@ static void xenon_mmc_enable_slot(struct sdhci_host *host, u8 slot)
>   	sdhci_writel(host, var, SDHC_SYS_OP_CTRL);
>   }
>   
> +/* Disable specific slot */
> +static void xenon_mmc_disable_slot(struct sdhci_host *host, u8 slot)
> +{
> +	u32 var;
> +
> +	var = sdhci_readl(host, SDHC_SYS_OP_CTRL);
> +	var &= ~(SLOT_MASK(slot) << SLOT_ENABLE_SHIFT);
> +	sdhci_writel(host, var, SDHC_SYS_OP_CTRL);
> +}
> +
>   /* Enable Parallel Transfer Mode */
>   static void xenon_mmc_enable_parallel_tran(struct sdhci_host *host, u8 slot)
>   {
> @@ -515,6 +525,14 @@ static int xenon_sdhci_probe(struct udevice *dev)
>   	return ret;
>   }
>   
> +static int xenon_sdhci_remove(struct udevice *dev)
> +{
> +	struct sdhci_host *host = dev_get_priv(dev);
> +
> +	xenon_mmc_disable_slot(host, XENON_MMC_SLOT_ID_HYPERION);
> +	return 0;
> +}
> +
>   static int xenon_sdhci_ofdata_to_platdata(struct udevice *dev)
>   {
>   	struct sdhci_host *host = dev_get_priv(dev);
> @@ -564,6 +582,7 @@ U_BOOT_DRIVER(xenon_sdhci_drv) = {
>   	.ops		= &sdhci_ops,
>   	.bind		= xenon_sdhci_bind,
>   	.probe		= xenon_sdhci_probe,
> +	.remove		= xenon_sdhci_remove,
>   	.priv_auto_alloc_size = sizeof(struct xenon_sdhci_priv),
>   	.platdata_auto_alloc_size = sizeof(struct xenon_sdhci_plat),
>   };
> 


Viele Gr??e,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de

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

end of thread, other threads:[~2020-12-22 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 10:09 [PATCH] arm: mvebu: Espressobin: Disable slot when emmc is not present Pali Rohár
2020-12-22 10:09 ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.