Lines Matching refs:rate

3  * Kunit test for clk rate management
19 unsigned long rate;
28 return ctx->rate;
34 /* Just return the same rate without modifying it */
46 req->rate = req->max_rate;
59 req->rate = req->min_rate;
65 unsigned long rate,
71 ctx->rate = rate;
110 * clk_round_rate() or clk_set_rate() with a rate lower than
114 * behaviour to always pick up the closest rate higher than the
115 * requested rate. If we get something lower, it thus considers
119 * between rates above the parent rate which would be rounded to
176 ctx->rate = DUMMY_CLOCK_INIT_RATE;
213 * Test that the actual rate matches what is returned by clk_get_rate()
220 unsigned long rate;
222 rate = clk_get_rate(clk);
223 KUNIT_ASSERT_GT(test, rate, 0);
224 KUNIT_EXPECT_EQ(test, rate, ctx->rate);
230 * Test that, after a call to clk_set_rate(), the rate returned by
234 * modify the requested rate, which is our case in clk_dummy_rate_ops.
241 unsigned long rate;
247 rate = clk_get_rate(clk);
248 KUNIT_ASSERT_GT(test, rate, 0);
249 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
255 * Test that, after several calls to clk_set_rate(), the rate returned
259 * modify the requested rate, which is our case in clk_dummy_rate_ops.
266 unsigned long rate;
276 rate = clk_get_rate(clk);
277 KUNIT_ASSERT_GT(test, rate, 0);
278 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
319 * Test suite for a basic rate clock, without any parent.
321 * These tests exercise the rate API with simple scenarios
340 ctx->rate = DUMMY_CLOCK_INIT_RATE;
354 * the rate and clk_get_rate() will return the underlying clock rate
362 unsigned long rate;
364 rate = clk_get_rate(clk);
365 KUNIT_ASSERT_GT(test, rate, 0);
366 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE);
368 /* We change the rate behind the clock framework's back */
369 ctx->rate = DUMMY_CLOCK_RATE_1;
370 rate = clk_get_rate(clk);
371 KUNIT_ASSERT_GT(test, rate, 0);
372 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
379 * properly if the rate hasn't changed.
386 unsigned long rate;
394 rate = clk_get_rate(clk);
395 KUNIT_ASSERT_GT(test, rate, 0);
396 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
397 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
404 * properly if the rate has changed in hardware.
406 * In this case, it means that if the rate wasn't initially in the range
408 * without the kernel knowing about it, its rate shouldn't be affected.
415 unsigned long rate;
417 /* We change the rate behind the clock framework's back */
418 ctx->rate = DUMMY_CLOCK_RATE_1 + 1000;
425 rate = clk_get_rate(clk);
426 KUNIT_ASSERT_GT(test, rate, 0);
427 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
440 * Test suite for a basic, uncached, rate clock, without any parent.
442 * These tests exercise the rate API with simple scenarios
466 ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1;
474 ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2;
543 * that clock and the parent is changed, its rate after the reparenting
547 * reevaluate whether the new clock rate is within its boundaries or
557 unsigned long rate;
583 rate = clk_get_rate(clk);
584 KUNIT_ASSERT_GT(test, rate, 0);
585 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 - 1000);
586 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
630 ctx->parents_ctx[1].rate = DUMMY_CLOCK_INIT_RATE;
701 * rate.
735 * parent, the rate of the mux and its new parent are consistent.
744 unsigned long parent_rate, rate;
756 rate = clk_get_rate(clk);
757 KUNIT_ASSERT_GT(test, rate, 0);
758 KUNIT_EXPECT_EQ(test, parent_rate, rate);
766 * parent, calling clk_put() on the mux won't affect the parent rate.
800 * its rate is out of range.
809 unsigned long rate;
821 rate = clk_get_rate(clk);
822 KUNIT_ASSERT_GT(test, rate, 0);
823 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
824 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
833 * its rate is within range.
870 * account when rounding a rate.
878 long rate;
884 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000);
885 KUNIT_ASSERT_GT(test, rate, 0);
886 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
887 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
893 * Test that, for a mux that started orphan, was assigned and rate and
894 * then got switched to a valid parent, its rate is eventually within
897 * FIXME: Even though we update the rate as part of clk_set_parent(), we
898 * don't evaluate whether that new rate is within range and needs to be
908 unsigned long rate;
921 rate = clk_get_rate(clk);
922 KUNIT_ASSERT_GT(test, rate, 0);
923 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
924 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
974 ctx->parent_ctx.rate = DUMMY_CLOCK_INIT_RATE;
1041 * Test that for a clock that can't modify its rate and with a single
1073 * Test that for a clock that can't modify its rate and with a single
1105 * Test that for a clock that can't modify its rate and with a single
1117 long rate;
1126 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000);
1127 KUNIT_ASSERT_GT(test, rate, 0);
1128 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
1129 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
1135 * Test that for a clock that can't modify its rate and with a single
1147 long rate;
1159 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000);
1160 KUNIT_ASSERT_GT(test, rate, 0);
1161 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
1162 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000);
1164 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_2 + 1000);
1165 KUNIT_ASSERT_GT(test, rate, 0);
1166 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
1167 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000);
1173 * Test that for a clock that can't modify its rate and with a single
1185 long rate;
1197 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000);
1198 KUNIT_ASSERT_GT(test, rate, 0);
1199 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
1200 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000);
1202 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_2 + 1000);
1203 KUNIT_ASSERT_GT(test, rate, 0);
1204 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
1205 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2 - 1000);
1263 ctx->parent_ctx.rate = DUMMY_CLOCK_INIT_RATE;
1273 * Test that a mux-only clock, with an initial rate within a range,
1274 * will still have the same rate after the range has been enforced.
1284 unsigned long rate, new_rate;
1286 rate = clk_get_rate(clk);
1287 KUNIT_ASSERT_GT(test, rate, 0);
1291 ctx->parent_ctx.rate - 1000,
1292 ctx->parent_ctx.rate + 1000),
1297 KUNIT_EXPECT_EQ(test, rate, new_rate);
1356 ctx->parent_parent_ctx.rate = DUMMY_CLOCK_INIT_RATE;
1380 * will return the proper rate.
1388 unsigned long rate;
1390 rate = clk_get_rate(clk);
1391 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE);
1398 * clk_set_rate_range() won't affect its rate if it is already within
1410 unsigned long rate;
1418 rate = clk_get_rate(clk);
1419 KUNIT_ASSERT_GT(test, rate, 0);
1420 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_INIT_RATE);
1454 * and that it will make sure the rate of the clock is within the
1462 unsigned long rate;
1470 rate = clk_get_rate(clk);
1471 KUNIT_ASSERT_GT(test, rate, 0);
1472 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
1473 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
1479 * Test that calling clk_set_rate_range with a minimum rate higher than
1480 * the maximum rate returns an error.
1526 * Test that if our clock has some boundaries and we try to round a rate
1527 * lower than the minimum, the returned rate will be within range.
1534 long rate;
1542 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_1 - 1000);
1543 KUNIT_ASSERT_GT(test, rate, 0);
1544 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
1545 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
1551 * Test that if our clock has some boundaries and we try to set a rate
1552 * higher than the maximum, the new rate will be within range.
1559 unsigned long rate;
1571 rate = clk_get_rate(clk);
1572 KUNIT_ASSERT_GT(test, rate, 0);
1573 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
1574 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
1581 * set a rate lower than the minimum, the rate returned by
1582 * clk_round_rate() will be consistent with the new rate set by
1611 * Test that if our clock has some boundaries and we try to round a rate
1612 * higher than the maximum, the returned rate will be within range.
1619 long rate;
1627 rate = clk_round_rate(clk, DUMMY_CLOCK_RATE_2 + 1000);
1628 KUNIT_ASSERT_GT(test, rate, 0);
1629 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
1630 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
1636 * Test that if our clock has some boundaries and we try to set a rate
1637 * higher than the maximum, the new rate will be within range.
1644 unsigned long rate;
1656 rate = clk_get_rate(clk);
1657 KUNIT_ASSERT_GT(test, rate, 0);
1658 KUNIT_EXPECT_GE(test, rate, DUMMY_CLOCK_RATE_1);
1659 KUNIT_EXPECT_LE(test, rate, DUMMY_CLOCK_RATE_2);
1666 * set a rate higher than the maximum, the rate returned by
1667 * clk_round_rate() will be consistent with the new rate set by
1696 * Test that if our clock has a rate lower than the minimum set by a
1697 * call to clk_set_rate_range(), the rate will be raised to match the
1701 * modify the requested rate, which is our case in clk_dummy_rate_ops.
1708 unsigned long rate;
1720 rate = clk_get_rate(clk);
1721 KUNIT_ASSERT_GT(test, rate, 0);
1722 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
1728 * Test that if our clock has a rate higher than the maximum set by a
1729 * call to clk_set_rate_range(), the rate will be lowered to match the
1733 * modify the requested rate, which is our case in clk_dummy_rate_ops.
1740 unsigned long rate;
1752 rate = clk_get_rate(clk);
1753 KUNIT_ASSERT_GT(test, rate, 0);
1754 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
1775 * Test suite for a basic rate clock, without any parent.
1777 * These tests exercise the rate range API: clk_set_rate_range(),
1789 * clk_set_rate_range(), the core will reevaluate whether a new rate is
1792 * With clk_dummy_maximize_rate_ops, this means that the rate will
1800 unsigned long rate;
1812 rate = clk_get_rate(clk);
1813 KUNIT_ASSERT_GT(test, rate, 0);
1814 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
1822 rate = clk_get_rate(clk);
1823 KUNIT_ASSERT_GT(test, rate, 0);
1824 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2 - 1000);
1832 rate = clk_get_rate(clk);
1833 KUNIT_ASSERT_GT(test, rate, 0);
1834 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
1842 * whether a new rate is needed each and every time.
1844 * With clk_dummy_maximize_rate_ops, this means that the rate will
1853 unsigned long rate;
1871 rate = clk_get_rate(clk);
1872 KUNIT_ASSERT_GT(test, rate, 0);
1873 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
1881 rate = clk_get_rate(clk);
1882 KUNIT_ASSERT_GT(test, rate, 0);
1883 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
1889 rate = clk_get_rate(clk);
1890 KUNIT_ASSERT_GT(test, rate, 0);
1891 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
1901 * whether a new rate is needed, including when a user drop its clock.
1903 * With clk_dummy_maximize_rate_ops, this means that the rate will
1912 unsigned long rate;
1930 rate = clk_get_rate(clk);
1931 KUNIT_ASSERT_GT(test, rate, 0);
1932 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
1940 rate = clk_get_rate(clk);
1941 KUNIT_ASSERT_GT(test, rate, 0);
1942 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
1946 rate = clk_get_rate(clk);
1947 KUNIT_ASSERT_GT(test, rate, 0);
1948 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
1962 * Test suite for a basic rate clock, without any parent.
1964 * These tests exercise the rate range API: clk_set_rate_range(),
1966 * driver that will always try to run at the highest possible rate.
1977 * clk_set_rate_range(), the core will reevaluate whether a new rate is
1980 * With clk_dummy_minimize_rate_ops, this means that the rate will
1988 unsigned long rate;
2000 rate = clk_get_rate(clk);
2001 KUNIT_ASSERT_GT(test, rate, 0);
2002 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
2010 rate = clk_get_rate(clk);
2011 KUNIT_ASSERT_GT(test, rate, 0);
2012 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1 + 1000);
2020 rate = clk_get_rate(clk);
2021 KUNIT_ASSERT_GT(test, rate, 0);
2022 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
2030 * whether a new rate is needed each and every time.
2032 * With clk_dummy_minimize_rate_ops, this means that the rate will
2041 unsigned long rate;
2055 rate = clk_get_rate(clk);
2056 KUNIT_ASSERT_GT(test, rate, 0);
2057 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
2065 rate = clk_get_rate(clk);
2066 KUNIT_ASSERT_GT(test, rate, 0);
2067 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
2073 rate = clk_get_rate(clk);
2074 KUNIT_ASSERT_GT(test, rate, 0);
2075 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
2085 * whether a new rate is needed, including when a user drop its clock.
2087 * With clk_dummy_minimize_rate_ops, this means that the rate will
2096 unsigned long rate;
2110 rate = clk_get_rate(clk);
2111 KUNIT_ASSERT_GT(test, rate, 0);
2112 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
2120 rate = clk_get_rate(clk);
2121 KUNIT_ASSERT_GT(test, rate, 0);
2122 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_2);
2126 rate = clk_get_rate(clk);
2127 KUNIT_ASSERT_GT(test, rate, 0);
2128 KUNIT_EXPECT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
2142 * Test suite for a basic rate clock, without any parent.
2144 * These tests exercise the rate range API: clk_set_rate_range(),
2146 * driver that will always try to run at the lowest possible rate.
2175 ctx->mux_ctx.parents_ctx[0].rate = DUMMY_CLOCK_RATE_1;
2183 ctx->mux_ctx.parents_ctx[1].rate = DUMMY_CLOCK_RATE_2;
2217 * Test that, for a clock that will forward any rate request to its
2218 * parent, the rate request structure returned by __clk_determine_rate
2227 unsigned long rate;
2230 rate = clk_get_rate(clk);
2231 KUNIT_ASSERT_EQ(test, rate, DUMMY_CLOCK_RATE_1);
2238 KUNIT_EXPECT_EQ(test, req.rate, DUMMY_CLOCK_RATE_2);
2252 * The leaf clock has CLK_SET_RATE_PARENT, and will forward rate
2254 * fit for a given rate.
2260 .name = "clk-leaf-mux-set-rate-parent",
2325 ctx->mux_ctx.parents_ctx[0].rate = DUMMY_CLOCK_RATE_1;
2333 ctx->mux_ctx.parents_ctx[1].rate = DUMMY_CLOCK_RATE_2;
2436 ctx->parents_ctx[0].rate = DUMMY_CLOCK_RATE_1;
2444 ctx->parents_ctx[1].rate = DUMMY_CLOCK_RATE_2;
2472 * clk_round_rate() on it with a rate that should cause it to change
2508 * clk_set_rate() on it with a rate that should cause it to change
2519 unsigned long rate;
2539 rate = clk_get_rate(clk);
2540 KUNIT_ASSERT_GT(test, rate, 0);
2541 KUNIT_EXPECT_EQ(test, rate, parent_rate);