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