Skip to content

Commit 3380bba

Browse files
committed
tests/drivers/clock_control: stm32h7_device: Add test for CKPER source
Add 2 scenarios to test CKPER used as a clock source. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 8920e87 commit 3380bba

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2021 Linaro Limited
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*
8+
* Warning: This overlay performs configuration from clean sheet.
9+
* It is assumed that it is applied after core_init.overlay file.
10+
*/
11+
12+
&clk_hsi {
13+
status = "okay";
14+
hsi-div = <1>;
15+
};
16+
17+
&perck {
18+
clocks = <&rcc STM32_SRC_HSI_KER CKPER_SEL(0)>;
19+
status = "okay";
20+
};
21+
22+
&spi1 {
23+
/delete-property/ clocks;
24+
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00001000>,
25+
<&rcc STM32_SRC_CKPER SPI123_SEL(4)>;
26+
clock-names = "reg", "kernel";
27+
status = "okay";
28+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2021 Linaro Limited
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*
8+
* Warning: This overlay performs configuration from clean sheet.
9+
* It is assumed that it is applied after core_init.overlay file.
10+
*/
11+
12+
&clk_hsi {
13+
status = "okay";
14+
hsi-div = <8>; /* HSI RC: 64MHz, hsi_clk = 8MHz */
15+
};
16+
17+
&perck {
18+
clocks = <&rcc STM32_SRC_HSI_KER CKPER_SEL(0)>;
19+
status = "okay";
20+
};
21+
22+
&spi1 {
23+
/delete-property/ clocks;
24+
clocks = <&rcc STM32_CLOCK_BUS_APB2 0x00001000>,
25+
<&rcc STM32_SRC_CKPER SPI123_SEL(4)>;
26+
clock-names = "reg", "kernel";
27+
status = "okay";
28+
};

tests/drivers/clock_control/stm32_clock_configuration/stm32h7_devices/src/test_stm32_clock_configuration.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ static void test_spi_clk_config(void)
7575
zassert_equal(spi1_actual_clk_src, RCC_SPI123CLKSOURCE_PLL3,
7676
"Expected SPI src: PLLQ (%d). Actual SPI src: %d",
7777
spi1_actual_clk_src, RCC_SPI123CLKSOURCE_PLL3);
78+
} else if (spi1_dt_ker_clk_src == STM32_SRC_CKPER) {
79+
zassert_equal(spi1_actual_clk_src, RCC_SPI123CLKSOURCE_CLKP,
80+
"Expected SPI src: PLLQ (%d). Actual SPI src: %d",
81+
spi1_actual_clk_src, RCC_SPI123CLKSOURCE_CLKP);
7882
} else {
7983
zassert_true(1, "Unexpected ker_clk src(%d)", spi1_dt_ker_clk_src);
8084
}
@@ -104,6 +108,8 @@ static void test_spi_clk_config(void)
104108
spi1_dt_clk_freq, spi1_actual_clk_freq);
105109
}
106110

111+
TC_PRINT("SPI1 clock freq: %d(MHz)\n", spi1_actual_clk_freq / (1000*1000));
112+
107113
/* Test clock_off(reg_clk) */
108114
r = clock_control_off(DEVICE_DT_GET(STM32_CLOCK_CONTROL_NODE),
109115
(clock_control_subsys_t) &spi1_reg_clk_cfg);

tests/drivers/clock_control/stm32_clock_configuration/stm32h7_devices/testcase.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ tests:
88
extra_args: DTC_OVERLAY_FILE="boards/core_init.overlay;boards/spi1_pllq_2_d1ppre_4.overlay"
99
drivers.stm32_clock_configuration.h7_dev.spi1_pll3p_1_d1ppre_4:
1010
extra_args: DTC_OVERLAY_FILE="boards/core_init.overlay;boards/spi1_pll3p_1_d1ppre_4.overlay"
11+
drivers.stm32_clock_configuration.h7_dev.spi1_per_ck_d1ppre_1:
12+
extra_args: DTC_OVERLAY_FILE="boards/core_init.overlay;boards/spi1_per_ck_d1ppre_1.overlay"
13+
drivers.stm32_clock_configuration.h7_dev.spi1_per_ck_hsi:
14+
extra_args: DTC_OVERLAY_FILE="boards/core_init.overlay;boards/spi1_per_ck_hsi.overlay"

0 commit comments

Comments
 (0)