Lines Matching full:mmc
17 #include <mmc.h>
43 ret = blk_get_device_by_str("mmc", STR(CONFIG_SYS_MMC_ENV_DEV), &desc); in mmc_offset_try_partition()
72 .offset_redund = "u-boot,mmc-env-offset-redundant", in mmc_offset()
73 .partition = "u-boot,mmc-env-partition", in mmc_offset()
74 .offset = "u-boot,mmc-env-offset", in mmc_offset()
81 /* look for the partition in mmc CONFIG_SYS_MMC_ENV_DEV */ in mmc_offset()
114 __weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) in mmc_get_env_addr() argument
119 offset += mmc->capacity; in mmc_get_env_addr()
132 __weak uint mmc_get_env_part(struct mmc *mmc) in mmc_get_env_part() argument
139 static int mmc_set_env_part(struct mmc *mmc) in mmc_set_env_part() argument
141 uint part = mmc_get_env_part(mmc); in mmc_set_env_part()
145 env_mmc_orig_hwpart = mmc_get_blk_desc(mmc)->hwpart; in mmc_set_env_part()
148 puts("MMC partition switch failed\n"); in mmc_set_env_part()
153 static inline int mmc_set_env_part(struct mmc *mmc) {return 0; }; in mmc_set_env_part() argument
156 static const char *init_mmc_for_env(struct mmc *mmc) in init_mmc_for_env() argument
158 if (!mmc) in init_mmc_for_env()
159 return "!No MMC card found"; in init_mmc_for_env()
164 if (blk_get_from_parent(mmc->dev, &dev)) in init_mmc_for_env()
167 if (mmc_init(mmc)) in init_mmc_for_env()
168 return "!MMC init failed"; in init_mmc_for_env()
170 if (mmc_set_env_part(mmc)) in init_mmc_for_env()
171 return "!MMC partition switch failed"; in init_mmc_for_env()
176 static void fini_mmc_for_env(struct mmc *mmc) in fini_mmc_for_env() argument
186 static inline int write_env(struct mmc *mmc, unsigned long size, in write_env() argument
190 struct blk_desc *desc = mmc_get_blk_desc(mmc); in write_env()
192 blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len; in write_env()
193 blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len; in write_env()
204 struct mmc *mmc = find_mmc_device(dev); in env_mmc_save() local
209 errmsg = init_mmc_for_env(mmc); in env_mmc_save()
224 if (mmc_get_env_addr(mmc, copy, &offset)) { in env_mmc_save()
230 if (write_env(mmc, CONFIG_ENV_SIZE, offset, (u_char *)env_new)) { in env_mmc_save()
244 fini_mmc_for_env(mmc); in env_mmc_save()
249 static inline int read_env(struct mmc *mmc, unsigned long size, in read_env() argument
253 struct blk_desc *desc = mmc_get_blk_desc(mmc); in read_env()
255 blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len; in read_env()
256 blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len; in read_env()
267 struct mmc *mmc; in env_mmc_load() local
277 mmc = find_mmc_device(dev); in env_mmc_load()
279 errmsg = init_mmc_for_env(mmc); in env_mmc_load()
285 if (mmc_get_env_addr(mmc, 0, &offset1) || in env_mmc_load()
286 mmc_get_env_addr(mmc, 1, &offset2)) { in env_mmc_load()
291 read1_fail = read_env(mmc, CONFIG_ENV_SIZE, offset1, tmp_env1); in env_mmc_load()
292 read2_fail = read_env(mmc, CONFIG_ENV_SIZE, offset2, tmp_env2); in env_mmc_load()
317 fini_mmc_for_env(mmc); in env_mmc_load()
330 struct mmc *mmc; in env_mmc_load() local
336 mmc = find_mmc_device(dev); in env_mmc_load()
338 errmsg = init_mmc_for_env(mmc); in env_mmc_load()
344 if (mmc_get_env_addr(mmc, 0, &offset)) { in env_mmc_load()
349 if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) { in env_mmc_load()
359 fini_mmc_for_env(mmc); in env_mmc_load()
368 U_BOOT_ENV_LOCATION(mmc) = {
370 ENV_NAME("MMC")