1 // SPDX-License-Identifier: GPL-2.0+
4 * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
13 struct board_sandbox_priv {
19 char vacation_spots[][64] = {"R'lyeh", "Dreamlands", "Plateau of Leng",
20 "Carcosa", "Yuggoth", "The Nameless City"};
22 int board_sandbox_detect(struct udevice *dev)
24 struct board_sandbox_priv *priv = dev_get_priv(dev);
26 priv->called_detect = true;
32 int board_sandbox_get_bool(struct udevice *dev, int id, bool *val)
34 struct board_sandbox_priv *priv = dev_get_priv(dev);
37 case BOOL_CALLED_DETECT:
38 /* Checks if the dectect method has been called */
39 *val = priv->called_detect;
46 int board_sandbox_get_int(struct udevice *dev, int id, int *val)
48 struct board_sandbox_priv *priv = dev_get_priv(dev);
53 /* Increments with every call */
58 /* Decrements with every call */
66 int board_sandbox_get_str(struct udevice *dev, int id, size_t size, char *val)
68 struct board_sandbox_priv *priv = dev_get_priv(dev);
69 int i1 = priv->test_i1;
70 int i2 = priv->test_i2;
71 int index = (i1 * i2) % ARRAY_SIZE(vacation_spots);
74 case STR_VACATIONSPOT:
75 /* Picks a vacation spot depending on i1 and i2 */
76 snprintf(val, size, vacation_spots[index]);
83 static const struct udevice_id board_sandbox_ids[] = {
84 { .compatible = "sandbox,board_sandbox" },
88 static const struct board_ops board_sandbox_ops = {
89 .detect = board_sandbox_detect,
90 .get_bool = board_sandbox_get_bool,
91 .get_int = board_sandbox_get_int,
92 .get_str = board_sandbox_get_str,
95 int board_sandbox_probe(struct udevice *dev)
100 U_BOOT_DRIVER(board_sandbox) = {
101 .name = "board_sandbox",
103 .of_match = board_sandbox_ids,
104 .ops = &board_sandbox_ops,
105 .priv_auto_alloc_size = sizeof(struct board_sandbox_priv),
106 .probe = board_sandbox_probe,