xref: /openbmc/u-boot/drivers/board/board-uclass.c (revision cbd2fba1)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2017
4  * Mario Six,  Guntermann & Drunck GmbH, mario.six@gdsys.cc
5  */
6 
7 #include <common.h>
8 #include <dm.h>
9 #include <board.h>
10 
11 int board_get(struct udevice **devp)
12 {
13 	return uclass_first_device_err(UCLASS_BOARD, devp);
14 }
15 
16 int board_detect(struct udevice *dev)
17 {
18 	struct board_ops *ops = board_get_ops(dev);
19 
20 	if (!ops->detect)
21 		return -ENOSYS;
22 
23 	return ops->detect(dev);
24 }
25 
26 int board_get_bool(struct udevice *dev, int id, bool *val)
27 {
28 	struct board_ops *ops = board_get_ops(dev);
29 
30 	if (!ops->get_bool)
31 		return -ENOSYS;
32 
33 	return ops->get_bool(dev, id, val);
34 }
35 
36 int board_get_int(struct udevice *dev, int id, int *val)
37 {
38 	struct board_ops *ops = board_get_ops(dev);
39 
40 	if (!ops->get_int)
41 		return -ENOSYS;
42 
43 	return ops->get_int(dev, id, val);
44 }
45 
46 int board_get_str(struct udevice *dev, int id, size_t size, char *val)
47 {
48 	struct board_ops *ops = board_get_ops(dev);
49 
50 	if (!ops->get_str)
51 		return -ENOSYS;
52 
53 	return ops->get_str(dev, id, size, val);
54 }
55 
56 UCLASS_DRIVER(board) = {
57 	.id		= UCLASS_BOARD,
58 	.name		= "board",
59 	.post_bind	= dm_scan_fdt_dev,
60 };
61