zynq_sdhci.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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(phys_addr_t 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_WAIT_SEND_CMD |
  25. SDHCI_QUIRK_BROKEN_R1B;
  26. host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
  27. add_sdhci(host, 52000000, 52000000 >> 9);
  28. return 0;
  29. }
  30. #if CONFIG_IS_ENABLED(OF_CONTROL)
  31. int zynq_sdhci_of_init(const void *blob)
  32. {
  33. int offset = 0;
  34. u32 ret = 0;
  35. phys_addr_t reg;
  36. debug("ZYNQ SDHCI: Initialization\n");
  37. do {
  38. offset = fdt_node_offset_by_compatible(blob, offset,
  39. "arasan,sdhci-8.9a");
  40. if (offset != -1) {
  41. reg = fdtdec_get_addr(blob, offset, "reg");
  42. if (reg != FDT_ADDR_T_NONE) {
  43. ret |= zynq_sdhci_init(reg);
  44. } else {
  45. debug("ZYNQ SDHCI: Can't get base address\n");
  46. return -1;
  47. }
  48. }
  49. } while (offset != -1);
  50. return ret;
  51. }
  52. #endif