test: lib: devicetree: add tests for DT_ macros for retrieving PWM period
Add tests for DT_ macros for retrieving the 'period' cell value. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
3046e228e7
commit
8b5b7fcf8d
3 changed files with 39 additions and 8 deletions
|
@ -12,8 +12,9 @@ properties:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
"#pwm-cells":
|
"#pwm-cells":
|
||||||
const: 2
|
const: 3
|
||||||
|
|
||||||
pwm-cells:
|
pwm-cells:
|
||||||
- channel
|
- channel
|
||||||
|
- period
|
||||||
- flags
|
- flags
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
pha-gpios = <&test_gpio_1 50 60>, <&test_gpio_3 70>, <&test_gpio_2 80 90>;
|
pha-gpios = <&test_gpio_1 50 60>, <&test_gpio_3 70>, <&test_gpio_2 80 90>;
|
||||||
foos = <&test_gpio_1 100>, <&test_gpio_2 110>;
|
foos = <&test_gpio_1 100>, <&test_gpio_2 110>;
|
||||||
foo-names = "A", "b-c";
|
foo-names = "A", "b-c";
|
||||||
pwms = <&test_pwm1 8 3>, <&test_pwm2 5 1>;
|
pwms = <&test_pwm1 8 200 3>, <&test_pwm2 5 100 1>;
|
||||||
pwm-names = "red", "green";
|
pwm-names = "red", "green";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@
|
||||||
|
|
||||||
test_pwm1: pwm@55551111 {
|
test_pwm1: pwm@55551111 {
|
||||||
compatible = "vnd,pwm";
|
compatible = "vnd,pwm";
|
||||||
#pwm-cells = <2>;
|
#pwm-cells = <3>;
|
||||||
reg = < 0x55551111 0x1000 >;
|
reg = < 0x55551111 0x1000 >;
|
||||||
label = "TEST_PWM_CTRL_1";
|
label = "TEST_PWM_CTRL_1";
|
||||||
status = "okay";
|
status = "okay";
|
||||||
|
@ -313,7 +313,7 @@
|
||||||
|
|
||||||
test_pwm2: pwm@55552222 {
|
test_pwm2: pwm@55552222 {
|
||||||
compatible = "vnd,pwm";
|
compatible = "vnd,pwm";
|
||||||
#pwm-cells = <2>;
|
#pwm-cells = <3>;
|
||||||
reg = < 0x55552222 0x1000 >;
|
reg = < 0x55552222 0x1000 >;
|
||||||
label = "TEST_PWM_CTRL_2";
|
label = "TEST_PWM_CTRL_2";
|
||||||
status = "okay";
|
status = "okay";
|
||||||
|
|
|
@ -1003,17 +1003,22 @@ static void test_pwms(void)
|
||||||
/* DT_PWMS_CELL_BY_IDX */
|
/* DT_PWMS_CELL_BY_IDX */
|
||||||
zassert_equal(DT_PWMS_CELL_BY_IDX(TEST_PH, 1, channel), 5,
|
zassert_equal(DT_PWMS_CELL_BY_IDX(TEST_PH, 1, channel), 5,
|
||||||
"pwm 2 channel");
|
"pwm 2 channel");
|
||||||
|
zassert_equal(DT_PWMS_CELL_BY_IDX(TEST_PH, 1, period), 100,
|
||||||
|
"pwm 2 period");
|
||||||
zassert_equal(DT_PWMS_CELL_BY_IDX(TEST_PH, 1, flags), 1,
|
zassert_equal(DT_PWMS_CELL_BY_IDX(TEST_PH, 1, flags), 1,
|
||||||
"pwm 2 flags");
|
"pwm 2 flags");
|
||||||
|
|
||||||
/* DT_PWMS_CELL_BY_NAME */
|
/* DT_PWMS_CELL_BY_NAME */
|
||||||
zassert_equal(DT_PWMS_CELL_BY_NAME(TEST_PH, red, channel), 8,
|
zassert_equal(DT_PWMS_CELL_BY_NAME(TEST_PH, red, channel), 8,
|
||||||
"pwm-red channel");
|
"pwm-red channel");
|
||||||
|
zassert_equal(DT_PWMS_CELL_BY_NAME(TEST_PH, red, period), 200,
|
||||||
|
"pwm-red period");
|
||||||
zassert_equal(DT_PWMS_CELL_BY_NAME(TEST_PH, red, flags), 3,
|
zassert_equal(DT_PWMS_CELL_BY_NAME(TEST_PH, red, flags), 3,
|
||||||
"pwm-red flags");
|
"pwm-red flags");
|
||||||
|
|
||||||
/* DT_PWMS_CELL */
|
/* DT_PWMS_CELL */
|
||||||
zassert_equal(DT_PWMS_CELL(TEST_PH, channel), 8, "pwm channel");
|
zassert_equal(DT_PWMS_CELL(TEST_PH, channel), 8, "pwm channel");
|
||||||
|
zassert_equal(DT_PWMS_CELL(TEST_PH, period), 200, "pwm period");
|
||||||
zassert_equal(DT_PWMS_CELL(TEST_PH, flags), 3, "pwm flags");
|
zassert_equal(DT_PWMS_CELL(TEST_PH, flags), 3, "pwm flags");
|
||||||
|
|
||||||
/* DT_PWMS_CHANNEL_BY_IDX */
|
/* DT_PWMS_CHANNEL_BY_IDX */
|
||||||
|
@ -1026,15 +1031,25 @@ static void test_pwms(void)
|
||||||
/* DT_PWMS_CHANNEL */
|
/* DT_PWMS_CHANNEL */
|
||||||
zassert_equal(DT_PWMS_CHANNEL(TEST_PH), 8, "pwm channel");
|
zassert_equal(DT_PWMS_CHANNEL(TEST_PH), 8, "pwm channel");
|
||||||
|
|
||||||
|
/* DT_PWMS_PERIOD_BY_IDX */
|
||||||
|
zassert_equal(DT_PWMS_PERIOD_BY_IDX(TEST_PH, 1), 100, "pwm period");
|
||||||
|
|
||||||
|
/* DT_PWMS_PERIOD_BY_NAME */
|
||||||
|
zassert_equal(DT_PWMS_PERIOD_BY_NAME(TEST_PH, green), 100,
|
||||||
|
"pwm period");
|
||||||
|
|
||||||
|
/* DT_PWMS_PERIOD */
|
||||||
|
zassert_equal(DT_PWMS_PERIOD(TEST_PH), 200, "pwm period");
|
||||||
|
|
||||||
/* DT_PWMS_FLAGS_BY_IDX */
|
/* DT_PWMS_FLAGS_BY_IDX */
|
||||||
zassert_equal(DT_PWMS_FLAGS_BY_IDX(TEST_PH, 1), 1, "pwm channel");
|
zassert_equal(DT_PWMS_FLAGS_BY_IDX(TEST_PH, 1), 1, "pwm flags");
|
||||||
|
|
||||||
/* DT_PWMS_FLAGS_BY_NAME */
|
/* DT_PWMS_FLAGS_BY_NAME */
|
||||||
zassert_equal(DT_PWMS_FLAGS_BY_NAME(TEST_PH, green), 1,
|
zassert_equal(DT_PWMS_FLAGS_BY_NAME(TEST_PH, green), 1,
|
||||||
"pwm channel");
|
"pwm flags");
|
||||||
|
|
||||||
/* DT_PWMS_FLAGS */
|
/* DT_PWMS_FLAGS */
|
||||||
zassert_equal(DT_PWMS_FLAGS(TEST_PH), 3, "pwm channel");
|
zassert_equal(DT_PWMS_FLAGS(TEST_PH), 3, "pwm flags");
|
||||||
|
|
||||||
/* DT_INST */
|
/* DT_INST */
|
||||||
zassert_equal(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT), 1,
|
zassert_equal(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT), 1,
|
||||||
|
@ -1057,16 +1072,22 @@ static void test_pwms(void)
|
||||||
/* DT_INST_PWMS_CELL_BY_IDX */
|
/* DT_INST_PWMS_CELL_BY_IDX */
|
||||||
zassert_equal(DT_INST_PWMS_CELL_BY_IDX(0, 1, channel), 5,
|
zassert_equal(DT_INST_PWMS_CELL_BY_IDX(0, 1, channel), 5,
|
||||||
"pwm 2 channel");
|
"pwm 2 channel");
|
||||||
zassert_equal(DT_INST_PWMS_CELL_BY_IDX(0, 1, flags), 1, "pwm 2 flags");
|
zassert_equal(DT_INST_PWMS_CELL_BY_IDX(0, 1, period), 100,
|
||||||
|
"pwm 2 period");
|
||||||
|
zassert_equal(DT_INST_PWMS_CELL_BY_IDX(0, 1, flags), 1,
|
||||||
|
"pwm 2 flags");
|
||||||
|
|
||||||
/* DT_INST_PWMS_CELL_BY_NAME */
|
/* DT_INST_PWMS_CELL_BY_NAME */
|
||||||
zassert_equal(DT_INST_PWMS_CELL_BY_NAME(0, green, channel), 5,
|
zassert_equal(DT_INST_PWMS_CELL_BY_NAME(0, green, channel), 5,
|
||||||
"pwm-green channel");
|
"pwm-green channel");
|
||||||
|
zassert_equal(DT_INST_PWMS_CELL_BY_NAME(0, green, period), 100,
|
||||||
|
"pwm-green period");
|
||||||
zassert_equal(DT_INST_PWMS_CELL_BY_NAME(0, green, flags), 1,
|
zassert_equal(DT_INST_PWMS_CELL_BY_NAME(0, green, flags), 1,
|
||||||
"pwm-green flags");
|
"pwm-green flags");
|
||||||
|
|
||||||
/* DT_INST_PWMS_CELL */
|
/* DT_INST_PWMS_CELL */
|
||||||
zassert_equal(DT_INST_PWMS_CELL(0, channel), 8, "pwm channel");
|
zassert_equal(DT_INST_PWMS_CELL(0, channel), 8, "pwm channel");
|
||||||
|
zassert_equal(DT_INST_PWMS_CELL(0, period), 200, "pwm period");
|
||||||
zassert_equal(DT_INST_PWMS_CELL(0, flags), 3, "pwm flags");
|
zassert_equal(DT_INST_PWMS_CELL(0, flags), 3, "pwm flags");
|
||||||
|
|
||||||
/* DT_INST_PWMS_CHANNEL_BY_IDX */
|
/* DT_INST_PWMS_CHANNEL_BY_IDX */
|
||||||
|
@ -1078,6 +1099,15 @@ static void test_pwms(void)
|
||||||
/* DT_INST_PWMS_CHANNEL */
|
/* DT_INST_PWMS_CHANNEL */
|
||||||
zassert_equal(DT_INST_PWMS_CHANNEL(0), 8, "pwm channel");
|
zassert_equal(DT_INST_PWMS_CHANNEL(0), 8, "pwm channel");
|
||||||
|
|
||||||
|
/* DT_INST_PWMS_PERIOD_BY_IDX */
|
||||||
|
zassert_equal(DT_INST_PWMS_PERIOD_BY_IDX(0, 1), 100, "pwm period");
|
||||||
|
|
||||||
|
/* DT_INST_PWMS_PERIOD_BY_NAME */
|
||||||
|
zassert_equal(DT_INST_PWMS_PERIOD_BY_NAME(0, red), 200, "pwm periodx");
|
||||||
|
|
||||||
|
/* DT_INST_PWMS_PERIOD */
|
||||||
|
zassert_equal(DT_INST_PWMS_PERIOD(0), 200, "pwm period");
|
||||||
|
|
||||||
/* DT_INST_PWMS_FLAGS_BY_IDX */
|
/* DT_INST_PWMS_FLAGS_BY_IDX */
|
||||||
zassert_equal(DT_INST_PWMS_FLAGS_BY_IDX(0, 1), 1, "pwm channel");
|
zassert_equal(DT_INST_PWMS_FLAGS_BY_IDX(0, 1), 1, "pwm channel");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue