mmc_private.h 3.3 KB

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