reboot-mode.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) 2018 Theobroma Systems Design und Consulting GmbH
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <reboot-mode/reboot-mode.h>
  8. #include <env.h>
  9. #include <log.h>
  10. #include <asm/gpio.h>
  11. #include <asm/test.h>
  12. #include <dm/test.h>
  13. #include <test/test.h>
  14. #include <test/ut.h>
  15. static int dm_test_reboot_mode_gpio(struct unit_test_state *uts)
  16. {
  17. struct udevice *gpio_dev;
  18. struct udevice *rm_dev;
  19. int gpio0_offset = 0;
  20. int gpio1_offset = 1;
  21. uclass_get_device_by_name(UCLASS_GPIO, "pinmux-gpios", &gpio_dev);
  22. /* Prepare the GPIOs for "download" mode */
  23. sandbox_gpio_set_direction(gpio_dev, gpio0_offset, 0);
  24. sandbox_gpio_set_direction(gpio_dev, gpio1_offset, 0);
  25. sandbox_gpio_set_value(gpio_dev, gpio0_offset, 1);
  26. sandbox_gpio_set_value(gpio_dev, gpio1_offset, 1);
  27. ut_assertok(uclass_get_device_by_name(UCLASS_REBOOT_MODE,
  28. "reboot-mode0", &rm_dev));
  29. ut_assertok(dm_reboot_mode_update(rm_dev));
  30. ut_asserteq_str("download", env_get("bootstatus"));
  31. return 0;
  32. }
  33. DM_TEST(dm_test_reboot_mode_gpio,
  34. UT_TESTF_PROBE_TEST | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);