xref: /openbmc/u-boot/drivers/mmc/mmc_private.h (revision 57efeb04)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2008,2010 Freescale Semiconductor, Inc
4  * Andy Fleming
5  *
6  * Based (loosely) on the Linux code
7  */
8 
9 #ifndef _MMC_PRIVATE_H_
10 #define _MMC_PRIVATE_H_
11 
12 #include <mmc.h>
13 
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 
22 #if CONFIG_IS_ENABLED(BLK)
23 ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
24 		void *dst);
25 #else
26 ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
27 		void *dst);
28 #endif
29 
30 #if CONFIG_IS_ENABLED(MMC_WRITE)
31 
32 #if CONFIG_IS_ENABLED(BLK)
33 ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
34 		 const void *src);
35 ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
36 #else
37 ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
38 		 const void *src);
39 ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
40 #endif
41 
42 #else /* CONFIG_SPL_MMC_WRITE is not defined */
43 
44 /* declare dummies to reduce code size. */
45 
46 #if CONFIG_IS_ENABLED(BLK)
47 static inline unsigned long mmc_berase(struct udevice *dev,
48 				       lbaint_t start, lbaint_t blkcnt)
49 {
50 	return 0;
51 }
52 
53 static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
54 			       lbaint_t blkcnt, const void *src)
55 {
56 	return 0;
57 }
58 #else
59 static inline unsigned long mmc_berase(struct blk_desc *block_dev,
60 				       lbaint_t start, lbaint_t blkcnt)
61 {
62 	return 0;
63 }
64 
65 static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
66 			       lbaint_t blkcnt, const void *src)
67 {
68 	return 0;
69 }
70 #endif
71 
72 #endif /* CONFIG_SPL_BUILD */
73 
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);
78 #else
79 static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
80 {
81 }
82 
83 static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
84 					 int ret)
85 {
86 }
87 
88 static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
89 {
90 }
91 #endif
92 
93 /**
94  * mmc_get_next_devnum() - Get the next available MMC device number
95  *
96  * @return next available device number (0 = first), or -ve on error
97  */
98 int mmc_get_next_devnum(void);
99 
100 /**
101  * mmc_do_preinit() - Get an MMC device ready for use
102  */
103 void mmc_do_preinit(void);
104 
105 /**
106  * mmc_list_init() - Set up the list of MMC devices
107  */
108 void mmc_list_init(void);
109 
110 /**
111  * mmc_list_add() - Add a new MMC device to the list of devices
112  *
113  * @mmc:	Device to add
114  */
115 void mmc_list_add(struct mmc *mmc);
116 
117 /**
118  * mmc_switch_part() - Switch to a new MMC hardware partition
119  *
120  * @mmc:	MMC device
121  * @part_num:	Hardware partition number
122  * @return 0 if OK, -ve on error
123  */
124 int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
125 
126 /**
127  * mmc_switch() - Issue and MMC switch mode command
128  *
129  * @mmc:	MMC device
130  * @set:	Unused
131  * @index:	Cmdarg index
132  * @value:	Cmdarg value
133  * @return 0 if OK, -ve on error
134  */
135 int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
136 
137 #endif /* _MMC_PRIVATE_H_ */
138