Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intel_adsp20: Enable LNL (ACE 2.0) platform in sof #7479

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions app/boards/intel_adsp_ace20_lnl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
CONFIG_LUNARLAKE=y
CONFIG_IPC_MAJOR_4=y

# turn off SOF drivers
CONFIG_INTEL_DMIC=n
CONFIG_INTEL_DMIC_NHLT=n
CONFIG_INTEL_SSP=n
CONFIG_INTEL_ALH=n
CONFIG_COMP_SRC=y

CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y

# power settings
CONFIG_PM=y
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y
CONFIG_PM_DEVICE_POWER_DOMAIN=y
CONFIG_PM_POLICY_CUSTOM=y

CONFIG_POWER_DOMAIN=y
CONFIG_POWER_DOMAIN_INTEL_ADSP=y

# enable Zephyr drivers
CONFIG_ZEPHYR_NATIVE_DRIVERS=y
CONFIG_DAI=y
CONFIG_DAI_INIT_PRIORITY=70
CONFIG_DAI_INTEL_DMIC=y
CONFIG_DAI_DMIC_HW_IOCLK=38400000
CONFIG_DAI_INTEL_DMIC_NHLT=y
CONFIG_DAI_DMIC_HAS_OWNERSHIP=n
CONFIG_DAI_DMIC_HAS_MULTIPLE_LINE_SYNC=y
CONFIG_DAI_INTEL_SSP=y
CONFIG_ZEPHYR_DP_SCHEDULER=y
CONFIG_DMA=y
CONFIG_DMA_INTEL_ADSP_GPDMA=n
CONFIG_DMA_DW_SUSPEND_DRAIN=y
CONFIG_INTEL_MODULES=y
CONFIG_LIBRARY_MANAGER=y
CONFIG_INTEL_ADSP_TIMER=y
CONFIG_MM_DRV_INTEL_ADSP_TLB_REMAP_UNUSED_RAM=y
CONFIG_AMS=y
CONFIG_COUNTER=y

CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_L3_HEAP=y
CONFIG_RIMAGE_SIGNING_SCHEMA="lnl"

CONFIG_FORMAT_CONVERT_HIFI3=n
CONFIG_PCM_CONVERTER_FORMAT_S16_C16_AND_S16_C32=y
CONFIG_PCM_CONVERTER_FORMAT_S16_C32_AND_S32_C32=y
CONFIG_PCM_CONVERTER_FORMAT_S16_C32_AND_S24_C32=y
CONFIG_PCM_CONVERTER_FORMAT_S24_C24_AND_S24_C32=y
CONFIG_PCM_CONVERTER_FORMAT_S24_C32_AND_S24_C24=y
CONFIG_PCM_CONVERTER_FORMAT_S16_C32_AND_S16_C32=y
CONFIG_LOG=y
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_FUNC_NAME_PREFIX_INF=y
CONFIG_COMP_VOLUME_WINDOWS_FADE=y
CONFIG_COMP_UP_DOWN_MIXER=y
CONFIG_COMP_CHAIN_DMA=y
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=38400000

CONFIG_LOG_BACKEND_ADSP_MTRACE=y
CONFIG_SOF_LOG_LEVEL_INF=y
CONFIG_ZEPHYR_LOG=y

CONFIG_INTEL_ADSP_IPC=y


# Temporary disabled options
CONFIG_TRACE=n
CONFIG_COMP_KPB=y
CONFIG_COMP_ARIA=y
CONFIG_CLOCK_CONTROL_ADSP=y
CONFIG_CLOCK_CONTROL=y
2 changes: 2 additions & 0 deletions app/overlays/lnl/fpga_overlay.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=19200000
CONFIG_DAI_DMIC_HW_IOCLK=19200000
8 changes: 7 additions & 1 deletion scripts/xtensa-build-zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class PlatformConfig:
f"RI-2022.10{xtensa_tools_version_postfix}",
"ace10_LX7HiFi4_2022_10",
),
"lnl" : PlatformConfig(
"lnl", "intel_adsp_ace20_lnl",
f"RI-2022.10{xtensa_tools_version_postfix}",
"ace10_LX7HiFi4_2022_10",
),

# NXP platforms
"imx8" : PlatformConfig(
"imx8", "nxp_adsp_imx8",
Expand Down Expand Up @@ -871,7 +877,7 @@ def gzip_compress(fname, gzdst=None):
RI_INFO_UNSUPPORTED += ['mt8186', 'mt8195']

# sof_ri_info.py has not caught up with the latest rimage yet: these will print a warning.
RI_INFO_FIXME = ['mtl']
RI_INFO_FIXME = ['mtl', 'lnl']

def reproducible_checksum(platform, ri_file):

Expand Down
22 changes: 17 additions & 5 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ static int create_dai(struct comp_dev *parent_dev, struct copier_data *cd,
const struct comp_driver *drv;
struct ipc_config_dai dai;
int dai_count;
int i;
int i, ret;

drv = ipc4_get_drv((uint8_t *)&id);
if (!drv)
Expand Down Expand Up @@ -492,6 +492,13 @@ static int create_dai(struct comp_dev *parent_dev, struct copier_data *cd,
dai.type = SOF_DAI_INTEL_SSP;
dai.is_config_blob = true;
type = ipc4_gtw_ssp;
ret = ipc4_find_dma_config(&dai, (uint8_t *)copier->gtw_cfg.config_data,
copier->gtw_cfg.config_length * 4);
if (ret != 0) {
comp_err(parent_dev, "No ssp dma_config found in blob!");
return -EINVAL;
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
}
dai.out_fmt = &copier->out_fmt;
break;
case ipc4_alh_link_output_class:
case ipc4_alh_link_input_class:
Expand Down Expand Up @@ -544,14 +551,20 @@ static int create_dai(struct comp_dev *parent_dev, struct copier_data *cd,
dai.type = SOF_DAI_INTEL_DMIC;
dai.is_config_blob = true;
type = ipc4_gtw_dmic;

ret = ipc4_find_dma_config(&dai, (uint8_t *)copier->gtw_cfg.config_data,
copier->gtw_cfg.config_length * 4);
if (ret != 0) {
comp_err(parent_dev, "No dmic dma_config found in blob!");
return -EINVAL;
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
}
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
dai.out_fmt = &copier->out_fmt;
break;
default:
return -EINVAL;
}

for (i = 0; i < dai_count; i++) {
int ret;

dai.dai_index = dai_index[i];
ret = init_dai(parent_dev, drv, config, copier, pipeline, &dai, type, i,
dai_count);
Expand All @@ -563,8 +576,7 @@ static int create_dai(struct comp_dev *parent_dev, struct copier_data *cd,

/* create multi_endpoint_buffer for ALH multi-gateway case */
if (dai_count > 1) {
int ret = create_endpoint_buffer(parent_dev, cd, config, copier, type, true, 0);

ret = create_endpoint_buffer(parent_dev, cd, config, copier, type, true, 0);
if (ret < 0)
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
return ret;
}
Expand Down
4 changes: 4 additions & 0 deletions src/audio/dai-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
case SOF_DAI_INTEL_SSP:
cfg.type = is_blob ? DAI_INTEL_SSP_NHLT : DAI_INTEL_SSP;
cfg_params = is_blob ? spec_config : &sof_cfg->ssp;
dai_set_link_hda_config(&cfg.link_config,
common_config, cfg_params);
break;
case SOF_DAI_INTEL_ALH:
cfg.type = is_blob ? DAI_INTEL_ALH_NHLT : DAI_INTEL_ALH;
Expand All @@ -151,6 +153,8 @@ int dai_set_config(struct dai *dai, struct ipc_config_dai *common_config,
case SOF_DAI_INTEL_DMIC:
cfg.type = is_blob ? DAI_INTEL_DMIC_NHLT : DAI_INTEL_DMIC;
cfg_params = is_blob ? spec_config : &sof_cfg->dmic;
dai_set_link_hda_config(&cfg.link_config,
common_config, cfg_params);
break;
case SOF_DAI_INTEL_HDA:
cfg.type = is_blob ? DAI_INTEL_HDA_NHLT : DAI_INTEL_HDA;
Expand Down
4 changes: 4 additions & 0 deletions src/include/ipc4/alh.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
#include <ipc4/gateway.h>

#define IPC4_ALH_MAX_NUMBER_OF_GTW 16
#ifdef CONFIG_DMA_INTEL_ADSP_GPDMA
#define IPC4_ALH_DAI_INDEX_OFFSET 7
#else
#define IPC4_ALH_DAI_INDEX_OFFSET 0
#endif

/* copier id = (group id << 4) + codec id + IPC4_ALH_DAI_INDEX_OFFSET
* dai_index = (group id << 8) + codec id;
Expand Down
40 changes: 40 additions & 0 deletions src/include/sof/audio/ipc-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,42 @@
#include <stdint.h>
#include <stdbool.h>

/* ACE 2.0 and newer */
#define GTW_DMA_CONFIG_ID 0x1000
#define GTW_DMA_INVALID_CHANNEL_ID 0xffffffff
/* Maximum number of devices */
#define GTW_DMA_DEVICE_MAX_COUNT 16

struct dma_device_stream_channel_map {
uint32_t device_address;
uint32_t channel_map;
};

struct dma_stream_channel_map {
uint32_t device_count;
struct dma_device_stream_channel_map map[GTW_DMA_DEVICE_MAX_COUNT];
};

struct ipc_dma_config {
uint8_t dma_method; /**< DMA method */
uint8_t pre_allocated_by_host; /**< 1 - DMA pre-allocated by host, otherwise to be
* allocated by DSP
*/
uint16_t rsvd;
uint32_t dma_channel_id; /**< channel ID if DMA pre-allocated by host, otherwise
* invalid channel ID
*/
uint32_t stream_id;
/* DmaStreamChannelMap */
struct dma_stream_channel_map channel_map;
uint32_t dma_priv_config_size;
uint8_t dma_priv_config[0];
} __attribute__((packed, aligned(4)));

#define GET_IPC_DMA_CONFIG(buffer, size) \
((struct ipc_dma_config *)((uint8_t *)(buffer) + (size) - sizeof(struct ipc_dma_config)))
#define GET_IPC_DMA_CONFIG_ID(buffer, size) ((uint32_t *)GET_IPC_DMA_CONFIG(buffer, size) - 2)

/*
* Generic IPC information for base components. Fields can be added here with NO impact on
* IPC ABI version.
Expand Down Expand Up @@ -39,6 +75,10 @@ struct ipc_config_dai {
uint32_t feature_mask; /**< copier feature mask (set directly from
* ipc4_copier_module_cfg on init)
*/
struct ipc_dma_config *host_dma_config; /**< DMA config - required for ACE 2.0 and newer */
const struct ipc4_audio_format *out_fmt;/**< audio format for output pin 0 - required
* for ACE 2.0 and newer
*/
};

/* generic volume component */
Expand Down
1 change: 1 addition & 0 deletions src/include/sof/ipc/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ int ipc4_create_chain_dma(struct ipc *ipc, struct ipc4_chain_dma *cdma);
int ipc4_trigger_chain_dma(struct ipc *ipc, struct ipc4_chain_dma *cdma, bool *delay);
int ipc4_process_on_core(uint32_t core, bool blocking);
int ipc4_pipeline_complete(struct ipc *ipc, uint32_t comp_id);
int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint32_t size);
#else
#error "No or invalid IPC MAJOR version selected."
#endif
Expand Down
7 changes: 7 additions & 0 deletions src/include/sof/lib/dai-legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,13 @@ static inline const struct dai_info *dai_info_get(void)
*/
int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void *config);

/**
* \brief Configure HD Audio DMA params for DAI
*/
void dai_set_link_hda_config(uint16_t *link_config,
struct ipc_config_dai *common_config,
const void *spec_config);

/**
* \brief Reset DAI DMA config
*/
Expand Down
16 changes: 16 additions & 0 deletions src/include/sof/lib/dai-zephyr.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ struct timestamp_ops {
struct timestamp_data *tsd);
};

union hdalink_cfg {
uint16_t full;
struct {
uint16_t lchan :4;
uint16_t hchan :4;
uint16_t stream :6;
uint16_t rsvd :1;
uint16_t dir :1;
} part;
};
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
/**
* \brief DAI group information
*/
Expand Down Expand Up @@ -255,6 +265,12 @@ int dai_get_stream_id(struct dai *dai, int direction);
*/
int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void *config);

/**
* \brief Configure HD Audio DMA params for DAI
*/
void dai_set_link_hda_config(uint16_t *link_config,
struct ipc_config_dai *common_config,
const void *spec_config);
/**
* \brief Reset DAI DMA config
*/
Expand Down
5 changes: 5 additions & 0 deletions src/ipc/ipc3/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);

void dai_set_link_hda_config(uint16_t *link_config,
struct ipc_config_dai *common_config,
const void *spec_config)
{ }

int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void *spec_config)
{
const struct sof_ipc_dai_config *config = spec_config;
Expand Down
40 changes: 40 additions & 0 deletions src/ipc/ipc4/dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,42 @@

LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL);

void dai_set_link_hda_config(uint16_t *link_config,
struct ipc_config_dai *common_config,
const void *spec_config)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this too HDA specific? I'd say it should go in the driver

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lyakh @jxstelter This is a bit iffy but we do have DAI type specific code for all vendors here and we need to convert from the IPC structs into language of the Zephyr driver interface (e.g. a single link_config field). At least in my initial review I checked that we need IPC4 structs the driver does not have access to.

@jxstelter Can you double-check could we calculate this in the driver? Direction and stream_id should be available already in driver code -- I guess depth and channel count should be available as well...?

#if defined(CONFIG_ACE_VERSION_2_0)
const struct ipc4_audio_format *out_fmt = common_config->out_fmt;
const struct sof_ipc_dai_config *sof_cfg = spec_config;
union hdalink_cfg link_cfg;

switch (common_config->type) {
case SOF_DAI_INTEL_SSP:
link_cfg.full = 0;
link_cfg.part.dir = common_config->direction;
link_cfg.part.stream = common_config->host_dma_config->stream_id;
break;
case SOF_DAI_INTEL_DMIC:
link_cfg.full = 0;
if (out_fmt->depth == IPC4_DEPTH_16BIT) {
/* 16bit dmic packs two 16bit samples into single 32bit word
* fw needs to adjust channel count to match final sample
* group size
*/
link_cfg.part.hchan = (out_fmt->channels_count - 1) / 2;
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
} else {
link_cfg.part.hchan = out_fmt->channels_count - 1;
}
link_cfg.part.stream = common_config->host_dma_config->stream_id;
break;
default:
/* other types of DAIs not need link_config */
return;
}
*link_config = link_cfg.full;
#endif
}

int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void *spec_config)
{
const struct ipc4_copier_module_cfg *copier_cfg = spec_config;
Expand All @@ -42,6 +78,10 @@ int dai_config_dma_channel(struct dai_data *dd, struct comp_dev *dev, const void
COMPILER_FALLTHROUGH;
case SOF_DAI_INTEL_DMIC:
channel = 0;
#if defined(CONFIG_ACE_VERSION_2_0)
if (dai->host_dma_config->pre_allocated_by_host)
channel = dai->host_dma_config->dma_channel_id;
#endif
break;
case SOF_DAI_INTEL_HDA:
channel = copier_cfg->gtw_cfg.node_id.f.v_index;
Expand Down
14 changes: 14 additions & 0 deletions src/ipc/ipc4/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,17 @@ int ipc4_add_comp_dev(struct comp_dev *dev)

return IPC4_SUCCESS;
};

int ipc4_find_dma_config(struct ipc_config_dai *dai, uint8_t *data_buffer, uint32_t size)
{
#if defined(CONFIG_ACE_VERSION_2_0)
uint32_t *dma_config_id = GET_IPC_DMA_CONFIG_ID(data_buffer, size);

if (*dma_config_id != GTW_DMA_CONFIG_ID)
return IPC4_INVALID_REQUEST;

dai->host_dma_config = GET_IPC_DMA_CONFIG(data_buffer, size);
#endif
jxstelter marked this conversation as resolved.
Show resolved Hide resolved
return IPC4_SUCCESS;
}

Loading