cpu.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2018
  4. * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <dm/test.h>
  9. #include <dm/uclass-internal.h>
  10. #include <cpu.h>
  11. #include <test/ut.h>
  12. static int dm_test_cpu(struct unit_test_state *uts)
  13. {
  14. struct udevice *dev;
  15. char text[128];
  16. struct cpu_info info;
  17. ut_assertok(cpu_probe_all());
  18. /* Check that cpu_probe_all really activated all CPUs */
  19. for (uclass_find_first_device(UCLASS_CPU, &dev);
  20. dev;
  21. uclass_find_next_device(&dev))
  22. ut_assert(dev->flags & DM_FLAG_ACTIVATED);
  23. ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu-test1", &dev));
  24. ut_assertok(cpu_get_desc(dev, text, sizeof(text)));
  25. ut_assertok(strcmp(text, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"));
  26. ut_assertok(cpu_get_info(dev, &info));
  27. ut_asserteq(info.cpu_freq, 42 * 42 * 42 * 42 * 42);
  28. ut_asserteq(info.features, 0x42424242);
  29. ut_asserteq(cpu_get_count(dev), 42);
  30. ut_assertok(cpu_get_vendor(dev, text, sizeof(text)));
  31. ut_assertok(strcmp(text, "Languid Example Garbage Inc."));
  32. return 0;
  33. }
  34. DM_TEST(dm_test_cpu, DM_TESTF_SCAN_FDT);