blob: cfc4aca18d32c84efcb8fe8c3809201b6ec0d457 [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 Glassc40fdca2016-05-01 13:52:35 -060076/**
77 * mmc_get_next_devnum() - Get the next available MMC device number
78 *
79 * @return next available device number (0 = first), or -ve on error
80 */
81int mmc_get_next_devnum(void);
82
83/**
84 * mmc_do_preinit() - Get an MMC device ready for use
85 */
86void mmc_do_preinit(void);
87
88/**
89 * mmc_list_init() - Set up the list of MMC devices
90 */
91void mmc_list_init(void);
92
93/**
94 * mmc_list_add() - Add a new MMC device to the list of devices
95 *
96 * @mmc: Device to add
97 */
98void mmc_list_add(struct mmc *mmc);
99
Simon Glass7dba0b92016-06-12 23:30:15 -0600100/**
101 * mmc_switch_part() - Switch to a new MMC hardware partition
102 *
103 * @mmc: MMC device
104 * @part_num: Hardware partition number
105 * @return 0 if OK, -ve on error
106 */
107int mmc_switch_part(struct mmc *mmc, unsigned int part_num);
108
Paul Burtonda61fa52013-09-09 15:30:26 +0100109#endif /* _MMC_PRIVATE_H_ */