summaryrefslogtreecommitdiffstats
path: root/sound/soc/sof/amd/acp-loader.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/sof/amd/acp-loader.c')
-rw-r--r--sound/soc/sof/amd/acp-loader.c82
1 files changed, 60 insertions, 22 deletions
diff --git a/sound/soc/sof/amd/acp-loader.c b/sound/soc/sof/amd/acp-loader.c
index a427673cfb..e05eb7a86d 100644
--- a/sound/soc/sof/amd/acp-loader.c
+++ b/sound/soc/sof/amd/acp-loader.c
@@ -19,8 +19,9 @@
#include "acp-dsp-offset.h"
#include "acp.h"
-#define FW_BIN 0
-#define FW_DATA_BIN 1
+#define FW_BIN 0
+#define FW_DATA_BIN 1
+#define FW_SRAM_DATA_BIN 2
#define FW_BIN_PTE_OFFSET 0x00
#define FW_DATA_BIN_PTE_OFFSET 0x08
@@ -49,7 +50,6 @@ int acp_dsp_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_t
u32 offset, void *src, size_t size)
{
struct pci_dev *pci = to_pci_dev(sdev->dev);
- const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);
struct acp_dev_data *adata;
void *dest;
u32 dma_size, page_count;
@@ -83,11 +83,21 @@ int acp_dsp_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_t
}
dest = adata->data_buf + offset;
adata->fw_data_bin_size = size + offset;
+ adata->is_dram_in_use = true;
break;
case SOF_FW_BLK_TYPE_SRAM:
- offset = offset - desc->sram_pte_offset;
- memcpy_to_scratch(sdev, offset, src, size);
- return 0;
+ if (!adata->sram_data_buf) {
+ adata->sram_data_buf = dma_alloc_coherent(&pci->dev,
+ ACP_DEFAULT_SRAM_LENGTH,
+ &adata->sram_dma_addr,
+ GFP_ATOMIC);
+ if (!adata->sram_data_buf)
+ return -ENOMEM;
+ }
+ adata->fw_sram_data_bin_size = size + offset;
+ dest = adata->sram_data_buf + offset;
+ adata->is_sram_in_use = true;
+ break;
default:
dev_err(sdev->dev, "bad blk type 0x%x\n", blk_type);
return -EINVAL;
@@ -122,6 +132,10 @@ static void configure_pte_for_fw_loading(int type, int num_pages, struct acp_dev
offset = adata->fw_bin_page_count * 8;
addr = adata->dma_addr;
break;
+ case FW_SRAM_DATA_BIN:
+ offset = (adata->fw_bin_page_count + ACP_DRAM_PAGE_COUNT) * 8;
+ addr = adata->sram_dma_addr;
+ break;
default:
dev_err(sdev->dev, "Invalid data type %x\n", type);
return;
@@ -153,7 +167,7 @@ int acp_dsp_pre_fw_run(struct snd_sof_dev *sdev)
struct pci_dev *pci = to_pci_dev(sdev->dev);
const struct sof_amd_acp_desc *desc = get_chip_info(sdev->pdata);
struct acp_dev_data *adata;
- unsigned int src_addr, size_fw;
+ unsigned int src_addr, size_fw, dest_addr;
u32 page_count, dma_size;
int ret;
@@ -174,19 +188,36 @@ int acp_dsp_pre_fw_run(struct snd_sof_dev *sdev)
dev_err(sdev->dev, "SHA DMA transfer failed status: %d\n", ret);
return ret;
}
- configure_pte_for_fw_loading(FW_DATA_BIN, ACP_DRAM_PAGE_COUNT, adata);
-
- src_addr = ACP_SYSTEM_MEMORY_WINDOW + page_count * ACP_PAGE_SIZE;
- ret = configure_and_run_dma(adata, src_addr, ACP_DATA_RAM_BASE_ADDRESS,
- adata->fw_data_bin_size);
- if (ret < 0) {
- dev_err(sdev->dev, "acp dma configuration failed: %d\n", ret);
- return ret;
+ if (adata->is_dram_in_use) {
+ configure_pte_for_fw_loading(FW_DATA_BIN, ACP_DRAM_PAGE_COUNT, adata);
+ src_addr = ACP_SYSTEM_MEMORY_WINDOW + (page_count * ACP_PAGE_SIZE);
+ dest_addr = ACP_DRAM_BASE_ADDRESS;
+
+ ret = configure_and_run_dma(adata, src_addr, dest_addr, adata->fw_data_bin_size);
+ if (ret < 0) {
+ dev_err(sdev->dev, "acp dma configuration failed: %d\n", ret);
+ return ret;
+ }
+ ret = acp_dma_status(adata, 0);
+ if (ret < 0)
+ dev_err(sdev->dev, "acp dma transfer status: %d\n", ret);
+ }
+ if (adata->is_sram_in_use) {
+ configure_pte_for_fw_loading(FW_SRAM_DATA_BIN, ACP_SRAM_PAGE_COUNT, adata);
+ src_addr = ACP_SYSTEM_MEMORY_WINDOW + ACP_DEFAULT_SRAM_LENGTH +
+ (page_count * ACP_PAGE_SIZE);
+ dest_addr = ACP_SRAM_BASE_ADDRESS;
+
+ ret = configure_and_run_dma(adata, src_addr, dest_addr,
+ adata->fw_sram_data_bin_size);
+ if (ret < 0) {
+ dev_err(sdev->dev, "acp dma configuration failed: %d\n", ret);
+ return ret;
+ }
+ ret = acp_dma_status(adata, 0);
+ if (ret < 0)
+ dev_err(sdev->dev, "acp dma transfer status: %d\n", ret);
}
-
- ret = acp_dma_status(adata, 0);
- if (ret < 0)
- dev_err(sdev->dev, "acp dma transfer status: %d\n", ret);
if (desc->rev > 3) {
/* Cache Window enable */
@@ -197,10 +228,17 @@ int acp_dsp_pre_fw_run(struct snd_sof_dev *sdev)
/* Free memory once DMA is complete */
dma_size = (PAGE_ALIGN(sdev->basefw.fw->size) >> PAGE_SHIFT) * ACP_PAGE_SIZE;
dma_free_coherent(&pci->dev, dma_size, adata->bin_buf, adata->sha_dma_addr);
- dma_free_coherent(&pci->dev, ACP_DEFAULT_DRAM_LENGTH, adata->data_buf, adata->dma_addr);
adata->bin_buf = NULL;
- adata->data_buf = NULL;
-
+ if (adata->is_dram_in_use) {
+ dma_free_coherent(&pci->dev, ACP_DEFAULT_DRAM_LENGTH, adata->data_buf,
+ adata->dma_addr);
+ adata->data_buf = NULL;
+ }
+ if (adata->is_sram_in_use) {
+ dma_free_coherent(&pci->dev, ACP_DEFAULT_SRAM_LENGTH, adata->sram_data_buf,
+ adata->sram_dma_addr);
+ adata->sram_data_buf = NULL;
+ }
return ret;
}
EXPORT_SYMBOL_NS(acp_dsp_pre_fw_run, SND_SOC_SOF_AMD_COMMON);