All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] MMC: Enable DM_MMC for Davinci
@ 2018-08-09 11:15 Adam Ford
  2018-08-09 11:15 ` [U-Boot] [PATCH 2/3] ARM: davinci: da850evm: Support DM_MMC Adam Ford
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Adam Ford @ 2018-08-09 11:15 UTC (permalink / raw)
  To: u-boot

With CONFIG_BLK becoming a requirement, the Davinci MMC driver
needs to be updated with DM_MMC support.  Since SPL is tiny and
many boards do not support DM in SPL, this retains the backwards
compatibility for those boards who need to initialize MMC manually
in SPL.

Signed-off-by: Peter Howard <phoward@gme.net.au>
Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c
index d7cb88a40a..db950ea5ec 100644
--- a/drivers/mmc/davinci_mmc.c
+++ b/drivers/mmc/davinci_mmc.c
@@ -7,9 +7,10 @@
 
 #include <config.h>
 #include <common.h>
-#include <command.h>
+#include <dm.h>
 #include <errno.h>
 #include <mmc.h>
+#include <command.h>
 #include <part.h>
 #include <malloc.h>
 #include <asm/io.h>
@@ -23,10 +24,38 @@
 #define set_bit(addr, val)	set_val((addr), (get_val(addr) | (val)))
 #define clear_bit(addr, val)	set_val((addr), (get_val(addr) & ~(val)))
 
+#ifdef CONFIG_DM_MMC
+struct davinci_of_data {
+	const char *name;
+	u8 version;
+};
+
+/* Davinci MMC board definitions */
+struct davinci_mmc_priv {
+	struct davinci_mmc_regs *reg_base;	/* Register base address */
+	uint input_clk;		/* Input clock to MMC controller */
+	uint version;		/* MMC Controller version */
+};
+
+struct davinci_mmc_plat
+{
+	struct mmc_config cfg;
+	struct mmc mmc;
+};
+#endif
+
 /* Set davinci clock prescalar value based on the required clock in HZ */
+#if !CONFIG_IS_ENABLED(DM_MMC)
 static void dmmc_set_clock(struct mmc *mmc, uint clock)
 {
 	struct davinci_mmc *host = mmc->priv;
+#else
+
+static void davinci_mmc_set_clock(struct udevice *dev, uint clock)
+{
+	struct davinci_mmc_priv *host = dev_get_priv(dev);
+        struct mmc *mmc = mmc_get_mmc_dev(dev);
+#endif
 	struct davinci_mmc_regs *regs = host->reg_base;
 	uint clkrt, sysclk2, act_clock;
 
@@ -120,13 +149,19 @@ static int dmmc_check_status(volatile struct davinci_mmc_regs *regs,
 }
 
 /*
- * Sends a command out on the bus.  Takes the mmc pointer,
+ * Sends a command out on the bus.  Takes the device pointer,
  * a command pointer, and an optional data pointer.
  */
-static int
-dmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+#if !CONFIG_IS_ENABLED(DM_MMC)
+static int dmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 {
 	struct davinci_mmc *host = mmc->priv;
+#else
+static int
+davinci_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, struct mmc_data *data)
+{
+	struct davinci_mmc_priv *host = dev_get_priv(dev);
+#endif
 	volatile struct davinci_mmc_regs *regs = host->reg_base;
 	uint mmcstatus, status_rdy, status_err;
 	uint i, cmddata, bytes_left = 0;
@@ -312,9 +347,15 @@ dmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
 }
 
 /* Initialize Davinci MMC controller */
+#if !CONFIG_IS_ENABLED(DM_MMC)
 static int dmmc_init(struct mmc *mmc)
 {
 	struct davinci_mmc *host = mmc->priv;
+#else
+static int davinci_dm_mmc_init(struct udevice *dev)
+{
+	struct davinci_mmc_priv *host = dev_get_priv(dev);
+#endif
 	struct davinci_mmc_regs *regs = host->reg_base;
 
 	/* Clear status registers explicitly - soft reset doesn't clear it
@@ -347,11 +388,19 @@ static int dmmc_init(struct mmc *mmc)
 }
 
 /* Set buswidth or clock as indicated by the MMC framework */
+#if !CONFIG_IS_ENABLED(DM_MMC)
 static int dmmc_set_ios(struct mmc *mmc)
 {
 	struct davinci_mmc *host = mmc->priv;
 	struct davinci_mmc_regs *regs = host->reg_base;
+#else
+static int davinci_mmc_set_ios(struct udevice *dev)
+{
+	struct mmc *mmc = mmc_get_mmc_dev(dev);
 
+	struct davinci_mmc_priv *host = dev_get_priv(dev);
+	struct davinci_mmc_regs *regs = host->reg_base;
+#endif
 	/* Set the bus width */
 	if (mmc->bus_width == 4)
 		set_bit(&regs->mmcctl, MMCCTL_WIDTH_4_BIT);
@@ -359,21 +408,33 @@ static int dmmc_set_ios(struct mmc *mmc)
 		clear_bit(&regs->mmcctl, MMCCTL_WIDTH_4_BIT);
 
 	/* Set clock speed */
-	if (mmc->clock)
+	if (mmc->clock) {
+#if !CONFIG_IS_ENABLED(DM_MMC)
 		dmmc_set_clock(mmc, mmc->clock);
-
+#else
+		davinci_mmc_set_clock(dev, mmc->clock);
+#endif
+	}
 	return 0;
 }
 
+#if !CONFIG_IS_ENABLED(DM_MMC)
 static const struct mmc_ops dmmc_ops = {
-	.send_cmd	= dmmc_send_cmd,
-	.set_ios	= dmmc_set_ios,
-	.init		= dmmc_init,
+       .send_cmd       = dmmc_send_cmd,
+       .set_ios        = dmmc_set_ios,
+       .init           = dmmc_init,
 };
+#else
+static const struct dm_mmc_ops davinci_mmc_ops = {
+	.send_cmd	= davinci_mmc_send_cmd,
+	.set_ios	= davinci_mmc_set_ios,
+};
+#endif
 
+#if !CONFIG_IS_ENABLED(DM_MMC)
 /* Called from board_mmc_init during startup. Can be called multiple times
- * depending on the number of slots available on board and controller
- */
+* depending on the number of slots available on board and controller
+*/
 int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host)
 {
 	host->cfg.name = "davinci";
@@ -389,3 +450,78 @@ int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host)
 
 	return 0;
 }
+#else
+
+
+static int davinci_mmc_probe(struct udevice *dev)
+{
+	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
+	struct davinci_mmc_plat *plat = dev_get_platdata(dev);
+	struct davinci_mmc_priv *priv = dev_get_priv(dev);
+	struct mmc_config *cfg = &plat->cfg;
+	struct davinci_of_data *data =
+			(struct davinci_of_data *)dev_get_driver_data(dev);
+	cfg->f_min = 200000;
+	cfg->f_max = 25000000;
+	cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
+	cfg->host_caps = MMC_MODE_4BIT, /* DA850 supports only 4-bit SD/MMC */
+	cfg->b_max = DAVINCI_MAX_BLOCKS;
+
+	if (data) {
+		cfg->name = data->name;
+		priv->version = data->version;
+	}
+
+	priv->reg_base = (struct davinci_mmc_regs *)dev_read_addr(dev);
+	priv->input_clk = clk_get(DAVINCI_MMCSD_CLKID);
+
+	upriv->mmc = &plat->mmc;
+
+	return davinci_dm_mmc_init(dev);
+}
+
+static int davinci_mmc_bind(struct udevice *dev)
+{
+	struct davinci_mmc_plat *plat = dev_get_platdata(dev);
+
+	return mmc_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+
+const struct davinci_of_data davinci_mmc_host_info[] = {
+	{
+		.name	= "dm6441-mmc",
+		.version = MMC_CTLR_VERSION_1,
+	},
+	{
+		.name	= "da830-mmc",
+		.version = MMC_CTLR_VERSION_2,
+	},
+	{},
+};
+
+static const struct udevice_id davinci_mmc_ids[] = {
+	{
+		.compatible = "ti,dm6441-mmc",
+		.data = (ulong) &davinci_mmc_host_info[MMC_CTLR_VERSION_1]
+	},
+	{
+		.compatible = "ti,da830-mmc",
+		.data = (ulong) &davinci_mmc_host_info[MMC_CTLR_VERSION_2]
+	},
+	{},
+};
+
+U_BOOT_DRIVER(davinci_mmc_drv) = {
+	.name = "davinci_mmc",
+	.id		= UCLASS_MMC,
+	.of_match	= davinci_mmc_ids,
+#if CONFIG_BLK
+	.bind		= davinci_mmc_bind,
+#endif
+	.probe = davinci_mmc_probe,
+	.ops = &davinci_mmc_ops,
+	.platdata_auto_alloc_size = sizeof(struct davinci_mmc_plat),
+	.priv_auto_alloc_size = sizeof(struct davinci_mmc_priv),
+};
+#endif
-- 
2.17.1

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

* [U-Boot] [PATCH 2/3] ARM: davinci: da850evm: Support DM_MMC
  2018-08-09 11:15 [U-Boot] [PATCH 1/3] MMC: Enable DM_MMC for Davinci Adam Ford
@ 2018-08-09 11:15 ` Adam Ford
  2018-09-18 21:26   ` [U-Boot] [U-Boot,2/3] " Tom Rini
  2018-08-09 11:15 ` [U-Boot] [PATCH 3/3] ARM: davinci: omapl138_lcdk: Enable DM_MMC Adam Ford
  2018-09-18 21:26 ` [U-Boot] [U-Boot,1/3] MMC: Enable DM_MMC for Davinci Tom Rini
  2 siblings, 1 reply; 6+ messages in thread
From: Adam Ford @ 2018-08-09 11:15 UTC (permalink / raw)
  To: u-boot

With the updated driver available to support DM_MMC, this patch
enables DM_MMC for da850evm.

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c
index 5583b45792..e8ec553f99 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -204,6 +204,7 @@ int misc_init_r(void)
 	return 0;
 }
 
+#ifndef CONFIG_DM_MMC
 #ifdef CONFIG_MMC_DAVINCI
 static struct davinci_mmc mmc_sd0 = {
 	.reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
@@ -220,6 +221,7 @@ int board_mmc_init(bd_t *bis)
 	return davinci_mmc_init(bis, &mmc_sd0);
 }
 #endif
+#endif
 
 static const struct pinmux_config gpio_pins[] = {
 #ifdef CONFIG_USE_NOR
diff --git a/configs/da850evm_defconfig b/configs/da850evm_defconfig
index 4242728e6a..f98851c0aa 100644
--- a/configs/da850evm_defconfig
+++ b/configs/da850evm_defconfig
@@ -40,6 +40,7 @@ CONFIG_DM_GPIO=y
 CONFIG_DA8XX_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_DM_I2C_COMPAT=y
+CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
 CONFIG_MTD_PARTITIONS=y
 CONFIG_DM_SPI_FLASH=y
-- 
2.17.1

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

* [U-Boot] [PATCH 3/3] ARM: davinci: omapl138_lcdk: Enable DM_MMC
  2018-08-09 11:15 [U-Boot] [PATCH 1/3] MMC: Enable DM_MMC for Davinci Adam Ford
  2018-08-09 11:15 ` [U-Boot] [PATCH 2/3] ARM: davinci: da850evm: Support DM_MMC Adam Ford
@ 2018-08-09 11:15 ` Adam Ford
  2018-09-18 21:26   ` [U-Boot] [U-Boot, " Tom Rini
  2018-09-18 21:26 ` [U-Boot] [U-Boot,1/3] MMC: Enable DM_MMC for Davinci Tom Rini
  2 siblings, 1 reply; 6+ messages in thread
From: Adam Ford @ 2018-08-09 11:15 UTC (permalink / raw)
  To: u-boot

With DM_MMC now available, this patch enables DM_MMC for the
omapl138_lcdk in U-Boot and keeps the older style for SPL.

Signed-off-by: Peter Howard <phoward@gme.net.au>
Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/board/davinci/da8xxevm/omapl138_lcdk.c b/board/davinci/da8xxevm/omapl138_lcdk.c
index 15ffc3bfac..2c2f885d43 100644
--- a/board/davinci/da8xxevm/omapl138_lcdk.c
+++ b/board/davinci/da8xxevm/omapl138_lcdk.c
@@ -353,6 +353,7 @@ int misc_init_r(void)
 	return 0;
 }
 
+#ifndef CONFIG_DM_MMC
 #ifdef CONFIG_MMC_DAVINCI
 static struct davinci_mmc mmc_sd0 = {
 	.reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
@@ -369,3 +370,4 @@ int board_mmc_init(bd_t *bis)
 	return davinci_mmc_init(bis, &mmc_sd0);
 }
 #endif
+#endif
diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig
index 4a97269dd4..d7ed7817ea 100644
--- a/configs/omapl138_lcdk_defconfig
+++ b/configs/omapl138_lcdk_defconfig
@@ -34,6 +34,7 @@ CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
 CONFIG_DM_I2C=y
 CONFIG_DM_I2C_COMPAT=y
+CONFIG_DM_MMC=y
 CONFIG_NAND=y
 CONFIG_NAND_DAVINCI=y
 CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
-- 
2.17.1

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

* [U-Boot] [U-Boot,1/3] MMC: Enable DM_MMC for Davinci
  2018-08-09 11:15 [U-Boot] [PATCH 1/3] MMC: Enable DM_MMC for Davinci Adam Ford
  2018-08-09 11:15 ` [U-Boot] [PATCH 2/3] ARM: davinci: da850evm: Support DM_MMC Adam Ford
  2018-08-09 11:15 ` [U-Boot] [PATCH 3/3] ARM: davinci: omapl138_lcdk: Enable DM_MMC Adam Ford
@ 2018-09-18 21:26 ` Tom Rini
  2 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2018-09-18 21:26 UTC (permalink / raw)
  To: u-boot

On Thu, Aug 09, 2018 at 06:15:12AM -0500, Adam Ford wrote:

> With CONFIG_BLK becoming a requirement, the Davinci MMC driver
> needs to be updated with DM_MMC support.  Since SPL is tiny and
> many boards do not support DM in SPL, this retains the backwards
> compatibility for those boards who need to initialize MMC manually
> in SPL.
> 
> Signed-off-by: Peter Howard <phoward@gme.net.au>
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c
> index d7cb88a40a..db950ea5ec 100644

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180918/7972066c/attachment.sig>

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

* [U-Boot] [U-Boot,2/3] ARM: davinci: da850evm: Support DM_MMC
  2018-08-09 11:15 ` [U-Boot] [PATCH 2/3] ARM: davinci: da850evm: Support DM_MMC Adam Ford
@ 2018-09-18 21:26   ` Tom Rini
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2018-09-18 21:26 UTC (permalink / raw)
  To: u-boot

On Thu, Aug 09, 2018 at 06:15:13AM -0500, Adam Ford wrote:

> With the updated driver available to support DM_MMC, this patch
> enables DM_MMC for da850evm.
> 
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c
> index 5583b45792..e8ec553f99 100644

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180918/9fe9283c/attachment.sig>

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

* [U-Boot] [U-Boot, 3/3] ARM: davinci: omapl138_lcdk: Enable DM_MMC
  2018-08-09 11:15 ` [U-Boot] [PATCH 3/3] ARM: davinci: omapl138_lcdk: Enable DM_MMC Adam Ford
@ 2018-09-18 21:26   ` Tom Rini
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Rini @ 2018-09-18 21:26 UTC (permalink / raw)
  To: u-boot

On Thu, Aug 09, 2018 at 06:15:14AM -0500, Adam Ford wrote:

> With DM_MMC now available, this patch enables DM_MMC for the
> omapl138_lcdk in U-Boot and keeps the older style for SPL.
> 
> Signed-off-by: Peter Howard <phoward@gme.net.au>
> Signed-off-by: Adam Ford <aford173@gmail.com>
> 
> diff --git a/board/davinci/da8xxevm/omapl138_lcdk.c b/board/davinci/da8xxevm/omapl138_lcdk.c
> index 15ffc3bfac..2c2f885d43 100644

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180918/8da80115/attachment.sig>

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

end of thread, other threads:[~2018-09-18 21:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09 11:15 [U-Boot] [PATCH 1/3] MMC: Enable DM_MMC for Davinci Adam Ford
2018-08-09 11:15 ` [U-Boot] [PATCH 2/3] ARM: davinci: da850evm: Support DM_MMC Adam Ford
2018-09-18 21:26   ` [U-Boot] [U-Boot,2/3] " Tom Rini
2018-08-09 11:15 ` [U-Boot] [PATCH 3/3] ARM: davinci: omapl138_lcdk: Enable DM_MMC Adam Ford
2018-09-18 21:26   ` [U-Boot] [U-Boot, " Tom Rini
2018-09-18 21:26 ` [U-Boot] [U-Boot,1/3] MMC: Enable DM_MMC for Davinci Tom Rini

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.