tests: lib: devicetree: api: Add tests for IRQ_INTC_* macros

Extend api test suite to cover the new devicetree macros. This
includes extending the devicetree overlay with two new bindings:

- GPIO device which is also an interrupt controller
- interrupt holder using interrupts-extended to point to both
  existing interrupt controller test_intc, and the newly added
  GPIO device

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
This commit is contained in:
Bjarki Arge Andreasen 2023-12-08 19:52:00 +01:00 committed by Carles Cufí
parent 6516e7fac2
commit 4403d8f4c6
4 changed files with 93 additions and 0 deletions

View file

@ -0,0 +1,29 @@
# Copyright (c) 2023 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0
description: Test GPIO with INTC node
compatible: "vnd,gpio-intc-device"
include:
- gpio-controller.yaml
- interrupt-controller.yaml
- base.yaml
properties:
reg:
required: true
"#gpio-cells":
const: 2
"#interrupt-cells":
const: 2
gpio-cells:
- pin
- flags
interrupt-cells:
- pin
- flags

View file

@ -0,0 +1,15 @@
# Copyright (c) 2023 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0
description: Test Interrupt Controller with extended interrupts
compatible: "vnd,interrupt-holder-extended"
include: [base.yaml]
properties:
interrupts-extended:
required: true
interrupt-names:
required: true

View file

@ -203,6 +203,16 @@
status = "okay"; status = "okay";
}; };
test_gpio_4: gpio@1234abcd {
compatible = "vnd,gpio-intc-device";
reg = <0x1234abcd 0x500>;
gpio-controller;
#gpio-cells = <0x2>;
interrupt-controller;
#interrupt-cells = <0x2>;
status = "okay";
};
test_i2c: i2c@11112222 { test_i2c: i2c@11112222 {
#address-cells = < 1 >; #address-cells = < 1 >;
#size-cells = < 0 >; #size-cells = < 0 >;
@ -431,6 +441,15 @@
interrupt-names = "err", "stat", "done"; interrupt-names = "err", "stat", "done";
}; };
/* there should only be one of these */
test_irq_extended: interrupt-holder-extended {
compatible = "vnd,interrupt-holder-extended";
status = "okay";
interrupts-extended = <&test_intc 70 7>,
<&test_gpio_4 30 3>;
interrupt-names = "int1", "int2";
};
test_fixed_clk: test-fixed-clock { test_fixed_clk: test-fixed-clock {
compatible = "fixed-clock"; compatible = "fixed-clock";
clock-frequency = <25000000>; clock-frequency = <25000000>;

View file

@ -21,12 +21,14 @@
#define TEST_ARRAYS DT_NODELABEL(test_arrays) #define TEST_ARRAYS DT_NODELABEL(test_arrays)
#define TEST_PH DT_NODELABEL(test_phandles) #define TEST_PH DT_NODELABEL(test_phandles)
#define TEST_IRQ DT_NODELABEL(test_irq) #define TEST_IRQ DT_NODELABEL(test_irq)
#define TEST_IRQ_EXT DT_NODELABEL(test_irq_extended)
#define TEST_TEMP DT_NODELABEL(test_temp_sensor) #define TEST_TEMP DT_NODELABEL(test_temp_sensor)
#define TEST_REG DT_NODELABEL(test_reg) #define TEST_REG DT_NODELABEL(test_reg)
#define TEST_VENDOR DT_NODELABEL(test_vendor) #define TEST_VENDOR DT_NODELABEL(test_vendor)
#define TEST_MODEL DT_NODELABEL(test_vendor) #define TEST_MODEL DT_NODELABEL(test_vendor)
#define TEST_ENUM_0 DT_NODELABEL(test_enum_0) #define TEST_ENUM_0 DT_NODELABEL(test_enum_0)
#define TEST_64BIT DT_NODELABEL(test_reg_64) #define TEST_64BIT DT_NODELABEL(test_reg_64)
#define TEST_INTC DT_NODELABEL(test_intc)
#define TEST_I2C DT_NODELABEL(test_i2c) #define TEST_I2C DT_NODELABEL(test_i2c)
#define TEST_I2C_DEV DT_PATH(test, i2c_11112222, test_i2c_dev_10) #define TEST_I2C_DEV DT_PATH(test, i2c_11112222, test_i2c_dev_10)
@ -44,6 +46,7 @@
#define TEST_GPIO_1 DT_NODELABEL(test_gpio_1) #define TEST_GPIO_1 DT_NODELABEL(test_gpio_1)
#define TEST_GPIO_2 DT_NODELABEL(test_gpio_2) #define TEST_GPIO_2 DT_NODELABEL(test_gpio_2)
#define TEST_GPIO_4 DT_NODELABEL(test_gpio_4)
#define TEST_GPIO_HOG_1 DT_PATH(test, gpio_deadbeef, test_gpio_hog_1) #define TEST_GPIO_HOG_1 DT_PATH(test, gpio_deadbeef, test_gpio_hog_1)
#define TEST_GPIO_HOG_2 DT_PATH(test, gpio_deadbeef, test_gpio_hog_2) #define TEST_GPIO_HOG_2 DT_PATH(test, gpio_deadbeef, test_gpio_hog_2)
@ -3149,4 +3152,31 @@ ZTEST(devicetree_api, test_reset)
zassert_equal(DT_INST_RESET_ID(0), 10, ""); zassert_equal(DT_INST_RESET_ID(0), 10, "");
} }
#undef DT_DRV_COMPAT
#define DT_DRV_COMPAT vnd_interrupt_holder_extended
ZTEST(devicetree_api, test_interrupt_controller)
{
/* DT_IRQ_INTC_BY_IDX */
zassert_true(DT_SAME_NODE(DT_IRQ_INTC_BY_IDX(TEST_IRQ_EXT, 0), TEST_INTC), "");
zassert_true(DT_SAME_NODE(DT_IRQ_INTC_BY_IDX(TEST_IRQ_EXT, 1), TEST_GPIO_4), "");
/* DT_IRQ_INTC_BY_NAME */
zassert_true(DT_SAME_NODE(DT_IRQ_INTC_BY_NAME(TEST_IRQ_EXT, int1), TEST_INTC), "");
zassert_true(DT_SAME_NODE(DT_IRQ_INTC_BY_NAME(TEST_IRQ_EXT, int2), TEST_GPIO_4), "");
/* DT_IRQ_INTC */
zassert_true(DT_SAME_NODE(DT_IRQ_INTC(TEST_IRQ_EXT), TEST_INTC), "");
/* DT_INST_IRQ_INTC_BY_IDX */
zassert_true(DT_SAME_NODE(DT_INST_IRQ_INTC_BY_IDX(0, 0), TEST_INTC), "");
zassert_true(DT_SAME_NODE(DT_INST_IRQ_INTC_BY_IDX(0, 1), TEST_GPIO_4), "");
/* DT_INST_IRQ_INTC_BY_NAME */
zassert_true(DT_SAME_NODE(DT_INST_IRQ_INTC_BY_NAME(0, int1), TEST_INTC), "");
zassert_true(DT_SAME_NODE(DT_INST_IRQ_INTC_BY_NAME(0, int2), TEST_GPIO_4), "");
/* DT_INST_IRQ_INTC */
zassert_true(DT_SAME_NODE(DT_INST_IRQ_INTC(0), TEST_INTC), "");
}
ZTEST_SUITE(devicetree_api, NULL, NULL, NULL, NULL, NULL); ZTEST_SUITE(devicetree_api, NULL, NULL, NULL, NULL, NULL);