pic32_sdhci.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 <asm/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. return add_sdhci(host, f_min_max[1], f_min_max[0]);
  38. }
  39. static const struct udevice_id pic32_sdhci_ids[] = {
  40. { .compatible = "microchip,pic32mzda-sdhci" },
  41. { }
  42. };
  43. U_BOOT_DRIVER(pic32_sdhci_drv) = {
  44. .name = "pic32_sdhci",
  45. .id = UCLASS_MMC,
  46. .of_match = pic32_sdhci_ids,
  47. .probe = pic32_sdhci_probe,
  48. .priv_auto_alloc_size = sizeof(struct sdhci_host),
  49. };