Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 15 | extern int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, |
| 16 | struct mmc_data *data); |
| 17 | extern int mmc_send_status(struct mmc *mmc, int timeout); |
| 18 | extern int mmc_set_blocklen(struct mmc *mmc, int len); |
Yangbo Lu | b124f8a | 2015-04-22 13:57:00 +0800 | [diff] [blame] | 19 | #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT |
| 20 | void mmc_adapter_card_type_ident(void); |
| 21 | #endif |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 22 | |
Simon Glass | 5f4bd8c | 2017-07-04 13:31:19 -0600 | [diff] [blame] | 23 | #if CONFIG_IS_ENABLED(BLK) |
Simon Glass | 62e293a | 2016-06-12 23:30:15 -0600 | [diff] [blame] | 24 | ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, |
| 25 | void *dst); |
| 26 | #else |
| 27 | ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, |
| 28 | void *dst); |
| 29 | #endif |
| 30 | |
B, Ravi | e94b024 | 2016-09-28 14:46:18 +0530 | [diff] [blame] | 31 | #if !(defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_SAVEENV)) |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 32 | |
Simon Glass | 5f4bd8c | 2017-07-04 13:31:19 -0600 | [diff] [blame] | 33 | #if CONFIG_IS_ENABLED(BLK) |
Simon Glass | 59bc6f2 | 2016-05-01 13:52:41 -0600 | [diff] [blame] | 34 | ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, |
| 35 | const void *src); |
Simon Glass | fcc53c1 | 2016-10-01 14:43:17 -0600 | [diff] [blame] | 36 | ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt); |
Simon Glass | 59bc6f2 | 2016-05-01 13:52:41 -0600 | [diff] [blame] | 37 | #else |
| 38 | ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, |
| 39 | const void *src); |
Simon Glass | fcc53c1 | 2016-10-01 14:43:17 -0600 | [diff] [blame] | 40 | ulong mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt); |
Simon Glass | 59bc6f2 | 2016-05-01 13:52:41 -0600 | [diff] [blame] | 41 | #endif |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 42 | |
B, Ravi | e94b024 | 2016-09-28 14:46:18 +0530 | [diff] [blame] | 43 | #else /* CONFIG_SPL_BUILD and CONFIG_SPL_SAVEENV is not defined */ |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 44 | |
B, Ravi | e94b024 | 2016-09-28 14:46:18 +0530 | [diff] [blame] | 45 | /* declare dummies to reduce code size. */ |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 46 | |
Simon Glass | 5f4bd8c | 2017-07-04 13:31:19 -0600 | [diff] [blame] | 47 | #if CONFIG_IS_ENABLED(BLK) |
Simon Glass | 9f72e37 | 2016-05-14 14:03:09 -0600 | [diff] [blame] | 48 | static inline unsigned long mmc_berase(struct udevice *dev, |
| 49 | lbaint_t start, lbaint_t blkcnt) |
| 50 | { |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start, |
| 55 | lbaint_t blkcnt, const void *src) |
| 56 | { |
| 57 | return 0; |
| 58 | } |
| 59 | #else |
Simon Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 60 | static inline unsigned long mmc_berase(struct blk_desc *block_dev, |
Stephen Warren | e73f296 | 2015-12-07 11:38:48 -0700 | [diff] [blame] | 61 | lbaint_t start, lbaint_t blkcnt) |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 62 | { |
| 63 | return 0; |
| 64 | } |
| 65 | |
Simon Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 66 | static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, |
Stephen Warren | e73f296 | 2015-12-07 11:38:48 -0700 | [diff] [blame] | 67 | lbaint_t blkcnt, const void *src) |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 68 | { |
| 69 | return 0; |
| 70 | } |
Simon Glass | 9f72e37 | 2016-05-14 14:03:09 -0600 | [diff] [blame] | 71 | #endif |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 72 | |
| 73 | #endif /* CONFIG_SPL_BUILD */ |
| 74 | |
Simon Glass | b23d96e | 2016-06-12 23:30:20 -0600 | [diff] [blame] | 75 | #ifdef CONFIG_MMC_TRACE |
| 76 | void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd); |
| 77 | void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret); |
| 78 | void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd); |
| 79 | #else |
| 80 | static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd) |
| 81 | { |
| 82 | } |
| 83 | |
| 84 | static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, |
| 85 | int ret) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd) |
| 90 | { |
| 91 | } |
| 92 | #endif |
| 93 | |
Simon Glass | e5db115 | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 94 | /** |
| 95 | * mmc_get_next_devnum() - Get the next available MMC device number |
| 96 | * |
| 97 | * @return next available device number (0 = first), or -ve on error |
| 98 | */ |
| 99 | int mmc_get_next_devnum(void); |
| 100 | |
| 101 | /** |
| 102 | * mmc_do_preinit() - Get an MMC device ready for use |
| 103 | */ |
| 104 | void mmc_do_preinit(void); |
| 105 | |
| 106 | /** |
| 107 | * mmc_list_init() - Set up the list of MMC devices |
| 108 | */ |
| 109 | void mmc_list_init(void); |
| 110 | |
| 111 | /** |
| 112 | * mmc_list_add() - Add a new MMC device to the list of devices |
| 113 | * |
| 114 | * @mmc: Device to add |
| 115 | */ |
| 116 | void mmc_list_add(struct mmc *mmc); |
| 117 | |
Simon Glass | 62e293a | 2016-06-12 23:30:15 -0600 | [diff] [blame] | 118 | /** |
| 119 | * mmc_switch_part() - Switch to a new MMC hardware partition |
| 120 | * |
| 121 | * @mmc: MMC device |
| 122 | * @part_num: Hardware partition number |
| 123 | * @return 0 if OK, -ve on error |
| 124 | */ |
| 125 | int mmc_switch_part(struct mmc *mmc, unsigned int part_num); |
| 126 | |
Simon Glass | 84f9df9 | 2016-06-12 23:30:18 -0600 | [diff] [blame] | 127 | /** |
| 128 | * mmc_switch() - Issue and MMC switch mode command |
| 129 | * |
| 130 | * @mmc: MMC device |
| 131 | * @set: Unused |
| 132 | * @index: Cmdarg index |
| 133 | * @value: Cmdarg value |
| 134 | * @return 0 if OK, -ve on error |
| 135 | */ |
| 136 | int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value); |
| 137 | |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 138 | #endif /* _MMC_PRIVATE_H_ */ |