Lines Matching +full:mmc +full:-

1 // SPDX-License-Identifier: GPL-2.0+
9 #include <mmc.h>
13 static int cur_dev_num = -1;
16 static struct mmc mmc_static;
17 struct mmc *find_mmc_device(int dev_num) in find_mmc_device()
24 struct mmc *m = &mmc_static; in mmc_do_preinit()
28 if (m->preinit) in mmc_do_preinit()
32 struct blk_desc *mmc_get_blk_desc(struct mmc *mmc) in mmc_get_blk_desc() argument
34 return &mmc->block_dev; in mmc_get_blk_desc()
37 struct mmc *find_mmc_device(int dev_num) in find_mmc_device()
39 struct mmc *m; in find_mmc_device()
43 m = list_entry(entry, struct mmc, link); in find_mmc_device()
45 if (m->block_dev.devnum == dev_num) in find_mmc_device()
50 printf("MMC Device %d not found\n", dev_num); in find_mmc_device()
61 struct blk_desc *mmc_get_blk_desc(struct mmc *mmc) in mmc_get_blk_desc() argument
63 return &mmc->block_dev; in mmc_get_blk_desc()
73 struct mmc *m; in mmc_do_preinit()
77 m = list_entry(entry, struct mmc, link); in mmc_do_preinit()
82 if (m->preinit) in mmc_do_preinit()
94 void mmc_list_add(struct mmc *mmc) in mmc_list_add() argument
96 INIT_LIST_HEAD(&mmc->link); in mmc_list_add()
98 list_add_tail(&mmc->link, &mmc_devices); in mmc_list_add()
104 struct mmc *m; in print_mmc_devices()
109 m = list_entry(entry, struct mmc, link); in print_mmc_devices()
111 if (m->has_init) in print_mmc_devices()
116 printf("%s: %d", m->cfg->name, m->block_dev.devnum); in print_mmc_devices()
120 if (entry->next != &mmc_devices) { in print_mmc_devices()
135 static struct mmc mmc_static = {
149 struct mmc *mmc_create(const struct mmc_config *cfg, void *priv) in mmc_create()
151 struct mmc *mmc = &mmc_static; in mmc_create() local
153 mmc->cfg = cfg; in mmc_create()
154 mmc->priv = priv; in mmc_create()
156 return mmc; in mmc_create()
159 void mmc_destroy(struct mmc *mmc) in mmc_destroy() argument
163 struct mmc *mmc_create(const struct mmc_config *cfg, void *priv) in mmc_create()
166 struct mmc *mmc; in mmc_create() local
169 if (cfg == NULL || cfg->f_min == 0 || in mmc_create()
170 cfg->f_max == 0 || cfg->b_max == 0) in mmc_create()
174 if (cfg->ops == NULL || cfg->ops->send_cmd == NULL) in mmc_create()
178 mmc = calloc(1, sizeof(*mmc)); in mmc_create()
179 if (mmc == NULL) in mmc_create()
182 mmc->cfg = cfg; in mmc_create()
183 mmc->priv = priv; in mmc_create()
188 mmc->dsr_imp = 0; in mmc_create()
189 mmc->dsr = 0xffffffff; in mmc_create()
191 bdesc = mmc_get_blk_desc(mmc); in mmc_create()
192 bdesc->if_type = IF_TYPE_MMC; in mmc_create()
193 bdesc->removable = 1; in mmc_create()
194 bdesc->devnum = mmc_get_next_devnum(); in mmc_create()
195 bdesc->block_read = mmc_bread; in mmc_create()
196 bdesc->block_write = mmc_bwrite; in mmc_create()
197 bdesc->block_erase = mmc_berase; in mmc_create()
200 bdesc->part_type = mmc->cfg->part_type; in mmc_create()
201 mmc_list_add(mmc); in mmc_create()
203 return mmc; in mmc_create()
206 void mmc_destroy(struct mmc *mmc) in mmc_destroy() argument
209 free(mmc); in mmc_destroy()
215 struct mmc *mmc = find_mmc_device(desc->devnum); in mmc_select_hwpartp() local
218 if (!mmc) in mmc_select_hwpartp()
219 return -ENODEV; in mmc_select_hwpartp()
221 if (mmc->block_dev.hwpart == hwpart) in mmc_select_hwpartp()
224 if (mmc->part_config == MMCPART_NOAVAILABLE) in mmc_select_hwpartp()
225 return -EMEDIUMTYPE; in mmc_select_hwpartp()
227 ret = mmc_switch_part(mmc, hwpart); in mmc_select_hwpartp()
236 struct mmc *mmc = find_mmc_device(dev); in mmc_get_dev() local
239 if (!mmc) in mmc_get_dev()
240 return -ENODEV; in mmc_get_dev()
241 ret = mmc_init(mmc); in mmc_get_dev()
245 *descp = &mmc->block_dev; in mmc_get_dev()
250 U_BOOT_LEGACY_BLK(mmc) = {
251 .if_typename = "mmc",
253 .max_devs = -1,