xref: /rk3399_rockchip-uboot/drivers/mtd/mtd-uclass.c (revision 3cccee98d513346f131b0872647af8e21541e818)
1d8587993SThomas Chou /*
2d8587993SThomas Chou  * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
3d8587993SThomas Chou  *
4d8587993SThomas Chou  * SPDX-License-Identifier:	GPL-2.0+
5d8587993SThomas Chou  */
6d8587993SThomas Chou 
7d8587993SThomas Chou #include <common.h>
8d8587993SThomas Chou #include <dm.h>
9*3cccee98SMiquel Raynal #include <dm/device-internal.h>
10d8587993SThomas Chou #include <errno.h>
11d8587993SThomas Chou #include <mtd.h>
12d8587993SThomas Chou 
13*3cccee98SMiquel Raynal /**
14*3cccee98SMiquel Raynal  * mtd_probe - Probe the device @dev if not already done
15*3cccee98SMiquel Raynal  *
16*3cccee98SMiquel Raynal  * @dev: U-Boot device to probe
17*3cccee98SMiquel Raynal  *
18*3cccee98SMiquel Raynal  * @return 0 on success, an error otherwise.
19*3cccee98SMiquel Raynal  */
mtd_probe(struct udevice * dev)20*3cccee98SMiquel Raynal int mtd_probe(struct udevice *dev)
21*3cccee98SMiquel Raynal {
22*3cccee98SMiquel Raynal 	if (device_active(dev))
23*3cccee98SMiquel Raynal 		return 0;
24*3cccee98SMiquel Raynal 
25*3cccee98SMiquel Raynal 	return device_probe(dev);
26*3cccee98SMiquel Raynal }
27*3cccee98SMiquel Raynal 
28d8587993SThomas Chou /*
29d8587993SThomas Chou  * Implement a MTD uclass which should include most flash drivers.
30d8587993SThomas Chou  * The uclass private is pointed to mtd_info.
31d8587993SThomas Chou  */
32d8587993SThomas Chou 
33d8587993SThomas Chou UCLASS_DRIVER(mtd) = {
34d8587993SThomas Chou 	.id		= UCLASS_MTD,
35d8587993SThomas Chou 	.name		= "mtd",
36d8587993SThomas Chou 	.per_device_auto_alloc_size = sizeof(struct mtd_info),
37d8587993SThomas Chou };
38