Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Thomas Chou | d858799 | 2015-11-07 14:20:31 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw> |
Thomas Chou | d858799 | 2015-11-07 14:20:31 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Miquel Raynal | e9f62db | 2018-09-29 12:58:24 +0200 | [diff] [blame] | 8 | #include <dm/device-internal.h> |
Thomas Chou | d858799 | 2015-11-07 14:20:31 +0800 | [diff] [blame] | 9 | #include <errno.h> |
| 10 | #include <mtd.h> |
| 11 | |
Miquel Raynal | e9f62db | 2018-09-29 12:58:24 +0200 | [diff] [blame] | 12 | /** |
| 13 | * mtd_probe - Probe the device @dev if not already done |
| 14 | * |
| 15 | * @dev: U-Boot device to probe |
| 16 | * |
| 17 | * @return 0 on success, an error otherwise. |
| 18 | */ |
| 19 | int mtd_probe(struct udevice *dev) |
| 20 | { |
| 21 | if (device_active(dev)) |
| 22 | return 0; |
| 23 | |
| 24 | return device_probe(dev); |
| 25 | } |
| 26 | |
Thomas Chou | d858799 | 2015-11-07 14:20:31 +0800 | [diff] [blame] | 27 | /* |
| 28 | * Implement a MTD uclass which should include most flash drivers. |
| 29 | * The uclass private is pointed to mtd_info. |
| 30 | */ |
| 31 | |
| 32 | UCLASS_DRIVER(mtd) = { |
| 33 | .id = UCLASS_MTD, |
| 34 | .name = "mtd", |
| 35 | .per_device_auto_alloc_size = sizeof(struct mtd_info), |
| 36 | }; |