mmc_private.h 3.2 KB

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