From: Walter Lozano <walter.lozano@collabora.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 2/6] mmc: fsl_esdhc_imx: add OF_PLATDATA support
Date: Wed, 29 Jul 2020 12:31:17 -0300 [thread overview]
Message-ID: <20200729153121.29548-3-walter.lozano@collabora.com> (raw)
In-Reply-To: <20200729153121.29548-1-walter.lozano@collabora.com>
In order to reduce the footprint of SPL by removing dtb and library
overhead, add OF_PLATDATA support to fsl_esdhc_imx. This initial
approach does not support card detection, which will be enabled after
adding OF_PLATDATA support to GPIO.
Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
- Fix commit message
drivers/mmc/fsl_esdhc_imx.c | 67 +++++++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 14 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 6b727dbbd5..2713682cf7 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -33,6 +33,9 @@
#include <dm.h>
#include <asm-generic/gpio.h>
#include <dm/pinctrl.h>
+#include <dt-structs.h>
+#include <mapmem.h>
+#include <dm/ofnode.h>
#if !CONFIG_IS_ENABLED(BLK)
#include "mmc_private.h"
@@ -102,6 +105,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_esdhc dtplat;
+#endif
+
struct mmc_config cfg;
struct mmc mmc;
};
@@ -1378,25 +1386,19 @@ __weak void init_clk_usdhc(u32 index)
{
}
-static int fsl_esdhc_probe(struct udevice *dev)
+static int fsl_esdhc_ofdata_to_platdata(struct udevice *dev)
{
- struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
- struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
+#if !CONFIG_IS_ENABLED(OF_PLATDATA)
struct fsl_esdhc_priv *priv = dev_get_priv(dev);
- const void *fdt = gd->fdt_blob;
- int node = dev_of_offset(dev);
- struct esdhc_soc_data *data =
- (struct esdhc_soc_data *)dev_get_driver_data(dev);
#if CONFIG_IS_ENABLED(DM_REGULATOR)
struct udevice *vqmmc_dev;
+ int ret;
#endif
+ const void *fdt = gd->fdt_blob;
+ int node = dev_of_offset(dev);
+
fdt_addr_t addr;
unsigned int val;
- struct mmc *mmc;
-#if !CONFIG_IS_ENABLED(BLK)
- struct blk_desc *bdesc;
-#endif
- int ret;
addr = dev_read_addr(dev);
if (addr == FDT_ADDR_T_NONE)
@@ -1404,8 +1406,6 @@ static int fsl_esdhc_probe(struct udevice *dev)
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)
@@ -1469,6 +1469,40 @@ static int fsl_esdhc_probe(struct udevice *dev)
priv->vs18_enable = 1;
}
#endif
+#endif
+ return 0;
+}
+
+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);
+ struct esdhc_soc_data *data =
+ (struct esdhc_soc_data *)dev_get_driver_data(dev);
+ struct mmc *mmc;
+#if !CONFIG_IS_ENABLED(BLK)
+ struct blk_desc *bdesc;
+#endif
+ int ret;
+
+#if CONFIG_IS_ENABLED(OF_PLATDATA)
+ struct dtd_fsl_esdhc *dtplat = &plat->dtplat;
+ unsigned int val;
+
+ 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;
+#endif
+
+ if (data)
+ priv->flags = data->flags;
/*
* TODO:
@@ -1520,9 +1554,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;
@@ -1647,6 +1683,7 @@ U_BOOT_DRIVER(fsl_esdhc) = {
.name = "fsl_esdhc",
.id = UCLASS_MMC,
.of_match = fsl_esdhc_ids,
+ .ofdata_to_platdata = fsl_esdhc_ofdata_to_platdata,
.ops = &fsl_esdhc_ops,
#if CONFIG_IS_ENABLED(BLK)
.bind = fsl_esdhc_bind,
@@ -1655,4 +1692,6 @@ U_BOOT_DRIVER(fsl_esdhc) = {
.platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat),
.priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv),
};
+
+U_BOOT_DRIVER_ALIAS(fsl_esdhc, fsl_imx6q_usdhc)
#endif
--
2.20.1
next prev parent reply other threads:[~2020-07-29 15:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-29 15:31 [PATCH v3 0/6] mx6cuboxi: enable OF_PLATDATA with MMC support Walter Lozano
2020-07-29 15:31 ` [PATCH v3 1/6] mmc: fsl_esdhc_imx: rename driver name to match ll_entry Walter Lozano
2020-08-04 8:52 ` sbabic at denx.de
2020-07-29 15:31 ` Walter Lozano [this message]
2020-08-04 8:52 ` [PATCH v3 2/6] mmc: fsl_esdhc_imx: add OF_PLATDATA support sbabic at denx.de
2020-07-29 15:31 ` [PATCH v3 3/6] gpio: mxc_gpio: " Walter Lozano
2020-08-04 8:52 ` sbabic at denx.de
2020-07-29 15:31 ` [PATCH v3 4/6] mmc: fsl_esdhc_imx: add CD support when OF_PLATDATA is enabled Walter Lozano
2020-08-04 8:52 ` sbabic at denx.de
2020-07-29 15:31 ` [PATCH v3 5/6] drivers: rename more drivers to match compatible string Walter Lozano
2020-08-04 8:52 ` sbabic at denx.de
2020-07-29 15:31 ` [PATCH v3 6/6] mx6cuboxi: enable OF_PLATDATA Walter Lozano
2020-08-04 8:52 ` sbabic at denx.de
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=20200729153121.29548-3-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