tests: lib: devicetree: Add tests for endpoint DT macros
Add tests for the new port / endpoint DT macros Signed-off-by: Josuah Demangeon <me@josuah.net> Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
This commit is contained in:
parent
0a9016731f
commit
25f56342da
4 changed files with 178 additions and 0 deletions
|
@ -506,6 +506,71 @@
|
|||
status = "okay";
|
||||
};
|
||||
|
||||
test_video0: video@10010000 {
|
||||
compatible = "vnd,video-single-port";
|
||||
reg = <0x10010000 0x1000>;
|
||||
|
||||
test_video0_port: port {
|
||||
test_video0_out: endpoint {
|
||||
remote-endpoint-label = "test_video2_port0_in0";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test_video1: video@10011000 {
|
||||
compatible = "vnd,video-single-port";
|
||||
reg = <0x10011000 0x1000>;
|
||||
|
||||
test_video1_port: port {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test_video1_out0: endpoint@0 {
|
||||
reg = <0x0>;
|
||||
remote-endpoint-label = "test_video2_port0_in1";
|
||||
};
|
||||
|
||||
test_video1_out1: endpoint@1 {
|
||||
reg = <0x1>;
|
||||
remote-endpoint-label = "test_video2_port1_in";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test_video2: video@10012000 {
|
||||
compatible = "vnd,video-multi-port";
|
||||
reg = <0x10012000 0x1000>;
|
||||
|
||||
ports {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test_video2_port0: port@0 {
|
||||
reg = <0x0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
test_video2_port0_in0: endpoint@0 {
|
||||
reg = <0x0>;
|
||||
remote-endpoint-label = "test_video0_out";
|
||||
};
|
||||
|
||||
test_video2_port0_in1: endpoint@1 {
|
||||
reg = <0x1>;
|
||||
remote-endpoint-label = "test_video1_out0";
|
||||
};
|
||||
};
|
||||
|
||||
test_video2_port1: port@1 {
|
||||
reg = <0x1>;
|
||||
|
||||
test_video2_port1_in: endpoint {
|
||||
remote-endpoint-label = "test_video1_out1";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
test_pwm1: pwm@55551111 {
|
||||
compatible = "vnd,pwm";
|
||||
#pwm-cells = <3>;
|
||||
|
|
|
@ -76,6 +76,20 @@
|
|||
#define TEST_DMA_CTLR_1 DT_NODELABEL(test_dma1)
|
||||
#define TEST_DMA_CTLR_2 DT_NODELABEL(test_dma2)
|
||||
|
||||
#define TEST_VIDEO2 DT_NODELABEL(test_video2)
|
||||
#define TEST_VIDEO2_PORT0 DT_NODELABEL(test_video2_port0)
|
||||
#define TEST_VIDEO2_PORT0_IN0 DT_NODELABEL(test_video2_port0_in0)
|
||||
#define TEST_VIDEO2_PORT0_IN1 DT_NODELABEL(test_video2_port0_in1)
|
||||
#define TEST_VIDEO2_PORT1 DT_NODELABEL(test_video2_port1)
|
||||
#define TEST_VIDEO2_PORT1_IN DT_NODELABEL(test_video2_port1_in)
|
||||
#define TEST_VIDEO0 DT_NODELABEL(test_video0)
|
||||
#define TEST_VIDEO0_OUT DT_NODELABEL(test_video0_out)
|
||||
#define TEST_VIDEO0_PORT DT_NODELABEL(test_video0_port)
|
||||
#define TEST_VIDEO1 DT_NODELABEL(test_video1)
|
||||
#define TEST_VIDEO1_OUT0 DT_NODELABEL(test_video1_out0)
|
||||
#define TEST_VIDEO1_OUT1 DT_NODELABEL(test_video1_out1)
|
||||
#define TEST_VIDEO1_PORT DT_NODELABEL(test_video1_port)
|
||||
|
||||
#define TEST_IO_CHANNEL_CTLR_1 DT_NODELABEL(test_adc_1)
|
||||
#define TEST_IO_CHANNEL_CTLR_2 DT_NODELABEL(test_adc_2)
|
||||
|
||||
|
@ -1309,6 +1323,78 @@ ZTEST(devicetree_api, test_dma)
|
|||
zassert_false(DT_INST_DMAS_HAS_IDX(0, 2), "");
|
||||
}
|
||||
|
||||
#undef DT_DRV_COMPAT
|
||||
DT_FOREACH_STATUS_OKAY_VARGS(vnd_video_single_port, DEVICE_DT_DEFINE, NULL, NULL, NULL, NULL,
|
||||
POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY, NULL);
|
||||
DT_FOREACH_STATUS_OKAY_VARGS(vnd_video_multi_port, DEVICE_DT_DEFINE, NULL, NULL, NULL, NULL,
|
||||
POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY, NULL);
|
||||
ZTEST(devicetree_api, test_video)
|
||||
{
|
||||
/* DT_INST_PORT_BY_ID */
|
||||
#define DT_DRV_COMPAT vnd_video_single_port
|
||||
zassert_true(DT_SAME_NODE(DT_INST_PORT_BY_ID(0, 0),
|
||||
TEST_VIDEO0_PORT), "get port node of video0");
|
||||
zassert_true(DT_SAME_NODE(DT_INST_PORT_BY_ID(1, 0), TEST_VIDEO1_PORT),
|
||||
"get port node of video1");
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT vnd_video_multi_port
|
||||
zassert_true(DT_SAME_NODE(DT_INST_PORT_BY_ID(0, 0), TEST_VIDEO2_PORT0),
|
||||
"get port@0 node of video2");
|
||||
zassert_true(DT_SAME_NODE(DT_INST_PORT_BY_ID(0, 1), TEST_VIDEO2_PORT1),
|
||||
"get port@1 node of video2");
|
||||
#undef DT_DRV_COMPAT
|
||||
|
||||
/* DT_INST_ENDPOINT_BY_ID */
|
||||
#define DT_DRV_COMPAT vnd_video_single_port
|
||||
zassert_true(DT_SAME_NODE(DT_INST_ENDPOINT_BY_ID(0, 0, 0), TEST_VIDEO0_OUT),
|
||||
"get endpoint node of port node of video0");
|
||||
zassert_true(DT_SAME_NODE(DT_INST_ENDPOINT_BY_ID(1, 0, 0), TEST_VIDEO1_OUT0),
|
||||
"get endpoint@0 node of port node of video1");
|
||||
zassert_true(DT_SAME_NODE(DT_INST_ENDPOINT_BY_ID(1, 0, 1), TEST_VIDEO1_OUT1),
|
||||
"get endpoint@1 node of port node of video1");
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT vnd_video_multi_port
|
||||
zassert_true(DT_SAME_NODE(DT_INST_ENDPOINT_BY_ID(0, 0, 0), TEST_VIDEO2_PORT0_IN0),
|
||||
"get endpoint@0 node of port@0 node of video2");
|
||||
zassert_true(DT_SAME_NODE(DT_INST_ENDPOINT_BY_ID(0, 0, 1), TEST_VIDEO2_PORT0_IN1),
|
||||
"get endpoint@1 node of port@0 node of video2");
|
||||
zassert_true(DT_SAME_NODE(DT_INST_ENDPOINT_BY_ID(0, 1, 0), TEST_VIDEO2_PORT1_IN),
|
||||
"get endpoint node of port@1 node of video2");
|
||||
#undef DT_DRV_COMPAT
|
||||
|
||||
/* DT_NODE_BY_ENDPOINT */
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_BY_ENDPOINT(TEST_VIDEO0_OUT),
|
||||
TEST_VIDEO0), "get video0 node from its endpoint");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_BY_ENDPOINT(TEST_VIDEO1_OUT0), TEST_VIDEO1),
|
||||
"get video1 node from its endpoint@0");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_BY_ENDPOINT(TEST_VIDEO1_OUT1), TEST_VIDEO1),
|
||||
"get video1 node from its endpoint@1");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_BY_ENDPOINT(TEST_VIDEO2_PORT0_IN0), TEST_VIDEO2),
|
||||
"get video2 node from its endpoint@0 at port@0");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_BY_ENDPOINT(TEST_VIDEO2_PORT0_IN1), TEST_VIDEO2),
|
||||
"get video2 node from its endpoint@1 at port@0");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_BY_ENDPOINT(TEST_VIDEO2_PORT1_IN), TEST_VIDEO2),
|
||||
"get video2 node from its endpoint at port@1");
|
||||
|
||||
/* DT_NODE_REMOTE_DEVICE */
|
||||
#define DT_DRV_COMPAT vnd_video_single_port
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_REMOTE_DEVICE(TEST_VIDEO0_OUT), TEST_VIDEO2),
|
||||
"get remote device node of video0's endpoint");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_REMOTE_DEVICE(TEST_VIDEO1_OUT0), TEST_VIDEO2),
|
||||
"get remote device node of video1's endpoint@0");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_REMOTE_DEVICE(TEST_VIDEO1_OUT1), TEST_VIDEO2),
|
||||
"get remote device node of video1's endpoint@1");
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT vnd_video_multi_port
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_REMOTE_DEVICE(TEST_VIDEO2_PORT0_IN0), TEST_VIDEO0),
|
||||
"get remote device node of video2's port@0 endpoint@0");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_REMOTE_DEVICE(TEST_VIDEO2_PORT0_IN1), TEST_VIDEO1),
|
||||
"get remote device node of video2's port@0 endpoint@1");
|
||||
zassert_true(DT_SAME_NODE(DT_NODE_REMOTE_DEVICE(TEST_VIDEO2_PORT1_IN), TEST_VIDEO1),
|
||||
"get remote device node of video2's port@1 endpoint");
|
||||
#undef DT_DRV_COMPAT
|
||||
}
|
||||
|
||||
#undef DT_DRV_COMPAT
|
||||
#define DT_DRV_COMPAT vnd_phandle_holder
|
||||
ZTEST(devicetree_api, test_pwms)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue