/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2021-2022 Intel Corporation
*
* Authors: Cezary Rojewski <cezary.rojewski@intel.com>
* Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
*/
#ifndef __SOUND_SOC_INTEL_AVS_MSGS_H
#define __SOUND_SOC_INTEL_AVS_MSGS_H
#include <linux/sizes.h>
struct avs_dev;
#define AVS_MAILBOX_SIZE SZ_4K
enum avs_msg_target {
AVS_FW_GEN_MSG = 0,
AVS_MOD_MSG = 1
};
enum avs_msg_direction {
AVS_MSG_REQUEST = 0,
AVS_MSG_REPLY = 1
};
enum avs_global_msg_type {
AVS_GLB_ROM_CONTROL = 1,
AVS_GLB_LOAD_MULTIPLE_MODULES = 15,
AVS_GLB_UNLOAD_MULTIPLE_MODULES = 16,
AVS_GLB_CREATE_PIPELINE = 17,
AVS_GLB_DELETE_PIPELINE = 18,
AVS_GLB_SET_PIPELINE_STATE = 19,
AVS_GLB_GET_PIPELINE_STATE = 20,
AVS_GLB_LOAD_LIBRARY = 24,
AVS_GLB_NOTIFICATION = 27,
};
union avs_global_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 rsvd:24;
u32 global_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
/* set boot config */
struct {
u32 rom_ctrl_msg_type:9;
u32 dma_id:5;
u32 purge_request:1;
} boot_cfg;
/* module loading */
struct {
u32 mod_cnt:8;
} load_multi_mods;
/* pipeline management */
struct {
u32 ppl_mem_size:11;
u32 ppl_priority:5;
u32 instance_id:8;
} create_ppl;
struct {
u32 rsvd:16;
u32 instance_id:8;
} ppl; /* generic ppl request */
struct {
u32 state:16;
u32 ppl_id:8;
} set_ppl_state;
struct {
u32 ppl_id:8;
} get_ppl_state;
/* library loading */
struct {
u32 dma_id:5;
u32 rsvd:11;
u32 lib_id:4;
} load_lib;
};
union {
u32 val;
/* pipeline management */
struct {
u32 lp:1; /* low power flag */
u32 rsvd:3;
u32 attributes:16; /* additional scheduling flags */
} create_ppl;
} ext;
};
} __packed;
static_assert(sizeof(union avs_global_msg) == 8);
struct avs_tlv {
u32 type;
u32 length;
u32 value[];
} __packed;
static_assert(sizeof(struct avs_tlv) == 8);
enum avs_module_msg_type {
AVS_MOD_INIT_INSTANCE = 0,
AVS_MOD_LARGE_CONFIG_GET = 3,
AVS_MOD_LARGE_CONFIG_SET = 4,
AVS_MOD_BIND = 5,
AVS_MOD_UNBIND = 6,
AVS_MOD_SET_DX = 7,
AVS_MOD_SET_D0IX = 8,
AVS_MOD_DELETE_INSTANCE = 11,
};
union avs_module_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 module_id:16;
u32 instance_id:8;
u32 module_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
};
union {
u32 val;
struct {
u32 param_block_size:16;
u32 ppl_instance_id:8;
u32 core_id:4;
u32 proc_domain:1;
} init_instance;
struct {
u32 data_off_size:20;
u32 large_param_id:8;
u32 final_block:1;
u32 init_block:1;
} large_config;
struct {
u32 dst_module_id:16;
u32 dst_instance_id:8;
u32 dst_queue:3;
u32 src_queue:3;
} bind_unbind;
struct {
/* pre-IceLake */
u32 wake:1;
u32 streaming:1;
/* IceLake and onwards */
u32 prevent_pg:1;
u32 prevent_local_cg:1;
} set_d0ix;
} ext;
};
} __packed;
static_assert(sizeof(union avs_module_msg) == 8);
#define AVS_IPC_NOT_SUPPORTED 15
union avs_reply_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 status:24;
u32 global_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
};
union {
u32 val;
/* module loading */
struct {
u32 err_mod_id:16;
} load_multi_mods;
/* pipeline management */
struct {
u32 state:5;
} get_ppl_state;
/* module management */
struct {
u32 data_off_size:20;
u32 large_param_id:8;
u32 final_block:1;
u32 init_block:1;
} large_config;
} ext;
};
} __packed;
static_assert(sizeof(union avs_reply_msg) == 8);
enum avs_notify_msg_type {
AVS_NOTIFY_PHRASE_DETECTED = 4,
AVS_NOTIFY_RESOURCE_EVENT = 5,
AVS_NOTIFY_LOG_BUFFER_STATUS = 6,
AVS_NOTIFY_FW_READY = 8,
AVS_NOTIFY_EXCEPTION_CAUGHT = 10,
AVS_NOTIFY_MODULE_EVENT = 12,
};
union avs_notify_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 rsvd:16;
u32 notify_msg_type:8;
u32 global_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
struct {
u16 rsvd:12;
u16 core:4;
} log;
};
union {
u32 val;
struct {
u32 core_id:2;
u32 stack_dump_size:16;
} coredump;
} ext;
};
} __packed;
static_assert(sizeof(union avs_notify_msg) == 8);
#define AVS_MSG(hdr) { .val = hdr }
#define AVS_GLOBAL_REQUEST(msg_type) \
{ \
.global_msg_type = AVS_GLB_##msg_type, \
.msg_direction = AVS_MSG_REQUEST, \
.msg_target = AVS_FW_GEN_MSG, \
}
#define AVS_MODULE_REQUEST(msg_type) \
{ \
.module_msg_type = AVS_MOD_##msg_type, \
.msg_direction = AVS_MSG_REQUEST, \
.msg_target = AVS_MOD_MSG, \
}
#define AVS_NOTIFICATION(msg_type) \
{ \
.notify_msg_type = AVS_NOTIFY_##msg_type,\
.global_msg_type = AVS_GLB_NOTIFICATION,\
.msg_direction = AVS_MSG_REPLY, \
.msg_target = AVS_FW_GEN_MSG, \
}
#define avs_msg_is_reply(hdr) \
({ \
union avs_reply_msg __msg = AVS_MSG(hdr); \