@@ -1238,6 +1238,65 @@ static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#endif
+static int
+do_mem_mwait(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ ulong addr;
+#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
+ u64 val, readval;
+#else
+ ulong val, readval;
+#endif
+ int size;
+
+ if (argc != 3)
+ return CMD_RET_USAGE;
+
+ /* check for size specification */
+ size = cmd_get_data_size(argv[0], 4);
+ if (size < 1)
+ return 1;
+
+ /* first arg: address */
+ addr = simple_strtoul(argv[1], NULL, 16);
+
+ /* second arg: expected value */
+#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
+ val = simple_strtoull(argv[2], NULL, 16);
+ printf("waiting 0x%llx at 0x%lx...\n", val, addr);
+#else
+ val = simple_strtoul(argv[2], NULL, 16);
+ printf("waiting 0x%lx at 0x%lx...\n", val, addr);
+#endif
+
+ for (;;) {
+ if (size == 4)
+ readval = *((u32 *)addr);
+#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
+ else if (size == 8)
+ readval = *((u64 *)addr);
+#endif
+ else if (size == 2)
+ readval = *((u16 *)addr);
+ else
+ readval = *((u8 *)addr);
+
+ if (readval == val)
+ return 0;
+
+ /* check for ctrl-c to abort... */
+ if (ctrlc()) {
+ puts("Abort\n");
+ return 0;
+ }
+
+ WATCHDOG_RESET();
+ udelay(1000);
+ }
+
+ return 0;
+}
+
/**************************************************/
U_BOOT_CMD(
md, 3, 1, do_mem_md,
@@ -1399,6 +1458,16 @@ U_BOOT_CMD(
);
#endif /* CONFIG_MX_CYCLIC */
+U_BOOT_CMD(
+ mwait, 3, 1, do_mem_mwait,
+ "memory wait for value",
+#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
+ "[.b, .w, .l, .q] address value\n"
+#else
+ "[.b, .w, .l] address value\n"
+#endif
+);
+
#ifdef CONFIG_CMD_MEMINFO
U_BOOT_CMD(
meminfo, 3, 1, do_mem_info,