Add a quirk to identify that the controller is Renesas RCar variant
of the Matsushita SD IP and another quirk indicating it can support
Renesas RCar HS200/HS400/SDR104 modes.

Signed-off-by: Marek Vasut <marek.vasut+rene...@gmail.com>
Cc: Jaehoon Chung <jh80.ch...@samsung.com>
Cc: Masahiro Yamada <yamada.masah...@socionext.com>
---
 drivers/mmc/matsushita-common.h |  5 +++++
 drivers/mmc/renesas-sdhi.c      | 43 ++++++++++++++++++++++++-----------------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/drivers/mmc/matsushita-common.h b/drivers/mmc/matsushita-common.h
index a03d8f97e5..c23dc1a79a 100644
--- a/drivers/mmc/matsushita-common.h
+++ b/drivers/mmc/matsushita-common.h
@@ -124,6 +124,11 @@ struct matsu_sd_priv {
 #define MATSU_SD_CAP_DIV1024           BIT(2)  /* divisor 1024 is available */
 #define MATSU_SD_CAP_64BIT             BIT(3)  /* Controller is 64bit */
 #define MATSU_SD_CAP_16BIT             BIT(4)  /* Controller is 16bit */
+#define MATSU_SD_CAP_RCAR_GEN2         BIT(5)  /* Renesas RCar version of IP */
+#define MATSU_SD_CAP_RCAR_GEN3         BIT(6)  /* Renesas RCar version of IP */
+#define MATSU_SD_CAP_RCAR_UHS          BIT(7)  /* Renesas RCar UHS/SDR modes */
+#define MATSU_SD_CAP_RCAR              \
+       (MATSU_SD_CAP_RCAR_GEN2 | MATSU_SD_CAP_RCAR_GEN3)
 };
 
 int matsu_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
diff --git a/drivers/mmc/renesas-sdhi.c b/drivers/mmc/renesas-sdhi.c
index 521574387b..73f68c8c3a 100644
--- a/drivers/mmc/renesas-sdhi.c
+++ b/drivers/mmc/renesas-sdhi.c
@@ -24,17 +24,21 @@ static const struct dm_mmc_ops renesas_sdhi_ops = {
        .get_cd = matsu_sd_get_cd,
 };
 
+#define RENESAS_GEN2_QUIRKS    MATSU_SD_CAP_RCAR_GEN2
+#define RENESAS_GEN3_QUIRKS                            \
+       MATSU_SD_CAP_64BIT | MATSU_SD_CAP_RCAR_GEN3 | MATSU_SD_CAP_RCAR_UHS
+
 static const struct udevice_id renesas_sdhi_match[] = {
-       { .compatible = "renesas,sdhi-r8a7790", .data = 0 },
-       { .compatible = "renesas,sdhi-r8a7791", .data = 0 },
-       { .compatible = "renesas,sdhi-r8a7792", .data = 0 },
-       { .compatible = "renesas,sdhi-r8a7793", .data = 0 },
-       { .compatible = "renesas,sdhi-r8a7794", .data = 0 },
-       { .compatible = "renesas,sdhi-r8a7795", .data = MATSU_SD_CAP_64BIT },
-       { .compatible = "renesas,sdhi-r8a7796", .data = MATSU_SD_CAP_64BIT },
-       { .compatible = "renesas,sdhi-r8a77965", .data = MATSU_SD_CAP_64BIT },
-       { .compatible = "renesas,sdhi-r8a77970", .data = MATSU_SD_CAP_64BIT },
-       { .compatible = "renesas,sdhi-r8a77995", .data = MATSU_SD_CAP_64BIT },
+       { .compatible = "renesas,sdhi-r8a7790", .data = RENESAS_GEN2_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a7791", .data = RENESAS_GEN2_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a7792", .data = RENESAS_GEN2_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a7793", .data = RENESAS_GEN2_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a7794", .data = RENESAS_GEN2_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a7795", .data = RENESAS_GEN3_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a7796", .data = RENESAS_GEN3_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a77965", .data = RENESAS_GEN3_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a77970", .data = RENESAS_GEN3_QUIRKS },
+       { .compatible = "renesas,sdhi-r8a77995", .data = RENESAS_GEN3_QUIRKS },
        { /* sentinel */ }
 };
 
@@ -45,15 +49,18 @@ static int renesas_sdhi_probe(struct udevice *dev)
        DECLARE_GLOBAL_DATA_PTR;
        int ret;
 
-       ret = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
-                              0, &reg_res);
-       if (ret < 0) {
-               dev_err(dev, "\"reg\" resource not found, ret=%i\n", ret);
-               return ret;
-       }
+       if (quirks == RENESAS_GEN2_QUIRKS) {
+               ret = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev),
+                                      "reg", 0, &reg_res);
+               if (ret < 0) {
+                       dev_err(dev, "\"reg\" resource not found, ret=%i\n",
+                               ret);
+                       return ret;
+               }
 
-       if (quirks == 0 && fdt_resource_size(&reg_res) == 0x100)
-               quirks = MATSU_SD_CAP_16BIT;
+               if (fdt_resource_size(&reg_res) == 0x100)
+                       quirks |= MATSU_SD_CAP_16BIT;
+       }
 
        return matsu_sd_probe(dev, quirks);
 }
-- 
2.16.2

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to