host.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/drivers/mmc/core/host.h
  4. *
  5. * Copyright (C) 2003 Russell King, All Rights Reserved.
  6. * Copyright 2007 Pierre Ossman
  7. */
  8. #ifndef _MMC_CORE_HOST_H
  9. #define _MMC_CORE_HOST_H
  10. #include <linux/mmc/host.h>
  11. int mmc_register_host_class(void);
  12. void mmc_unregister_host_class(void);
  13. void mmc_retune_enable(struct mmc_host *host);
  14. void mmc_retune_disable(struct mmc_host *host);
  15. void mmc_retune_hold(struct mmc_host *host);
  16. void mmc_retune_release(struct mmc_host *host);
  17. int mmc_retune(struct mmc_host *host);
  18. void mmc_retune_pause(struct mmc_host *host);
  19. void mmc_retune_unpause(struct mmc_host *host);
  20. static inline void mmc_retune_clear(struct mmc_host *host)
  21. {
  22. host->retune_now = 0;
  23. host->need_retune = 0;
  24. }
  25. static inline void mmc_retune_hold_now(struct mmc_host *host)
  26. {
  27. host->retune_now = 0;
  28. host->hold_retune += 1;
  29. }
  30. static inline void mmc_retune_recheck(struct mmc_host *host)
  31. {
  32. if (host->hold_retune <= 1)
  33. host->retune_now = 1;
  34. }
  35. static inline int mmc_host_cmd23(struct mmc_host *host)
  36. {
  37. return host->caps & MMC_CAP_CMD23;
  38. }
  39. static inline bool mmc_host_done_complete(struct mmc_host *host)
  40. {
  41. return host->caps & MMC_CAP_DONE_COMPLETE;
  42. }
  43. static inline int mmc_boot_partition_access(struct mmc_host *host)
  44. {
  45. return !(host->caps2 & MMC_CAP2_BOOTPART_NOACC);
  46. }
  47. static inline int mmc_host_uhs(struct mmc_host *host)
  48. {
  49. return host->caps &
  50. (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
  51. MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 |
  52. MMC_CAP_UHS_DDR50) &&
  53. host->caps & MMC_CAP_4_BIT_DATA;
  54. }
  55. static inline bool mmc_card_hs200(struct mmc_card *card)
  56. {
  57. return card->host->ios.timing == MMC_TIMING_MMC_HS200;
  58. }
  59. static inline bool mmc_card_ddr52(struct mmc_card *card)
  60. {
  61. return card->host->ios.timing == MMC_TIMING_MMC_DDR52;
  62. }
  63. static inline bool mmc_card_hs400(struct mmc_card *card)
  64. {
  65. return card->host->ios.timing == MMC_TIMING_MMC_HS400;
  66. }
  67. static inline bool mmc_card_hs400es(struct mmc_card *card)
  68. {
  69. return card->host->ios.enhanced_strobe;
  70. }
  71. static inline bool mmc_card_sd_express(struct mmc_host *host)
  72. {
  73. return host->ios.timing == MMC_TIMING_SD_EXP ||
  74. host->ios.timing == MMC_TIMING_SD_EXP_1_2V;
  75. }
  76. #endif