pic32_sdhci.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Support of SDHCI for Microchip PIC32 SoC.
  3. *
  4. * Copyright (C) 2015 Microchip Technology Inc.
  5. * Andrei Pistirica <andrei.pistirica@microchip.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <dm.h>
  10. #include <common.h>
  11. #include <sdhci.h>
  12. #include <linux/errno.h>
  13. #include <mach/pic32.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. static int pic32_sdhci_probe(struct udevice *dev)
  16. {
  17. struct sdhci_host *host = dev_get_priv(dev);
  18. const void *fdt = gd->fdt_blob;
  19. u32 f_min_max[2];
  20. fdt_addr_t addr;
  21. fdt_size_t size;
  22. int ret;
  23. addr = fdtdec_get_addr_size(fdt, dev->of_offset, "reg", &size);
  24. if (addr == FDT_ADDR_T_NONE)
  25. return -EINVAL;
  26. host->ioaddr = ioremap(addr, size);
  27. host->name = dev->name;
  28. host->quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_NO_CD;
  29. host->bus_width = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
  30. "bus-width", 4);
  31. ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset,
  32. "clock-freq-min-max", f_min_max, 2);
  33. if (ret) {
  34. printf("sdhci: clock-freq-min-max not found\n");
  35. return ret;
  36. }
  37. ret = add_sdhci(host, f_min_max[1], f_min_max[0]);
  38. if (ret)
  39. return ret;
  40. host->mmc->dev = dev;
  41. return 0;
  42. }
  43. static const struct udevice_id pic32_sdhci_ids[] = {
  44. { .compatible = "microchip,pic32mzda-sdhci" },
  45. { }
  46. };
  47. U_BOOT_DRIVER(pic32_sdhci_drv) = {
  48. .name = "pic32_sdhci",
  49. .id = UCLASS_MMC,
  50. .of_match = pic32_sdhci_ids,
  51. .probe = pic32_sdhci_probe,
  52. .priv_auto_alloc_size = sizeof(struct sdhci_host),
  53. };