1 // SPDX-License-Identifier: (GPL-2.0-only OR B 1 2 // 3 // This file is provided under a dual BSD/GPLv 4 // redistributing this file, you may do so und 5 // 6 // Copyright(c) 2021 Advanced Micro Devices, I 7 // 8 // Authors: Ajit Kumar Pandey <AjitKumar.Pande 9 10 /* 11 * Hardware interface for generic AMD audio DS 12 */ 13 14 #include "../ops.h" 15 #include "acp-dsp-offset.h" 16 #include "acp.h" 17 18 #define PTE_GRP1_OFFSET 0x00000000 19 #define PTE_GRP2_OFFSET 0x00800000 20 #define PTE_GRP3_OFFSET 0x01000000 21 #define PTE_GRP4_OFFSET 0x01800000 22 #define PTE_GRP5_OFFSET 0x02000000 23 #define PTE_GRP6_OFFSET 0x02800000 24 #define PTE_GRP7_OFFSET 0x03000000 25 #define PTE_GRP8_OFFSET 0x03800000 26 27 int acp_dsp_stream_config(struct snd_sof_dev * 28 { 29 const struct sof_amd_acp_desc *desc = 30 unsigned int pte_reg, pte_size, phy_ad 31 int stream_tag = stream->stream_tag; 32 u32 low, high, offset, reg_val; 33 dma_addr_t addr; 34 int page_idx; 35 36 switch (stream_tag) { 37 case 1: 38 pte_reg = ACPAXI2AXI_ATU_BASE_ 39 pte_size = ACPAXI2AXI_ATU_PAGE 40 offset = offsetof(struct scrat 41 stream->reg_offset = PTE_GRP1_ 42 break; 43 case 2: 44 pte_reg = ACPAXI2AXI_ATU_BASE_ 45 pte_size = ACPAXI2AXI_ATU_PAGE 46 offset = offsetof(struct scrat 47 stream->reg_offset = PTE_GRP2_ 48 break; 49 case 3: 50 pte_reg = ACPAXI2AXI_ATU_BASE_ 51 pte_size = ACPAXI2AXI_ATU_PAGE 52 offset = offsetof(struct scrat 53 stream->reg_offset = PTE_GRP3_ 54 break; 55 case 4: 56 pte_reg = ACPAXI2AXI_ATU_BASE_ 57 pte_size = ACPAXI2AXI_ATU_PAGE 58 offset = offsetof(struct scrat 59 stream->reg_offset = PTE_GRP4_ 60 break; 61 case 5: 62 pte_reg = ACPAXI2AXI_ATU_BASE_ 63 pte_size = ACPAXI2AXI_ATU_PAGE 64 offset = offsetof(struct scrat 65 stream->reg_offset = PTE_GRP5_ 66 break; 67 case 6: 68 pte_reg = ACPAXI2AXI_ATU_BASE_ 69 pte_size = ACPAXI2AXI_ATU_PAGE 70 offset = offsetof(struct scrat 71 stream->reg_offset = PTE_GRP6_ 72 break; 73 case 7: 74 pte_reg = ACPAXI2AXI_ATU_BASE_ 75 pte_size = ACPAXI2AXI_ATU_PAGE 76 offset = offsetof(struct scrat 77 stream->reg_offset = PTE_GRP7_ 78 break; 79 case 8: 80 pte_reg = ACPAXI2AXI_ATU_BASE_ 81 pte_size = ACPAXI2AXI_ATU_PAGE 82 offset = offsetof(struct scrat 83 stream->reg_offset = PTE_GRP8_ 84 break; 85 default: 86 dev_err(sdev->dev, "Invalid st 87 return -EINVAL; 88 } 89 90 /* write phy_addr in scratch memory */ 91 92 phy_addr_offset = sdev->debug_box.offs 93 offsetof(struct scra 94 index = stream_tag - 1; 95 phy_addr_offset = phy_addr_offset + in 96 97 snd_sof_dsp_write(sdev, ACP_DSP_BAR, A 98 phy_addr_offset, str 99 100 /* Group Enable */ 101 offset = offset + sdev->debug_box.offs 102 reg_val = desc->sram_pte_offset + offs 103 snd_sof_dsp_write(sdev, ACP_DSP_BAR, p 104 snd_sof_dsp_write(sdev, ACP_DSP_BAR, p 105 106 for (page_idx = 0; page_idx < stream-> 107 addr = snd_sgbuf_get_addr(stre 108 109 /* Load the low address of pag 110 low = lower_32_bits(addr); 111 high = upper_32_bits(addr); 112 113 snd_sof_dsp_write(sdev, ACP_DS 114 115 high |= BIT(31); 116 snd_sof_dsp_write(sdev, ACP_DS 117 /* Move to next physically con 118 offset += 8; 119 } 120 121 /* Flush ATU Cache after PTE Update */ 122 snd_sof_dsp_write(sdev, ACP_DSP_BAR, A 123 124 return 0; 125 } 126 127 struct acp_dsp_stream *acp_dsp_stream_get(stru 128 { 129 struct acp_dev_data *adata = sdev->pda 130 struct acp_dsp_stream *stream = adata- 131 int i; 132 133 for (i = 0; i < ACP_MAX_STREAM; i++, s 134 if (stream->active) 135 continue; 136 137 /* return stream if tag not sp 138 if (!tag) { 139 stream->active = 1; 140 return stream; 141 } 142 143 /* check if this is the reques 144 if (stream->stream_tag == tag) 145 stream->active = 1; 146 return stream; 147 } 148 } 149 150 dev_err(sdev->dev, "stream %d active o 151 return NULL; 152 } 153 EXPORT_SYMBOL_NS(acp_dsp_stream_get, SND_SOC_S 154 155 int acp_dsp_stream_put(struct snd_sof_dev *sde 156 struct acp_dsp_stream * 157 { 158 struct acp_dev_data *adata = sdev->pda 159 struct acp_dsp_stream *stream = adata- 160 int i; 161 162 /* Free an active stream */ 163 for (i = 0; i < ACP_MAX_STREAM; i++, s 164 if (stream == acp_stream) { 165 stream->active = 0; 166 return 0; 167 } 168 } 169 170 dev_err(sdev->dev, "Cannot find active 171 return -EINVAL; 172 } 173 EXPORT_SYMBOL_NS(acp_dsp_stream_put, SND_SOC_S 174 175 int acp_dsp_stream_init(struct snd_sof_dev *sd 176 { 177 struct acp_dev_data *adata = sdev->pda 178 int i; 179 180 for (i = 0; i < ACP_MAX_STREAM; i++) { 181 adata->stream_buf[i].sdev = sd 182 adata->stream_buf[i].active = 183 adata->stream_buf[i].stream_ta 184 } 185 return 0; 186 } 187 EXPORT_SYMBOL_NS(acp_dsp_stream_init, SND_SOC_ 188
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.