Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2008,2010 Freescale Semiconductor, Inc |
| 4 | * Andy Fleming |
| 5 | * |
| 6 | * Based (loosely) on the Linux code |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _MMC_PRIVATE_H_ |
| 10 | #define _MMC_PRIVATE_H_ |
| 11 | |
| 12 | #include <mmc.h> |
| 13 | |
| 14 | extern int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, |
| 15 | struct mmc_data *data); |
| 16 | extern int mmc_send_status(struct mmc *mmc, int timeout); |
| 17 | extern int mmc_set_blocklen(struct mmc *mmc, int len); |
Yangbo Lu | b124f8a | 2015-04-22 13:57:00 +0800 | [diff] [blame] | 18 | #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT |
| 19 | void mmc_adapter_card_type_ident(void); |
| 20 | #endif |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 21 | |
Simon Glass | 5f4bd8c | 2017-07-04 13:31:19 -0600 | [diff] [blame] | 22 | #if CONFIG_IS_ENABLED(BLK) |
Simon Glass | 62e293a | 2016-06-12 23:30:15 -0600 | [diff] [blame] | 23 | ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, |
| 24 | void *dst); |
| 25 | #else |
| 26 | ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, |
| 27 | void *dst); |
| 28 | #endif |
| 29 | |
Jean-Jacques Hiblot | d053167 | 2018-01-04 15:23:32 +0100 | [diff] [blame] | 30 | #if CONFIG_IS_ENABLED(MMC_WRITE) |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 31 | |
Simon Glass | 5f4bd8c | 2017-07-04 13:31:19 -0600 | [diff] [blame] | 32 | #if CONFIG_IS_ENABLED(BLK) |
Simon Glass | 59bc6f2 | 2016-05-01 13:52:41 -0600 | [diff] [blame] | 33 | ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, |
| 34 | const void *src); |
Simon Glass | fcc53c1 | 2016-10-01 14:43:17 -0600 | [diff] [blame] | 35 | ulong mmc_berase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt); |
Simon Glass | 59bc6f2 | 2016-05-01 13:52:41 -0600 | [diff] [blame] | 36 | #else |
| 37 | ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, |
| 38 | const void *src); |
Simon Glass | fcc53c1 | 2016-10-01 14:43:17 -0600 | [diff] [blame] | 39 | 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] | 40 | #endif |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 41 | |
Jean-Jacques Hiblot | d053167 | 2018-01-04 15:23:32 +0100 | [diff] [blame] | 42 | #else /* CONFIG_SPL_MMC_WRITE is not defined */ |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 43 | |
B, Ravi | e94b024 | 2016-09-28 14:46:18 +0530 | [diff] [blame] | 44 | /* declare dummies to reduce code size. */ |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 45 | |
Simon Glass | 5f4bd8c | 2017-07-04 13:31:19 -0600 | [diff] [blame] | 46 | #if CONFIG_IS_ENABLED(BLK) |
Simon Glass | 9f72e37 | 2016-05-14 14:03:09 -0600 | [diff] [blame] | 47 | static inline unsigned long mmc_berase(struct udevice *dev, |
| 48 | lbaint_t start, lbaint_t blkcnt) |
| 49 | { |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | static 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 Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 59 | static inline unsigned long mmc_berase(struct blk_desc *block_dev, |
Stephen Warren | e73f296 | 2015-12-07 11:38:48 -0700 | [diff] [blame] | 60 | lbaint_t start, lbaint_t blkcnt) |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 61 | { |
| 62 | return 0; |
| 63 | } |
| 64 | |
Simon Glass | e339475 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 65 | 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] | 66 | lbaint_t blkcnt, const void *src) |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 67 | { |
| 68 | return 0; |
| 69 | } |
Simon Glass | 9f72e37 | 2016-05-14 14:03:09 -0600 | [diff] [blame] | 70 | #endif |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 71 | |
| 72 | #endif /* CONFIG_SPL_BUILD */ |
| 73 | |
Simon Glass | b23d96e | 2016-06-12 23:30:20 -0600 | [diff] [blame] | 74 | #ifdef CONFIG_MMC_TRACE |
| 75 | void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd); |
| 76 | void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, int ret); |
| 77 | void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd); |
| 78 | #else |
| 79 | static inline void mmmc_trace_before_send(struct mmc *mmc, struct mmc_cmd *cmd) |
| 80 | { |
| 81 | } |
| 82 | |
| 83 | static inline void mmmc_trace_after_send(struct mmc *mmc, struct mmc_cmd *cmd, |
| 84 | int ret) |
| 85 | { |
| 86 | } |
| 87 | |
| 88 | static inline void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd) |
| 89 | { |
| 90 | } |
| 91 | #endif |
| 92 | |
Simon Glass | e5db115 | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 93 | /** |
| 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 | */ |
| 98 | int mmc_get_next_devnum(void); |
| 99 | |
| 100 | /** |
| 101 | * mmc_do_preinit() - Get an MMC device ready for use |
| 102 | */ |
| 103 | void mmc_do_preinit(void); |
| 104 | |
| 105 | /** |
| 106 | * mmc_list_init() - Set up the list of MMC devices |
| 107 | */ |
| 108 | void 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 | */ |
| 115 | void mmc_list_add(struct mmc *mmc); |
| 116 | |
Simon Glass | 62e293a | 2016-06-12 23:30:15 -0600 | [diff] [blame] | 117 | /** |
| 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 | */ |
| 124 | int mmc_switch_part(struct mmc *mmc, unsigned int part_num); |
| 125 | |
Simon Glass | 84f9df9 | 2016-06-12 23:30:18 -0600 | [diff] [blame] | 126 | /** |
| 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 | */ |
| 135 | int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value); |
| 136 | |
Paul Burton | 8d30cc9 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 137 | #endif /* _MMC_PRIVATE_H_ */ |