Lines Matching +full:mmc +full:-
1 // SPDX-License-Identifier: GPL-2.0+
13 #include <asm/u-boot.h>
15 #include <mmc.h>
18 static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc, in mmc_load_legacy() argument
29 /* convert size to sectors - round up */ in mmc_load_legacy()
30 image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) / in mmc_load_legacy()
31 mmc->read_bl_len; in mmc_load_legacy()
34 count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors, in mmc_load_legacy()
35 (void *)(ulong)spl_image->load_addr); in mmc_load_legacy()
37 spl_image->load_addr); in mmc_load_legacy()
39 return -EIO; in mmc_load_legacy()
47 struct mmc *mmc = load->dev; in h_spl_load_read() local
49 return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); in h_spl_load_read()
54 struct mmc *mmc, unsigned long sector) in mmc_load_image_raw_sector() argument
58 struct blk_desc *bd = mmc_get_blk_desc(mmc); in mmc_load_image_raw_sector()
61 header = spl_get_load_buffer(-sizeof(*header), bd->blksz); in mmc_load_image_raw_sector()
67 ret = -EIO; in mmc_load_image_raw_sector()
76 load.dev = mmc; in mmc_load_image_raw_sector()
79 load.bl_len = mmc->read_bl_len; in mmc_load_image_raw_sector()
83 ret = mmc_load_legacy(spl_image, mmc, sector, header); in mmc_load_image_raw_sector()
89 puts("mmc_load_image_raw_sector: mmc block read error\n"); in mmc_load_image_raw_sector()
91 return -1; in mmc_load_image_raw_sector()
108 printf("spl: unsupported mmc boot device.\n"); in spl_mmc_get_device_index()
111 return -ENODEV; in spl_mmc_get_device_index()
114 static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device) in spl_mmc_find_device()
128 printf("spl: could not initialize mmc. error: %d\n", err); in spl_mmc_find_device()
139 err = *mmcp ? 0 : -ENODEV; in spl_mmc_find_device()
143 printf("spl: could not find mmc device %d. error: %d\n", in spl_mmc_find_device()
154 struct mmc *mmc, int partition, in mmc_load_image_raw_partition() argument
164 err = part_get_info(mmc_get_blk_desc(mmc), type_part, &info); in mmc_load_image_raw_partition()
175 err = part_get_info(mmc_get_blk_desc(mmc), partition, &info); in mmc_load_image_raw_partition()
180 return -1; in mmc_load_image_raw_partition()
184 return mmc_load_image_raw_sector(spl_image, mmc, info.start + sector); in mmc_load_image_raw_partition()
186 return mmc_load_image_raw_sector(spl_image, mmc, info.start); in mmc_load_image_raw_partition()
193 struct mmc *mmc) in mmc_load_image_raw_os() argument
200 count = blk_dread(mmc_get_blk_desc(mmc), in mmc_load_image_raw_os()
206 puts("mmc_load_image_raw_os: mmc block read error\n"); in mmc_load_image_raw_os()
208 return -1; in mmc_load_image_raw_os()
212 ret = mmc_load_image_raw_sector(spl_image, mmc, in mmc_load_image_raw_os()
217 if (spl_image->os != IH_OS_LINUX) { in mmc_load_image_raw_os()
218 puts("Expected Linux image is not found. Trying to start U-boot\n"); in mmc_load_image_raw_os()
219 return -ENOENT; in mmc_load_image_raw_os()
230 struct mmc *mmc) in mmc_load_image_raw_os() argument
232 return -ENOSYS; in mmc_load_image_raw_os()
237 static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc, in spl_mmc_do_fs_boot() argument
240 int err = -ENOSYS; in spl_mmc_do_fs_boot()
244 err = spl_load_image_fat_os(spl_image, mmc_get_blk_desc(mmc), in spl_mmc_do_fs_boot()
250 err = spl_load_image_fat(spl_image, mmc_get_blk_desc(mmc), in spl_mmc_do_fs_boot()
259 err = spl_load_image_ext_os(spl_image, mmc_get_blk_desc(mmc), in spl_mmc_do_fs_boot()
265 err = spl_load_image_ext(spl_image, mmc_get_blk_desc(mmc), in spl_mmc_do_fs_boot()
274 err = -ENOENT; in spl_mmc_do_fs_boot()
280 static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc, in spl_mmc_do_fs_boot() argument
283 return -ENOSYS; in spl_mmc_do_fs_boot()
312 static struct mmc *mmc; in spl_mmc_load() local
318 if (!mmc) { in spl_mmc_load()
319 err = spl_mmc_find_device(&mmc, bootdev->boot_device); in spl_mmc_load()
323 err = mmc_init(mmc); in spl_mmc_load()
325 mmc = NULL; in spl_mmc_load()
327 printf("spl: mmc init failed with error: %d\n", err); in spl_mmc_load()
333 boot_mode = spl_boot_mode(bootdev->boot_device); in spl_mmc_load()
334 err = -EINVAL; in spl_mmc_load()
342 part = (mmc->part_config >> 3) & PART_ACCESS_MASK; in spl_mmc_load()
348 err = mmc_switch_part(mmc, part); in spl_mmc_load()
350 err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part); in spl_mmc_load()
354 puts("spl: mmc partition switch failed\n"); in spl_mmc_load()
360 debug("spl: mmc boot mode: raw\n"); in spl_mmc_load()
363 err = mmc_load_image_raw_os(spl_image, mmc); in spl_mmc_load()
368 err = mmc_load_image_raw_partition(spl_image, mmc, raw_part, in spl_mmc_load()
374 err = mmc_load_image_raw_sector(spl_image, mmc, raw_sect); in spl_mmc_load()
380 debug("spl: mmc boot mode: fs\n"); in spl_mmc_load()
382 err = spl_mmc_do_fs_boot(spl_image, mmc, filename); in spl_mmc_load()
389 puts("spl: mmc: wrong boot mode\n"); in spl_mmc_load()
406 spl_boot_partition(bootdev->boot_device), in spl_mmc_load_image()