zynq_sdhci.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * (C) Copyright 2013 Inc.
  3. *
  4. * Xilinx Zynq SD Host Controller Interface
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <fdtdec.h>
  10. #include <libfdt.h>
  11. #include <malloc.h>
  12. #include <sdhci.h>
  13. #include <asm/arch/sys_proto.h>
  14. int zynq_sdhci_init(u32 regbase)
  15. {
  16. struct sdhci_host *host = NULL;
  17. host = (struct sdhci_host *)malloc(sizeof(struct sdhci_host));
  18. if (!host) {
  19. printf("zynq_sdhci_init: sdhci_host malloc fail\n");
  20. return 1;
  21. }
  22. host->name = "zynq_sdhci";
  23. host->ioaddr = (void *)regbase;
  24. host->quirks = SDHCI_QUIRK_NO_CD | SDHCI_QUIRK_WAIT_SEND_CMD |
  25. SDHCI_QUIRK_BROKEN_R1B;
  26. host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
  27. host->host_caps = MMC_MODE_HC;
  28. add_sdhci(host, 52000000, 52000000 >> 9);
  29. return 0;
  30. }
  31. #ifdef CONFIG_OF_CONTROL
  32. int zynq_sdhci_of_init(const void *blob)
  33. {
  34. int offset = 0;
  35. u32 ret = 0;
  36. u32 reg;
  37. debug("ZYNQ SDHCI: Initialization\n");
  38. do {
  39. offset = fdt_node_offset_by_compatible(blob, offset,
  40. "arasan,sdhci-8.9a");
  41. if (offset != -1) {
  42. reg = fdtdec_get_addr(blob, offset, "reg");
  43. if (reg != FDT_ADDR_T_NONE) {
  44. ret |= zynq_sdhci_init(reg);
  45. } else {
  46. debug("ZYNQ SDHCI: Can't get base address\n");
  47. return -1;
  48. }
  49. }
  50. } while (offset != -1);
  51. return ret;
  52. }
  53. #endif