mmc_private.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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_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. #if CONFIG_IS_ENABLED(BLK)
  16. ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
  17. void *dst);
  18. #else
  19. ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
  20. void *dst);
  21. #endif
  22. #if CONFIG_IS_ENABLED(MMC_WRITE)
  23. #if CONFIG_IS_ENABLED(BLK)
  24. ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
  25. const void *src);
  26. ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
  27. #else
  28. ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
  29. const void *src);
  30. ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
  31. #endif
  32. #else /* CONFIG_SPL_MMC_WRITE is not defined */
  33. /* declare dummies to reduce code size. */
  34. #if CONFIG_IS_ENABLED(BLK)
  35. static inline unsigned long mmc_berase(struct udevice *dev,
  36. lbaint_t start, lbaint_t blkcnt)
  37. {
  38. return 0;
  39. }
  40. static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
  41. lbaint_t blkcnt, const void *src)
  42. {
  43. return 0;
  44. }
  45. #else
  46. static inline unsigned long mmc_berase(struct blk_desc *block_dev,
  47. lbaint_t start, lbaint_t blkcnt)
  48. {
  49. return 0;
  50. }
  51. static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
  52. lbaint_t blkcnt, const void *src)
  53. {
  54. return 0;
  55. }
  56. #endif
  57. #endif /* CONFIG_SPL_BUILD */
  58. #ifdef CONFIG_MMC_TRACE
  59. void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
  60. void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
  61. void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
  62. #else
  63. static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
  64. {
  65. }
  66. static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
  67. int ret)
  68. {
  69. }
  70. static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
  71. {
  72. }
  73. #endif
  74. /**
  75. * mmc_get_next_devnum() - Get the next available MMC device number
  76. *
  77. * @return next available device number (0 = first), or -ve on error
  78. */
  79. int mmc_get_next_devnum(void);
  80. /**
  81. * mmc_do_preinit() - Get an MMC device ready for use
  82. */
  83. void mmc_do_preinit(void);
  84. /**
  85. * mmc_list_init() - Set up the list of MMC devices
  86. */
  87. void mmc_list_init(void);
  88. /**
  89. * mmc_list_add() - Add a new MMC device to the list of devices
  90. *
  91. * @mmc: Device to add
  92. */
  93. void mmc_list_add(struct mmc *mmc);
  94. /**
  95. * mmc_switch_part() - Switch to a new MMC hardware partition
  96. *
  97. * @mmc: MMC device
  98. * @part_num: Hardware partition number
  99. * @return 0 if OK, -ve on error
  100. */
  101. int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
  102. /**
  103. * mmc_switch() - Issue and MMC switch mode command
  104. *
  105. * @mmc: MMC device
  106. * @set: Unused
  107. * @index: Cmdarg index
  108. * @value: Cmdarg value
  109. * @return 0 if OK, -ve on error
  110. */
  111. int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
  112. #endif /* _MMC_PRIVATE_H_ */