Commit 1704d083b3a1acfe167dc2e3b687263f05a65087

Authored by Simon Glass
1 parent dc6f4d3a55

dm: reset: Allow reset_walk() to return

Add a new reset_walk_halt() function to cause a reset and then halt on
failure. The reset_walk() function returns an error code.

This is needed for testing since otherwise U-Boot will halt in the middle
of a test.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 35 additions and 7 deletions Side-by-side Diff

drivers/misc/reset-uclass.c
... ... @@ -25,23 +25,34 @@
25 25 return ops->request(dev, type);
26 26 }
27 27  
28   -void reset_walk(enum reset_t type)
  28 +int reset_walk(enum reset_t type)
29 29 {
30 30 struct udevice *dev;
31   - int ret = 0;
  31 + int ret = -ENOSYS;
32 32  
33 33 while (ret != -EINPROGRESS && type < RESET_COUNT) {
34 34 for (uclass_first_device(UCLASS_RESET, &dev);
35   - dev;
36   - uclass_next_device(&dev)) {
  35 + dev;
  36 + uclass_next_device(&dev)) {
37 37 ret = reset_request(dev, type);
38 38 if (ret == -EINPROGRESS)
39 39 break;
40 40 }
  41 + type++;
41 42 }
42 43  
  44 + return ret;
  45 +}
  46 +
  47 +void reset_walk_halt(enum reset_t type)
  48 +{
  49 + int ret;
  50 +
  51 + ret = reset_walk(type);
  52 +
43 53 /* Wait for the reset to take effect */
44   - mdelay(100);
  54 + if (ret == -EINPROGRESS)
  55 + mdelay(100);
45 56  
46 57 /* Still no reset? Give up */
47 58 printf("Reset not supported on this platform\n");
... ... @@ -53,7 +64,15 @@
53 64 */
54 65 void reset_cpu(ulong addr)
55 66 {
56   - reset_walk(RESET_WARM);
  67 + reset_walk_halt(RESET_WARM);
  68 +}
  69 +
  70 +
  71 +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  72 +{
  73 + reset_walk_halt(RESET_WARM);
  74 +
  75 + return 0;
57 76 }
58 77  
59 78 UCLASS_DRIVER(reset) = {
... ... @@ -51,8 +51,17 @@
51 51 * If this function fails to reset, it will display a message and halt
52 52 *
53 53 * @type: Reset type to request
  54 + * @return -EINPROGRESS if a reset is in progress, -ENOSYS if not available
54 55 */
55   -void reset_walk(enum reset_t type);
  56 +int reset_walk(enum reset_t type);
  57 +
  58 +/**
  59 + * reset_walk_halt() - try to reset, otherwise halt
  60 + *
  61 + * This calls reset_walk(). If it returns, indicating that reset is not
  62 + * supported, it prints a message and halts.
  63 + */
  64 +void reset_walk_halt(enum reset_t type);
56 65  
57 66 /**
58 67 * reset_cpu() - calls reset_walk(RESET_WARM)