2022-08-10 08:31:37 +08:00
|
|
|
/* Copyright(c) 2022 Intel Corporation. All rights reserved.
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2023-04-18 21:44:01 +08:00
|
|
|
#include <zephyr/cache.h>
|
2022-08-10 08:31:37 +08:00
|
|
|
#include <zephyr/device.h>
|
|
|
|
#include <zephyr/devicetree.h>
|
2022-10-12 00:44:34 +08:00
|
|
|
#include <zephyr/arch/cpu.h>
|
2022-08-10 08:31:37 +08:00
|
|
|
|
|
|
|
#include <adsp_memory.h>
|
|
|
|
#include <adsp_shim.h>
|
|
|
|
#include <mem_window.h>
|
2023-03-28 22:30:26 +08:00
|
|
|
#include <soc_util.h>
|
2022-08-10 08:31:37 +08:00
|
|
|
|
|
|
|
/* host windows */
|
|
|
|
#define DMWBA(win_base) (win_base + 0x0)
|
|
|
|
#define DMWLO(win_base) (win_base + 0x4)
|
|
|
|
|
|
|
|
#define DT_DRV_COMPAT intel_adsp_mem_window
|
|
|
|
|
|
|
|
__imr int mem_win_init(const struct device *dev)
|
|
|
|
{
|
|
|
|
const struct mem_win_config *config = dev->config;
|
|
|
|
|
|
|
|
if (config->initialize) {
|
2022-09-18 04:27:47 +08:00
|
|
|
bbzero((void *)config->mem_base, config->size);
|
2022-08-10 08:31:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sys_write32(config->size | 0x7, DMWLO(config->base_addr));
|
2022-09-16 22:41:45 +08:00
|
|
|
if (config->read_only) {
|
|
|
|
sys_write32((config->mem_base | ADSP_DMWBA_READONLY | ADSP_DMWBA_ENABLE),
|
|
|
|
DMWBA(config->base_addr));
|
|
|
|
} else {
|
|
|
|
sys_write32((config->mem_base | ADSP_DMWBA_ENABLE), DMWBA(config->base_addr));
|
|
|
|
}
|
2022-08-10 08:31:37 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-03-23 21:43:50 +08:00
|
|
|
void mem_window_idle_exit(void)
|
|
|
|
{
|
|
|
|
mem_win_init(DEVICE_DT_GET(MEM_WINDOW_NODE(0)));
|
|
|
|
mem_win_init(DEVICE_DT_GET(MEM_WINDOW_NODE(1)));
|
|
|
|
mem_win_init(DEVICE_DT_GET(MEM_WINDOW_NODE(2)));
|
|
|
|
mem_win_init(DEVICE_DT_GET(MEM_WINDOW_NODE(3)));
|
|
|
|
}
|
|
|
|
|
2022-09-18 04:27:47 +08:00
|
|
|
#define MEM_WINDOW_DEFINE(n) \
|
|
|
|
static const struct mem_win_config mem_win_config_##n = { \
|
|
|
|
.base_addr = DT_REG_ADDR(MEM_WINDOW_NODE(n)), \
|
|
|
|
.size = WIN_SIZE(n), \
|
|
|
|
.offset = WIN_OFFSET(n), \
|
|
|
|
.read_only = DT_PROP(MEM_WINDOW_NODE(n), read_only), \
|
|
|
|
.mem_base = DT_REG_ADDR(DT_PHANDLE(MEM_WINDOW_NODE(n), memory)) + WIN_OFFSET(n), \
|
|
|
|
.initialize = DT_PROP(MEM_WINDOW_NODE(n), initialize), \
|
2022-08-10 08:31:37 +08:00
|
|
|
}; \
|
2023-09-20 09:32:18 +08:00
|
|
|
DEVICE_DT_DEFINE(MEM_WINDOW_NODE(n), mem_win_init, NULL, NULL, \
|
|
|
|
&mem_win_config_##n, PRE_KERNEL_1, \
|
|
|
|
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL);
|
2022-09-18 04:27:47 +08:00
|
|
|
|
|
|
|
#if DT_NODE_HAS_STATUS(MEM_WINDOW_NODE(0), okay)
|
|
|
|
MEM_WINDOW_DEFINE(0)
|
|
|
|
#endif
|
|
|
|
#if DT_NODE_HAS_STATUS(MEM_WINDOW_NODE(1), okay)
|
|
|
|
MEM_WINDOW_DEFINE(1)
|
|
|
|
#endif
|
|
|
|
#if DT_NODE_HAS_STATUS(MEM_WINDOW_NODE(2), okay)
|
|
|
|
MEM_WINDOW_DEFINE(2)
|
|
|
|
#endif
|
|
|
|
#if DT_NODE_HAS_STATUS(MEM_WINDOW_NODE(3), okay)
|
|
|
|
MEM_WINDOW_DEFINE(3)
|
|
|
|
#endif
|