[PATCH 20/22] sandbox: mmc: Support fixed MMC devices
Simon Glass
sjg at chromium.org
Tue Jul 6 00:32:58 CEST 2021
Add support for reading devicetree flags for MMC devices. With this we
can distinguish between fixed and removable drives. Note that this
information is only available when the device is probed, not when it is
bound, since it is read in the of_to_plat() method. This could be changed
if needed later.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/sandbox/dts/test.dts | 1 +
drivers/mmc/sandbox_mmc.c | 24 +++++++++++++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index d85bb46ceba..0cee15a0ea2 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -819,6 +819,7 @@
mmc2 {
compatible = "sandbox,mmc";
+ non-removable;
};
mmc1 {
diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
index 18ba020aacc..895fbffecfc 100644
--- a/drivers/mmc/sandbox_mmc.c
+++ b/drivers/mmc/sandbox_mmc.c
@@ -136,14 +136,31 @@ static const struct dm_mmc_ops sandbox_mmc_ops = {
.get_cd = sandbox_mmc_get_cd,
};
-int sandbox_mmc_probe(struct udevice *dev)
+static int sandbox_mmc_of_to_plat(struct udevice *dev)
+{
+ struct sandbox_mmc_plat *plat = dev_get_plat(dev);
+ struct mmc_config *cfg = &plat->cfg;
+ struct blk_desc *blk;
+ int ret;
+
+ ret = mmc_of_parse(dev, cfg);
+ if (ret)
+ return ret;
+ blk = mmc_get_blk_desc(&plat->mmc);
+ if (blk)
+ blk->removable = !(cfg->host_caps & MMC_CAP_NONREMOVABLE);
+
+ return 0;
+}
+
+static int sandbox_mmc_probe(struct udevice *dev)
{
struct sandbox_mmc_plat *plat = dev_get_plat(dev);
return mmc_init(&plat->mmc);
}
-int sandbox_mmc_bind(struct udevice *dev)
+static int sandbox_mmc_bind(struct udevice *dev)
{
struct sandbox_mmc_plat *plat = dev_get_plat(dev);
struct mmc_config *cfg = &plat->cfg;
@@ -158,7 +175,7 @@ int sandbox_mmc_bind(struct udevice *dev)
return mmc_bind(dev, &plat->mmc, cfg);
}
-int sandbox_mmc_unbind(struct udevice *dev)
+static int sandbox_mmc_unbind(struct udevice *dev)
{
mmc_unbind(dev);
@@ -177,6 +194,7 @@ U_BOOT_DRIVER(mmc_sandbox) = {
.ops = &sandbox_mmc_ops,
.bind = sandbox_mmc_bind,
.unbind = sandbox_mmc_unbind,
+ .of_to_plat = sandbox_mmc_of_to_plat,
.probe = sandbox_mmc_probe,
.priv_auto = sizeof(struct sandbox_mmc_priv),
.plat_auto = sizeof(struct sandbox_mmc_plat),
--
2.32.0.93.g670b81a890-goog
More information about the U-Boot
mailing list