[RFC 4/4] mmc: fsl_esdhc_imx: make use of dtoc to generate struct udevice_id
Walter Lozano
walter.lozano at collabora.com
Fri Jun 19 23:11:40 CEST 2020
As an example of use, convert fsl_esdhc_imx to use COMPATIBLE entries
for declaring compatible strings.
As a result of these entries dtoc will generate code similar to
Signed-off-by: Walter Lozano <walter.lozano at collabora.com>
---
drivers/mmc/fsl_esdhc_imx.c | 58 ++++++++++++++++++++++++++-----------
1 file changed, 41 insertions(+), 17 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 588d6a9d76..16448a9ebe 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -33,6 +33,7 @@
#include <dm.h>
#include <asm-generic/gpio.h>
#include <dm/pinctrl.h>
+#include <generated/compatible.h>
#if !CONFIG_IS_ENABLED(BLK)
#include "mmc_private.h"
@@ -1613,22 +1614,45 @@ static struct esdhc_soc_data usdhc_imx8qm_data = {
ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES,
};
-static const struct udevice_id fsl_esdhc_ids[] = {
- { .compatible = "fsl,imx53-esdhc", },
- { .compatible = "fsl,imx6ul-usdhc", },
- { .compatible = "fsl,imx6sx-usdhc", },
- { .compatible = "fsl,imx6sl-usdhc", },
- { .compatible = "fsl,imx6q-usdhc", },
- { .compatible = "fsl,imx7d-usdhc", .data = (ulong)&usdhc_imx7d_data,},
- { .compatible = "fsl,imx7ulp-usdhc", },
- { .compatible = "fsl,imx8qm-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
- { .compatible = "fsl,imx8mm-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
- { .compatible = "fsl,imx8mn-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
- { .compatible = "fsl,imx8mq-usdhc", .data = (ulong)&usdhc_imx8qm_data,},
- { .compatible = "fsl,imxrt-usdhc", },
- { .compatible = "fsl,esdhc", },
- { /* sentinel */ }
-};
+#if 0
+// As result of the COMPATIBLE entries, dtoc will produce
+// code similar to this
+
+#define COMPATIBLE(__driver_name, compatible, ...)
+
+#define COMPATIBLE_LIST_FSL_ESDHC { \
+{.compatible = "fsl,imx53-esdhc"},\
+{.compatible = "fsl,imx6ul-usdhc"},\
+{.compatible = "fsl,imx6sx-usdhc"},\
+{.compatible = "fsl,imx6sl-usdhc"},\
+{.compatible = "fsl,imx6q-usdhc"},\
+{.compatible = "fsl,imx7ulp-usdhc"},\
+{.compatible = "fsl,imxrt-usdhc"},\
+{.compatible = "fsl,esdhc"},\
+{ /* sentinel */ },\
+}
+#define COMPATIBLE_LIST_FSL_ESDHC2 { \
+{.compatible = "fsl,imxrt-usdhc2"},\
+{.compatible = "fsl,esdhc2"},\
+{ /* sentinel */ },\
+}
+#endif
+
+COMPATIBLE(FSL_ESDHC, "fsl,imx53-esdhc")
+COMPATIBLE(FSL_ESDHC, "fsl,imx6ul-usdhc")
+COMPATIBLE(FSL_ESDHC, "fsl,imx6sx-usdhc")
+COMPATIBLE(FSL_ESDHC, "fsl,imx6sl-usdhc")
+COMPATIBLE(FSL_ESDHC, "fsl,imx6q-usdhc")
+COMPATIBLE(FSL_ESDHC, "fsl,imx7d-usdhc", (ulong)&usdhc_imx7d_data)
+COMPATIBLE(FSL_ESDHC, "fsl,imx7ulp-usdhc")
+COMPATIBLE(FSL_ESDHC, "fsl,imx8qm-usdhc", &usdhc_imx8qm_data)
+COMPATIBLE(FSL_ESDHC, "fsl,imx8mm-usdhc", &usdhc_imx8qm_data)
+COMPATIBLE(FSL_ESDHC, "fsl,imx8mn-usdhc", &usdhc_imx8qm_data)
+COMPATIBLE(FSL_ESDHC, "fsl,imx8mq-usdhc", &usdhc_imx8qm_data)
+COMPATIBLE(FSL_ESDHC, "fsl,imxrt-usdhc")
+COMPATIBLE(FSL_ESDHC, "fsl,esdhc")
+
+static const struct udevice_id fsl_esdhc_ids[] = COMPATIBLE_LIST_FSL_ESDHC;
#if CONFIG_IS_ENABLED(BLK)
static int fsl_esdhc_bind(struct udevice *dev)
@@ -1640,7 +1664,7 @@ static int fsl_esdhc_bind(struct udevice *dev)
#endif
U_BOOT_DRIVER(fsl_esdhc) = {
- .name = "fsl-esdhc-mmc",
+ .name = "fsl_esdhc",
.id = UCLASS_MMC,
.of_match = fsl_esdhc_ids,
.ops = &fsl_esdhc_ops,
--
2.20.1
More information about the U-Boot
mailing list