1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2008,2010 Freescale Semiconductor, Inc
6 * Based (loosely) on the Linux code
9 #ifndef _MMC_PRIVATE_H_
10 #define _MMC_PRIVATE_H_
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);
22 #if CONFIG_IS_ENABLED(BLK)
23 ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
26 ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
30 #if CONFIG_IS_ENABLED(MMC_WRITE)
32 #if CONFIG_IS_ENABLED(BLK)
33 ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
35 ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
37 ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
39 ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
42 #else /* CONFIG_SPL_MMC_WRITE is not defined */
44 /* declare dummies to reduce code size. */
46 #if CONFIG_IS_ENABLED(BLK)
47 static inline unsigned long mmc_berase(struct udevice *dev,
48 lbaint_t start, lbaint_t blkcnt)
53 static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
54 lbaint_t blkcnt, const void *src)
59 static inline unsigned long mmc_berase(struct blk_desc *block_dev,
60 lbaint_t start, lbaint_t blkcnt)
65 static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
66 lbaint_t blkcnt, const void *src)
72 #endif /* CONFIG_SPL_BUILD */
74 #ifdef CONFIG_MMC_TRACE
75 void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
76 void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
77 void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
79 static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
83 static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
88 static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
94 * mmc_get_next_devnum() - Get the next available MMC device number
96 * @return next available device number (0 = first), or -ve on error
98 int mmc_get_next_devnum(void);
101 * mmc_do_preinit() - Get an MMC device ready for use
103 void mmc_do_preinit(void);
106 * mmc_list_init() - Set up the list of MMC devices
108 void mmc_list_init(void);
111 * mmc_list_add() - Add a new MMC device to the list of devices
113 * @mmc: Device to add
115 void mmc_list_add(struct mmc *mmc);
118 * mmc_switch_part() - Switch to a new MMC hardware partition
121 * @part_num: Hardware partition number
122 * @return 0 if OK, -ve on error
124 int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
127 * mmc_switch() - Issue and MMC switch mode command
131 * @index: Cmdarg index
132 * @value: Cmdarg value
133 * @return 0 if OK, -ve on error
135 int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
137 #endif /* _MMC_PRIVATE_H_ */