Commit aac89748 authored by Vijendar Mukunda's avatar Vijendar Mukunda Committed by Mark Brown

ASoC: AMD: DMA driver changes for Stoney Platform

Added DMA driver changes for Stoney platform.
Below are the key differences between Stoney and CZ

In Stoney, Memory Gating is disabled.SRAM Banks won't
be turned off.No Of SRAM Banks reduced to 6.
DAGB Garlic Interface used and 16 bit resolution is supported.
SRAM bank 1 & SRAM bank 2 will be used for playback scenario.
SRAM Bank 3 & SRAM Bank 4 will be used for Capture scenario.
Acked-by: default avatarMark Brown <broonie@kernel.org>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarVijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 607b39ef
...@@ -137,8 +137,8 @@ static void config_dma_descriptor_in_sram(void __iomem *acp_mmio, ...@@ -137,8 +137,8 @@ static void config_dma_descriptor_in_sram(void __iomem *acp_mmio,
* system memory <-> ACP SRAM * system memory <-> ACP SRAM
*/ */
static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
u32 size, int direction, u32 size, int direction,
u32 pte_offset) u32 pte_offset, u32 asic_type)
{ {
u16 i; u16 i;
u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12;
...@@ -152,20 +152,42 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, ...@@ -152,20 +152,42 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
(size / 2) - (i * (size/2)); (size / 2) - (i * (size/2));
dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS
+ (pte_offset * SZ_4K) + (i * (size/2)); + (pte_offset * SZ_4K) + (i * (size/2));
dmadscr[i].xfer_val |= switch (asic_type) {
(ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM << 16) | case CHIP_STONEY:
(size / 2); dmadscr[i].xfer_val |=
(ACP_DMA_ATTRIBUTES_DAGB_GARLIC_TO_SHAREDMEM << 16) |
(size / 2);
break;
default:
dmadscr[i].xfer_val |=
(ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM << 16) |
(size / 2);
}
} else { } else {
dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14 + i; dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14 + i;
dmadscr[i].src = ACP_SHARED_RAM_BANK_5_ADDRESS + switch (asic_type) {
(i * (size/2)); case CHIP_STONEY:
dmadscr[i].dest = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS dmadscr[i].src = ACP_SHARED_RAM_BANK_3_ADDRESS +
+ (pte_offset * SZ_4K) + (i * (size/2));
(i * (size/2)); dmadscr[i].dest =
dmadscr[i].xfer_val |= ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS +
BIT(22) | (pte_offset * SZ_4K) + (i * (size/2));
(ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION << 16) | dmadscr[i].xfer_val |=
(size / 2); BIT(22) |
(ACP_DMA_ATTRIBUTES_SHARED_MEM_TO_DAGB_GARLIC << 16) |
(size / 2);
break;
default:
dmadscr[i].src = ACP_SHARED_RAM_BANK_5_ADDRESS +
(i * (size/2));
dmadscr[i].dest =
ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS +
(pte_offset * SZ_4K) + (i * (size/2));
dmadscr[i].xfer_val |=
BIT(22) |
(ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION << 16) |
(size / 2);
}
} }
config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx, config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx,
&dmadscr[i]); &dmadscr[i]);
...@@ -186,7 +208,8 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, ...@@ -186,7 +208,8 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
* ACP SRAM <-> I2S * ACP SRAM <-> I2S
*/ */
static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio, static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio,
u32 size, int direction) u32 size, int direction,
u32 asic_type)
{ {
u16 i; u16 i;
...@@ -207,8 +230,17 @@ static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio, ...@@ -207,8 +230,17 @@ static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio,
dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15 + i; dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15 + i;
/* dmadscr[i].src is unused by hardware. */ /* dmadscr[i].src is unused by hardware. */
dmadscr[i].src = 0; dmadscr[i].src = 0;
dmadscr[i].dest = ACP_SHARED_RAM_BANK_5_ADDRESS + switch (asic_type) {
case CHIP_STONEY:
dmadscr[i].dest =
ACP_SHARED_RAM_BANK_3_ADDRESS +
(i * (size / 2)); (i * (size / 2));
break;
default:
dmadscr[i].dest =
ACP_SHARED_RAM_BANK_5_ADDRESS +
(i * (size / 2));
}
dmadscr[i].xfer_val |= BIT(22) | dmadscr[i].xfer_val |= BIT(22) |
(FROM_ACP_I2S_1 << 16) | (size / 2); (FROM_ACP_I2S_1 << 16) | (size / 2);
} }
...@@ -264,7 +296,8 @@ static void acp_pte_config(void __iomem *acp_mmio, struct page *pg, ...@@ -264,7 +296,8 @@ static void acp_pte_config(void __iomem *acp_mmio, struct page *pg,
} }
static void config_acp_dma(void __iomem *acp_mmio, static void config_acp_dma(void __iomem *acp_mmio,
struct audio_substream_data *audio_config) struct audio_substream_data *audio_config,
u32 asic_type)
{ {
u32 pte_offset; u32 pte_offset;
...@@ -278,11 +311,11 @@ static void config_acp_dma(void __iomem *acp_mmio, ...@@ -278,11 +311,11 @@ static void config_acp_dma(void __iomem *acp_mmio,
/* Configure System memory <-> ACP SRAM DMA descriptors */ /* Configure System memory <-> ACP SRAM DMA descriptors */
set_acp_sysmem_dma_descriptors(acp_mmio, audio_config->size, set_acp_sysmem_dma_descriptors(acp_mmio, audio_config->size,
audio_config->direction, pte_offset); audio_config->direction, pte_offset, asic_type);
/* Configure ACP SRAM <-> I2S DMA descriptors */ /* Configure ACP SRAM <-> I2S DMA descriptors */
set_acp_to_i2s_dma_descriptors(acp_mmio, audio_config->size, set_acp_to_i2s_dma_descriptors(acp_mmio, audio_config->size,
audio_config->direction); audio_config->direction, asic_type);
} }
/* Start a given DMA channel transfer */ /* Start a given DMA channel transfer */
...@@ -502,6 +535,12 @@ static int acp_init(void __iomem *acp_mmio, u32 asic_type) ...@@ -502,6 +535,12 @@ static int acp_init(void __iomem *acp_mmio, u32 asic_type)
acp_set_sram_bank_state(acp_mmio, bank, false); acp_set_sram_bank_state(acp_mmio, bank, false);
} }
/* Stoney supports 16bit resolution */
if (asic_type == CHIP_STONEY) {
val = acp_reg_read(acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
val |= 0x03;
acp_reg_write(val, acp_mmio, mmACP_I2S_16BIT_RESOLUTION_EN);
}
return 0; return 0;
} }
...@@ -680,6 +719,8 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, ...@@ -680,6 +719,8 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
struct page *pg; struct page *pg;
struct snd_pcm_runtime *runtime; struct snd_pcm_runtime *runtime;
struct audio_substream_data *rtd; struct audio_substream_data *rtd;
struct snd_soc_pcm_runtime *prtd = substream->private_data;
struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev);
runtime = substream->runtime; runtime = substream->runtime;
rtd = runtime->private_data; rtd = runtime->private_data;
...@@ -707,7 +748,7 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, ...@@ -707,7 +748,7 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
rtd->num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; rtd->num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
rtd->direction = substream->stream; rtd->direction = substream->stream;
config_acp_dma(rtd->acp_mmio, rtd); config_acp_dma(rtd->acp_mmio, rtd, adata->asic_type);
status = 0; status = 0;
} else { } else {
status = -ENOMEM; status = -ENOMEM;
...@@ -1011,7 +1052,8 @@ static int acp_pcm_resume(struct device *dev) ...@@ -1011,7 +1052,8 @@ static int acp_pcm_resume(struct device *dev)
true); true);
} }
config_acp_dma(adata->acp_mmio, config_acp_dma(adata->acp_mmio,
adata->play_stream->runtime->private_data); adata->play_stream->runtime->private_data,
adata->asic_type);
} }
if (adata->capture_stream && adata->capture_stream->runtime) { if (adata->capture_stream && adata->capture_stream->runtime) {
if (adata->asic_type != CHIP_STONEY) { if (adata->asic_type != CHIP_STONEY) {
...@@ -1020,7 +1062,8 @@ static int acp_pcm_resume(struct device *dev) ...@@ -1020,7 +1062,8 @@ static int acp_pcm_resume(struct device *dev)
true); true);
} }
config_acp_dma(adata->acp_mmio, config_acp_dma(adata->acp_mmio,
adata->capture_stream->runtime->private_data); adata->capture_stream->runtime->private_data,
adata->asic_type);
} }
acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
return 0; return 0;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
/* Capture SRAM address (as a source in dma descriptor) */ /* Capture SRAM address (as a source in dma descriptor) */
#define ACP_SHARED_RAM_BANK_5_ADDRESS 0x400A000 #define ACP_SHARED_RAM_BANK_5_ADDRESS 0x400A000
#define ACP_SHARED_RAM_BANK_3_ADDRESS 0x4006000
#define ACP_DMA_RESET_TIME 10000 #define ACP_DMA_RESET_TIME 10000
#define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF #define ACP_CLOCK_EN_TIME_OUT_VALUE 0x000000FF
...@@ -67,6 +68,7 @@ ...@@ -67,6 +68,7 @@
#define CAPTURE_START_DMA_DESCR_CH15 6 #define CAPTURE_START_DMA_DESCR_CH15 6
#define CAPTURE_END_DMA_DESCR_CH15 7 #define CAPTURE_END_DMA_DESCR_CH15 7
#define mmACP_I2S_16BIT_RESOLUTION_EN 0x5209
enum acp_dma_priority_level { enum acp_dma_priority_level {
/* 0x0 Specifies the DMA channel is given normal priority */ /* 0x0 Specifies the DMA channel is given normal priority */
ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0, ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment