[PATCH v4 0/3] Add reboot mode support

Nandor Han nandor.han at vaisala.com
Thu Jun 10 15:56:42 CEST 2021


Description
-----------
Add support for reboot-mode configuration using GPIOs and RTC SRAM as
back-end.

Testing
-------

Tested on a Zynq based board where device tree was configured to contain
the reboot-mode configuration:

&amba {
    status = "okay";

    reboot-mode-gpio {
        compatible = "reboot-mode-gpio";
        gpios = <&gpio0 47 GPIO_ACTIVE_LOW>;
        mode-test = <0x1>;
    };

    reboot-mode-rtc {
        compatible = "reboot-mode-rtc";
        rtc = <&rtc_0>;
        reg = <0x14 4>;
        mode-test = <0x21969147>;
    };
};

In addition to this and not part of this patchset is a change to board.c
where GPIO or RTC SRAM backed is selected dynamically at runtime.

1. Test that the reboot mode configured in user-space is read in U-Boot and
environment configured: PASS

Userspace ~ # reboot test
....
[  177.335936] reboot: Restarting system with command 'test'

U-Boot SPL 2019.01 (Mar 29 2019 - 10:44:22 +0000)
...
U-Boot> print reboot-mode
reboot-mode=test

2. Reset the system using the reset command and stop in U-Boot.
3. Verify that reboot-mode env variable is not configured anymore: PASS

U-Boot> print reboot-mode
## Error: "reboot-mode" not defined

4. Toggle the GPIO configured for test mode to active and reset the system
with command reset.
5. Stop in U-Boot and check that reboot-mode env variable is configured:PASS

U-Boot> print reboot-mode
reboot-mode=test


6. Verify that unit-tests are successful: PASS
```
localhost /u-boot-latest (wip-reboot-mode)> ./test/py/test.py --bd sandbox --build -k ut_dm_reboot_mode -v
...
test/py/tests/test_ut.py::test_ut[ut_dm_reboot_mode_gpio] PASSED                                                                                       [ 50%]
test/py/tests/test_ut.py::test_ut[ut_dm_reboot_mode_rtc] PASSED                                                                                        [100%]

========================================================== 2 passed, 759 deselected in 0.40 seconds ==========================================================
```

Changes since v1:
----------------
- rebased

Changes since v2:
----------------
- unit-tests added

Changes since v3:
----------------
- rebased
- fix the struct udevice and struct driver incompatibilities

Nandor Han (3):
  reboot-mode: add support for reboot mode control
  reboot-mode: read the boot mode from GPIOs status
  reboot-mode: read the boot mode from RTC memory

 arch/sandbox/dts/test.dts                     |  18 +++
 configs/sandbox_defconfig                     |   3 +
 .../reboot-mode/reboot-mode-gpio.txt          |  20 +++
 .../reboot-mode/reboot-mode-rtc.txt           |  22 +++
 drivers/Kconfig                               |   2 +
 drivers/Makefile                              |   1 +
 drivers/reboot-mode/Kconfig                   |  36 +++++
 drivers/reboot-mode/Makefile                  |   9 ++
 drivers/reboot-mode/reboot-mode-gpio.c        | 128 +++++++++++++++++
 drivers/reboot-mode/reboot-mode-rtc.c         | 127 +++++++++++++++++
 drivers/reboot-mode/reboot-mode-uclass.c      | 134 ++++++++++++++++++
 include/dm/uclass-id.h                        |   1 +
 include/reboot-mode/reboot-mode-gpio.h        |  32 +++++
 include/reboot-mode/reboot-mode-rtc.h         |  16 +++
 include/reboot-mode/reboot-mode.h             |  56 ++++++++
 test/dm/Makefile                              |   1 +
 test/dm/reboot-mode.c                         |  71 ++++++++++
 17 files changed, 677 insertions(+)
 create mode 100644 doc/device-tree-bindings/reboot-mode/reboot-mode-gpio.txt
 create mode 100644 doc/device-tree-bindings/reboot-mode/reboot-mode-rtc.txt
 create mode 100644 drivers/reboot-mode/Kconfig
 create mode 100644 drivers/reboot-mode/Makefile
 create mode 100644 drivers/reboot-mode/reboot-mode-gpio.c
 create mode 100644 drivers/reboot-mode/reboot-mode-rtc.c
 create mode 100644 drivers/reboot-mode/reboot-mode-uclass.c
 create mode 100644 include/reboot-mode/reboot-mode-gpio.h
 create mode 100644 include/reboot-mode/reboot-mode-rtc.h
 create mode 100644 include/reboot-mode/reboot-mode.h
 create mode 100644 test/dm/reboot-mode.c

-- 
2.26.3



More information about the U-Boot mailing list