summaryrefslogtreecommitdiff
path: root/drivers/mmc/mmc_private.h
blob: a6cd250d2935f87792adce0290f9a17f67cac3b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright 2008,2010 Freescale Semiconductor, Inc
 * Copyright 2020 NXP
 * Andy Fleming
 *
 * Based (loosely) on the Linux code
 */

#ifndef _MMC_PRIVATE_H_
#define _MMC_PRIVATE_H_

#include <mmc.h>

int mmc_send_status(struct mmc *mmc, unsigned int *status);
int mmc_poll_for_busy(struct mmc *mmc, int timeout);

int mmc_set_blocklen(struct mmc *mmc, int len);

#if CONFIG_IS_ENABLED(BLK)
ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
		void *dst);
#else
ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
		void *dst);
#endif

#if CONFIG_IS_ENABLED(MMC_WRITE)

#if CONFIG_IS_ENABLED(BLK)
ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt,
		 const void *src);
ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
#else
ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
		 const void *src);
ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt);
#endif

#else /* CONFIG_SPL_MMC_WRITE is not defined */

/* declare dummies to reduce code size. */

#if CONFIG_IS_ENABLED(BLK)
static inline unsigned long mmc_berase(struct udevice *dev,
				       lbaint_t start, lbaint_t blkcnt)
{
	return 0;
}

static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start,
			       lbaint_t blkcnt, const void *src)
{
	return 0;
}
#else
static inline unsigned long mmc_berase(struct blk_desc *block_dev,
				       lbaint_t start, lbaint_t blkcnt)
{
	return 0;
}

static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,
			       lbaint_t blkcnt, const void *src)
{
	return 0;
}
#endif

#endif /* CONFIG_SPL_BUILD */

#ifdef CONFIG_MMC_TRACE
void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd);
void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret);
void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd);
#else
static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd)
{
}

static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd,
					 int ret)
{
}

static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd)
{
}
#endif

/**
 * mmc_get_next_devnum() - Get the next available MMC device number
 *
 * @return next available device number (0 = first), or -ve on error
 */
int mmc_get_next_devnum(void);

/**
 * mmc_do_preinit() - Get an MMC device ready for use
 */
void mmc_do_preinit(void);

/**
 * mmc_list_init() - Set up the list of MMC devices
 */
void mmc_list_init(void);

/**
 * mmc_list_add() - Add a new MMC device to the list of devices
 *
 * @mmc:	Device to add
 */
void mmc_list_add(struct mmc *mmc);

/**
 * mmc_switch_part() - Switch to a new MMC hardware partition
 *
 * @mmc:	MMC device
 * @part_num:	Hardware partition number
 * @return 0 if OK, -ve on error
 */
int mmc_switch_part(struct mmc *mmc, unsigned int part_num);

/**
 * mmc_switch() - Issue and MMC switch mode command
 *
 * @mmc:	MMC device
 * @set:	Unused
 * @index:	Cmdarg index
 * @value:	Cmdarg value
 * @return 0 if OK, -ve on error
 */
int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value);

#endif /* _MMC_PRIVATE_H_ */