xref: /openbmc/u-boot/drivers/mmc/mmc-uclass.c (revision 83d290c5)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2e7ecf7cbSSimon Glass /*
3e7ecf7cbSSimon Glass  * Copyright (C) 2015 Google, Inc
4e7ecf7cbSSimon Glass  * Written by Simon Glass <sjg@chromium.org>
5e7ecf7cbSSimon Glass  */
6e7ecf7cbSSimon Glass 
7e7ecf7cbSSimon Glass #include <common.h>
8e7ecf7cbSSimon Glass #include <mmc.h>
9e7ecf7cbSSimon Glass #include <dm.h>
10eede897eSSimon Glass #include <dm/device-internal.h>
11e7ecf7cbSSimon Glass #include <dm/lists.h>
12eede897eSSimon Glass #include "mmc_private.h"
13e7ecf7cbSSimon Glass 
148ca51e51SSimon Glass int dm_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
158ca51e51SSimon Glass 		    struct mmc_data *data)
168ca51e51SSimon Glass {
178ca51e51SSimon Glass 	struct mmc *mmc = mmc_get_mmc_dev(dev);
188ca51e51SSimon Glass 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
198ca51e51SSimon Glass 	int ret;
208ca51e51SSimon Glass 
218ca51e51SSimon Glass 	mmmc_trace_before_send(mmc, cmd);
228ca51e51SSimon Glass 	if (ops->send_cmd)
238ca51e51SSimon Glass 		ret = ops->send_cmd(dev, cmd, data);
248ca51e51SSimon Glass 	else
258ca51e51SSimon Glass 		ret = -ENOSYS;
268ca51e51SSimon Glass 	mmmc_trace_after_send(mmc, cmd, ret);
278ca51e51SSimon Glass 
288ca51e51SSimon Glass 	return ret;
298ca51e51SSimon Glass }
308ca51e51SSimon Glass 
318ca51e51SSimon Glass int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
328ca51e51SSimon Glass {
338ca51e51SSimon Glass 	return dm_mmc_send_cmd(mmc->dev, cmd, data);
348ca51e51SSimon Glass }
358ca51e51SSimon Glass 
368ca51e51SSimon Glass int dm_mmc_set_ios(struct udevice *dev)
378ca51e51SSimon Glass {
388ca51e51SSimon Glass 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
398ca51e51SSimon Glass 
408ca51e51SSimon Glass 	if (!ops->set_ios)
418ca51e51SSimon Glass 		return -ENOSYS;
428ca51e51SSimon Glass 	return ops->set_ios(dev);
438ca51e51SSimon Glass }
448ca51e51SSimon Glass 
458ca51e51SSimon Glass int mmc_set_ios(struct mmc *mmc)
468ca51e51SSimon Glass {
478ca51e51SSimon Glass 	return dm_mmc_set_ios(mmc->dev);
488ca51e51SSimon Glass }
498ca51e51SSimon Glass 
50318a7a57SJean-Jacques Hiblot void dm_mmc_send_init_stream(struct udevice *dev)
51318a7a57SJean-Jacques Hiblot {
52318a7a57SJean-Jacques Hiblot 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
53318a7a57SJean-Jacques Hiblot 
54318a7a57SJean-Jacques Hiblot 	if (ops->send_init_stream)
55318a7a57SJean-Jacques Hiblot 		ops->send_init_stream(dev);
56318a7a57SJean-Jacques Hiblot }
57318a7a57SJean-Jacques Hiblot 
58318a7a57SJean-Jacques Hiblot void mmc_send_init_stream(struct mmc *mmc)
59318a7a57SJean-Jacques Hiblot {
60318a7a57SJean-Jacques Hiblot 	dm_mmc_send_init_stream(mmc->dev);
61318a7a57SJean-Jacques Hiblot }
62318a7a57SJean-Jacques Hiblot 
63f99c2efeSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
64c10b85d6SJean-Jacques Hiblot int dm_mmc_wait_dat0(struct udevice *dev, int state, int timeout)
65c10b85d6SJean-Jacques Hiblot {
66c10b85d6SJean-Jacques Hiblot 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
67c10b85d6SJean-Jacques Hiblot 
68c10b85d6SJean-Jacques Hiblot 	if (!ops->wait_dat0)
69c10b85d6SJean-Jacques Hiblot 		return -ENOSYS;
70c10b85d6SJean-Jacques Hiblot 	return ops->wait_dat0(dev, state, timeout);
71c10b85d6SJean-Jacques Hiblot }
72c10b85d6SJean-Jacques Hiblot 
73c10b85d6SJean-Jacques Hiblot int mmc_wait_dat0(struct mmc *mmc, int state, int timeout)
74c10b85d6SJean-Jacques Hiblot {
75c10b85d6SJean-Jacques Hiblot 	return dm_mmc_wait_dat0(mmc->dev, state, timeout);
76c10b85d6SJean-Jacques Hiblot }
77f99c2efeSJean-Jacques Hiblot #endif
78c10b85d6SJean-Jacques Hiblot 
798ca51e51SSimon Glass int dm_mmc_get_wp(struct udevice *dev)
808ca51e51SSimon Glass {
818ca51e51SSimon Glass 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
828ca51e51SSimon Glass 
838ca51e51SSimon Glass 	if (!ops->get_wp)
848ca51e51SSimon Glass 		return -ENOSYS;
858ca51e51SSimon Glass 	return ops->get_wp(dev);
868ca51e51SSimon Glass }
878ca51e51SSimon Glass 
888ca51e51SSimon Glass int mmc_getwp(struct mmc *mmc)
898ca51e51SSimon Glass {
908ca51e51SSimon Glass 	return dm_mmc_get_wp(mmc->dev);
918ca51e51SSimon Glass }
928ca51e51SSimon Glass 
938ca51e51SSimon Glass int dm_mmc_get_cd(struct udevice *dev)
948ca51e51SSimon Glass {
958ca51e51SSimon Glass 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
968ca51e51SSimon Glass 
978ca51e51SSimon Glass 	if (!ops->get_cd)
988ca51e51SSimon Glass 		return -ENOSYS;
998ca51e51SSimon Glass 	return ops->get_cd(dev);
1008ca51e51SSimon Glass }
1018ca51e51SSimon Glass 
1028ca51e51SSimon Glass int mmc_getcd(struct mmc *mmc)
1038ca51e51SSimon Glass {
1048ca51e51SSimon Glass 	return dm_mmc_get_cd(mmc->dev);
1058ca51e51SSimon Glass }
1068ca51e51SSimon Glass 
107f99c2efeSJean-Jacques Hiblot #ifdef MMC_SUPPORTS_TUNING
108ec841209SKishon Vijay Abraham I int dm_mmc_execute_tuning(struct udevice *dev, uint opcode)
109ec841209SKishon Vijay Abraham I {
110ec841209SKishon Vijay Abraham I 	struct dm_mmc_ops *ops = mmc_get_ops(dev);
111ec841209SKishon Vijay Abraham I 
112ec841209SKishon Vijay Abraham I 	if (!ops->execute_tuning)
113ec841209SKishon Vijay Abraham I 		return -ENOSYS;
114ec841209SKishon Vijay Abraham I 	return ops->execute_tuning(dev, opcode);
115ec841209SKishon Vijay Abraham I }
116ec841209SKishon Vijay Abraham I 
117ec841209SKishon Vijay Abraham I int mmc_execute_tuning(struct mmc *mmc, uint opcode)
118ec841209SKishon Vijay Abraham I {
119ec841209SKishon Vijay Abraham I 	return dm_mmc_execute_tuning(mmc->dev, opcode);
120ec841209SKishon Vijay Abraham I }
121f99c2efeSJean-Jacques Hiblot #endif
122ec841209SKishon Vijay Abraham I 
1237abff2c3SJean-Jacques Hiblot int mmc_of_parse(struct udevice *dev, struct mmc_config *cfg)
1249215ef5eSKishon Vijay Abraham I {
1259215ef5eSKishon Vijay Abraham I 	int val;
1269215ef5eSKishon Vijay Abraham I 
1277abff2c3SJean-Jacques Hiblot 	val = dev_read_u32_default(dev, "bus-width", 1);
1289215ef5eSKishon Vijay Abraham I 
1299215ef5eSKishon Vijay Abraham I 	switch (val) {
1309215ef5eSKishon Vijay Abraham I 	case 0x8:
1319215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_MODE_8BIT;
1329215ef5eSKishon Vijay Abraham I 		/* fall through */
1339215ef5eSKishon Vijay Abraham I 	case 0x4:
1349215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_MODE_4BIT;
1359215ef5eSKishon Vijay Abraham I 		/* fall through */
1369215ef5eSKishon Vijay Abraham I 	case 0x1:
1379215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_MODE_1BIT;
1389215ef5eSKishon Vijay Abraham I 		break;
1399215ef5eSKishon Vijay Abraham I 	default:
1404b28f7bcSMasahiro Yamada 		dev_err(dev, "Invalid \"bus-width\" value %u!\n", val);
1414b28f7bcSMasahiro Yamada 		return -EINVAL;
1429215ef5eSKishon Vijay Abraham I 	}
1439215ef5eSKishon Vijay Abraham I 
144c42ee367SMasahiro Yamada 	/* f_max is obtained from the optional "max-frequency" property */
145c42ee367SMasahiro Yamada 	dev_read_u32(dev, "max-frequency", &cfg->f_max);
1469215ef5eSKishon Vijay Abraham I 
1477abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "cap-sd-highspeed"))
1489215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(SD_HS);
1497abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "cap-mmc-highspeed"))
1509215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(MMC_HS);
1517abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "sd-uhs-sdr12"))
1529215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(UHS_SDR12);
1537abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "sd-uhs-sdr25"))
1549215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(UHS_SDR25);
1557abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "sd-uhs-sdr50"))
1569215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(UHS_SDR50);
1577abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "sd-uhs-sdr104"))
1589215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(UHS_SDR104);
1597abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "sd-uhs-ddr50"))
1609215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(UHS_DDR50);
1617abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "mmc-ddr-1_8v"))
1629215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(MMC_DDR_52);
1637abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "mmc-ddr-1_2v"))
1647abff2c3SJean-Jacques Hiblot 		cfg->host_caps |= MMC_CAP(MMC_DDR_52);
1657abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "mmc-hs200-1_8v"))
1667abff2c3SJean-Jacques Hiblot 		cfg->host_caps |= MMC_CAP(MMC_HS_200);
1677abff2c3SJean-Jacques Hiblot 	if (dev_read_bool(dev, "mmc-hs200-1_2v"))
1689215ef5eSKishon Vijay Abraham I 		cfg->host_caps |= MMC_CAP(MMC_HS_200);
1699215ef5eSKishon Vijay Abraham I 
1709215ef5eSKishon Vijay Abraham I 	return 0;
1719215ef5eSKishon Vijay Abraham I }
1729215ef5eSKishon Vijay Abraham I 
173e7ecf7cbSSimon Glass struct mmc *mmc_get_mmc_dev(struct udevice *dev)
174e7ecf7cbSSimon Glass {
175e7ecf7cbSSimon Glass 	struct mmc_uclass_priv *upriv;
176e7ecf7cbSSimon Glass 
177e7ecf7cbSSimon Glass 	if (!device_active(dev))
178e7ecf7cbSSimon Glass 		return NULL;
179e7ecf7cbSSimon Glass 	upriv = dev_get_uclass_priv(dev);
180e7ecf7cbSSimon Glass 	return upriv->mmc;
181e7ecf7cbSSimon Glass }
182e7ecf7cbSSimon Glass 
183c4d660d4SSimon Glass #if CONFIG_IS_ENABLED(BLK)
1848ef761edSSimon Glass struct mmc *find_mmc_device(int dev_num)
1858ef761edSSimon Glass {
1868ef761edSSimon Glass 	struct udevice *dev, *mmc_dev;
1878ef761edSSimon Glass 	int ret;
1888ef761edSSimon Glass 
18997525647SSimon Glass 	ret = blk_find_device(IF_TYPE_MMC, dev_num, &dev);
1908ef761edSSimon Glass 
1918ef761edSSimon Glass 	if (ret) {
1928ef761edSSimon Glass #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
1938ef761edSSimon Glass 		printf("MMC Device %d not found\n", dev_num);
1948ef761edSSimon Glass #endif
1958ef761edSSimon Glass 		return NULL;
1968ef761edSSimon Glass 	}
1978ef761edSSimon Glass 
1988ef761edSSimon Glass 	mmc_dev = dev_get_parent(dev);
1998ef761edSSimon Glass 
20097525647SSimon Glass 	struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
20197525647SSimon Glass 
20297525647SSimon Glass 	return mmc;
2038ef761edSSimon Glass }
2048ef761edSSimon Glass 
2058ef761edSSimon Glass int get_mmc_num(void)
2068ef761edSSimon Glass {
20746683f3dSKever Yang 	return max((blk_find_max_devnum(IF_TYPE_MMC) + 1), 0);
2088ef761edSSimon Glass }
2098ef761edSSimon Glass 
2108ef761edSSimon Glass int mmc_get_next_devnum(void)
2118ef761edSSimon Glass {
212dd399cb7SMasahiro Yamada 	return blk_find_max_devnum(IF_TYPE_MMC);
2138ef761edSSimon Glass }
2148ef761edSSimon Glass 
2158ef761edSSimon Glass struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
2168ef761edSSimon Glass {
2178ef761edSSimon Glass 	struct blk_desc *desc;
2188ef761edSSimon Glass 	struct udevice *dev;
2198ef761edSSimon Glass 
2208ef761edSSimon Glass 	device_find_first_child(mmc->dev, &dev);
2218ef761edSSimon Glass 	if (!dev)
2228ef761edSSimon Glass 		return NULL;
2238ef761edSSimon Glass 	desc = dev_get_uclass_platdata(dev);
2248ef761edSSimon Glass 
2258ef761edSSimon Glass 	return desc;
2268ef761edSSimon Glass }
2278ef761edSSimon Glass 
2288ef761edSSimon Glass void mmc_do_preinit(void)
2298ef761edSSimon Glass {
2308ef761edSSimon Glass 	struct udevice *dev;
2318ef761edSSimon Glass 	struct uclass *uc;
2328ef761edSSimon Glass 	int ret;
2338ef761edSSimon Glass 
2348ef761edSSimon Glass 	ret = uclass_get(UCLASS_MMC, &uc);
2358ef761edSSimon Glass 	if (ret)
2368ef761edSSimon Glass 		return;
2378ef761edSSimon Glass 	uclass_foreach_dev(dev, uc) {
2388ef761edSSimon Glass 		struct mmc *m = mmc_get_mmc_dev(dev);
2398ef761edSSimon Glass 
2408ef761edSSimon Glass 		if (!m)
2418ef761edSSimon Glass 			continue;
2428ef761edSSimon Glass #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
2438ef761edSSimon Glass 		mmc_set_preinit(m, 1);
2448ef761edSSimon Glass #endif
2458ef761edSSimon Glass 		if (m->preinit)
2468ef761edSSimon Glass 			mmc_start_init(m);
2478ef761edSSimon Glass 	}
2488ef761edSSimon Glass }
2498ef761edSSimon Glass 
2508ef761edSSimon Glass #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
2518ef761edSSimon Glass void print_mmc_devices(char separator)
2528ef761edSSimon Glass {
2538ef761edSSimon Glass 	struct udevice *dev;
2548ef761edSSimon Glass 	char *mmc_type;
2558ef761edSSimon Glass 	bool first = true;
2568ef761edSSimon Glass 
2578ef761edSSimon Glass 	for (uclass_first_device(UCLASS_MMC, &dev);
2588ef761edSSimon Glass 	     dev;
2591bd4f92cSXu Ziyuan 	     uclass_next_device(&dev), first = false) {
2608ef761edSSimon Glass 		struct mmc *m = mmc_get_mmc_dev(dev);
2618ef761edSSimon Glass 
2628ef761edSSimon Glass 		if (!first) {
2638ef761edSSimon Glass 			printf("%c", separator);
2648ef761edSSimon Glass 			if (separator != '\n')
2658ef761edSSimon Glass 				puts(" ");
2668ef761edSSimon Glass 		}
2678ef761edSSimon Glass 		if (m->has_init)
2688ef761edSSimon Glass 			mmc_type = IS_SD(m) ? "SD" : "eMMC";
2698ef761edSSimon Glass 		else
2708ef761edSSimon Glass 			mmc_type = NULL;
2718ef761edSSimon Glass 
2728ef761edSSimon Glass 		printf("%s: %d", m->cfg->name, mmc_get_blk_desc(m)->devnum);
2738ef761edSSimon Glass 		if (mmc_type)
2748ef761edSSimon Glass 			printf(" (%s)", mmc_type);
2758ef761edSSimon Glass 	}
2768ef761edSSimon Glass 
2778ef761edSSimon Glass 	printf("\n");
2788ef761edSSimon Glass }
2798ef761edSSimon Glass 
2808ef761edSSimon Glass #else
2818ef761edSSimon Glass void print_mmc_devices(char separator) { }
2828ef761edSSimon Glass #endif
283eede897eSSimon Glass 
284eede897eSSimon Glass int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
285eede897eSSimon Glass {
286eede897eSSimon Glass 	struct blk_desc *bdesc;
287eede897eSSimon Glass 	struct udevice *bdev;
28802ad33aaSJaehoon Chung 	int ret, devnum = -1;
289eede897eSSimon Glass 
29066656020SSimon Glass 	if (!mmc_get_ops(dev))
29166656020SSimon Glass 		return -ENOSYS;
29202ad33aaSJaehoon Chung #ifndef CONFIG_SPL_BUILD
29302ad33aaSJaehoon Chung 	/* Use the fixed index with aliase node's index */
29466e0ed5cSSimon Glass 	ret = dev_read_alias_seq(dev, &devnum);
29566e0ed5cSSimon Glass 	debug("%s: alias ret=%d, devnum=%d\n", __func__, ret, devnum);
29602ad33aaSJaehoon Chung #endif
29702ad33aaSJaehoon Chung 
29802ad33aaSJaehoon Chung 	ret = blk_create_devicef(dev, "mmc_blk", "blk", IF_TYPE_MMC,
29902ad33aaSJaehoon Chung 			devnum, 512, 0, &bdev);
300eede897eSSimon Glass 	if (ret) {
301eede897eSSimon Glass 		debug("Cannot create block device\n");
302eede897eSSimon Glass 		return ret;
303eede897eSSimon Glass 	}
304eede897eSSimon Glass 	bdesc = dev_get_uclass_platdata(bdev);
305eede897eSSimon Glass 	mmc->cfg = cfg;
306eede897eSSimon Glass 	mmc->priv = dev;
307eede897eSSimon Glass 
308eede897eSSimon Glass 	/* the following chunk was from mmc_register() */
309eede897eSSimon Glass 
310eede897eSSimon Glass 	/* Setup dsr related values */
311eede897eSSimon Glass 	mmc->dsr_imp = 0;
312eede897eSSimon Glass 	mmc->dsr = 0xffffffff;
313eede897eSSimon Glass 	/* Setup the universal parts of the block interface just once */
314eede897eSSimon Glass 	bdesc->removable = 1;
315eede897eSSimon Glass 
316eede897eSSimon Glass 	/* setup initial part type */
317eede897eSSimon Glass 	bdesc->part_type = cfg->part_type;
318eede897eSSimon Glass 	mmc->dev = dev;
319eede897eSSimon Glass 
320eede897eSSimon Glass 	return 0;
321eede897eSSimon Glass }
322eede897eSSimon Glass 
323eede897eSSimon Glass int mmc_unbind(struct udevice *dev)
324eede897eSSimon Glass {
325eede897eSSimon Glass 	struct udevice *bdev;
326eede897eSSimon Glass 
327eede897eSSimon Glass 	device_find_first_child(dev, &bdev);
328eede897eSSimon Glass 	if (bdev) {
329706865afSStefan Roese 		device_remove(bdev, DM_REMOVE_NORMAL);
330eede897eSSimon Glass 		device_unbind(bdev);
331eede897eSSimon Glass 	}
332eede897eSSimon Glass 
333eede897eSSimon Glass 	return 0;
334eede897eSSimon Glass }
335eede897eSSimon Glass 
336eede897eSSimon Glass static int mmc_select_hwpart(struct udevice *bdev, int hwpart)
337eede897eSSimon Glass {
338eede897eSSimon Glass 	struct udevice *mmc_dev = dev_get_parent(bdev);
339eede897eSSimon Glass 	struct mmc *mmc = mmc_get_mmc_dev(mmc_dev);
340eede897eSSimon Glass 	struct blk_desc *desc = dev_get_uclass_platdata(bdev);
341eede897eSSimon Glass 
342eede897eSSimon Glass 	if (desc->hwpart == hwpart)
343eede897eSSimon Glass 		return 0;
344eede897eSSimon Glass 
345eede897eSSimon Glass 	if (mmc->part_config == MMCPART_NOAVAILABLE)
346eede897eSSimon Glass 		return -EMEDIUMTYPE;
347eede897eSSimon Glass 
348dd399cb7SMasahiro Yamada 	return mmc_switch_part(mmc, hwpart);
349eede897eSSimon Glass }
350eede897eSSimon Glass 
351a0269bb6SFiach Antaw static int mmc_blk_probe(struct udevice *dev)
352a0269bb6SFiach Antaw {
353854f9a71SSimon Glass 	struct udevice *mmc_dev = dev_get_parent(dev);
354854f9a71SSimon Glass 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(mmc_dev);
355854f9a71SSimon Glass 	struct mmc *mmc = upriv->mmc;
356854f9a71SSimon Glass 	int ret;
357a0269bb6SFiach Antaw 
358854f9a71SSimon Glass 	ret = mmc_init(mmc);
359854f9a71SSimon Glass 	if (ret) {
360854f9a71SSimon Glass 		debug("%s: mmc_init() failed (err=%d)\n", __func__, ret);
361854f9a71SSimon Glass 		return ret;
362854f9a71SSimon Glass 	}
363854f9a71SSimon Glass 
364854f9a71SSimon Glass 	return 0;
365a0269bb6SFiach Antaw }
366a0269bb6SFiach Antaw 
367eede897eSSimon Glass static const struct blk_ops mmc_blk_ops = {
368eede897eSSimon Glass 	.read	= mmc_bread,
369d6400c3fSJean-Jacques Hiblot #if CONFIG_IS_ENABLED(MMC_WRITE)
370eede897eSSimon Glass 	.write	= mmc_bwrite,
371561e624cSSimon Glass 	.erase	= mmc_berase,
372eede897eSSimon Glass #endif
373eede897eSSimon Glass 	.select_hwpart	= mmc_select_hwpart,
374eede897eSSimon Glass };
375eede897eSSimon Glass 
376eede897eSSimon Glass U_BOOT_DRIVER(mmc_blk) = {
377eede897eSSimon Glass 	.name		= "mmc_blk",
378eede897eSSimon Glass 	.id		= UCLASS_BLK,
379eede897eSSimon Glass 	.ops		= &mmc_blk_ops,
380a0269bb6SFiach Antaw 	.probe		= mmc_blk_probe,
381eede897eSSimon Glass };
3828ef761edSSimon Glass #endif /* CONFIG_BLK */
3838ef761edSSimon Glass 
384e7ecf7cbSSimon Glass U_BOOT_DRIVER(mmc) = {
385e7ecf7cbSSimon Glass 	.name	= "mmc",
386e7ecf7cbSSimon Glass 	.id	= UCLASS_MMC,
387e7ecf7cbSSimon Glass };
388e7ecf7cbSSimon Glass 
389e7ecf7cbSSimon Glass UCLASS_DRIVER(mmc) = {
390e7ecf7cbSSimon Glass 	.id		= UCLASS_MMC,
391e7ecf7cbSSimon Glass 	.name		= "mmc",
392e7ecf7cbSSimon Glass 	.flags		= DM_UC_FLAG_SEQ_ALIAS,
393e7ecf7cbSSimon Glass 	.per_device_auto_alloc_size = sizeof(struct mmc_uclass_priv),
394e7ecf7cbSSimon Glass };
395