Paul Burton | da61fa5 | 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 | 5a8dbdc | 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 | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 22 | |
Simon Glass | 7dba0b9 | 2016-06-12 23:30:15 -0600 | [diff] [blame^] | 23 | #ifdef CONFIG_BLK |
| 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 | |
Paul Burton | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 31 | #ifndef CONFIG_SPL_BUILD |
| 32 | |
Simon Glass | 4101f68 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 33 | unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start, |
Stephen Warren | 7c4213f | 2015-12-07 11:38:48 -0700 | [diff] [blame] | 34 | lbaint_t blkcnt); |
Paul Burton | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 35 | |
Simon Glass | 33fb211 | 2016-05-01 13:52:41 -0600 | [diff] [blame] | 36 | #ifdef CONFIG_BLK |
| 37 | ulong mmc_bwrite(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, |
| 38 | const void *src); |
| 39 | #else |
| 40 | ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, |
| 41 | const void *src); |
| 42 | #endif |
Paul Burton | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 43 | |
| 44 | #else /* CONFIG_SPL_BUILD */ |
| 45 | |
| 46 | /* SPL will never write or erase, declare dummies to reduce code size. */ |
| 47 | |
Simon Glass | e419a3e | 2016-05-14 14:03:09 -0600 | [diff] [blame] | 48 | #ifdef CONFIG_BLK |
| 49 | static inline unsigned long mmc_berase(struct udevice *dev, |
| 50 | lbaint_t start, lbaint_t blkcnt) |
| 51 | { |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static 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 Glass | 4101f68 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 61 | static inline unsigned long mmc_berase(struct blk_desc *block_dev, |
Stephen Warren | 7c4213f | 2015-12-07 11:38:48 -0700 | [diff] [blame] | 62 | lbaint_t start, lbaint_t blkcnt) |
Paul Burton | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 63 | { |
| 64 | return 0; |
| 65 | } |
| 66 | |
Simon Glass | 4101f68 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 67 | static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, |
Stephen Warren | 7c4213f | 2015-12-07 11:38:48 -0700 | [diff] [blame] | 68 | lbaint_t blkcnt, const void *src) |
Paul Burton | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 69 | { |
| 70 | return 0; |
| 71 | } |
Simon Glass | e419a3e | 2016-05-14 14:03:09 -0600 | [diff] [blame] | 72 | #endif |
Paul Burton | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 73 | |
| 74 | #endif /* CONFIG_SPL_BUILD */ |
| 75 | |
Simon Glass | c40fdca | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 76 | /** |
| 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 | */ |
| 81 | int mmc_get_next_devnum(void); |
| 82 | |
| 83 | /** |
| 84 | * mmc_do_preinit() - Get an MMC device ready for use |
| 85 | */ |
| 86 | void mmc_do_preinit(void); |
| 87 | |
| 88 | /** |
| 89 | * mmc_list_init() - Set up the list of MMC devices |
| 90 | */ |
| 91 | void 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 | */ |
| 98 | void mmc_list_add(struct mmc *mmc); |
| 99 | |
Simon Glass | 7dba0b9 | 2016-06-12 23:30:15 -0600 | [diff] [blame^] | 100 | /** |
| 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 | */ |
| 107 | int mmc_switch_part(struct mmc *mmc, unsigned int part_num); |
| 108 | |
Paul Burton | da61fa5 | 2013-09-09 15:30:26 +0100 | [diff] [blame] | 109 | #endif /* _MMC_PRIVATE_H_ */ |