Skip to content

Commit 92d7172

Browse files
ajitkupandeyplbossart
authored andcommitted
ASoC: SOF: amd: Use dedicated MBOX for ACP and PSP communication
We are currently using generic PSP Mailbox register for sending SHA complete command to PSP but observe random arbitration issue during PSP validation as MP0_C2PMSG_26_REG used by other kernel modules. Use separate mailbox registers and doorbell mechanism to send SHA_DMA complete command to PSP. This fixes such validation issues and added flexibility for sending more ACP commands to PSP in future as new mbox registers i.e MP0_C2PMSG_114_REG and MP0_C2PMSG_73_REG are dedicated by PSP for ACP communications. Signed-off-by: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
1 parent aa6861a commit 92d7172

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

sound/soc/sof/amd/acp.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
152152

153153
for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) {
154154
msleep(20);
155-
smn_read(adata->smn_dev, MP0_C2PMSG_26_REG, &data);
155+
smn_read(adata->smn_dev, MP0_C2PMSG_114_REG, &data);
156156
if (data & MBOX_READY_MASK)
157157
return 0;
158158
}
@@ -174,17 +174,34 @@ static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
174174
static int psp_send_cmd(struct acp_dev_data *adata, int cmd)
175175
{
176176
struct snd_sof_dev *sdev = adata->dev;
177-
int ret;
177+
int ret, timeout;
178+
u32 data;
178179

179180
if (!cmd)
180181
return -EINVAL;
181182

183+
/* Get a non-zero Doorbell value from PSP */
184+
for (timeout = ACP_PSP_TIMEOUT_COUNTER; timeout > 0; timeout--) {
185+
msleep(MBOX_DELAY);
186+
smn_read(adata->smn_dev, MP0_C2PMSG_73_REG, &data);
187+
if (data)
188+
break;
189+
}
190+
191+
if (!timeout) {
192+
dev_err(sdev->dev, "Failed to get Doorbell from MBOX %x\n", MP0_C2PMSG_73_REG);
193+
return -EINVAL;
194+
}
195+
182196
/* Check if PSP is ready for new command */
183197
ret = psp_mbox_ready(adata, 0);
184198
if (ret)
185199
return ret;
186200

187-
smn_write(adata->smn_dev, MP0_C2PMSG_26_REG, cmd);
201+
smn_write(adata->smn_dev, MP0_C2PMSG_114_REG, cmd);
202+
203+
/* Ring the Doorbell for PSP */
204+
smn_write(adata->smn_dev, MP0_C2PMSG_73_REG, data);
188205

189206
/* Check MBOX ready as PSP ack */
190207
ret = psp_mbox_ready(adata, 1);

sound/soc/sof/amd/acp.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@
5757
#define ACP_SHA_STAT 0x8000
5858
#define ACP_PSP_TIMEOUT_COUNTER 5
5959
#define ACP_EXT_INTR_ERROR_STAT 0x20000000
60-
#define MP0_C2PMSG_26_REG 0x03810570
61-
#define MBOX_ACP_SHA_DMA_COMMAND 0x330000
60+
#define MP0_C2PMSG_114_REG 0x3810AC8
61+
#define MP0_C2PMSG_73_REG 0x3810A24
62+
#define MBOX_ACP_SHA_DMA_COMMAND 0x70000
63+
#define MBOX_DELAY 1000
6264
#define MBOX_READY_MASK 0x80000000
6365
#define MBOX_STATUS_MASK 0xFFFF
6466

0 commit comments

Comments
 (0)