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