1 /*
2 * Copyright 2021 Google LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6 #include <zephyr/device.h>
7 #include <zephyr/drivers/espi.h>
8 #include <zephyr/drivers/espi_emul.h>
9 #include <zephyr/ztest.h>
10
ZTEST(espi,test_acpi_shared_memory)11 ZTEST(espi, test_acpi_shared_memory)
12 {
13 const struct device *const espi_dev = DEVICE_DT_GET(DT_NODELABEL(espi0));
14 struct espi_cfg cfg = {
15 .channel_caps = ESPI_CHANNEL_VWIRE | ESPI_CHANNEL_PERIPHERAL,
16 };
17 uintptr_t host_shm, peripheral_shm;
18
19 zassert_true(device_is_ready(espi_dev), "Device is not ready");
20
21 zassert_ok(espi_config(espi_dev, &cfg));
22
23 host_shm = emul_espi_host_get_acpi_shm(espi_dev);
24 zassert_not_equal(host_shm, 0, NULL);
25
26 zassert_ok(espi_read_lpc_request(espi_dev, EACPI_GET_SHARED_MEMORY,
27 (uint32_t *)&peripheral_shm),
28 NULL);
29
30 zassert_equal(host_shm, peripheral_shm);
31 }
32
33 ZTEST_SUITE(espi, NULL, NULL, NULL, NULL, NULL);
34