diff options
author | Jonas Karlman <jonas@kwiboo.se> | 2023-02-22 22:44:39 +0000 |
---|---|---|
committer | Kever Yang <kever.yang@rock-chips.com> | 2023-02-28 18:07:28 +0800 |
commit | 9a850d1fcd2bd2def1adceef58b48d9a9cf3e309 (patch) | |
tree | cb79767ad0e3bb3169218df40c62c0858e4141f8 | |
parent | f888098229174514029c02d76918e27be50d9e1a (diff) |
rockchip: otp: Add dump_otp debug command
Add a simple debug command to dump the content of the otp.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
-rw-r--r-- | drivers/misc/rockchip-otp.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/misc/rockchip-otp.c b/drivers/misc/rockchip-otp.c index 3da99e83179..c19cd5ce625 100644 --- a/drivers/misc/rockchip-otp.c +++ b/drivers/misc/rockchip-otp.c @@ -5,6 +5,8 @@ #include <common.h> #include <asm/io.h> +#include <command.h> +#include <display_options.h> #include <dm.h> #include <linux/bitops.h> #include <linux/delay.h> @@ -70,6 +72,39 @@ struct rockchip_otp_data { int block_size; }; +#if defined(DEBUG) +static int dump_otp(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + struct udevice *dev; + u8 data[4]; + int ret, i; + + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_DRIVER_GET(rockchip_otp), &dev); + if (ret) { + printf("%s: no misc-device found\n", __func__); + return 0; + } + + for (i = 0; true; i += sizeof(data)) { + ret = misc_read(dev, i, &data, sizeof(data)); + if (ret < 0) + return 0; + + print_buffer(i, data, 1, sizeof(data), sizeof(data)); + } + + return 0; +} + +U_BOOT_CMD( + dump_otp, 1, 1, dump_otp, + "Dump the content of the otp", + "" +); +#endif + static int rockchip_otp_poll_timeout(struct rockchip_otp_plat *otp, u32 flag, u32 reg) { |