1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd 4 */ 5 6 #include <common.h> 7 #include <command.h> 8 #include <dm.h> 9 #include <misc.h> 10 11 #ifdef CONFIG_ROCKCHIP_OTP 12 static int dump_otps(cmd_tbl_t *cmdtp, int flag, 13 int argc, char * const argv[]) 14 { 15 struct udevice *dev; 16 u8 otps[64] = {0}; 17 int ret; 18 19 /* retrieve the device */ 20 ret = uclass_get_device_by_driver(UCLASS_MISC, 21 DM_GET_DRIVER(rockchip_otp), &dev); 22 if (ret) { 23 printf("%s: no misc-device found\n", __func__); 24 return 0; 25 } 26 27 ret = misc_read(dev, 0, &otps, sizeof(otps)); 28 if (ret) { 29 printf("%s: misc_read failed\n", __func__); 30 return 0; 31 } 32 33 printf("otp-contents:\n"); 34 print_buffer(0, otps, 1, 64, 16); 35 36 return 0; 37 } 38 39 U_BOOT_CMD( 40 rockchip_dump_otps, 1, 1, dump_otps, 41 "Dump the content of the otps", 42 "" 43 ); 44 #endif 45 46 #ifdef CONFIG_ROCKCHIP_EFUSE 47 static int dump_efuses(cmd_tbl_t *cmdtp, int flag, 48 int argc, char * const argv[]) 49 { 50 /* 51 * N.B.: This function is tailored towards the RK3399 and assumes that 52 * there's always 32 fuses x 32 bits (i.e. 128 bytes of data) to 53 * be read. 54 */ 55 56 struct udevice *dev; 57 u8 fuses[128] = {0}; 58 int ret; 59 60 /* retrieve the device */ 61 ret = uclass_get_device_by_driver(UCLASS_MISC, 62 DM_GET_DRIVER(rockchip_efuse), &dev); 63 if (ret) { 64 printf("%s: no misc-device found\n", __func__); 65 return 0; 66 } 67 68 ret = misc_read(dev, 0, &fuses, sizeof(fuses)); 69 if (ret) { 70 printf("%s: misc_read failed\n", __func__); 71 return 0; 72 } 73 74 printf("efuse-contents:\n"); 75 print_buffer(0, fuses, 1, 128, 16); 76 77 return 0; 78 } 79 80 U_BOOT_CMD( 81 rockchip_dump_efuses, 1, 1, dump_efuses, 82 "Dump the content of the efuses", 83 "" 84 ); 85 #endif 86