2 * Copyright (c) 2013 Google, Inc
5 * Pavel Herrmann <morpheus.ibis@gmail.com>
7 * SPDX-License-Identifier: GPL-2.0+
14 struct udevice *demo_dev;
16 static int do_demo_hello(cmd_tbl_t *cmdtp, int flag, int argc,
24 return demo_hello(demo_dev, ch);
27 static int do_demo_status(cmd_tbl_t *cmdtp, int flag, int argc,
33 ret = demo_status(demo_dev, &status);
37 printf("Status: %d\n", status);
42 int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
47 puts("Demo uclass entries:\n");
49 for (i = 0, ret = uclass_first_device(UCLASS_DEMO, &dev);
51 ret = uclass_next_device(&dev)) {
52 printf("entry %d - instance %08x, ops %08x, platdata %08x\n",
53 i++, map_to_sysmem(dev),
54 map_to_sysmem(dev->driver->ops),
55 map_to_sysmem(dev_get_platdata(dev)));
58 return cmd_process_error(cmdtp, ret);
61 static cmd_tbl_t demo_commands[] = {
62 U_BOOT_CMD_MKENT(list, 0, 1, do_demo_list, "", ""),
63 U_BOOT_CMD_MKENT(hello, 2, 1, do_demo_hello, "", ""),
64 U_BOOT_CMD_MKENT(status, 1, 1, do_demo_status, "", ""),
67 static int do_demo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
75 demo_cmd = find_cmd_tbl(argv[1], demo_commands,
76 ARRAY_SIZE(demo_commands));
79 if (!demo_cmd || argc > demo_cmd->maxargs)
83 devnum = simple_strtoul(argv[0], NULL, 10);
84 ret = uclass_get_device(UCLASS_DEMO, devnum, &demo_dev);
86 return cmd_process_error(cmdtp, ret);
91 ret = demo_cmd->cmd(demo_cmd, flag, argc, argv);
93 return cmd_process_error(demo_cmd, ret);
98 "Driver model (dm) demo operations",
99 "list List available demo devices\n"
100 "demo hello <num> [<char>] Say hello\n"
101 "demo status <num> Get demo device status"