mmc_private.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2008,2010 Freescale Semiconductor, Inc
  4. * Andy Fleming
  5. *
  6. * Based (loosely) on the Linux code
  7. */
  8. #ifndef _MMC_PRIVATE_H_
  9. #define _MMC_PRIVATE_H_
  10. #include <mmc.h>
  11. int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data);
  12. int mmc_send_status(struct mmc *mmc, unsigned int *status);
  13. int mmc_poll_for_busy(struct mmc *mmc, int timeout);
  14. int mmc_set_blocklen(struct mmc *mmc, int len);
  15. #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
  16. void mmc_adapter_card_type_ident(void);
  17. #endif
  18. #if CONFIG_IS_ENABLED(BLK)
  19. ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
  20. void *dst);
  21. #else
  22. ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
  23. void *dst);
  24. #endif
  25. #if CONFIG_IS_ENABLED(MMC_WRITE)
  26. #if CONFIG_IS_ENABLED(BLK)
  27. ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
  28. const void *src);
  29. ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
  30. #else
  31. ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
  32. const void *src);
  33. ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
  34. #endif
  35. #else /* CONFIG_SPL_MMC_WRITE is not defined */
  36. /* declare dummies to reduce code size. */
  37. #if CONFIG_IS_ENABLED(BLK)
  38. static inline unsigned long mmc_berase(struct udevice *dev,
  39. lbaint_t start, lbaint_t blkcnt)
  40. {
  41. return 0;
  42. }
  43. static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
  44. lbaint_t blkcnt, const void *src)
  45. {
  46. return 0;
  47. }
  48. #else
  49. static inline unsigned long mmc_berase(struct blk_desc *block_dev,
  50. lbaint_t start, lbaint_t blkcnt)
  51. {
  52. return 0;
  53. }
  54. static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
  55. lbaint_t blkcnt, const void *src)
  56. {
  57. return 0;
  58. }
  59. #endif
  60. #endif /* CONFIG_SPL_BUILD */
  61. #ifdef CONFIG_MMC_TRACE
  62. void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
  63. void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
  64. void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
  65. #else
  66. static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
  67. {
  68. }
  69. static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
  70. int ret)
  71. {
  72. }
  73. static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
  74. {
  75. }
  76. #endif
  77. /**
  78. * mmc_get_next_devnum() - Get the next available MMC device number
  79. *
  80. * @return next available device number (0 = first), or -ve on error
  81. */
  82. int mmc_get_next_devnum(void);
  83. /**
  84. * mmc_do_preinit() - Get an MMC device ready for use
  85. */
  86. void mmc_do_preinit(void);
  87. /**
  88. * mmc_list_init() - Set up the list of MMC devices
  89. */
  90. void mmc_list_init(void);
  91. /**
  92. * mmc_list_add() - Add a new MMC device to the list of devices
  93. *
  94. * @mmc: Device to add
  95. */
  96. void mmc_list_add(struct mmc *mmc);
  97. /**
  98. * mmc_switch_part() - Switch to a new MMC hardware partition
  99. *
  100. * @mmc: MMC device
  101. * @part_num: Hardware partition number
  102. * @return 0 if OK, -ve on error
  103. */
  104. int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
  105. /**
  106. * mmc_switch() - Issue and MMC switch mode command
  107. *
  108. * @mmc: MMC device
  109. * @set: Unused
  110. * @index: Cmdarg index
  111. * @value: Cmdarg value
  112. * @return 0 if OK, -ve on error
  113. */
  114. int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
  115. #endif /* _MMC_PRIVATE_H_ */