blob: f49b6eb573c000be3d600c38a087ffdfd7b26fc9 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Paul Burtonda61fa52013-09-09 15:30:26 +01002/*
3 * Copyright 2008,2010 Freescale Semiconductor, Inc
4 * Andy Fleming
5 *
6 * Based (loosely) on the Linux code
Paul Burtonda61fa52013-09-09 15:30:26 +01007 */
8
9#ifndef _MMC_PRIVATE_H_
10#define _MMC_PRIVATE_H_
11
12#include <mmc.h>
13
14extern int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
15 struct mmc_data *data);
16extern int mmc_send_status(struct mmc *mmc, int timeout);
17extern int mmc_set_blocklen(struct mmc *mmc, int len);
Yangbo Lu5a8dbdc2015-04-22 13:57:00 +080018#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
19void mmc_adapter_card_type_ident(void);
20#endif
Paul Burtonda61fa52013-09-09 15:30:26 +010021
Simon Glassc4d660d2017-07-04 13:31:19 -060022#if CONFIG_IS_ENABLED(BLK)
Simon Glass7dba0b92016-06-12 23:30:15 -060023ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
24 void *dst);
25#else
26ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
27 void *dst);
28#endif
29
Jean-Jacques Hiblotd6400c32018-01-04 15:23:32 +010030#if CONFIG_IS_ENABLED(MMC_WRITE)
Paul Burtonda61fa52013-09-09 15:30:26 +010031
Simon Glassc4d660d2017-07-04 13:31:19 -060032#if CONFIG_IS_ENABLED(BLK)
Simon Glass33fb2112016-05-01 13:52:41 -060033ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
34 const void *src);
Simon Glass561e6242016-10-01 14:43:17 -060035ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
Simon Glass33fb2112016-05-01 13:52:41 -060036#else
37ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
38 const void *src);
Simon Glass561e6242016-10-01 14:43:17 -060039ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
Simon Glass33fb2112016-05-01 13:52:41 -060040#endif
Paul Burtonda61fa52013-09-09 15:30:26 +010041
Jean-Jacques Hiblotd6400c32018-01-04 15:23:32 +010042#else /* CONFIG_SPL_MMC_WRITE is not defined */
Paul Burtonda61fa52013-09-09 15:30:26 +010043
B, Ravid2d9bdf2016-09-28 14:46:18 +053044/* declare dummies to reduce code size. */
Paul Burtonda61fa52013-09-09 15:30:26 +010045
Simon Glassc4d660d2017-07-04 13:31:19 -060046#if CONFIG_IS_ENABLED(BLK)
Simon Glasse419a3e2016-05-14 14:03:09 -060047static inline unsigned long mmc_berase(struct udevice *dev,
48 lbaint_t start, lbaint_t blkcnt)
49{
50 return 0;
51}
52
53static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
54 lbaint_t blkcnt, const void *src)
55{
56 return 0;
57}
58#else
Simon Glass4101f682016-02-29 15:25:34 -070059static inline unsigned long mmc_berase(struct blk_desc *block_dev,
Stephen Warren7c4213f2015-12-07 11:38:48 -070060 lbaint_t start, lbaint_t blkcnt)
Paul Burtonda61fa52013-09-09 15:30:26 +010061{
62 return 0;
63}
64
Simon Glass4101f682016-02-29 15:25:34 -070065static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
Stephen Warren7c4213f2015-12-07 11:38:48 -070066 lbaint_t blkcnt, const void *src)
Paul Burtonda61fa52013-09-09 15:30:26 +010067{
68 return 0;
69}
Simon Glasse419a3e2016-05-14 14:03:09 -060070#endif
Paul Burtonda61fa52013-09-09 15:30:26 +010071
72#endif /* CONFIG_SPL_BUILD */
73
Simon Glassc0c76eb2016-06-12 23:30:20 -060074#ifdef CONFIG_MMC_TRACE
75void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
76void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
77void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
78#else
79static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
80{
81}
82
83static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
84 int ret)
85{
86}
87
88static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
89{
90}
91#endif
92
Simon Glassc40fdca2016-05-01 13:52:35 -060093/**
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 */
98int mmc_get_next_devnum(void);
99
100/**
101 * mmc_do_preinit() - Get an MMC device ready for use
102 */
103void mmc_do_preinit(void);
104
105/**
106 * mmc_list_init() - Set up the list of MMC devices
107 */
108void 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 */
115void mmc_list_add(struct mmc *mmc);
116
Simon Glass7dba0b92016-06-12 23:30:15 -0600117/**
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 */
124int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
125
Simon Glassc40704f2016-06-12 23:30:18 -0600126/**
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 */
135int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
136
Paul Burtonda61fa52013-09-09 15:30:26 +0100137#endif /* _MMC_PRIVATE_H_ */