luckfox-pico-sdk/sysdrv/source/uboot/u-boot/cmd/demo.c
luckfox-eng29 8f34c2760d project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between
the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door
for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more
usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp:
Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for
compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem.
sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device
tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately.
sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick
boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades.
sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for
fastboot.

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
2024-10-14 09:47:04 +08:00

132 lines
2.8 KiB
C

/*
* Copyright (c) 2013 Google, Inc
*
* (C) Copyright 2012
* Pavel Herrmann <morpheus.ibis@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm-demo.h>
#include <mapmem.h>
#include <asm/io.h>
struct udevice *demo_dev;
static int do_demo_hello(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
int ch = 0;
if (argc)
ch = *argv[0];
return demo_hello(demo_dev, ch);
}
static int do_demo_status(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
int status;
int ret;
ret = demo_status(demo_dev, &status);
if (ret)
return ret;
printf("Status: %d\n", status);
return 0;
}
static int do_demo_light(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
int light;
int ret;
if (argc) {
light = simple_strtoul(argv[0], NULL, 16);
ret = demo_set_light(demo_dev, light);
} else {
ret = demo_get_light(demo_dev);
if (ret >= 0) {
printf("Light: %x\n", ret);
ret = 0;
}
}
return ret;
}
int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
struct udevice *dev;
int i, ret;
puts("Demo uclass entries:\n");
for (i = 0, uclass_first_device(UCLASS_DEMO, &dev); dev;
uclass_next_device(&dev)) {
printf("entry %d - instance %08x, ops %08x, platdata %08x\n",
i++, map_to_sysmem(dev),
map_to_sysmem(dev->driver->ops),
map_to_sysmem(dev_get_platdata(dev)));
}
return cmd_process_error(cmdtp, ret);
}
static cmd_tbl_t demo_commands[] = {
U_BOOT_CMD_MKENT(list, 0, 1, do_demo_list, "", ""),
U_BOOT_CMD_MKENT(hello, 2, 1, do_demo_hello, "", ""),
U_BOOT_CMD_MKENT(light, 2, 1, do_demo_light, "", ""),
U_BOOT_CMD_MKENT(status, 1, 1, do_demo_status, "", ""),
};
static int do_demo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
cmd_tbl_t *demo_cmd;
int devnum = 0;
int ret;
if (argc < 2)
return CMD_RET_USAGE;
demo_cmd = find_cmd_tbl(argv[1], demo_commands,
ARRAY_SIZE(demo_commands));
argc -= 2;
argv += 2;
if ((!demo_cmd || argc > demo_cmd->maxargs) ||
((demo_cmd->name[0] != 'l') && (argc < 1)))
return CMD_RET_USAGE;
if (argc) {
devnum = simple_strtoul(argv[0], NULL, 10);
ret = uclass_get_device(UCLASS_DEMO, devnum, &demo_dev);
if (ret)
return cmd_process_error(cmdtp, ret);
argc--;
argv++;
} else {
demo_dev = NULL;
if (demo_cmd->cmd != do_demo_list)
return CMD_RET_USAGE;
}
ret = demo_cmd->cmd(demo_cmd, flag, argc, argv);
return cmd_process_error(demo_cmd, ret);
}
U_BOOT_CMD(
demo, 4, 1, do_demo,
"Driver model (dm) demo operations",
"list List available demo devices\n"
"demo hello <num> [<char>] Say hello\n"
"demo light [<num>] Set or get the lights\n"
"demo status <num> Get demo device status\n"
"demo list List available demo devices"
);