blob: 49ec022a9e9cd96ebaf9404a3de1959c4dfb245d [file] [log] [blame]
Paul Burton8d30cc92013-09-09 15:30:26 +01001/*
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
15extern int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
16 struct mmc_data *data);
17extern int mmc_send_status(struct mmc *mmc, int timeout);
18extern int mmc_set_blocklen(struct mmc *mmc, int len);
Yangbo Lub124f8a2015-04-22 13:57:00 +080019#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
20void mmc_adapter_card_type_ident(void);
21#endif
Paul Burton8d30cc92013-09-09 15:30:26 +010022
Simon Glass62e293a2016-06-12 23:30:15 -060023#ifdef CONFIG_BLK
24ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
25 void *dst);
26#else
27ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
28 void *dst);
29#endif
30
Paul Burton8d30cc92013-09-09 15:30:26 +010031#ifndef CONFIG_SPL_BUILD
32
Simon Glasse3394752016-02-29 15:25:34 -070033unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
Stephen Warrene73f2962015-12-07 11:38:48 -070034 lbaint_t blkcnt);
Paul Burton8d30cc92013-09-09 15:30:26 +010035
Simon Glass59bc6f22016-05-01 13:52:41 -060036#ifdef CONFIG_BLK
37ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
38 const void *src);
39#else
40ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
41 const void *src);
42#endif
Paul Burton8d30cc92013-09-09 15:30:26 +010043
44#else /* CONFIG_SPL_BUILD */
45
46/* SPL will never write or erase, declare dummies to reduce code size. */
47
Simon Glass9f72e372016-05-14 14:03:09 -060048#ifdef CONFIG_BLK
49static inline unsigned long mmc_berase(struct udevice *dev,
50 lbaint_t start, lbaint_t blkcnt)
51{
52 return 0;
53}
54
55static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
56 lbaint_t blkcnt, const void *src)
57{
58 return 0;
59}
60#else
Simon Glasse3394752016-02-29 15:25:34 -070061static inline unsigned long mmc_berase(struct blk_desc *block_dev,
Stephen Warrene73f2962015-12-07 11:38:48 -070062 lbaint_t start, lbaint_t blkcnt)
Paul Burton8d30cc92013-09-09 15:30:26 +010063{
64 return 0;
65}
66
Simon Glasse3394752016-02-29 15:25:34 -070067static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
Stephen Warrene73f2962015-12-07 11:38:48 -070068 lbaint_t blkcnt, const void *src)
Paul Burton8d30cc92013-09-09 15:30:26 +010069{
70 return 0;
71}
Simon Glass9f72e372016-05-14 14:03:09 -060072#endif
Paul Burton8d30cc92013-09-09 15:30:26 +010073
74#endif /* CONFIG_SPL_BUILD */
75
Simon Glassb23d96e2016-06-12 23:30:20 -060076#ifdef CONFIG_MMC_TRACE
77void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
78void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
79void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
80#else
81static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
82{
83}
84
85static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
86 int ret)
87{
88}
89
90static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
91{
92}
93#endif
94
Simon Glasse5db1152016-05-01 13:52:35 -060095/**
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 */
100int mmc_get_next_devnum(void);
101
102/**
103 * mmc_do_preinit() - Get an MMC device ready for use
104 */
105void mmc_do_preinit(void);
106
107/**
108 * mmc_list_init() - Set up the list of MMC devices
109 */
110void 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 */
117void mmc_list_add(struct mmc *mmc);
118
Simon Glass62e293a2016-06-12 23:30:15 -0600119/**
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 */
126int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
127
Simon Glass84f9df92016-06-12 23:30:18 -0600128/**
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 */
137int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
138
Paul Burton8d30cc92013-09-09 15:30:26 +0100139#endif /* _MMC_PRIVATE_H_ */