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); 19 #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT 20 void mmc_adapter_card_type_ident(void); 21 #endif 22 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 31 #ifndef CONFIG_SPL_BUILD 32 33 unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start, 34 lbaint_t blkcnt); 35 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 43 44 #else /* CONFIG_SPL_BUILD */ 45 46 /* SPL will never write or erase, declare dummies to reduce code size. */ 47 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 61 static inline unsigned long mmc_berase(struct blk_desc *block_dev, 62 lbaint_t start, lbaint_t blkcnt) 63 { 64 return 0; 65 } 66 67 static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, 68 lbaint_t blkcnt, const void *src) 69 { 70 return 0; 71 } 72 #endif 73 74 #endif /* CONFIG_SPL_BUILD */ 75 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 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 109 #endif /* _MMC_PRIVATE_H_ */ 110