|
1 | 1 | /* |
2 | 2 | * Copyright (c) 2021, Commonwealth Scientific and Industrial Research |
3 | 3 | * Organisation (CSIRO) ABN 41 687 119 230. |
| 4 | + * Copyright (c) 2025 Analog Devices, Inc. |
4 | 5 | * |
5 | 6 | * SPDX-License-Identifier: Apache-2.0 |
6 | 7 | */ |
|
11 | 12 | #include <zephyr/drivers/gpio.h> |
12 | 13 | #include <zephyr/drivers/adc.h> |
13 | 14 | #include <zephyr/drivers/mbox.h> |
| 15 | +#include <zephyr/drivers/hwspinlock.h> |
14 | 16 |
|
15 | 17 | #include <zephyr/linker/devicetree_regions.h> |
16 | 18 |
|
@@ -59,4 +61,37 @@ ZTEST(devicetree_api_ext, test_mbox_dt_spec) |
59 | 61 | zassert_equal(channel_zero.channel_id, 0, ""); |
60 | 62 | } |
61 | 63 |
|
| 64 | +#define TEST_HWSPINLOCK \ |
| 65 | + DT_NODELABEL(test_hwspinlock) |
| 66 | + |
| 67 | +#define TEST_HWSPINLOCK_DEV \ |
| 68 | + DT_NODELABEL(test_hwspinlock_dev) |
| 69 | + |
| 70 | +#define HWSPINLOCK_BY_IDX(node_id, prop, idx) \ |
| 71 | + HWSPINLOCK_DT_SPEC_GET_BY_IDX(node_id, idx) |
| 72 | + |
| 73 | +static const struct hwspinlock_dt_spec spec[] = { |
| 74 | + DT_FOREACH_PROP_ELEM_SEP(TEST_HWSPINLOCK_DEV, hwlocks, HWSPINLOCK_BY_IDX, (,)) |
| 75 | +}; |
| 76 | + |
| 77 | +static const struct hwspinlock_dt_spec rd = |
| 78 | + HWSPINLOCK_DT_SPEC_GET_BY_NAME(TEST_HWSPINLOCK_DEV, rd); |
| 79 | + |
| 80 | +static const struct hwspinlock_dt_spec wr = |
| 81 | + HWSPINLOCK_DT_SPEC_GET_BY_NAME(TEST_HWSPINLOCK_DEV, wr); |
| 82 | + |
| 83 | +ZTEST(devicetree_api_ext, test_hwspinlock_dt_spec) |
| 84 | +{ |
| 85 | + for (int i = 0; i < ARRAY_SIZE(spec); i++) { |
| 86 | + zassert_equal(spec[i].dev, DEVICE_DT_GET(TEST_HWSPINLOCK)); |
| 87 | + zassert_equal(spec[i].id, i + 1); |
| 88 | + } |
| 89 | + |
| 90 | + zassert_equal(rd.dev, DEVICE_DT_GET(TEST_HWSPINLOCK)); |
| 91 | + zassert_equal(rd.id, 1); |
| 92 | + |
| 93 | + zassert_equal(wr.dev, DEVICE_DT_GET(TEST_HWSPINLOCK)); |
| 94 | + zassert_equal(wr.id, 2); |
| 95 | +} |
| 96 | + |
62 | 97 | ZTEST_SUITE(devicetree_api_ext, NULL, NULL, NULL, NULL, NULL); |
0 commit comments