]>
git.ipfire.org Git - people/ms/u-boot.git/blob - test/dm/clk.c
2 * Copyright (C) 2015 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/err.h>
15 /* Test that we can find and adjust clocks */
16 static int dm_test_clk_base(struct unit_test_state
*uts
)
21 ut_assertok(uclass_get_device(UCLASS_CLK
, 0, &clk
));
22 rate
= clk_get_rate(clk
);
23 ut_asserteq(SANDBOX_CLK_RATE
, rate
);
24 ut_asserteq(-EINVAL
, clk_set_rate(clk
, 0));
25 ut_assertok(clk_set_rate(clk
, rate
* 2));
26 ut_asserteq(SANDBOX_CLK_RATE
* 2, clk_get_rate(clk
));
30 DM_TEST(dm_test_clk_base
, DM_TESTF_SCAN_PDATA
| DM_TESTF_SCAN_FDT
);
32 /* Test that peripheral clocks work as expected */
33 static int dm_test_clk_periph(struct unit_test_state
*uts
)
38 ut_assertok(uclass_get_device(UCLASS_CLK
, 0, &clk
));
39 rate
= clk_set_periph_rate(clk
, PERIPH_ID_COUNT
, 123);
40 ut_asserteq(-EINVAL
, rate
);
41 ut_asserteq(1, IS_ERR_VALUE(rate
));
43 rate
= clk_set_periph_rate(clk
, PERIPH_ID_SPI
, 123);
45 ut_asserteq(123, clk_get_periph_rate(clk
, PERIPH_ID_SPI
));
47 rate
= clk_set_periph_rate(clk
, PERIPH_ID_SPI
, 1234);
48 ut_asserteq(123, rate
);
50 rate
= clk_set_periph_rate(clk
, PERIPH_ID_I2C
, 567);
52 rate
= clk_set_periph_rate(clk
, PERIPH_ID_SPI
, 1234);
53 ut_asserteq(1234, rate
);
55 ut_asserteq(567, clk_get_periph_rate(clk
, PERIPH_ID_I2C
));
59 DM_TEST(dm_test_clk_periph
, DM_TESTF_SCAN_PDATA
| DM_TESTF_SCAN_FDT
);