blob: a6cd250d2935f87792adce0290f9a17f67cac3b7 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Paul Burton8d30cc92013-09-09 15:30:26 +01002/*
3 * Copyright 2008,2010 Freescale Semiconductor, Inc
Yangbo Luf9049b22020-06-17 18:08:58 +08004 * Copyright 2020 NXP
Paul Burton8d30cc92013-09-09 15:30:26 +01005 * Andy Fleming
6 *
7 * Based (loosely) on the Linux code
Paul Burton8d30cc92013-09-09 15:30:26 +01008 */
9
10#ifndef _MMC_PRIVATE_H_
11#define _MMC_PRIVATE_H_
12
13#include <mmc.h>
14
Jean-Jacques Hiblot443edbe2019-07-02 10:53:52 +020015int mmc_send_status(struct mmc *mmc, unsigned int *status);
16int mmc_poll_for_busy(struct mmc *mmc, int timeout);
17
18int mmc_set_blocklen(struct mmc *mmc, int len);
Paul Burton8d30cc92013-09-09 15:30:26 +010019
Simon Glass5f4bd8c2017-07-04 13:31:19 -060020#if CONFIG_IS_ENABLED(BLK)
Simon Glass62e293a2016-06-12 23:30:15 -060021ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
22 void *dst);
23#else
24ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
25 void *dst);
26#endif
27
Jean-Jacques Hiblotd0531672018-01-04 15:23:32 +010028#if CONFIG_IS_ENABLED(MMC_WRITE)
Paul Burton8d30cc92013-09-09 15:30:26 +010029
Simon Glass5f4bd8c2017-07-04 13:31:19 -060030#if CONFIG_IS_ENABLED(BLK)
Simon Glass59bc6f22016-05-01 13:52:41 -060031ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
32 const void *src);
Simon Glassfcc53c12016-10-01 14:43:17 -060033ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
Simon Glass59bc6f22016-05-01 13:52:41 -060034#else
35ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
36 const void *src);
Simon Glassfcc53c12016-10-01 14:43:17 -060037ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
Simon Glass59bc6f22016-05-01 13:52:41 -060038#endif
Paul Burton8d30cc92013-09-09 15:30:26 +010039
Jean-Jacques Hiblotd0531672018-01-04 15:23:32 +010040#else /* CONFIG_SPL_MMC_WRITE is not defined */
Paul Burton8d30cc92013-09-09 15:30:26 +010041
B, Ravie94b0242016-09-28 14:46:18 +053042/* declare dummies to reduce code size. */
Paul Burton8d30cc92013-09-09 15:30:26 +010043
Simon Glass5f4bd8c2017-07-04 13:31:19 -060044#if CONFIG_IS_ENABLED(BLK)
Simon Glass9f72e372016-05-14 14:03:09 -060045static inline unsigned long mmc_berase(struct udevice *dev,
46 lbaint_t start, lbaint_t blkcnt)
47{
48 return 0;
49}
50
51static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
52 lbaint_t blkcnt, const void *src)
53{
54 return 0;
55}
56#else
Simon Glasse3394752016-02-29 15:25:34 -070057static inline unsigned long mmc_berase(struct blk_desc *block_dev,
Stephen Warrene73f2962015-12-07 11:38:48 -070058 lbaint_t start, lbaint_t blkcnt)
Paul Burton8d30cc92013-09-09 15:30:26 +010059{
60 return 0;
61}
62
Simon Glasse3394752016-02-29 15:25:34 -070063static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
Stephen Warrene73f2962015-12-07 11:38:48 -070064 lbaint_t blkcnt, const void *src)
Paul Burton8d30cc92013-09-09 15:30:26 +010065{
66 return 0;
67}
Simon Glass9f72e372016-05-14 14:03:09 -060068#endif
Paul Burton8d30cc92013-09-09 15:30:26 +010069
70#endif /* CONFIG_SPL_BUILD */
71
Simon Glassb23d96e2016-06-12 23:30:20 -060072#ifdef CONFIG_MMC_TRACE
73void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
74void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
75void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
76#else
77static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
78{
79}
80
81static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
82 int ret)
83{
84}
85
86static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
87{
88}
89#endif
90
Simon Glasse5db1152016-05-01 13:52:35 -060091/**
92 * mmc_get_next_devnum() - Get the next available MMC device number
93 *
94 * @return next available device number (0 = first), or -ve on error
95 */
96int mmc_get_next_devnum(void);
97
98/**
99 * mmc_do_preinit() - Get an MMC device ready for use
100 */
101void mmc_do_preinit(void);
102
103/**
104 * mmc_list_init() - Set up the list of MMC devices
105 */
106void mmc_list_init(void);
107
108/**
109 * mmc_list_add() - Add a new MMC device to the list of devices
110 *
111 * @mmc: Device to add
112 */
113void mmc_list_add(struct mmc *mmc);
114
Simon Glass62e293a2016-06-12 23:30:15 -0600115/**
116 * mmc_switch_part() - Switch to a new MMC hardware partition
117 *
118 * @mmc: MMC device
119 * @part_num: Hardware partition number
120 * @return 0 if OK, -ve on error
121 */
122int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
123
Simon Glass84f9df92016-06-12 23:30:18 -0600124/**
125 * mmc_switch() - Issue and MMC switch mode command
126 *
127 * @mmc: MMC device
128 * @set: Unused
129 * @index: Cmdarg index
130 * @value: Cmdarg value
131 * @return 0 if OK, -ve on error
132 */
133int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);
134
Paul Burton8d30cc92013-09-09 15:30:26 +0100135#endif /* _MMC_PRIVATE_H_ */