zynq_sdhci.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * (C) Copyright 2013 - 2015 Xilinx, Inc.
  3. *
  4. * Xilinx Zynq SD Host Controller Interface
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <fdtdec.h>
  11. #include <libfdt.h>
  12. #include <malloc.h>
  13. #include <sdhci.h>
  14. #ifndef CONFIG_ZYNQ_SDHCI_MIN_FREQ
  15. # define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0
  16. #endif
  17. struct arasan_sdhci_plat {
  18. struct mmc_config cfg;
  19. struct mmc mmc;
  20. };
  21. static int arasan_sdhci_probe(struct udevice *dev)
  22. {
  23. struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
  24. struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
  25. struct sdhci_host *host = dev_get_priv(dev);
  26. int ret;
  27. host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD |
  28. SDHCI_QUIRK_BROKEN_R1B;
  29. #ifdef CONFIG_ZYNQ_HISPD_BROKEN
  30. host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
  31. #endif
  32. host->max_clk = CONFIG_ZYNQ_SDHCI_MAX_FREQ;
  33. ret = sdhci_setup_cfg(&plat->cfg, host, 0,
  34. CONFIG_ZYNQ_SDHCI_MIN_FREQ);
  35. host->mmc = &plat->mmc;
  36. if (ret)
  37. return ret;
  38. host->mmc->priv = host;
  39. host->mmc->dev = dev;
  40. upriv->mmc = host->mmc;
  41. return sdhci_probe(dev);
  42. }
  43. static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
  44. {
  45. struct sdhci_host *host = dev_get_priv(dev);
  46. host->name = dev->name;
  47. host->ioaddr = (void *)dev_get_addr(dev);
  48. return 0;
  49. }
  50. static int arasan_sdhci_bind(struct udevice *dev)
  51. {
  52. struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
  53. return sdhci_bind(dev, &plat->mmc, &plat->cfg);
  54. }
  55. static const struct udevice_id arasan_sdhci_ids[] = {
  56. { .compatible = "arasan,sdhci-8.9a" },
  57. { }
  58. };
  59. U_BOOT_DRIVER(arasan_sdhci_drv) = {
  60. .name = "arasan_sdhci",
  61. .id = UCLASS_MMC,
  62. .of_match = arasan_sdhci_ids,
  63. .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
  64. .ops = &sdhci_ops,
  65. .bind = arasan_sdhci_bind,
  66. .probe = arasan_sdhci_probe,
  67. .priv_auto_alloc_size = sizeof(struct sdhci_host),
  68. .platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat),
  69. };