2 * Copyright (C) 2018 Marek Vasut <marek.vasut@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/compat.h>
13 #include <linux/dma-direction.h>
15 #include <linux/sizes.h>
16 #include <power/regulator.h>
17 #include <asm/unaligned.h>
19 #include "matsushita-common.h"
21 static const struct dm_mmc_ops renesas_sdhi_ops = {
22 .send_cmd = matsu_sd_send_cmd,
23 .set_ios = matsu_sd_set_ios,
24 .get_cd = matsu_sd_get_cd,
27 #define RENESAS_GEN2_QUIRKS MATSU_SD_CAP_RCAR_GEN2
28 #define RENESAS_GEN3_QUIRKS \
29 MATSU_SD_CAP_64BIT | MATSU_SD_CAP_RCAR_GEN3 | MATSU_SD_CAP_RCAR_UHS
31 static const struct udevice_id renesas_sdhi_match[] = {
32 { .compatible = "renesas,sdhi-r8a7790", .data = RENESAS_GEN2_QUIRKS },
33 { .compatible = "renesas,sdhi-r8a7791", .data = RENESAS_GEN2_QUIRKS },
34 { .compatible = "renesas,sdhi-r8a7792", .data = RENESAS_GEN2_QUIRKS },
35 { .compatible = "renesas,sdhi-r8a7793", .data = RENESAS_GEN2_QUIRKS },
36 { .compatible = "renesas,sdhi-r8a7794", .data = RENESAS_GEN2_QUIRKS },
37 { .compatible = "renesas,sdhi-r8a7795", .data = RENESAS_GEN3_QUIRKS },
38 { .compatible = "renesas,sdhi-r8a7796", .data = RENESAS_GEN3_QUIRKS },
39 { .compatible = "renesas,sdhi-r8a77965", .data = RENESAS_GEN3_QUIRKS },
40 { .compatible = "renesas,sdhi-r8a77970", .data = RENESAS_GEN3_QUIRKS },
41 { .compatible = "renesas,sdhi-r8a77995", .data = RENESAS_GEN3_QUIRKS },
45 static int renesas_sdhi_probe(struct udevice *dev)
47 u32 quirks = dev_get_driver_data(dev);
48 struct fdt_resource reg_res;
49 DECLARE_GLOBAL_DATA_PTR;
52 if (quirks == RENESAS_GEN2_QUIRKS) {
53 ret = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev),
56 dev_err(dev, "\"reg\" resource not found, ret=%i\n",
61 if (fdt_resource_size(®_res) == 0x100)
62 quirks |= MATSU_SD_CAP_16BIT;
65 return matsu_sd_probe(dev, quirks);
68 U_BOOT_DRIVER(renesas_sdhi) = {
69 .name = "renesas-sdhi",
71 .of_match = renesas_sdhi_match,
72 .bind = matsu_sd_bind,
73 .probe = renesas_sdhi_probe,
74 .priv_auto_alloc_size = sizeof(struct matsu_sd_priv),
75 .platdata_auto_alloc_size = sizeof(struct matsu_sd_plat),
76 .ops = &renesas_sdhi_ops,