Re: [PATCH 04/11] rockchip: otp: Add dump_otp debug command

2023-02-22 Thread Kever Yang



On 2023/2/16 07:48, Jonas Karlman wrote:

Add a simple debug command to dump the content of the otp.

Signed-off-by: Jonas Karlman 

Reviewed-by: Kever Yang 

Thanks,
- Kever

---
  drivers/misc/rockchip-otp.c | 35 +++
  1 file changed, 35 insertions(+)

diff --git a/drivers/misc/rockchip-otp.c b/drivers/misc/rockchip-otp.c
index babb6ce2f241..c41f0a606258 100644
--- a/drivers/misc/rockchip-otp.c
+++ b/drivers/misc/rockchip-otp.c
@@ -5,6 +5,8 @@
  
  #include 

  #include 
+#include 
+#include 
  #include 
  #include 
  #include 
@@ -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), );
+   if (ret) {
+   printf("%s: no misc-device found\n", __func__);
+   return 0;
+   }
+
+   for (i = 0; true; i += sizeof(data)) {
+   ret = misc_read(dev, i, , sizeof(data));
+   if (ret < 0)
+   return 0;
+
+   print_buffer(i, data, sizeof(data), 1, 1);
+   }
+
+   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)
  {


[PATCH 04/11] rockchip: otp: Add dump_otp debug command

2023-02-15 Thread Jonas Karlman
Add a simple debug command to dump the content of the otp.

Signed-off-by: Jonas Karlman 
---
 drivers/misc/rockchip-otp.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/drivers/misc/rockchip-otp.c b/drivers/misc/rockchip-otp.c
index babb6ce2f241..c41f0a606258 100644
--- a/drivers/misc/rockchip-otp.c
+++ b/drivers/misc/rockchip-otp.c
@@ -5,6 +5,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -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), );
+   if (ret) {
+   printf("%s: no misc-device found\n", __func__);
+   return 0;
+   }
+
+   for (i = 0; true; i += sizeof(data)) {
+   ret = misc_read(dev, i, , sizeof(data));
+   if (ret < 0)
+   return 0;
+
+   print_buffer(i, data, sizeof(data), 1, 1);
+   }
+
+   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)
 {
-- 
2.39.1