diff --git a/cmd/Kconfig b/cmd/Kconfig index d9507cd927..39c1df16c6 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -930,6 +930,11 @@ config CMD_RKSFC help Rockchip SFC device support +config CMD_RK_SECURE_STORAGE + bool "dump rockchip efuse/otp content" + help + Dump the data which is written in OTP or efuse. + config CMD_SATA bool "sata - Access SATA subsystem" select SATA diff --git a/cmd/Makefile b/cmd/Makefile index e485988fc8..b35c28c638 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -122,6 +122,7 @@ obj-$(CONFIG_CMD_NVME) += nvme.o obj-$(CONFIG_CMD_ROCKUSB) += rockusb.o obj-$(CONFIG_CMD_RKNAND) += rknand.o obj-$(CONFIG_CMD_RKSFC) += rksfc.o +obj-$(CONFIG_CMD_RK_SECURE_STORAGE) += rk_secure_storage.o obj-$(CONFIG_CMD_SF) += sf.o obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o diff --git a/cmd/rk_secure_storage.c b/cmd/rk_secure_storage.c new file mode 100644 index 0000000000..1edb0ac015 --- /dev/null +++ b/cmd/rk_secure_storage.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd + */ + +#include +#include +#include +#include + +#ifdef CONFIG_ROCKCHIP_OTP +static int dump_otps(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + struct udevice *dev; + u8 otps[64] = {0}; + int ret; + + /* retrieve the device */ + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_GET_DRIVER(rockchip_otp), &dev); + if (ret) { + printf("%s: no misc-device found\n", __func__); + return 0; + } + + ret = misc_read(dev, 0, &otps, sizeof(otps)); + if (ret) { + printf("%s: misc_read failed\n", __func__); + return 0; + } + + printf("otp-contents:\n"); + print_buffer(0, otps, 1, 64, 16); + + return 0; +} + +U_BOOT_CMD( + rockchip_dump_otps, 1, 1, dump_otps, + "Dump the content of the otps", + "" +); +#endif + +#ifdef CONFIG_ROCKCHIP_EFUSE +static int dump_efuses(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + /* + * N.B.: This function is tailored towards the RK3399 and assumes that + * there's always 32 fuses x 32 bits (i.e. 128 bytes of data) to + * be read. + */ + + struct udevice *dev; + u8 fuses[128] = {0}; + int ret; + + /* retrieve the device */ + ret = uclass_get_device_by_driver(UCLASS_MISC, + DM_GET_DRIVER(rockchip_efuse), &dev); + if (ret) { + printf("%s: no misc-device found\n", __func__); + return 0; + } + + ret = misc_read(dev, 0, &fuses, sizeof(fuses)); + if (ret) { + printf("%s: misc_read failed\n", __func__); + return 0; + } + + printf("efuse-contents:\n"); + print_buffer(0, fuses, 1, 128, 16); + + return 0; +} + +U_BOOT_CMD( + rockchip_dump_efuses, 1, 1, dump_efuses, + "Dump the content of the efuses", + "" +); +#endif