2018-08-06 10:23:44 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* (C) Copyright 2018
|
|
|
|
* Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
2020-05-10 11:40:05 -06:00
|
|
|
#include <log.h>
|
2018-08-06 10:23:44 +02:00
|
|
|
#include <dm/test.h>
|
|
|
|
#include <dm/uclass-internal.h>
|
|
|
|
#include <cpu.h>
|
2020-07-19 10:15:37 -06:00
|
|
|
#include <test/test.h>
|
2018-08-06 10:23:44 +02:00
|
|
|
#include <test/ut.h>
|
|
|
|
|
|
|
|
static int dm_test_cpu(struct unit_test_state *uts)
|
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
char text[128];
|
|
|
|
struct cpu_info info;
|
|
|
|
|
|
|
|
ut_assertok(cpu_probe_all());
|
|
|
|
|
|
|
|
/* Check that cpu_probe_all really activated all CPUs */
|
|
|
|
for (uclass_find_first_device(UCLASS_CPU, &dev);
|
|
|
|
dev;
|
|
|
|
uclass_find_next_device(&dev))
|
2020-12-19 10:40:10 -07:00
|
|
|
ut_assert(dev_get_flags(dev) & DM_FLAG_ACTIVATED);
|
2018-08-06 10:23:44 +02:00
|
|
|
|
2021-08-28 11:42:08 +02:00
|
|
|
ut_assertok(uclass_get_device_by_name(UCLASS_CPU, "cpu@1", &dev));
|
2020-05-03 21:58:49 +08:00
|
|
|
ut_asserteq_ptr(cpu_get_current_dev(), dev);
|
|
|
|
ut_asserteq(cpu_is_current(dev), 1);
|
2018-08-06 10:23:44 +02:00
|
|
|
|
|
|
|
ut_assertok(cpu_get_desc(dev, text, sizeof(text)));
|
|
|
|
ut_assertok(strcmp(text, "LEG Inc. SuperMegaUltraTurbo CPU No. 1"));
|
|
|
|
|
|
|
|
ut_assertok(cpu_get_info(dev, &info));
|
|
|
|
ut_asserteq(info.cpu_freq, 42 * 42 * 42 * 42 * 42);
|
|
|
|
ut_asserteq(info.features, 0x42424242);
|
2023-08-13 21:52:19 +02:00
|
|
|
ut_asserteq(info.address_width, IS_ENABLED(CONFIG_PHYS_64BIT) ? 64 : 32);
|
2018-08-06 10:23:44 +02:00
|
|
|
|
|
|
|
ut_asserteq(cpu_get_count(dev), 42);
|
|
|
|
|
|
|
|
ut_assertok(cpu_get_vendor(dev, text, sizeof(text)));
|
|
|
|
ut_assertok(strcmp(text, "Languid Example Garbage Inc."));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-07-28 19:41:12 -06:00
|
|
|
DM_TEST(dm_test_cpu, UT_TESTF_SCAN_FDT);
|