All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support
@ 2019-04-11  2:56 Pierre Bourdon
  2019-04-11  2:56 ` [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model Pierre Bourdon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Pierre Bourdon @ 2019-04-11  2:56 UTC (permalink / raw)
  To: u-boot

The new DM implementation currently does not support the Sheeva
88SV331xV5 specific quirk present in the legacy implementation. The
legacy code is thus kept for this SoC and others not yet migrated to
DM_MMC.

Signed-off-by: Pierre Bourdon <delroth@gmail.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Stefan Roese <sr@denx.de>
---
 arch/arm/mach-mvebu/cpu.c              |  2 +-
 arch/arm/mach-mvebu/include/mach/cpu.h |  2 +
 drivers/mmc/mv_sdhci.c                 | 67 +++++++++++++++++++++++++-
 3 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
index 919d05c88c..ced9b5480a 100644
--- a/arch/arm/mach-mvebu/cpu.c
+++ b/arch/arm/mach-mvebu/cpu.c
@@ -491,7 +491,7 @@ int arch_misc_init(void)
 }
 #endif /* CONFIG_ARCH_MISC_INIT */
 
-#ifdef CONFIG_MMC_SDHCI_MV
+#if defined(CONFIG_MMC_SDHCI_MV) && !defined(CONFIG_DM_MMC)
 int board_mmc_init(bd_t *bis)
 {
 	mv_sdh_init(MVEBU_SDIO_BASE, 0, 0,
diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h
index 9e23043a48..42456a8b33 100644
--- a/arch/arm/mach-mvebu/include/mach/cpu.h
+++ b/arch/arm/mach-mvebu/include/mach/cpu.h
@@ -141,7 +141,9 @@ u32 mvebu_get_nand_clock(void);
 
 void return_to_bootrom(void);
 
+#ifndef CONFIG_DM_MMC
 int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks);
+#endif
 
 void get_sar_freq(struct sar_freq_modes *sar_freq);
 
diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c
index de4ae0a0e7..bf26d2e4e2 100644
--- a/drivers/mmc/mv_sdhci.c
+++ b/drivers/mmc/mv_sdhci.c
@@ -4,10 +4,13 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <malloc.h>
 #include <sdhci.h>
 #include <linux/mbus.h>
 
+#define MVSDH_NAME "mv_sdh"
+
 #define SDHCI_WINDOW_CTRL(win)		(0x4080 + ((win) << 4))
 #define SDHCI_WINDOW_BASE(win)		(0x4084 + ((win) << 4))
 
@@ -36,6 +39,8 @@ static void sdhci_mvebu_mbus_config(void __iomem *base)
 	}
 }
 
+#ifndef CONFIG_DM_MMC
+
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
 static struct sdhci_ops mv_ops;
 
@@ -63,7 +68,6 @@ static inline void mv_sdhci_writeb(struct sdhci_host *host, u8 val, int reg)
 #endif /* CONFIG_SHEEVA_88SV331xV5 */
 #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */
 
-static char *MVSDH_NAME = "mv_sdh";
 int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
 {
 	struct sdhci_host *host = NULL;
@@ -90,3 +94,64 @@ int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
 
 	return add_sdhci(host, 0, min_clk);
 }
+
+#else
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct mv_sdhci_plat {
+	struct mmc_config cfg;
+	struct mmc mmc;
+};
+
+static int mv_sdhci_probe(struct udevice *dev)
+{
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct mv_sdhci_plat *plat = dev_get_platdata(dev);
+	struct sdhci_host *host = dev_get_priv(dev);
+	int ret;
+
+	host->name = MVSDH_NAME;
+	host->ioaddr = (void *)devfdt_get_addr(dev);
+	host->quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD;
+
+	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
+	if (ret)
+		return ret;
+
+	if (CONFIG_IS_ENABLED(ARCH_MVEBU)) {
+		/* Configure SDHCI MBUS mbus bridge windows */
+		sdhci_mvebu_mbus_config(host->ioaddr);
+	}
+
+	host->mmc = &plat->mmc;
+	host->mmc->dev = dev;
+	host->mmc->priv = host;
+	upriv->mmc = host->mmc;
+
+	return sdhci_probe(dev);
+}
+
+static int mv_sdhci_bind(struct udevice *dev)
+{
+	struct mv_sdhci_plat *plat = dev_get_platdata(dev);
+
+	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+static const struct udevice_id mv_sdhci_ids[] = {
+	{ .compatible = "marvell,armada-380-sdhci" },
+	{ }
+};
+
+U_BOOT_DRIVER(mv_sdhci_drv) = {
+	.name		= MVSDH_NAME,
+	.id		= UCLASS_MMC,
+	.of_match	= mv_sdhci_ids,
+	.bind		= mv_sdhci_bind,
+	.probe		= mv_sdhci_probe,
+	.ops		= &sdhci_ops,
+	.priv_auto_alloc_size = sizeof(struct sdhci_host),
+	.platdata_auto_alloc_size = sizeof(struct mv_sdhci_plat),
+};
+#endif /* CONFIG_DM_MMC */
-- 
2.19.2

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

* [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model
  2019-04-11  2:56 [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support Pierre Bourdon
@ 2019-04-11  2:56 ` Pierre Bourdon
  2019-04-11  9:26   ` Stefan Roese
  2019-04-26 10:42   ` Stefan Roese
  2019-04-11  9:24 ` [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support Stefan Roese
  2019-04-26 10:42 ` Stefan Roese
  2 siblings, 2 replies; 7+ messages in thread
From: Pierre Bourdon @ 2019-04-11  2:56 UTC (permalink / raw)
  To: u-boot

Enable DM_MMC for compliance with the driver model migration.

Signed-off-by: Pierre Bourdon <delroth@gmail.com>
Cc: Marek Behun <marek.behun@nic.cz>
---
 configs/turris_omnia_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
index c406b25753..fd9dc5a61b 100644
--- a/configs/turris_omnia_defconfig
+++ b/configs/turris_omnia_defconfig
@@ -42,6 +42,7 @@ CONFIG_SCSI_AHCI=y
 CONFIG_ATSHA204A=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_MV=y
+CONFIG_DM_MMC=y
 CONFIG_SPI_FLASH=y
 CONFIG_PHY_MARVELL=y
 CONFIG_PHY_GIGE=y
-- 
2.19.2

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

* [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support
  2019-04-11  2:56 [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support Pierre Bourdon
  2019-04-11  2:56 ` [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model Pierre Bourdon
@ 2019-04-11  9:24 ` Stefan Roese
  2019-04-26 10:42 ` Stefan Roese
  2 siblings, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2019-04-11  9:24 UTC (permalink / raw)
  To: u-boot

On 11.04.19 04:56, Pierre Bourdon wrote:
> The new DM implementation currently does not support the Sheeva
> 88SV331xV5 specific quirk present in the legacy implementation. The
> legacy code is thus kept for this SoC and others not yet migrated to
> DM_MMC.
> 
> Signed-off-by: Pierre Bourdon <delroth@gmail.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Stefan Roese <sr@denx.de>
> ---
>   arch/arm/mach-mvebu/cpu.c              |  2 +-
>   arch/arm/mach-mvebu/include/mach/cpu.h |  2 +
>   drivers/mmc/mv_sdhci.c                 | 67 +++++++++++++++++++++++++-
>   3 files changed, 69 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
> index 919d05c88c..ced9b5480a 100644
> --- a/arch/arm/mach-mvebu/cpu.c
> +++ b/arch/arm/mach-mvebu/cpu.c
> @@ -491,7 +491,7 @@ int arch_misc_init(void)
>   }
>   #endif /* CONFIG_ARCH_MISC_INIT */
>   
> -#ifdef CONFIG_MMC_SDHCI_MV
> +#if defined(CONFIG_MMC_SDHCI_MV) && !defined(CONFIG_DM_MMC)
>   int board_mmc_init(bd_t *bis)
>   {
>   	mv_sdh_init(MVEBU_SDIO_BASE, 0, 0,
> diff --git a/arch/arm/mach-mvebu/include/mach/cpu.h b/arch/arm/mach-mvebu/include/mach/cpu.h
> index 9e23043a48..42456a8b33 100644
> --- a/arch/arm/mach-mvebu/include/mach/cpu.h
> +++ b/arch/arm/mach-mvebu/include/mach/cpu.h
> @@ -141,7 +141,9 @@ u32 mvebu_get_nand_clock(void);
>   
>   void return_to_bootrom(void);
>   
> +#ifndef CONFIG_DM_MMC
>   int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks);
> +#endif
>   
>   void get_sar_freq(struct sar_freq_modes *sar_freq);
>   
> diff --git a/drivers/mmc/mv_sdhci.c b/drivers/mmc/mv_sdhci.c
> index de4ae0a0e7..bf26d2e4e2 100644
> --- a/drivers/mmc/mv_sdhci.c
> +++ b/drivers/mmc/mv_sdhci.c
> @@ -4,10 +4,13 @@
>    */
>   
>   #include <common.h>
> +#include <dm.h>
>   #include <malloc.h>
>   #include <sdhci.h>
>   #include <linux/mbus.h>
>   
> +#define MVSDH_NAME "mv_sdh"
> +
>   #define SDHCI_WINDOW_CTRL(win)		(0x4080 + ((win) << 4))
>   #define SDHCI_WINDOW_BASE(win)		(0x4084 + ((win) << 4))
>   
> @@ -36,6 +39,8 @@ static void sdhci_mvebu_mbus_config(void __iomem *base)
>   	}
>   }
>   
> +#ifndef CONFIG_DM_MMC
> +
>   #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
>   static struct sdhci_ops mv_ops;
>   
> @@ -63,7 +68,6 @@ static inline void mv_sdhci_writeb(struct sdhci_host *host, u8 val, int reg)
>   #endif /* CONFIG_SHEEVA_88SV331xV5 */
>   #endif /* CONFIG_MMC_SDHCI_IO_ACCESSORS */
>   
> -static char *MVSDH_NAME = "mv_sdh";
>   int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
>   {
>   	struct sdhci_host *host = NULL;
> @@ -90,3 +94,64 @@ int mv_sdh_init(unsigned long regbase, u32 max_clk, u32 min_clk, u32 quirks)
>   
>   	return add_sdhci(host, 0, min_clk);
>   }
> +
> +#else
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +struct mv_sdhci_plat {
> +	struct mmc_config cfg;
> +	struct mmc mmc;
> +};
> +
> +static int mv_sdhci_probe(struct udevice *dev)
> +{
> +	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
> +	struct mv_sdhci_plat *plat = dev_get_platdata(dev);
> +	struct sdhci_host *host = dev_get_priv(dev);
> +	int ret;
> +
> +	host->name = MVSDH_NAME;
> +	host->ioaddr = (void *)devfdt_get_addr(dev);
> +	host->quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | SDHCI_QUIRK_WAIT_SEND_CMD;
> +
> +	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0);
> +	if (ret)
> +		return ret;
> +
> +	if (CONFIG_IS_ENABLED(ARCH_MVEBU)) {
> +		/* Configure SDHCI MBUS mbus bridge windows */
> +		sdhci_mvebu_mbus_config(host->ioaddr);
> +	}
> +
> +	host->mmc = &plat->mmc;
> +	host->mmc->dev = dev;
> +	host->mmc->priv = host;
> +	upriv->mmc = host->mmc;
> +
> +	return sdhci_probe(dev);
> +}
> +
> +static int mv_sdhci_bind(struct udevice *dev)
> +{
> +	struct mv_sdhci_plat *plat = dev_get_platdata(dev);
> +
> +	return sdhci_bind(dev, &plat->mmc, &plat->cfg);
> +}
> +
> +static const struct udevice_id mv_sdhci_ids[] = {
> +	{ .compatible = "marvell,armada-380-sdhci" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(mv_sdhci_drv) = {
> +	.name		= MVSDH_NAME,
> +	.id		= UCLASS_MMC,
> +	.of_match	= mv_sdhci_ids,
> +	.bind		= mv_sdhci_bind,
> +	.probe		= mv_sdhci_probe,
> +	.ops		= &sdhci_ops,
> +	.priv_auto_alloc_size = sizeof(struct sdhci_host),
> +	.platdata_auto_alloc_size = sizeof(struct mv_sdhci_plat),
> +};
> +#endif /* CONFIG_DM_MMC */
> 

Thanks for working on this. Looks good, so:

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

Thanks,
Stefan

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

* [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model
  2019-04-11  2:56 ` [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model Pierre Bourdon
@ 2019-04-11  9:26   ` Stefan Roese
  2019-04-13 13:20     ` Pierre Bourdon
  2019-04-26 10:42   ` Stefan Roese
  1 sibling, 1 reply; 7+ messages in thread
From: Stefan Roese @ 2019-04-11  9:26 UTC (permalink / raw)
  To: u-boot

On 11.04.19 04:56, Pierre Bourdon wrote:
> Enable DM_MMC for compliance with the driver model migration.
> 
> Signed-off-by: Pierre Bourdon <delroth@gmail.com>
> Cc: Marek Behun <marek.behun@nic.cz>
> ---
>   configs/turris_omnia_defconfig | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig
> index c406b25753..fd9dc5a61b 100644
> --- a/configs/turris_omnia_defconfig
> +++ b/configs/turris_omnia_defconfig
> @@ -42,6 +42,7 @@ CONFIG_SCSI_AHCI=y
>   CONFIG_ATSHA204A=y
>   CONFIG_MMC_SDHCI=y
>   CONFIG_MMC_SDHCI_MV=y
> +CONFIG_DM_MMC=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_PHY_MARVELL=y
>   CONFIG_PHY_GIGE=y
> 

With the new DM enabled MMC driver (thanks again), we should probably
better select DM_MMC in arch/arm/Kconfig for ARCH_MVEBU. This way, all
those boards will get moved to the new driver version.

What do you think?

Thanks,
Stefan

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

* [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model
  2019-04-11  9:26   ` Stefan Roese
@ 2019-04-13 13:20     ` Pierre Bourdon
  0 siblings, 0 replies; 7+ messages in thread
From: Pierre Bourdon @ 2019-04-13 13:20 UTC (permalink / raw)
  To: u-boot

On Thu, Apr 11, 2019 at 11:26 AM Stefan Roese <sr@denx.de> wrote:
> With the new DM enabled MMC driver (thanks again), we should probably
> better select DM_MMC in arch/arm/Kconfig for ARCH_MVEBU. This way, all
> those boards will get moved to the new driver version.
>
> What do you think?

I've only tested one specific board with this and I lack the knowledge
/ experience to properly judge the level of risk involved with
switching the default for all mvebu boards. If your call is that this
would be a safe change, sure, let's go for it.

DM_MMC is supposed to be a requirement for v2019.04 anyway, if I
understand correctly.

-- 
Pierre Bourdon <delroth@gmail.com>
Software Engineer @ Zürich, Switzerland
https://delroth.net/

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

* [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model
  2019-04-11  2:56 ` [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model Pierre Bourdon
  2019-04-11  9:26   ` Stefan Roese
@ 2019-04-26 10:42   ` Stefan Roese
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2019-04-26 10:42 UTC (permalink / raw)
  To: u-boot

On 11.04.19 04:56, Pierre Bourdon wrote:
> Enable DM_MMC for compliance with the driver model migration.
> 
> Signed-off-by: Pierre Bourdon <delroth@gmail.com>
> Cc: Marek Behun <marek.behun@nic.cz>

Applied to u-boot-marvell/master.

Thanks,
Stefan

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

* [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support
  2019-04-11  2:56 [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support Pierre Bourdon
  2019-04-11  2:56 ` [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model Pierre Bourdon
  2019-04-11  9:24 ` [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support Stefan Roese
@ 2019-04-26 10:42 ` Stefan Roese
  2 siblings, 0 replies; 7+ messages in thread
From: Stefan Roese @ 2019-04-26 10:42 UTC (permalink / raw)
  To: u-boot

On 11.04.19 04:56, Pierre Bourdon wrote:
> The new DM implementation currently does not support the Sheeva
> 88SV331xV5 specific quirk present in the legacy implementation. The
> legacy code is thus kept for this SoC and others not yet migrated to
> DM_MMC.
> 
> Signed-off-by: Pierre Bourdon <delroth@gmail.com>
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Stefan Roese <sr@denx.de>

Applied to u-boot-marvell/master.

Thanks,
Stefan

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

end of thread, other threads:[~2019-04-26 10:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11  2:56 [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support Pierre Bourdon
2019-04-11  2:56 ` [U-Boot] [PATCH 2/2] configs: turris_omnia: use MMC driver model Pierre Bourdon
2019-04-11  9:26   ` Stefan Roese
2019-04-13 13:20     ` Pierre Bourdon
2019-04-26 10:42   ` Stefan Roese
2019-04-11  9:24 ` [U-Boot] [PATCH 1/2] mmc: mv_sdhci: add driver model support Stefan Roese
2019-04-26 10:42 ` 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.