Skip to content

Commit bf69e51

Browse files
reddysujithplbossart
authored andcommitted
ASoC: SOF: amd: increase SRAM inbox and outbox size to 1024
Increase inbox and outbox mailbox size from 512 to 1024 to support thirdparty DTS integration ipc tx/rx messages communication. This is done through firmware window get info. Signed-off-by: V sujith kumar Reddy <Vsujithkumar.Reddy@amd.com>
1 parent a9f1f32 commit bf69e51

6 files changed

Lines changed: 48 additions & 17 deletions

File tree

‎sound/soc/sof/amd/acp-common.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct snd_sof_dsp_ops sof_acp_common_ops = {
7777
.send_msg = acp_sof_ipc_send_msg,
7878
.ipc_msg_data = acp_sof_ipc_msg_data,
7979
.get_mailbox_offset = acp_sof_ipc_get_mailbox_offset,
80+
.get_window_offset = acp_sof_ipc_get_window_offset,
8081
.irq_thread = acp_sof_ipc_irq_thread,
8182

8283
/* stream callbacks */

‎sound/soc/sof/amd/acp-ipc.c‎

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,24 @@ static void acpbus_trigger_host_to_dsp_swintr(struct acp_dev_data *adata)
4242

4343
static void acp_ipc_host_msg_set(struct snd_sof_dev *sdev)
4444
{
45-
unsigned int host_msg = offsetof(struct scratch_ipc_conf, sof_host_msg_write);
45+
unsigned int host_msg = sdev->debug_box.offset +
46+
offsetof(struct scratch_ipc_conf, sof_host_msg_write);
4647

4748
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + host_msg, 1);
4849
}
4950

5051
static void acp_dsp_ipc_host_done(struct snd_sof_dev *sdev)
5152
{
52-
unsigned int dsp_msg = offsetof(struct scratch_ipc_conf, sof_dsp_msg_write);
53+
unsigned int dsp_msg = sdev->debug_box.offset +
54+
offsetof(struct scratch_ipc_conf, sof_dsp_msg_write);
5355

5456
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_msg, 0);
5557
}
5658

5759
static void acp_dsp_ipc_dsp_done(struct snd_sof_dev *sdev)
5860
{
59-
unsigned int dsp_ack = offsetof(struct scratch_ipc_conf, sof_dsp_ack_write);
61+
unsigned int dsp_ack = sdev->debug_box.offset +
62+
offsetof(struct scratch_ipc_conf, sof_dsp_ack_write);
6063

6164
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_ack, 0);
6265
}
@@ -65,7 +68,7 @@ int acp_sof_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg)
6568
{
6669
struct acp_dev_data *adata = sdev->pdata->hw_pdata;
6770
const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);
68-
unsigned int offset = offsetof(struct scratch_ipc_conf, sof_in_box);
71+
unsigned int offset = sdev->host_box.offset;
6972
unsigned int count = ACP_HW_SEM_RETRY_COUNT;
7073

7174
while (snd_sof_dsp_read(sdev, ACP_DSP_BAR, desc->hw_semaphore_offset)) {
@@ -95,7 +98,7 @@ static void acp_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
9598
struct snd_sof_ipc_msg *msg = sdev->msg;
9699
struct sof_ipc_reply reply;
97100
struct sof_ipc_cmd_hdr *hdr;
98-
unsigned int offset = offsetof(struct scratch_ipc_conf, sof_in_box);
101+
unsigned int offset = sdev->host_box.offset;
99102
int ret = 0;
100103

101104
/*
@@ -145,11 +148,19 @@ static void acp_dsp_ipc_get_reply(struct snd_sof_dev *sdev)
145148
irqreturn_t acp_sof_ipc_irq_thread(int irq, void *context)
146149
{
147150
struct snd_sof_dev *sdev = context;
148-
unsigned int dsp_msg_write = offsetof(struct scratch_ipc_conf, sof_dsp_msg_write);
149-
unsigned int dsp_ack_write = offsetof(struct scratch_ipc_conf, sof_dsp_ack_write);
151+
unsigned int dsp_msg_write = sdev->debug_box.offset +
152+
offsetof(struct scratch_ipc_conf, sof_dsp_msg_write);
153+
unsigned int dsp_ack_write = sdev->debug_box.offset +
154+
offsetof(struct scratch_ipc_conf, sof_dsp_ack_write);
150155
bool ipc_irq = false;
151156
int dsp_msg, dsp_ack;
152157

158+
if (sdev->first_boot && sdev->fw_state != SOF_FW_BOOT_COMPLETE) {
159+
snd_sof_ipc_msgs_rx(sdev);
160+
acp_dsp_ipc_host_done(sdev);
161+
return IRQ_HANDLED;
162+
}
163+
153164
dsp_msg = snd_sof_dsp_read(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 + dsp_msg_write);
154165
if (dsp_msg) {
155166
snd_sof_ipc_msgs_rx(sdev);
@@ -179,7 +190,7 @@ EXPORT_SYMBOL_NS(acp_sof_ipc_irq_thread, SND_SOC_SOF_AMD_COMMON);
179190
int acp_sof_ipc_msg_data(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream,
180191
void *p, size_t sz)
181192
{
182-
unsigned int offset = offsetof(struct scratch_ipc_conf, sof_out_box);
193+
unsigned int offset = sdev->dsp_box.offset;
183194

184195
if (!substream || !sdev->stream_box.size)
185196
acp_mailbox_read(sdev, offset, p, sz);
@@ -196,4 +207,10 @@ int acp_sof_ipc_get_mailbox_offset(struct snd_sof_dev *sdev)
196207
}
197208
EXPORT_SYMBOL_NS(acp_sof_ipc_get_mailbox_offset, SND_SOC_SOF_AMD_COMMON);
198209

210+
int acp_sof_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id)
211+
{
212+
return 0;
213+
}
214+
EXPORT_SYMBOL_NS(acp_sof_ipc_get_window_offset, SND_SOC_SOF_AMD_COMMON);
215+
199216
MODULE_DESCRIPTION("AMD ACP sof-ipc driver");

‎sound/soc/sof/amd/acp-pcm.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ int acp_pcm_hw_params(struct snd_sof_dev *sdev, struct snd_pcm_substream *substr
4242

4343
/* write buffer size of stream in scratch memory */
4444

45-
buf_offset = offsetof(struct scratch_reg_conf, buf_size);
45+
buf_offset = sdev->debug_box.offset +
46+
offsetof(struct scratch_reg_conf, buf_size);
4647
index = stream->stream_tag - 1;
4748
buf_offset = buf_offset + index * 4;
4849

‎sound/soc/sof/amd/acp-stream.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,16 @@ int acp_dsp_stream_config(struct snd_sof_dev *sdev, struct acp_dsp_stream *strea
8989

9090
/* write phy_addr in scratch memory */
9191

92-
phy_addr_offset = offsetof(struct scratch_reg_conf, reg_offset);
92+
phy_addr_offset = sdev->debug_box.offset +
93+
offsetof(struct scratch_reg_conf, reg_offset);
9394
index = stream_tag - 1;
9495
phy_addr_offset = phy_addr_offset + index * 4;
9596

9697
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_SCRATCH_REG_0 +
9798
phy_addr_offset, stream->reg_offset);
9899

99100
/* Group Enable */
101+
offset = offset + sdev->debug_box.offset;
100102
reg_val = desc->sram_pte_offset + offset;
101103
snd_sof_dsp_write(sdev, ACP_DSP_BAR, pte_reg, reg_val | BIT(31));
102104
snd_sof_dsp_write(sdev, ACP_DSP_BAR, pte_size, PAGE_SIZE_4K_ENABLE);

‎sound/soc/sof/amd/acp.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ static void init_dma_descriptor(struct acp_dev_data *adata)
4242
const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);
4343
unsigned int addr;
4444

45-
addr = desc->sram_pte_offset + offsetof(struct scratch_reg_conf, dma_desc);
45+
addr = desc->sram_pte_offset + sdev->debug_box.offset +
46+
offsetof(struct scratch_reg_conf, dma_desc);
4647

4748
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_DESC_BASE_ADDR, addr);
4849
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_DMA_DESC_MAX_NUM_DSCR, ACP_MAX_DESC_CNT);
@@ -54,8 +55,9 @@ static void configure_dma_descriptor(struct acp_dev_data *adata, unsigned short
5455
struct snd_sof_dev *sdev = adata->dev;
5556
unsigned int offset;
5657

57-
offset = ACP_SCRATCH_REG_0 + offsetof(struct scratch_reg_conf, dma_desc) +
58-
idx * sizeof(struct dma_descriptor);
58+
offset = ACP_SCRATCH_REG_0 + sdev->debug_box.offset +
59+
offsetof(struct scratch_reg_conf, dma_desc) +
60+
idx * sizeof(struct dma_descriptor);
5961

6062
snd_sof_dsp_write(sdev, ACP_DSP_BAR, offset, dscr_info->src_addr);
6163
snd_sof_dsp_write(sdev, ACP_DSP_BAR, offset + 0x4, dscr_info->dest_addr);
@@ -516,6 +518,15 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
516518
return ret;
517519
}
518520

521+
sdev->dsp_box.offset = 0;
522+
sdev->dsp_box.size = BOX_SIZE_512;
523+
524+
sdev->host_box.offset = sdev->dsp_box.offset + sdev->dsp_box.size;
525+
sdev->host_box.size = BOX_SIZE_512;
526+
527+
sdev->debug_box.offset = sdev->host_box.offset + sdev->host_box.size;
528+
sdev->debug_box.size = BOX_SIZE_1024;
529+
519530
acp_memory_init(sdev);
520531

521532
acp_dsp_stream_init(sdev);

‎sound/soc/sof/amd/acp.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
#define MBOX_READY_MASK 0x80000000
6767
#define MBOX_STATUS_MASK 0xFFFF
6868

69+
#define BOX_SIZE_512 0x200
70+
#define BOX_SIZE_1024 0x400
71+
6972
struct acp_atu_grp_pte {
7073
u32 low;
7174
u32 high;
@@ -90,10 +93,6 @@ struct dma_descriptor {
9093

9194
/* Scratch memory structure for communication b/w host and dsp */
9295
struct scratch_ipc_conf {
93-
/* DSP mailbox */
94-
u8 sof_out_box[512];
95-
/* Host mailbox */
96-
u8 sof_in_box[512];
9796
/* Debug memory */
9897
u8 sof_debug_box[1024];
9998
/* Exception memory*/

0 commit comments

Comments
 (0)