public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Walter Lozano <walter.lozano@collabora.com>
To: u-boot@lists.denx.de
Subject: [RFC 1/7] mmc: fsl_esdhc_imx: add OF_PLATDATA support
Date: Mon, 30 Mar 2020 00:31:52 -0300	[thread overview]
Message-ID: <20200330033158.26751-2-walter.lozano@collabora.com> (raw)
In-Reply-To: <20200330033158.26751-1-walter.lozano@collabora.com>

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 drivers/mmc/fsl_esdhc_imx.c | 46 +++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 4900498e9b..761a4b46e9 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -29,6 +29,8 @@
 #include <dm.h>
 #include <asm-generic/gpio.h>
 #include <dm/pinctrl.h>
+#include <dt-structs.h>
+#include <mapmem.h>
 
 #if !CONFIG_IS_ENABLED(BLK)
 #include "mmc_private.h"
@@ -98,6 +100,11 @@ struct fsl_esdhc {
 };
 
 struct fsl_esdhc_plat {
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	/* Put this first since driver model will copy the data here */
+	struct dtd_fsl_imx6q_usdhc dtplat;
+#endif
+
 	struct mmc_config cfg;
 	struct mmc mmc;
 };
@@ -1377,14 +1384,18 @@ static int fsl_esdhc_probe(struct udevice *dev)
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
 	struct fsl_esdhc_priv *priv = dev_get_priv(dev);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	const void *fdt = gd->fdt_blob;
 	int node = dev_of_offset(dev);
+	fdt_addr_t addr;
+#else
+	struct dtd_fsl_imx6q_usdhc *dtplat = &plat->dtplat;
+#endif
 	struct esdhc_soc_data *data =
 		(struct esdhc_soc_data *)dev_get_driver_data(dev);
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	struct udevice *vqmmc_dev;
 #endif
-	fdt_addr_t addr;
 	unsigned int val;
 	struct mmc *mmc;
 #if !CONFIG_IS_ENABLED(BLK)
@@ -1392,14 +1403,23 @@ static int fsl_esdhc_probe(struct udevice *dev)
 #endif
 	int ret;
 
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+	priv->esdhc_regs = map_sysmem(dtplat->reg[0], dtplat->reg[1]);
+	val = plat->dtplat.bus_width;
+	if (val == 8)
+		priv->bus_width = 8;
+	else if (val == 4)
+		priv->bus_width = 4;
+	else
+		priv->bus_width = 1;
+	priv->non_removable = 1;
+#else
 	addr = dev_read_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 	priv->esdhc_regs = (struct fsl_esdhc *)addr;
 	priv->dev = dev;
 	priv->mode = -1;
-	if (data)
-		priv->flags = data->flags;
 
 	val = dev_read_u32_default(dev, "bus-width", -1);
 	if (val == 8)
@@ -1462,7 +1482,9 @@ static int fsl_esdhc_probe(struct udevice *dev)
 			priv->vs18_enable = 1;
 	}
 #endif
-
+#endif
+	if (data)
+		priv->flags = data->flags;
 	/*
 	 * TODO:
 	 * Because lack of clk driver, if SDHC clk is not enabled,
@@ -1513,9 +1535,11 @@ static int fsl_esdhc_probe(struct udevice *dev)
 		return ret;
 	}
 
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
 	ret = mmc_of_parse(dev, &plat->cfg);
 	if (ret)
 		return ret;
+#endif
 
 	mmc = &plat->mmc;
 	mmc->cfg = &plat->cfg;
@@ -1648,4 +1672,18 @@ U_BOOT_DRIVER(fsl_esdhc) = {
 	.platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat),
 	.priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv),
 };
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+U_BOOT_DRIVER(fsl_usdhc) = {
+	.name	= "fsl_imx6q_usdhc",
+	.id	= UCLASS_MMC,
+	.ops	= &fsl_esdhc_ops,
+#if CONFIG_IS_ENABLED(BLK)
+	.bind	= fsl_esdhc_bind,
+#endif
+	.probe	= fsl_esdhc_probe,
+	.platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat),
+	.priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv),
+};
+#endif
 #endif
-- 
2.20.1

  reply	other threads:[~2020-03-30  3:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30  3:31 [RFC 0/7] mx6cuboxi: enable OF_PLATDATA with MMC support Walter Lozano
2020-03-30  3:31 ` Walter Lozano [this message]
2020-04-06  3:42   ` [RFC 1/7] mmc: fsl_esdhc_imx: add OF_PLATDATA support Simon Glass
2020-04-07 20:05     ` Walter Lozano
2020-04-08  3:14       ` Simon Glass
2020-04-09 19:06         ` Walter Lozano
2020-04-09 19:36           ` Simon Glass
2020-04-09 19:44             ` Walter Lozano
2020-04-09 19:50               ` Simon Glass
2020-04-09 20:01                 ` Walter Lozano
2020-04-17 20:05                 ` Walter Lozano
2020-04-21 17:44                   ` Simon Glass
2020-03-30  3:31 ` [RFC 2/7] mmc: fsl_esdhc_imx: add ofdata_to_platdata support Walter Lozano
2020-04-06  3:42   ` Simon Glass
2020-04-07 20:05     ` Walter Lozano
2020-03-30  3:31 ` [RFC 3/7] dtoc: update dtb_platdata to support cd-gpio Walter Lozano
2020-04-06  3:42   ` Simon Glass
2020-04-07 20:05     ` Walter Lozano
2020-03-30  3:31 ` [RFC 4/7] dm: uclass: add functions to get device by platdata Walter Lozano
2020-03-30  3:31 ` [RFC 5/7] gpio: mxc_gpio: add OF_PLATDATA support Walter Lozano
2020-04-06  3:42   ` Simon Glass
2020-04-07 20:05     ` Walter Lozano
2020-03-30  3:31 ` [RFC 6/7] mmc: fsl_esdhc_imx: add CD support when OF_PLATDATA is enabled Walter Lozano
2020-03-30  3:31 ` [RFC 7/7] mx6cuboxi: enable OF_PLATDATA Walter Lozano
2020-04-06  3:43   ` Simon Glass
2020-04-07 20:06     ` Walter Lozano
2020-03-30  3:54 ` [RFC 0/7] mx6cuboxi: enable OF_PLATDATA with MMC support Baruch Siach
2020-03-30 14:33   ` Walter Lozano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200330033158.26751-2-walter.lozano@collabora.com \
    --to=walter.lozano@collabora.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox