2 * Copyright (C) 2016 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
11 static struct list_head mmc_devices;
12 static int cur_dev_num = -1;
14 struct mmc *find_mmc_device(int dev_num)
17 struct list_head *entry;
19 list_for_each(entry, &mmc_devices) {
20 m = list_entry(entry, struct mmc, link);
22 if (m->block_dev.devnum == dev_num)
26 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
27 printf("MMC Device %d not found\n", dev_num);
33 int mmc_get_next_devnum(void)
38 struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
40 return &mmc->block_dev;
48 void mmc_do_preinit(void)
51 struct list_head *entry;
53 list_for_each(entry, &mmc_devices) {
54 m = list_entry(entry, struct mmc, link);
56 #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
57 mmc_set_preinit(m, 1);
64 void mmc_list_init(void)
66 INIT_LIST_HEAD(&mmc_devices);
70 void mmc_list_add(struct mmc *mmc)
72 INIT_LIST_HEAD(&mmc->link);
74 list_add_tail(&mmc->link, &mmc_devices);
77 #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
78 void print_mmc_devices(char separator)
81 struct list_head *entry;
84 list_for_each(entry, &mmc_devices) {
85 m = list_entry(entry, struct mmc, link);
88 mmc_type = IS_SD(m) ? "SD" : "eMMC";
92 printf("%s: %d", m->cfg->name, m->block_dev.devnum);
94 printf(" (%s)", mmc_type);
96 if (entry->next != &mmc_devices) {
97 printf("%c", separator);
98 if (separator != '\n')
107 void print_mmc_devices(char separator) { }