mmc_private.h 3.4 KB

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