blob: 49ec022a9e9cd96ebaf9404a3de1959c4dfb245d [file] [log] [blame]
Paul Burtonda61fa52013-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 Lu5a8dbdc2015-04-22 13:57:00 +080019#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
20void mmc_adapter_card_type_ident(void);
21#endif
Paul Burtonda61fa52013-09-09 15:30:26 +010022
Simon Glass7dba0b92016-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 Burtonda61fa52013-09-09 15:30:26 +010031#ifndef CONFIG_SPL_BUILD
32
Simon Glass4101f682016-02-29 15:25:34 -070033unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
Stephen Warren7c4213f2015-12-07 11:38:48 -070034 lbaint_t blkcnt);
Paul Burtonda61fa52013-09-09 15:30:26 +010035
Simon Glass33fb2112016-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 Burtonda61fa52013-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 Glasse419a3e2016-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 Glass4101f682016-02-29 15:25:34 -070061static inline unsigned long mmc_berase(struct blk_desc *block_dev,
Stephen Warren7c4213f2015-12-07 11:38:48 -070062 lbaint_t start, lbaint_t blkcnt)
Paul Burtonda61fa52013-09-09 15:30:26 +010063{
64 return 0;
65}
66
Simon Glass4101f682016-02-29 15:25:34 -070067static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
Stephen Warren7c4213f2015-12-07 11:38:48 -070068 lbaint_t blkcnt, const void *src)
Paul Burtonda61fa52013-09-09 15:30:26 +010069{
70 return 0;
71}
Simon Glasse419a3e2016-05-14 14:03:09 -060072#endif
Paul Burtonda61fa52013-09-09 15:30:26 +010073
74#endif /* CONFIG_SPL_BUILD */
75
Simon Glassc0c76eb2016-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 Glassc40fdca2016-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 Glass7dba0b92016-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 Glassc40704f2016-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 Burtonda61fa52013-09-09 15:30:26 +0100139#endif /* _MMC_PRIVATE_H_ */