Skip to contentSkip to conversation

Add ASoC support for AMD Stoney APUs

PATCH Superseded Alex Deucher 7 participants 19 messages Jun 23, 2017 – Jun 30, 2017 2 messages not in the archive

Subsystems (5)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Add ASoC support for AMD Stoney APUs

This patch set updates the AMD GPU and Audio CoProcessor (ACP) audio drivers and the designware i2s driver for Stoney (ST). ST is an APU similar to Carrizo (CZ) which already has ACP audio support. The i2s controller and ACP audio DMA engine are part of the GPU and both need updating so I would like to upstream the whole patch set via one tree if possible.

The current code is based on drm-next, but I'm happy to rebase on whatever tree this ends up going through if there are any problems applying. The entire patch set can be viewed here:
https://cgit.freedesktop.org/~agd5f/linux/log/?h=drm-next-4.13-acp

Thanks!

Alex

Akshu Agrawal (1):
ASoC: AMD: Add machine driver for cz rt5650

Vijendar Mukunda (7):
drm/amd/amdgpu: Added asic_type as ACP DMA driver platform data
ASoC: dwc: Added a quirk DW_I2S_QUIRK_16BIT_IDX_OVERRIDE to dwc driver drm/amd/amdgpu: Added a dwc quirk for Stoney platform
ASoC: AMD: added condition checks for CZ specific code
ASoC: AMD: DMA driver changes for Stoney Platform
ASoC: AMD: Buffer related changes for Stoney drm/amd/amdgpu: Disable ACP Power Gating for Stoney platform

 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c |  54 +++++---
 include/sound/designware_i2s.h          |   1 +
 sound/soc/amd/Kconfig                   |   7 ++
 sound/soc/amd/Makefile                  |   2 +
 sound/soc/amd/acp-pcm-dma.c             | 215 ++++++++++++++++++++++++--------
 sound/soc/amd/acp-rt5645.c              | 210 +++++++++++++++++++++++++++++++
 sound/soc/amd/acp.h                     |   9 ++
 sound/soc/dwc/dwc-i2s.c                 |   6 +
 8 files changed, 432 insertions(+), 72 deletions(-)
 create mode 100644 sound/soc/amd/acp-rt5645.c
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1498235706-31111-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 1/8 drm/amd/amdgpu: Added asic_type as ACP DMA driver platform data

From: Vijendar Mukunda <[email protected]>

asic_type information is passed to ACP DMA Driver as platform data. We need this to determine whether the asic is Carrizo (CZ) or Stoney (ST) in the acp sound driver.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 4 ++++
 sound/soc/amd/acp-pcm-dma.c             | 8 ++------
 sound/soc/amd/acp.h                     | 7 +++++++
 3 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +4 -0
index 06879d1..7a2a765 100644
@@ -262,6 +262,7 @@ static int acp_hw_init(void *handle)
 	uint64_t acp_base;
 	struct device *dev;
 	struct i2s_platform_data *i2s_pdata;
+	u32 asic_type;
 
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
@@ -271,6 +272,7 @@ static int acp_hw_init(void *handle)
 	if (!ip_block)
 		return -EINVAL;
 
+	asic_type = adev->asic_type;
 	r = amd_acp_hw_init(adev->acp.cgs_device,
 			    ip_block->version->major, ip_block->version->minor);
 	/* -ENODEV means board uses AZ rather than ACP */
@@ -355,6 +357,8 @@ static int acp_hw_init(void *handle)
 	adev->acp.acp_cell[0].name = "acp_audio_dma";
 	adev->acp.acp_cell[0].num_resources = 4;
 	adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0];
+	adev->acp.acp_cell[0].platform_data = &asic_type;
+	adev->acp.acp_cell[0].pdata_size = sizeof(asic_type);
 
 	adev->acp.acp_cell[1].name = "designware-i2s";
 	adev->acp.acp_cell[1].num_resources = 1;
sound/soc/amd/acp-pcm-dma.c +2 -6
index 08b1399..dcbf997 100644
@@ -73,12 +73,6 @@ static const struct snd_pcm_hardware acp_pcm_hardware_capture = {
 	.periods_max = CAPTURE_MAX_NUM_PERIODS,
 };
 
-struct audio_drv_data {
-	struct snd_pcm_substream *play_stream;
-	struct snd_pcm_substream *capture_stream;
-	void __iomem *acp_mmio;
-};
-
 static u32 acp_reg_read(void __iomem *acp_mmio, u32 reg)
 {
 	return readl(acp_mmio + (reg * 4));
@@ -916,6 +910,7 @@ static int acp_audio_probe(struct platform_device *pdev)
 	int status;
 	struct audio_drv_data *audio_drv_data;
 	struct resource *res;
+	const u32 *pdata = pdev->dev.platform_data;
 
 	audio_drv_data = devm_kzalloc(&pdev->dev, sizeof(struct audio_drv_data),
 					GFP_KERNEL);
@@ -932,6 +927,7 @@ static int acp_audio_probe(struct platform_device *pdev)
 
 	audio_drv_data->play_stream = NULL;
 	audio_drv_data->capture_stream = NULL;
+	audio_drv_data->asic_type =  *pdata;
 
 	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (!res) {
sound/soc/amd/acp.h +7 -0
index 330832e..28cf914 100644
@@ -84,6 +84,13 @@ struct audio_substream_data {
 	void __iomem *acp_mmio;
 };
 
+struct audio_drv_data {
+	struct snd_pcm_substream *play_stream;
+	struct snd_pcm_substream *capture_stream;
+	void __iomem *acp_mmio;
+	u32 asic_type;
+};
+
 enum {
 	ACP_TILE_P1 = 0,
 	ACP_TILE_P2,
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1498235706-31111-2-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 1/8] drm/amd/amdgpu: Added asic_type as ACP DMA driver platform data

Am 23.06.2017 um 18:34 schrieb Alex Deucher:

Quoted 36 lines

From: Vijendar Mukunda <[email protected]>

asic_type information is passed to ACP DMA Driver as platform data. We need this to determine whether the asic is Carrizo (CZ) or Stoney (ST) in the acp sound driver.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 4 ++++
  sound/soc/amd/acp-pcm-dma.c             | 8 ++------
  sound/soc/amd/acp.h                     | 7 +++++++
  3 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2 -0
index 06879d1..7a2a765 100644
@@ -262,6 +262,7 @@ static int acp_hw_init(void *handle)
  	uint64_t acp_base;
  	struct device *dev;
  	struct i2s_platform_data *i2s_pdata;
+	u32 asic_type;
 
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
@@ -271,6 +272,7 @@ static int acp_hw_init(void *handle)
  	if (!ip_block)
  		return -EINVAL;
 
+	asic_type = adev->asic_type;
  	r = amd_acp_hw_init(adev->acp.cgs_device,
  			    ip_block->version->major, ip_block->version->minor);
  	/* -ENODEV means board uses AZ rather than ACP */

drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c static int acp_hw_init(void *handle) · line 361

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2 -0
@@ -355,6 +357,8 @@ static int acp_hw_init(void *handle)
  	adev->acp.acp_cell[0].name = "acp_audio_dma";
  	adev->acp.acp_cell[0].num_resources = 4;
  	adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0];
+	adev->acp.acp_cell[0].platform_data = &asic_type;
+	adev->acp.acp_cell[0].pdata_size = sizeof(asic_type);

Have the painkillers jellyfied my brain or are you setting a pointer in the amdgpu device structure to some variable on the stack?

If it's just for initialization then that's probably ok, but I would reset the pointer at the end of the function.

Otherwise somebody might have the idea to dereference it later on and that can only lead to trouble.

Christian.

Quoted 44 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0 -0
  	adev->acp.acp_cell[1].name = "designware-i2s";
  	adev->acp.acp_cell[1].num_resources = 1;
sound/soc/amd/acp-pcm-dma.c +2 -6
index 08b1399..dcbf997 100644
@@ -73,12 +73,6 @@ static const struct snd_pcm_hardware acp_pcm_hardware_capture = {
  	.periods_max = CAPTURE_MAX_NUM_PERIODS,
  };
 
-struct audio_drv_data {
-	struct snd_pcm_substream *play_stream;
-	struct snd_pcm_substream *capture_stream;
-	void __iomem *acp_mmio;
-};
-
  static u32 acp_reg_read(void __iomem *acp_mmio, u32 reg)
  {
  	return readl(acp_mmio + (reg * 4));
@@ -916,6 +910,7 @@ static int acp_audio_probe(struct platform_device *pdev)
  	int status;
  	struct audio_drv_data *audio_drv_data;
  	struct resource *res;
+	const u32 *pdata = pdev->dev.platform_data;
 
  	audio_drv_data = devm_kzalloc(&pdev->dev, sizeof(struct audio_drv_data),
  					GFP_KERNEL);
@@ -932,6 +927,7 @@ static int acp_audio_probe(struct platform_device *pdev)
 
  	audio_drv_data->play_stream = NULL;
  	audio_drv_data->capture_stream = NULL;
+	audio_drv_data->asic_type =  *pdata;
 
  	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  	if (!res) {
sound/soc/amd/acp.h +0 -0
index 330832e..28cf914 100644
@@ -84,6 +84,13 @@ struct audio_substream_data {
  	void __iomem *acp_mmio;
  };
 

sound/soc/amd/acp.h struct audio_substream_data { · line 96

Quoted 10 lines
sound/soc/amd/acp.h +7 -0
+struct audio_drv_data {
+	struct snd_pcm_substream *play_stream;
+	struct snd_pcm_substream *capture_stream;
+	void __iomem *acp_mmio;
+	u32 asic_type;
+};
+
  enum {
  	ACP_TILE_P1 = 0,
  	ACP_TILE_P2,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

Re: [PATCH 1/8] drm/amd/amdgpu: Added asic_type as ACP DMA driver platform data

Quoted 47 lines · Christian König

Am 23.06.2017 um 18:34 schrieb Alex Deucher:

Quoted 36 lines

From: Vijendar Mukunda <[email protected]>

asic_type information is passed to ACP DMA Driver as platform data. We need this to determine whether the asic is Carrizo (CZ) or Stoney (ST) in the acp sound driver.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 4 ++++
  sound/soc/amd/acp-pcm-dma.c             | 8 ++------
  sound/soc/amd/acp.h                     | 7 +++++++
  3 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +1 -0
index 06879d1..7a2a765 100644
@@ -262,6 +262,7 @@ static int acp_hw_init(void *handle)
        uint64_t acp_base;
        struct device *dev;
        struct i2s_platform_data *i2s_pdata;
+       u32 asic_type;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
  @@ -271,6 +272,7 @@ static int acp_hw_init(void *handle)
        if (!ip_block)
                return -EINVAL;
  +     asic_type = adev->asic_type;
        r = amd_acp_hw_init(adev->acp.cgs_device,
                            ip_block->version->major,
ip_block->version->minor);
        /* -ENODEV means board uses AZ rather than ACP */

drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c static int acp_hw_init(void *handle) · line 361

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2 -0
@@ -355,6 +357,8 @@ static int acp_hw_init(void *handle)
        adev->acp.acp_cell[0].name = "acp_audio_dma";
        adev->acp.acp_cell[0].num_resources = 4;
        adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0];
+       adev->acp.acp_cell[0].platform_data = &asic_type;
+       adev->acp.acp_cell[0].pdata_size = sizeof(asic_type);

Have the painkillers jellyfied my brain or are you setting a pointer in the amdgpu device structure to some variable on the stack?

Quoted 5 lines

If it's just for initialization then that's probably ok, but I would reset the pointer at the end of the function.

Otherwise somebody might have the idea to dereference it later on and that can only lead to trouble.

I think it's ok because the hotplug of the audio device is triggered from this function, so the audio device should be probed by the time this variable goes out of scope. That said, it would probably be better to use the asic_type from the GPU driver instance directly rather than a stack variable.

Alex

Quoted 48 lines

Christian.

Quoted 44 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0 -0
        adev->acp.acp_cell[1].name = "designware-i2s";
        adev->acp.acp_cell[1].num_resources = 1;
sound/soc/amd/acp-pcm-dma.c +1 -5
index 08b1399..dcbf997 100644
@@ -73,12 +73,6 @@ static const struct snd_pcm_hardware
 acp_pcm_hardware_capture = {
        .periods_max = CAPTURE_MAX_NUM_PERIODS,
  };
  -struct audio_drv_data {
-       struct snd_pcm_substream *play_stream;
-       struct snd_pcm_substream *capture_stream;
-       void __iomem *acp_mmio;
-};
-
  static u32 acp_reg_read(void __iomem *acp_mmio, u32 reg)
  {
        return readl(acp_mmio + (reg * 4));
@@ -916,6 +910,7 @@ static int acp_audio_probe(struct platform_device
 *pdev)
        int status;
        struct audio_drv_data *audio_drv_data;
        struct resource *res;
+       const u32 *pdata = pdev->dev.platform_data;
        audio_drv_data = devm_kzalloc(&pdev->dev, sizeof(struct
 audio_drv_data),
                                        GFP_KERNEL);
sound/soc/amd/acp-pcm-dma.c +1 -0
@@ -932,6 +927,7 @@ static int acp_audio_probe(struct platform_device
 *pdev)
        audio_drv_data->play_stream = NULL;
        audio_drv_data->capture_stream = NULL;
+       audio_drv_data->asic_type =  *pdata;
        res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (!res) {
sound/soc/amd/acp.h +1 -0
index 330832e..28cf914 100644
@@ -84,6 +84,13 @@ struct audio_substream_data {
        void __iomem *acp_mmio;
  };
  +struct audio_drv_data {
+       struct snd_pcm_substream *play_stream;
Quoted 11 lines

sound/soc/amd/acp.h struct audio_substream_data { · line 96

Quoted 8 lines
sound/soc/amd/acp.h +5 -0
+       struct snd_pcm_substream *capture_stream;
+       void __iomem *acp_mmio;
+       u32 asic_type;
+};
+
  enum {
        ACP_TILE_P1 = 0,
        ACP_TILE_P2,

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH 1/8] drm/amd/amdgpu: Added asic_type as ACP DMA driver platform data

Am 23.06.2017 um 19:05 schrieb Alex Deucher:

Quoted 50 lines
Quoted 48 lines · Christian König

Am 23.06.2017 um 18:34 schrieb Alex Deucher:

Quoted 35 lines

From: Vijendar Mukunda <[email protected]>

asic_type information is passed to ACP DMA Driver as platform data. We need this to determine whether the asic is Carrizo (CZ) or Stoney (ST) in the acp sound driver.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 4 ++++
   sound/soc/amd/acp-pcm-dma.c             | 8 ++------
   sound/soc/amd/acp.h                     | 7 +++++++
   3 files changed, 13 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +1 -0
index 06879d1..7a2a765 100644
@@ -262,6 +262,7 @@ static int acp_hw_init(void *handle)
         uint64_t acp_base;
         struct device *dev;
         struct i2s_platform_data *i2s_pdata;
+       u32 asic_type;
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;
   @@ -271,6 +272,7 @@ static int acp_hw_init(void *handle)
         if (!ip_block)
                 return -EINVAL;
   +     asic_type = adev->asic_type;
         r = amd_acp_hw_init(adev->acp.cgs_device,
                             ip_block->version->major,
ip_block->version->minor);
         /* -ENODEV means board uses AZ rather than ACP */

drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c static int acp_hw_init(void *handle) · line 361

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +2 -0
@@ -355,6 +357,8 @@ static int acp_hw_init(void *handle)
         adev->acp.acp_cell[0].name = "acp_audio_dma";
         adev->acp.acp_cell[0].num_resources = 4;
         adev->acp.acp_cell[0].resources = &adev->acp.acp_res[0];
+       adev->acp.acp_cell[0].platform_data = &asic_type;
+       adev->acp.acp_cell[0].pdata_size = sizeof(asic_type);

Have the painkillers jellyfied my brain or are you setting a pointer in the amdgpu device structure to some variable on the stack?

If it's just for initialization then that's probably ok, but I would reset the pointer at the end of the function.

Quoted 7 lines
Quoted 2 lines

Otherwise somebody might have the idea to dereference it later on and that can only lead to trouble.

I think it's ok because the hotplug of the audio device is triggered from this function, so the audio device should be probed by the time this variable goes out of scope. That said, it would probably be better to use the asic_type from the GPU driver instance directly rather than a stack variable.

Yeah, agree. But keeping a stale reference in to a stack variable in the driver struct is still ugly like hell.

At bare minimum set this to NULL at the end of the function, or even better use a intptr_t to encode the asic type into the pointer.

Christian.

Quoted 61 lines

Alex

Quoted 57 lines

Christian.

Quoted 52 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0 -0
         adev->acp.acp_cell[1].name = "designware-i2s";
         adev->acp.acp_cell[1].num_resources = 1;
sound/soc/amd/acp-pcm-dma.c +1 -5
index 08b1399..dcbf997 100644
@@ -73,12 +73,6 @@ static const struct snd_pcm_hardware
 acp_pcm_hardware_capture = {
         .periods_max = CAPTURE_MAX_NUM_PERIODS,
   };
   -struct audio_drv_data {
-       struct snd_pcm_substream *play_stream;
-       struct snd_pcm_substream *capture_stream;
-       void __iomem *acp_mmio;
-};
-
   static u32 acp_reg_read(void __iomem *acp_mmio, u32 reg)
   {
         return readl(acp_mmio + (reg * 4));
@@ -916,6 +910,7 @@ static int acp_audio_probe(struct platform_device
 *pdev)
         int status;
         struct audio_drv_data *audio_drv_data;
         struct resource *res;
+       const u32 *pdata = pdev->dev.platform_data;
         audio_drv_data = devm_kzalloc(&pdev->dev, sizeof(struct
 audio_drv_data),
                                         GFP_KERNEL);
sound/soc/amd/acp-pcm-dma.c +1 -0
@@ -932,6 +927,7 @@ static int acp_audio_probe(struct platform_device
 *pdev)
         audio_drv_data->play_stream = NULL;
         audio_drv_data->capture_stream = NULL;
+       audio_drv_data->asic_type =  *pdata;
         res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
         if (!res) {
sound/soc/amd/acp.h +6 -0
index 330832e..28cf914 100644
@@ -84,6 +84,13 @@ struct audio_substream_data {
         void __iomem *acp_mmio;
   };
   +struct audio_drv_data {
+       struct snd_pcm_substream *play_stream;
+       struct snd_pcm_substream *capture_stream;
+       void __iomem *acp_mmio;
+       u32 asic_type;
+};
+
   enum {
         ACP_TILE_P1 = 0,
         ACP_TILE_P2,

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#7 lore raw

Re: [PATCH 1/8] drm/amd/amdgpu: Added asic_type as ACP DMA driver platform data

In reply to Alex Deucher
Quoted 8 lines · Alex Deucher

On Fri, Jun 23, 2017 at 12:43 PM, Christian König

Quoted 5 lines

Have the painkillers jellyfied my brain or are you setting a pointer in the amdgpu device structure to some variable on the stack?

If it's just for initialization then that's probably ok, but I would reset the pointer at the end of the function.

Quoted 6 lines
Quoted 2 lines

Otherwise somebody might have the idea to dereference it later on and that can only lead to trouble.

I think it's ok because the hotplug of the audio device is triggered from this function, so the audio device should be probed by the time this variable goes out of scope. That said, it would probably be

No, that's in no way safe. There is no guarantee that probe is going to happen on any particular schedule, if the other driver isn't registered yet it'll need to wait for that to happen for example. You will often get away with it but that's at best going to be vulnerable to framework changes (what if someone decides to kick off the probe on a separate CPU in an effort to reduce boot time?).

Quoted 2 lines

better to use the asic_type from the GPU driver instance directly rather than a stack variable.

Yes.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw

PATCH 2/8 ASoC: dwc: Added a quirk DW_I2S_QUIRK_16BIT_IDX_OVERRIDE to dwc driver

In reply to a message not in the archive

From: Vijendar Mukunda <[email protected]>

Added quirk DW_I2S_QUIRK_16BIT_IDX_OVERRIDE to Designware driver. This quirk will set idx value to 1.

By setting this quirk, it will override supported format as 16 bit resolution and bus width as 2 Bytes.

---
 include/sound/designware_i2s.h | 1 +
 sound/soc/dwc/dwc-i2s.c        | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/designware_i2s.h +1 -0
index 5681855..830f5ca 100644
@@ -47,6 +47,7 @@ struct i2s_platform_data {
 
 	#define DW_I2S_QUIRK_COMP_REG_OFFSET	(1 << 0)
 	#define DW_I2S_QUIRK_COMP_PARAM1	(1 << 1)
+	#define DW_I2S_QUIRK_16BIT_IDX_OVERRIDE (1 << 2)
 	unsigned int quirks;
 	unsigned int i2s_reg_comp1;
 	unsigned int i2s_reg_comp2;
sound/soc/dwc/dwc-i2s.c +6 -0
index 9c46e41..9160676 100644
@@ -496,6 +496,8 @@ static int dw_configure_dai(struct dw_i2s_dev *dev,
 		idx = COMP1_TX_WORDSIZE_0(comp1);
 		if (WARN_ON(idx >= ARRAY_SIZE(formats)))
 			return -EINVAL;
+		if (dev->quirks & DW_I2S_QUIRK_16BIT_IDX_OVERRIDE)
+			idx = 1;
 		dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
 		dw_i2s_dai->playback.channels_max =
 				1 << (COMP1_TX_CHANNELS(comp1) + 1);
@@ -508,6 +510,8 @@ static int dw_configure_dai(struct dw_i2s_dev *dev,
 		idx = COMP2_RX_WORDSIZE_0(comp2);
 		if (WARN_ON(idx >= ARRAY_SIZE(formats)))
 			return -EINVAL;
+		if (dev->quirks & DW_I2S_QUIRK_16BIT_IDX_OVERRIDE)
+			idx = 1;
 		dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM;
 		dw_i2s_dai->capture.channels_max =
 				1 << (COMP1_RX_CHANNELS(comp1) + 1);
@@ -543,6 +547,8 @@ static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev,
 	if (ret < 0)
 		return ret;
 
+	if (dev->quirks & DW_I2S_QUIRK_16BIT_IDX_OVERRIDE)
+		idx = 1;
 	/* Set DMA slaves info */
 	dev->play_dma_data.pd.data = pdata->play_dma_data;
 	dev->capture_dma_data.pd.data = pdata->capture_dma_data;
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#9 lore raw

Applied "ASoC: dwc: Added a quirk DW_I2S_QUIRK_16BIT_IDX_OVERRIDE to dwc driver" to the asoc tree

The patch

ASoC: dwc: Added a quirk DW_I2S_QUIRK_16BIT_IDX_OVERRIDE to dwc driver

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

From 286345eef97ea8f4ea223410f025ed35f265e506 Mon Sep 17 00:00:00 2001
From: Vijendar Mukunda <[email protected]>
Date: Fri, 23 Jun 2017 12:35:00 -0400
Subject: [PATCH] ASoC: dwc: Added a quirk DW_I2S_QUIRK_16BIT_IDX_OVERRIDE to
dwc driver

Added quirk DW_I2S_QUIRK_16BIT_IDX_OVERRIDE to Designware driver. This quirk will set idx value to 1.

By setting this quirk, it will override supported format as 16 bit resolution and bus width as 2 Bytes.

---
 include/sound/designware_i2s.h | 1 +
 sound/soc/dwc/dwc-i2s.c        | 6 ++++++
 2 files changed, 7 insertions(+)
include/sound/designware_i2s.h +1 -0
index 5681855396c4..830f5caa915c 100644
@@ -47,6 +47,7 @@ struct i2s_platform_data {
 
 	#define DW_I2S_QUIRK_COMP_REG_OFFSET	(1 << 0)
 	#define DW_I2S_QUIRK_COMP_PARAM1	(1 << 1)
+	#define DW_I2S_QUIRK_16BIT_IDX_OVERRIDE (1 << 2)
 	unsigned int quirks;
 	unsigned int i2s_reg_comp1;
 	unsigned int i2s_reg_comp2;
sound/soc/dwc/dwc-i2s.c +6 -0
index 9c46e4112026..916067638180 100644
@@ -496,6 +496,8 @@ static int dw_configure_dai(struct dw_i2s_dev *dev,
 		idx = COMP1_TX_WORDSIZE_0(comp1);
 		if (WARN_ON(idx >= ARRAY_SIZE(formats)))
 			return -EINVAL;
+		if (dev->quirks & DW_I2S_QUIRK_16BIT_IDX_OVERRIDE)
+			idx = 1;
 		dw_i2s_dai->playback.channels_min = MIN_CHANNEL_NUM;
 		dw_i2s_dai->playback.channels_max =
 				1 << (COMP1_TX_CHANNELS(comp1) + 1);
@@ -508,6 +510,8 @@ static int dw_configure_dai(struct dw_i2s_dev *dev,
 		idx = COMP2_RX_WORDSIZE_0(comp2);
 		if (WARN_ON(idx >= ARRAY_SIZE(formats)))
 			return -EINVAL;
+		if (dev->quirks & DW_I2S_QUIRK_16BIT_IDX_OVERRIDE)
+			idx = 1;
 		dw_i2s_dai->capture.channels_min = MIN_CHANNEL_NUM;
 		dw_i2s_dai->capture.channels_max =
 				1 << (COMP1_RX_CHANNELS(comp1) + 1);
@@ -543,6 +547,8 @@ static int dw_configure_dai_by_pd(struct dw_i2s_dev *dev,
 	if (ret < 0)
 		return ret;
 
+	if (dev->quirks & DW_I2S_QUIRK_16BIT_IDX_OVERRIDE)
+		idx = 1;
 	/* Set DMA slaves info */
 	dev->play_dma_data.pd.data = pdata->play_dma_data;
 	dev->capture_dma_data.pd.data = pdata->capture_dma_data;
Signature · 6 lines
2.13.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH 4/8 ASoC: AMD: added condition checks for CZ specific code

In reply to a message not in the archive

From: Vijendar Mukunda <[email protected]>

Added condition checks for CZ specific code based on asic_type. Stoney specific code will be added in a future commit.

---
 sound/soc/amd/acp-pcm-dma.c | 62 ++++++++++++++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 23 deletions(-)
sound/soc/amd/acp-pcm-dma.c +39 -23
index dcbf997..e48ae5d 100644
@@ -34,6 +34,8 @@
 
 #define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS)
 #define MIN_BUFFER MAX_BUFFER
+#define CHIP_STONEY 14
+#define CHIP_CARRIZO 13
 
 static const struct snd_pcm_hardware acp_pcm_hardware_playback = {
 	.info = SNDRV_PCM_INFO_INTERLEAVED |
@@ -419,7 +421,7 @@ static void acp_set_sram_bank_state(void __iomem *acp_mmio, u16 bank,
 }
 
 /* Initialize and bring ACP hardware to default state. */
-static int acp_init(void __iomem *acp_mmio)
+static int acp_init(void __iomem *acp_mmio, u32 asic_type)
 {
 	u16 bank;
 	u32 val, count, sram_pte_offset;
@@ -494,8 +496,10 @@ static int acp_init(void __iomem *acp_mmio)
 	* Now, turn off all of them. This can't be done in 'poweron' of
 	* ACP pm domain, as this requires ACP to be initialized.
 	*/
-	for (bank = 1; bank < 48; bank++)
-		acp_set_sram_bank_state(acp_mmio, bank, false);
+	if (asic_type == CHIP_CARRIZO) {
+		for (bank = 1; bank < 48; bank++)
+			acp_set_sram_bank_state(acp_mmio, bank, false);
+	}
 
 	return 0;
 }
@@ -646,14 +650,18 @@ static int acp_dma_open(struct snd_pcm_substream *substream)
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		intr_data->play_stream = substream;
-		for (bank = 1; bank <= 4; bank++)
-			acp_set_sram_bank_state(intr_data->acp_mmio, bank,
-						true);
+		if (intr_data->asic_type == CHIP_CARRIZO) {
+			for (bank = 1; bank <= 4; bank++)
+				acp_set_sram_bank_state(intr_data->acp_mmio,
+							bank, true);
+		}
 	} else {
 		intr_data->capture_stream = substream;
-		for (bank = 5; bank <= 8; bank++)
-			acp_set_sram_bank_state(intr_data->acp_mmio, bank,
-						true);
+		if (intr_data->asic_type == CHIP_CARRIZO) {
+			for (bank = 5; bank <= 8; bank++)
+				acp_set_sram_bank_state(intr_data->acp_mmio,
+							bank, true);
+		}
 	}
 
 	return 0;
@@ -869,14 +877,18 @@ static int acp_dma_close(struct snd_pcm_substream *substream)
 
 	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
 		adata->play_stream = NULL;
-		for (bank = 1; bank <= 4; bank++)
-			acp_set_sram_bank_state(adata->acp_mmio, bank,
-						false);
-	} else {
+		if (adata->asic_type == CHIP_CARRIZO) {
+			for (bank = 1; bank <= 4; bank++)
+				acp_set_sram_bank_state(adata->acp_mmio, bank,
+				false);
+		}
+	} else  {
 		adata->capture_stream = NULL;
-		for (bank = 5; bank <= 8; bank++)
-			acp_set_sram_bank_state(adata->acp_mmio, bank,
-						false);
+		if (adata->asic_type == CHIP_CARRIZO) {
+			for (bank = 5; bank <= 8; bank++)
+				acp_set_sram_bank_state(adata->acp_mmio, bank,
+						     false);
+		}
 	}
 
 	/* Disable ACP irq, when the current stream is being closed and
@@ -945,7 +957,7 @@ static int acp_audio_probe(struct platform_device *pdev)
 	dev_set_drvdata(&pdev->dev, audio_drv_data);
 
 	/* Initialize the ACP */
-	acp_init(audio_drv_data->acp_mmio);
+	acp_init(audio_drv_data->acp_mmio, audio_drv_data->asic_type);
 
 	status = snd_soc_register_platform(&pdev->dev, &acp_asoc_platform);
 	if (status != 0) {
@@ -976,19 +988,23 @@ static int acp_pcm_resume(struct device *dev)
 	u16 bank;
 	struct audio_drv_data *adata = dev_get_drvdata(dev);
 
-	acp_init(adata->acp_mmio);
+	acp_init(adata->acp_mmio, adata->asic_type);
 
 	if (adata->play_stream && adata->play_stream->runtime) {
-		for (bank = 1; bank <= 4; bank++)
-			acp_set_sram_bank_state(adata->acp_mmio, bank,
+		if (adata->asic_type == CHIP_CARRIZO) {
+			for (bank = 1; bank <= 4; bank++)
+				acp_set_sram_bank_state(adata->acp_mmio, bank,
 						true);
+		}
 		config_acp_dma(adata->acp_mmio,
 				adata->play_stream->runtime->private_data);
 	}
 	if (adata->capture_stream && adata->capture_stream->runtime) {
-		for (bank = 5; bank <= 8; bank++)
-			acp_set_sram_bank_state(adata->acp_mmio, bank,
+		if (adata->asic_type == CHIP_CARRIZO) {
+			for (bank = 5; bank <= 8; bank++)
+				acp_set_sram_bank_state(adata->acp_mmio, bank,
 						true);
+		}
 		config_acp_dma(adata->acp_mmio,
 				adata->capture_stream->runtime->private_data);
 	}
@@ -1009,7 +1025,7 @@ static int acp_pcm_runtime_resume(struct device *dev)
 {
 	struct audio_drv_data *adata = dev_get_drvdata(dev);
 
-	acp_init(adata->acp_mmio);
+	acp_init(adata->acp_mmio, adata->asic_type);
 	acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB);
 	return 0;
 }
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#11 lore raw

Re: [PATCH 4/8] ASoC: AMD: added condition checks for CZ specific code

sound/soc/amd/acp-pcm-dma.c line 38

Quoted 12 lines · Alex Deucher

index dcbf997..e48ae5d 100644

sound/soc/amd/acp-pcm-dma.c +2 -0
@@ -34,6 +34,8 @@
 
 #define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS)
 #define MIN_BUFFER MAX_BUFFER
+#define CHIP_STONEY 14
+#define CHIP_CARRIZO 13

These defines are being added in the middle of a file but CHIP_STONEY is also used in another file in the previous patch (and apparently extensively throughout the DRM driver already). This is obviously not good, we shouldn't have multiple copies of the definition.

sound/soc/amd/acp-pcm-dma.c static int acp_dma_close(struct snd_pcm_substream *substream) · line 883

Quoted 5 lines
sound/soc/amd/acp-pcm-dma.c +4 -1
-	} else {
+		if (adata->asic_type == CHIP_CARRIZO) {
+			for (bank = 1; bank <= 4; bank++)
+				acp_set_sram_bank_state(adata->acp_mmio, bank,
+				false);

I'm not seeing any poweroff cases for other chips being added, and again switch statements please.

#12 lore raw

RE: [PATCH 4/8] ASoC: AMD: added condition checks for CZ specific code

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, June 28, 2017 11:36 PM
To: Alex Deucher
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Mukunda, Vijendar; [email protected]; [email protected]; [email protected]; [email protected]; Deucher, Alexander
Subject: Re: [PATCH 4/8] ASoC: AMD: added condition checks for CZ specific code

Quoted 21 lines · Alex Deucher

index dcbf997..e48ae5d 100644

sound/soc/amd/acp-pcm-dma.c +0 -0
@@ -34,6 +34,8 @@
 
 #define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * 

PLAYBACK_MAX_NUM_PERIODS) #define MIN_BUFFER MAX_BUFFER

sound/soc/amd/acp-pcm-dma.c +2 -0
+#define CHIP_STONEY 14
+#define CHIP_CARRIZO 13

These defines are being added in the middle of a file but CHIP_STONEY is also used in another file in the previous patch (and apparently extensively throughout the DRM driver already). This is obviously not good, >we shouldn't have multiple copies of the definition.

sound/soc/amd/acp-pcm-dma.c +4 -1
-	} else {
+		if (adata->asic_type == CHIP_CARRIZO) {
+			for (bank = 1; bank <= 4; bank++)
+				acp_set_sram_bank_state(adata->acp_mmio, bank,
+				false);
Quoted 1 line

I'm not seeing any poweroff cases for other chips being added, and again switch statements please.

We will modify code to use single definition for CHIP_STONEY and CHIP_CARRIZO. There are only two chip sets based on ACP 2.x design(Carrizo and Stoney). Our future Chip sets going to use different design based on next ACP IP version.

In the current patch, Condition checks added for Carrizo for setting SRAM BANK state.
Memory Gating is disabled in Stoney,i.e SRAM Bank's won't be turned off. The default state for SRAM banks is ON. As Memory Gating is disabled, there is no need to add condition checks for Stoney to set SRAM Bank state.

Apart from Memory Gating, there are few more differences between Stoney and Carrizo chip sets. Stoney specific DMA driver changes submitted in a separate patch.

Vijendar

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer
#13 lore raw

Re: [PATCH 4/8] ASoC: AMD: added condition checks for CZ specific code

Quoted 4 lines · Vijendar

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Wednesday, June 28, 2017 11:36 PM
To: Alex Deucher

Please fix your mail client to quote mails in a more normal fashion, this looks pretty broken...

Quoted 1 line
Quoted 1 line

These defines are being added in the middle of a file but CHIP_STONEY is also used in another file in the previous patch (and apparently extensively throughout the DRM driver already). This is obviously not good, >we shouldn't have multiple copies of the definition.

...especially in that it's reflowing the message it's replying to to cause 80 column problems and has serious problems in that regard itself.

Quoted 3 lines

We will modify code to use single definition for CHIP_STONEY and CHIP_CARRIZO. There are only two chip sets based on ACP 2.x design(Carrizo and Stoney). Our future Chip sets going to use different design based on next ACP IP version.

Write the code well, that way we don't have bad patterns in the codebase and if plans change with regard to new variants you're covered.

Quoted 3 lines

In the current patch, Condition checks added for Carrizo for setting SRAM BANK state.
Memory Gating is disabled in Stoney,i.e SRAM Bank's won't be turned off. The default state for SRAM banks is ON. As Memory Gating is disabled, there is no need to add condition checks for Stoney to set SRAM Bank state.

Some documentation of this in the code would be good.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#14 lore raw

PATCH 6/8 ASoC: AMD: Buffer related changes for Stoney

In reply to a message not in the archive

From: Vijendar Mukunda <[email protected]>

Stoney uses 16kb SRAM memory for playback and 16Kb for capture. Modified Max buffer size to have the correct mapping between System Memory and SRAM.

Added snd_pcm_hardware structures for playback and capture for Stoney.

---
 sound/soc/amd/acp-pcm-dma.c | 68 +++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 63 insertions(+), 5 deletions(-)
sound/soc/amd/acp-pcm-dma.c +63 -5
index 5b5e95d..c9bb618 100644
@@ -34,6 +34,10 @@
 
 #define MAX_BUFFER (PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS)
 #define MIN_BUFFER MAX_BUFFER
+#define ST_PLAYBACK_MAX_PERIOD_SIZE 8192
+#define ST_CAPTURE_MAX_PERIOD_SIZE  8192
+#define ST_MAX_BUFFER (ST_PLAYBACK_MAX_PERIOD_SIZE * PLAYBACK_MAX_NUM_PERIODS)
+#define ST_MIN_BUFFER ST_MAX_BUFFER
 #define CHIP_STONEY 14
 #define CHIP_CARRIZO 13
 
@@ -75,6 +79,44 @@ static const struct snd_pcm_hardware acp_pcm_hardware_capture = {
 	.periods_max = CAPTURE_MAX_NUM_PERIODS,
 };
 
+static const struct snd_pcm_hardware acp_st_pcm_hardware_playback = {
+	.info = SNDRV_PCM_INFO_INTERLEAVED |
+	SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
+		SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BATCH |
+		SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME,
+	.formats = SNDRV_PCM_FMTBIT_S16_LE |
+		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
+	.channels_min = 1,
+	.channels_max = 8,
+	.rates = SNDRV_PCM_RATE_8000_96000,
+	.rate_min = 8000,
+	.rate_max = 96000,
+	.buffer_bytes_max = ST_MAX_BUFFER,
+	.period_bytes_min = PLAYBACK_MIN_PERIOD_SIZE,
+	.period_bytes_max = ST_PLAYBACK_MAX_PERIOD_SIZE,
+	.periods_min = PLAYBACK_MIN_NUM_PERIODS,
+	.periods_max = PLAYBACK_MAX_NUM_PERIODS,
+};
+
+static const struct snd_pcm_hardware acp_st_pcm_hardware_capture = {
+	.info = SNDRV_PCM_INFO_INTERLEAVED |
+		SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP |
+		SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BATCH |
+		SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME,
+		.formats = SNDRV_PCM_FMTBIT_S16_LE |
+		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE,
+	.channels_min = 1,
+	.channels_max = 2,
+	.rates = SNDRV_PCM_RATE_8000_48000,
+	.rate_min = 8000,
+	.rate_max = 48000,
+	.buffer_bytes_max = ST_MAX_BUFFER,
+	.period_bytes_min = CAPTURE_MIN_PERIOD_SIZE,
+	.period_bytes_max = ST_CAPTURE_MAX_PERIOD_SIZE,
+	.periods_min = CAPTURE_MIN_NUM_PERIODS,
+	.periods_max = CAPTURE_MAX_NUM_PERIODS,
+};
+
 static u32 acp_reg_read(void __iomem *acp_mmio, u32 reg)
 {
 	return readl(acp_mmio + (reg * 4));
@@ -657,10 +699,17 @@ static int acp_dma_open(struct snd_pcm_substream *substream)
 	if (adata == NULL)
 		return -ENOMEM;
 
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		runtime->hw = acp_pcm_hardware_playback;
-	else
-		runtime->hw = acp_pcm_hardware_capture;
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		if (intr_data->asic_type == CHIP_STONEY)
+			runtime->hw = acp_st_pcm_hardware_playback;
+		else
+			runtime->hw = acp_pcm_hardware_playback;
+	} else {
+		if (intr_data->asic_type == CHIP_STONEY)
+			runtime->hw = acp_st_pcm_hardware_capture;
+		else
+			runtime->hw = acp_pcm_hardware_capture;
+	}
 
 	ret = snd_pcm_hw_constraint_integer(runtime,
 					    SNDRV_PCM_HW_PARAM_PERIODS);
@@ -894,10 +943,19 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd)
 
 static int acp_dma_new(struct snd_soc_pcm_runtime *rtd)
 {
-	return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
+	struct audio_drv_data *adata = dev_get_drvdata(rtd->platform->dev);
+
+	if (adata->asic_type == CHIP_STONEY) {
+		return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
+							SNDRV_DMA_TYPE_DEV,
+							NULL, MIN_BUFFER,
+							ST_MAX_BUFFER);
+	} else {
+		return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm,
 							SNDRV_DMA_TYPE_DEV,
 							NULL, MIN_BUFFER,
 							MAX_BUFFER);
+	}
 }
 
 static int acp_dma_close(struct snd_pcm_substream *substream)
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#15 lore raw

PATCH 7/8 drm/amd/amdgpu: Disable ACP Power Gating for Stoney platform

In reply to a message not in the archive

From: Vijendar Mukunda <[email protected]>

Power Gating is disabled in Stoney platform.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +18 -15
index 86b68f7..0e512fa 100644
@@ -287,19 +287,20 @@ static int acp_hw_init(void *handle)
 		return 0;
 	else if (r)
 		return r;
+	if (asic_type != CHIP_STONEY) {
+		adev->acp.acp_genpd = kzalloc(sizeof(struct acp_pm_domain), GFP_KERNEL);
+		if (adev->acp.acp_genpd == NULL)
+			return -ENOMEM;
 
-	adev->acp.acp_genpd = kzalloc(sizeof(struct acp_pm_domain), GFP_KERNEL);
-	if (adev->acp.acp_genpd == NULL)
-		return -ENOMEM;
-
-	adev->acp.acp_genpd->gpd.name = "ACP_AUDIO";
-	adev->acp.acp_genpd->gpd.power_off = acp_poweroff;
-	adev->acp.acp_genpd->gpd.power_on = acp_poweron;
+		adev->acp.acp_genpd->gpd.name = "ACP_AUDIO";
+		adev->acp.acp_genpd->gpd.power_off = acp_poweroff;
+		adev->acp.acp_genpd->gpd.power_on = acp_poweron;
 
 
-	adev->acp.acp_genpd->cgs_dev = adev->acp.cgs_device;
+		adev->acp.acp_genpd->cgs_dev = adev->acp.cgs_device;
 
-	pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
+		pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
+	}
 
 	adev->acp.acp_cell = kzalloc(sizeof(struct mfd_cell) * ACP_DEVS,
 							GFP_KERNEL);
@@ -388,12 +389,14 @@ static int acp_hw_init(void *handle)
 	if (r)
 		return r;
 
-	for (i = 0; i < ACP_DEVS ; i++) {
-		dev = get_mfd_cell_dev(adev->acp.acp_cell[i].name, i);
-		r = pm_genpd_add_device(&adev->acp.acp_genpd->gpd, dev);
-		if (r) {
-			dev_err(dev, "Failed to add dev to genpd\n");
-			return r;
+	if (asic_type != CHIP_STONEY) {
+		for (i = 0; i < ACP_DEVS ; i++) {
+			dev = get_mfd_cell_dev(adev->acp.acp_cell[i].name, i);
+			r = pm_genpd_add_device(&adev->acp.acp_genpd->gpd, dev);
+			if (r) {
+				dev_err(dev, "Failed to add dev to genpd\n");
+				return r;
+			}
 		}
 	}
 
Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#16 lore raw

PATCH 8/8 ASoC: AMD: Add machine driver for cz rt5650

In reply to a message not in the archive

From: Akshu Agrawal <[email protected]>

The driver is used for AMD board using rt5650 codec.

---
 sound/soc/amd/Kconfig      |   7 ++
 sound/soc/amd/Makefile     |   2 +
 sound/soc/amd/acp-rt5645.c | 210 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 219 insertions(+)
 create mode 100644 sound/soc/amd/acp-rt5645.c
sound/soc/amd/Kconfig +7 -0
index 78187eb..eb0ae60 100644
@@ -2,3 +2,10 @@ config SND_SOC_AMD_ACP
 	tristate "AMD Audio Coprocessor support"
 	help
 	 This option enables ACP DMA support on AMD platform.
+config SND_SOC_AMD_CZ_RT5645_MACH
+	tristate "AMD CZ support for RT5645"
+	select SND_SOC_RT5645
+	select SND_SOC_AMD_ACP
+	depends on I2C_DESIGNWARE_PLATFORM
+	help
+	 This option enables machine driver for rt5645.
sound/soc/amd/Makefile +2 -0
index 1a66ec0..eed64ff 100644
@@ -1,3 +1,5 @@
 snd-soc-acp-pcm-objs	:= acp-pcm-dma.o
+snd-soc-acp-rt5645-mach-objs := acp-rt5645.o
 
 obj-$(CONFIG_SND_SOC_AMD_ACP) += snd-soc-acp-pcm.o
+obj-$(CONFIG_SND_SOC_AMD_CZ_RT5645_MACH) += snd-soc-acp-rt5645-mach.o
sound/soc/amd/acp-rt5645.c new file +210 -0

210 lines not on this page · raw message

Signature · 6 lines
2.5.5

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#17 lore raw

Re: [PATCH 8/8] ASoC: AMD: Add machine driver for cz rt5650

sound/soc/amd/acp-rt5645.c line 192

Quoted 3 lines
sound/soc/amd/acp-rt5645.c new file +2 -0
+static const struct acpi_device_id cz_audio_acpi_match[] = {
+	{ "I2SC1002", 0 },

This one goes on my list of _HID that don't follow ACPI/PCI vendorID/PartID conventions.
AMD shoud use the "AMDI" ACPI ID or the 0x1002 PCI ID for the 4 first characters, if everyone does what they feel like one day we'll have a conflict between devices and probe the wrong driver...

Quoted 18 lines
sound/soc/amd/acp-rt5645.c new file +18 -0
+	{},
+};
+
+static struct platform_driver cz_pcm_driver = {
+	.driver = {
+		.name = "cz-rt5645",
+		.acpi_match_table = ACPI_PTR(cz_audio_acpi_match),
+		.pm = &snd_soc_pm_ops,
+	},
+	.probe = cz_probe,
+	.remove = cz_remove,
+};
+
+module_platform_driver(cz_pcm_driver);
+
+MODULE_AUTHOR("[email protected]");
+MODULE_DESCRIPTION("cz-rt5645 audio support");
+MODULE_LICENSE("GPL v2");
#18 lore raw

PATCH 3/8 drm/amd/amdgpu: Added a dwc quirk for Stoney platform

In reply to Alex Deucher

From: Vijendar Mukunda <[email protected]>

Added DW_I2S_QUIRK_16BIT_IDX_OVERRIDE quirk for Stoney.

Supported format and bus width for I2S controller read from I2S Component Parameter registers.
These are ready only registers.

For Stoney, I2S Component Parameter registers are programmed to support 32 bit format and 4 bytes bus width only.

By setting this quirk, it will override 32 bit format with 16 bit format and 2 bytes as bus width for Stoney.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +14 -3
index 7a2a765..86b68f7 100644
@@ -321,14 +321,25 @@ static int acp_hw_init(void *handle)
 		return -ENOMEM;
 	}
 
-	i2s_pdata[0].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET;
+	if (adev->asic_type == CHIP_STONEY) {
+		i2s_pdata[0].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
+			DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
+	} else {
+		i2s_pdata[0].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET;
+	}
 	i2s_pdata[0].cap = DWC_I2S_PLAY;
 	i2s_pdata[0].snd_rates = SNDRV_PCM_RATE_8000_96000;
 	i2s_pdata[0].i2s_reg_comp1 = ACP_I2S_COMP1_PLAY_REG_OFFSET;
 	i2s_pdata[0].i2s_reg_comp2 = ACP_I2S_COMP2_PLAY_REG_OFFSET;
+	if (adev->asic_type == CHIP_STONEY) {
+		i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
+			DW_I2S_QUIRK_COMP_PARAM1 |
+			DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
+	} else {
+		i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
+			DW_I2S_QUIRK_COMP_PARAM1;
+	}
 
-	i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
-				DW_I2S_QUIRK_COMP_PARAM1;
 	i2s_pdata[1].cap = DWC_I2S_RECORD;
 	i2s_pdata[1].snd_rates = SNDRV_PCM_RATE_8000_96000;
 	i2s_pdata[1].i2s_reg_comp1 = ACP_I2S_COMP1_CAP_REG_OFFSET;
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer
#19 lore raw

Re: [PATCH 3/8] drm/amd/amdgpu: Added a dwc quirk for Stoney platform

drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c static int acp_hw_init(void *handle) · line 341

Quoted 8 lines · Alex Deucher
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +8 -0
+	if (adev->asic_type == CHIP_STONEY) {
+		i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
+			DW_I2S_QUIRK_COMP_PARAM1 |
+			DW_I2S_QUIRK_16BIT_IDX_OVERRIDE;
+	} else {
+		i2s_pdata[1].quirks = DW_I2S_QUIRK_COMP_REG_OFFSET |
+			DW_I2S_QUIRK_COMP_PARAM1;
+	}

Quirks like this are better written as switch statements since that makes it easier to handle further variants in future.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

PATCH 5/8 ASoC: AMD: DMA driver changes for Stoney Platform

In reply to Alex Deucher

From: Vijendar Mukunda <[email protected]>

Added DMA driver changes for Stoney platform.
Below are the key differences between Stoney and CZ:
- Memory Gating is disabled
- SRAM Banks won't be turned off
- No Of SRAM Banks reduced to 6
- DAGB Garlic Interface used
- 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.

---
 sound/soc/amd/acp-pcm-dma.c | 81 +++++++++++++++++++++++++++++++++------------
 sound/soc/amd/acp.h         |  2 ++
 2 files changed, 61 insertions(+), 22 deletions(-)
sound/soc/amd/acp-pcm-dma.c +59 -22
index e48ae5d..5b5e95d 100644
@@ -139,8 +139,8 @@ static void config_dma_descriptor_in_sram(void __iomem *acp_mmio,
  * system memory <-> ACP SRAM
  */
 static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
-					   u32 size, int direction,
-					   u32 pte_offset)
+					u32 size, int direction,
+					u32 pte_offset, u32 asic_type)
 {
 	u16 i;
 	u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12;
@@ -154,20 +154,38 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
 					(size / 2) - (i * (size/2));
 			dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS
 				+ (pte_offset * SZ_4K) + (i * (size/2));
-			dmadscr[i].xfer_val |=
-			(ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM << 16) |
-			(size / 2);
+			if (asic_type == CHIP_STONEY) {
+				dmadscr[i].xfer_val |=
+				(ACP_DMA_ATTRIBUTES_DAGB_GARLIC_TO_SHAREDMEM  << 16) |
+				(size / 2);
+			} else {
+				dmadscr[i].xfer_val |=
+				(ACP_DMA_ATTRIBUTES_DAGB_ONION_TO_SHAREDMEM  << 16) |
+				(size / 2);
+			}
 		} else {
 			dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14 + i;
-			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);
+			if (asic_type == CHIP_STONEY) {
+				dmadscr[i].src = ACP_SHARED_RAM_BANK_3_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_SHARED_MEM_TO_DAGB_GARLIC << 16) |
+				(size / 2);
+			} else {
+				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,
 						&dmadscr[i]);
@@ -188,7 +206,8 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio,
  * ACP SRAM <-> I2S
  */
 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;
@@ -209,8 +228,15 @@ static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio,
 			dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15 + i;
 			/* dmadscr[i].src is unused by hardware. */
 			dmadscr[i].src = 0;
-			dmadscr[i].dest = ACP_SHARED_RAM_BANK_5_ADDRESS +
+			if (asic_type == CHIP_STONEY) {
+				dmadscr[i].dest =
+					 ACP_SHARED_RAM_BANK_3_ADDRESS +
 					(i * (size / 2));
+			} else {
+				dmadscr[i].dest =
+					 ACP_SHARED_RAM_BANK_5_ADDRESS +
+					(i * (size / 2));
+			}
 			dmadscr[i].xfer_val |= BIT(22) |
 					(FROM_ACP_I2S_1 << 16) | (size / 2);
 		}
@@ -266,7 +292,8 @@ static void acp_pte_config(void __iomem *acp_mmio, struct page *pg,
 }
 
 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;
 
@@ -280,11 +307,12 @@ static void config_acp_dma(void __iomem *acp_mmio,
 
 	/* Configure System memory <-> ACP SRAM DMA descriptors */
 	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 */
 	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 */
@@ -500,6 +528,11 @@ static int acp_init(void __iomem *acp_mmio, u32 asic_type)
 		for (bank = 1; bank < 48; bank++)
 			acp_set_sram_bank_state(acp_mmio, bank, false);
 	}
+	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;
 }
@@ -675,6 +708,8 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
 	struct page *pg;
 	struct snd_pcm_runtime *runtime;
 	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;
 	rtd = runtime->private_data;
@@ -702,7 +737,7 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream,
 		rtd->num_of_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
 		rtd->direction = substream->stream;
 
-		config_acp_dma(rtd->acp_mmio, rtd);
+		config_acp_dma(rtd->acp_mmio, rtd, adata->asic_type);
 		status = 0;
 	} else {
 		status = -ENOMEM;
@@ -997,7 +1032,8 @@ static int acp_pcm_resume(struct device *dev)
 						true);
 		}
 		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->asic_type == CHIP_CARRIZO) {
@@ -1006,7 +1042,8 @@ static int acp_pcm_resume(struct device *dev)
 						true);
 		}
 		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);
 	return 0;
sound/soc/amd/acp.h +2 -0
index 28cf914..a330a99 100644
@@ -19,6 +19,7 @@
 
 /* Capture SRAM address (as a source in dma descriptor) */
 #define ACP_SHARED_RAM_BANK_5_ADDRESS		0x400A000
+#define ACP_SHARED_RAM_BANK_3_ADDRESS		0x4006000
 
 #define ACP_DMA_RESET_TIME			10000
 #define ACP_CLOCK_EN_TIME_OUT_VALUE		0x000000FF
@@ -67,6 +68,7 @@
 #define CAPTURE_START_DMA_DESCR_CH15 6
 #define CAPTURE_END_DMA_DESCR_CH15 7
 
+#define mmACP_I2S_16BIT_RESOLUTION_EN       0x5209
 enum acp_dma_priority_level {
 	/* 0x0 Specifies the DMA channel is given normal priority */
 	ACP_DMA_PRIORITY_LEVEL_NORMAL = 0x0,
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel