2 * Support of SDHCI for Microchip PIC32 SoC.
4 * Copyright (C) 2015 Microchip Technology Inc.
5 * Andrei Pistirica <andrei.pistirica@microchip.com>
7 * SPDX-License-Identifier: GPL-2.0+
13 #include <linux/errno.h>
14 #include <mach/pic32.h>
16 DECLARE_GLOBAL_DATA_PTR
;
18 static int pci32_sdhci_get_cd(struct sdhci_host
*host
)
20 /* PIC32 SDHCI CD errata:
21 * - set CD_TEST and clear CD_TEST_INS bit
23 sdhci_writeb(host
, SDHCI_CTRL_CD_TEST
, SDHCI_HOST_CONTROL
);
28 static const struct sdhci_ops pic32_sdhci_ops
= {
29 .get_cd
= pci32_sdhci_get_cd
,
32 static int pic32_sdhci_probe(struct udevice
*dev
)
34 struct sdhci_host
*host
= dev_get_priv(dev
);
35 const void *fdt
= gd
->fdt_blob
;
41 addr
= fdtdec_get_addr_size(fdt
, dev
->of_offset
, "reg", &size
);
42 if (addr
== FDT_ADDR_T_NONE
)
45 host
->ioaddr
= ioremap(addr
, size
);
46 host
->name
= dev
->name
;
47 host
->quirks
= SDHCI_QUIRK_NO_HISPD_BIT
;
48 host
->bus_width
= fdtdec_get_int(gd
->fdt_blob
, dev
->of_offset
,
50 host
->ops
= &pic32_sdhci_ops
;
52 ret
= fdtdec_get_int_array(gd
->fdt_blob
, dev
->of_offset
,
53 "clock-freq-min-max", f_min_max
, 2);
55 printf("sdhci: clock-freq-min-max not found\n");
59 ret
= add_sdhci(host
, f_min_max
[1], f_min_max
[0]);
67 static const struct udevice_id pic32_sdhci_ids
[] = {
68 { .compatible
= "microchip,pic32mzda-sdhci" },
72 U_BOOT_DRIVER(pic32_sdhci_drv
) = {
73 .name
= "pic32_sdhci",
75 .of_match
= pic32_sdhci_ids
,
76 .probe
= pic32_sdhci_probe
,
77 .priv_auto_alloc_size
= sizeof(struct sdhci_host
),