1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2008,2010 Freescale Semiconductor, Inc
7 * Based (loosely) on the Linux code
10 #ifndef _MMC_PRIVATE_H_
11 #define _MMC_PRIVATE_H_
15 int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data);
16 int mmc_send_status(struct mmc *mmc, unsigned int *status);
17 int mmc_poll_for_busy(struct mmc *mmc, int timeout);
19 int mmc_set_blocklen(struct mmc *mmc, int len);
21 #if CONFIG_IS_ENABLED(BLK)
22 ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
25 ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
29 #if CONFIG_IS_ENABLED(MMC_WRITE)
31 #if CONFIG_IS_ENABLED(BLK)
32 ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
34 ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
36 ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
38 ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
41 #else /* CONFIG_SPL_MMC_WRITE is not defined */
43 /* declare dummies to reduce code size. */
45 #if CONFIG_IS_ENABLED(BLK)
46 static inline unsigned long mmc_berase(struct udevice *dev,
47 lbaint_t start, lbaint_t blkcnt)
52 static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
53 lbaint_t blkcnt, const void *src)
58 static inline unsigned long mmc_berase(struct blk_desc *block_dev,
59 lbaint_t start, lbaint_t blkcnt)
64 static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
65 lbaint_t blkcnt, const void *src)
71 #endif /* CONFIG_SPL_BUILD */
73 #ifdef CONFIG_MMC_TRACE
74 void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
75 void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
76 void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
78 static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
82 static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
87 static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
93 * mmc_get_next_devnum() - Get the next available MMC device number
95 * @return next available device number (0 = first), or -ve on error
97 int mmc_get_next_devnum(void);
100 * mmc_do_preinit() - Get an MMC device ready for use
102 void mmc_do_preinit(void);
105 * mmc_list_init() - Set up the list of MMC devices
107 void mmc_list_init(void);
110 * mmc_list_add() - Add a new MMC device to the list of devices
112 * @mmc: Device to add
114 void mmc_list_add(struct mmc *mmc);
117 * mmc_switch_part() - Switch to a new MMC hardware partition
120 * @part_num: Hardware partition number
121 * @return 0 if OK, -ve on error
123 int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
126 * mmc_switch() - Issue and MMC switch mode command
130 * @index: Cmdarg index
131 * @value: Cmdarg value
132 * @return 0 if OK, -ve on error
134 int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
136 #endif /* _MMC_PRIVATE_H_ */