zynq_sdhci.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. ret = sdhci_setup_cfg(&plat->cfg, host, CONFIG_ZYNQ_SDHCI_MAX_FREQ,
  33. CONFIG_ZYNQ_SDHCI_MIN_FREQ);
  34. host->mmc = &plat->mmc;
  35. if (ret)
  36. return ret;
  37. host->mmc->priv = host;
  38. host->mmc->dev = dev;
  39. upriv->mmc = host->mmc;
  40. return sdhci_probe(dev);
  41. }
  42. static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)
  43. {
  44. struct sdhci_host *host = dev_get_priv(dev);
  45. host->name = dev->name;
  46. host->ioaddr = (void *)dev_get_addr(dev);
  47. return 0;
  48. }
  49. static int arasan_sdhci_bind(struct udevice *dev)
  50. {
  51. struct arasan_sdhci_plat *plat = dev_get_platdata(dev);
  52. return sdhci_bind(dev, &plat->mmc, &plat->cfg);
  53. }
  54. static const struct udevice_id arasan_sdhci_ids[] = {
  55. { .compatible = "arasan,sdhci-8.9a" },
  56. { }
  57. };
  58. U_BOOT_DRIVER(arasan_sdhci_drv) = {
  59. .name = "arasan_sdhci",
  60. .id = UCLASS_MMC,
  61. .of_match = arasan_sdhci_ids,
  62. .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata,
  63. .ops = &sdhci_ops,
  64. .bind = arasan_sdhci_bind,
  65. .probe = arasan_sdhci_probe,
  66. .priv_auto_alloc_size = sizeof(struct sdhci_host),
  67. .platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat),
  68. };