Add ASoC support for AMD APUs [v4]
Subsystems (6)
cover Add ASoC support for AMD APUs [v4]
This patch set implements support for i2s audio and new AMD GPUs. The i2s codec is fed by a DMA engine on the GPU. To handle this we create mfd cells which we hang the i2s codec and DMA engine on. Because of this, this patch set covers two subsystems: drm and alsa. The drm patches add support for the ACP hw block which provides the DMA engine for the i2s codec. The alsa patches add the ASoC driver for the i2s codec. Since the alsa changes depend on the drm changes in this patch set as well as some other drm changes queued for 4.3, I'd like to take the alsa patches in via the drm tree.
V2 changes:
- Use the MFD subsystem rather than adding our own bus
- Squash all sub-feature patches together
- fix comments mentioned in previous review
V3 changes:
- Update the designware driver to handle slave mode, amd specific features
- Use the designware driver directly for i2s
- Move the DMA handling from the GPU driver into the AMD ASoC driver
- Change the license on the ASoC driver to GPL
V4 changes:
- get the master vs slave mode for the designware codec from registers
- copy designware quirks from platform data in local struct
Patch 4 adds the register headers for the ACP block which is a pretty big patch so I've excluded it from email. The entire patch set can be viewed here:
http://cgit.freedesktop.org/~agd5f/linux/log/?h=acp-upstream4
Thanks,
Alex
Maruthi Bayyavarapu (1):
drm/amd: add ACP driver support
Maruthi Srinivas Bayyavarapu (4):
ASoC : dwc : support dw i2s in slave mode
ASoC : dwc : support dw i2s in AMD platform
ASoC : AMD : add ACP 2.2 register headers
ASoC: AMD: add AMD ASoC ACP-I2S driver
drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/amd/acp/Kconfig | 10 + drivers/gpu/drm/amd/acp/Makefile | 9 + drivers/gpu/drm/amd/acp/acp_hw.c | 127 ++ drivers/gpu/drm/amd/acp/include/acp_gfx_if.h | 49 + drivers/gpu/drm/amd/amdgpu/Makefile | 13 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 12 + drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 269 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h | 41 + drivers/gpu/drm/amd/amdgpu/vi.c | 12 + drivers/gpu/drm/amd/include/amd_shared.h | 1 + include/linux/mfd/amd_acp.h | 43 + include/sound/designware_i2s.h | 5 + sound/soc/Kconfig | 1 + sound/soc/Makefile | 1 + sound/soc/amd/Kconfig | 4 + sound/soc/amd/Makefile | 3 + sound/soc/amd/acp-pcm-dma.c | 518 ++++++ sound/soc/amd/acp.c | 736 +++++++++ sound/soc/amd/acp.h | 147 ++ sound/soc/amd/include/acp_2_2_d.h | 609 +++++++ sound/soc/amd/include/acp_2_2_enum.h | 1068 ++++++++++++ sound/soc/amd/include/acp_2_2_sh_mask.h | 2292 ++++++++++++++++++++++++++ sound/soc/dwc/designware_i2s.c | 276 ++-- 24 files changed, 6146 insertions(+), 102 deletions(-) create mode 100644 drivers/gpu/drm/amd/acp/Kconfig create mode 100644 drivers/gpu/drm/amd/acp/Makefile create mode 100644 drivers/gpu/drm/amd/acp/acp_hw.c create mode 100644 drivers/gpu/drm/amd/acp/include/acp_gfx_if.h create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h create mode 100644 include/linux/mfd/amd_acp.h create mode 100644 sound/soc/amd/Kconfig create mode 100644 sound/soc/amd/Makefile create mode 100644 sound/soc/amd/acp-pcm-dma.c create mode 100644 sound/soc/amd/acp.c create mode 100644 sound/soc/amd/acp.h create mode 100644 sound/soc/amd/include/acp_2_2_d.h create mode 100644 sound/soc/amd/include/acp_2_2_enum.h create mode 100644 sound/soc/amd/include/acp_2_2_sh_mask.h
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/5 ASoC : dwc : support dw i2s in slave mode
From: Maruthi Srinivas Bayyavarapu <[email protected]>
dw i2s controller can work in slave mode, codec being master. dw i2s is made to support master/slave operation, by reading dwc register.
---
v2: check register to determine master/slave mode
include/sound/designware_i2s.h | 2 + sound/soc/dwc/designware_i2s.c | 92 +++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 37 deletions(-)
include/sound/designware_i2s.h +2 -0
@@ -38,6 +38,8 @@ struct i2s_clk_config_data {struct i2s_platform_data {#define DWC_I2S_PLAY (1 << 0)#define DWC_I2S_RECORD (1 << 1) +#define DW_I2S_SLAVE (1 << 2) +#define DW_I2S_MASTER (1 << 3)unsigned int cap;int channel;u32 snd_fmts;
sound/soc/dwc/designware_i2s.c +55 -37
150 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerRe: [PATCH 1/5] ASoC : dwc : support dw i2s in slave mode
Quoted 5 lines · Alex Deucher
From: Maruthi Srinivas Bayyavarapu <[email protected]>
dw i2s controller can work in slave mode, codec being master. dw i2s is made to support master/slave operation, by reading dwc register.
I'll apply this but can you please send a followup implementing a _dai_fmt() operation that checks to make sure that the mode we're setting corresponds to what we read back from the hardware.
Re: [alsa-devel] [PATCH 1/5] ASoC : dwc : support dw i2s in slave mode
Quoted 10 lines · Mark Brown
Quoted 5 lines · Alex Deucher
From: Maruthi Srinivas Bayyavarapu <[email protected]>
dw i2s controller can work in slave mode, codec being master. dw i2s is made to support master/slave operation, by reading dwc register.
I'll apply this but can you please send a followup implementing a
_dai_fmt()operation that checks to make sure that the mode we're setting corresponds to what we read back from the hardware.
Ok, I will send.
Quoted 6 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerApplied "ASoC: dwc: support dw i2s in slave mode" to the asoc tree
In reply to Alex DeucherThe patch
ASoC: dwc: support dw i2s in slave mode
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
Quoted 1 line
From
1d957d862ac782eaf5803d4d4cf167708e4dc147Mon Sep 17 00:00:00 2001
From: Maruthi Srinivas Bayyavarapu <[email protected]>
Date: Fri, 25 Sep 2015 17:48:22 -0400
Subject: [PATCH] ASoC: dwc: support dw i2s in slave mode
dw i2s controller can work in slave mode, codec being master. dw i2s is made to support master/slave operation, by reading dwc register.
--- include/sound/designware_i2s.h | 2 + sound/soc/dwc/designware_i2s.c | 92 +++++++++++++++++++++++++----------------- 2 files changed, 57 insertions(+), 37 deletions(-)
include/sound/designware_i2s.h +2 -0
@@ -38,6 +38,8 @@ struct i2s_clk_config_data {struct i2s_platform_data {#define DWC_I2S_PLAY (1 << 0)#define DWC_I2S_RECORD (1 << 1) +#define DW_I2S_SLAVE (1 << 2) +#define DW_I2S_MASTER (1 << 3)unsigned int cap;int channel;u32 snd_fmts;
sound/soc/dwc/designware_i2s.c +55 -37
150 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 2/5 ASoC : dwc : support dw i2s in AMD platform
In reply to Alex DeucherFrom: Maruthi Srinivas Bayyavarapu <[email protected]>
Vendor specific quirk was added to:
1. Support AMD platform which has two dwc controllers with different base address for playback and capture. Also, I2S_COMP_PARAM_* registers offsets differed.
2. Resume audio which was active before system suspend. After 'resume', dwc need to be reconfigured with params configured during 'hw_params' callback. With this, audio usecase continues from where it got stopped because of 'suspend'.
---
v2: Copy quirks from platform data to local struct since platform data may not be available in some use cases.
include/sound/designware_i2s.h | 3 + sound/soc/dwc/designware_i2s.c | 190 ++++++++++++++++++++++++++--------------- 2 files changed, 126 insertions(+), 67 deletions(-)
include/sound/designware_i2s.h +3 -0
@@ -44,6 +44,9 @@ struct i2s_platform_data {int channel;u32 snd_fmts;u32 snd_rates; +#define DW_I2S_VENDOR_AMD (1 << 0) +unsigned int quirks; +void *play_dma_data;void *capture_dma_data;
sound/soc/dwc/designware_i2s.c +123 -67
343 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Mark Brown
maintainerRe: [PATCH 2/5] ASoC : dwc : support dw i2s in AMD platform
Quoted 11 lines · Alex Deucher
From: Maruthi Srinivas Bayyavarapu <[email protected]>
Vendor specific quirk was added to:
1. Support AMD platform which has two dwc controllers with different base address for playback and capture. Also, I2S_COMP_PARAM_* registers offsets differed.2. Resume audio which was active before system suspend. After 'resume', dwc need to be reconfigured with params configured during '
hw_params' callback. With this, audio usecase continues from where it got stopped because of 'suspend'.
This is hard to review since there are several different changes in here, one change per commit is muuch more helpful. As is I'm not 100% sure exactly what each bit of the change is intended to do. One example here is that a separate patch splitting pbase and cbase would be really helpful.
include/sound/designware_i2s.h struct i2s_platform_data { · line 48
Quoted 8 lines
include/sound/designware_i2s.h +2
-0@@ -44,6 +44,9 @@ struct i2s_platform_data {int channel;u32 snd_fmts;u32 snd_rates; +#define DW_I2S_VENDOR_AMD (1 << 0) +unsigned int quirks;
I would expect to see a set of quirks with the AMD devices selecting those that apply to them rather than just a per vendor define - this is more generic and more maintainable long term. AMD may require different sets of quirks with some future device and systems from other vendors may require some but not all of the quirks that AMD requires.
include/sound/designware_i2s.h struct i2s_platform_data { · line 51
Quoted 3 lines
include/sound/designware_i2s.h +3
-0+if (dev->quirks &DW_I2S_VENDOR_AMD ) { + comp1 =i2s_read_reg (dev->i2s_pbase,0x124 ); + comp2 =i2s_read_reg (dev->i2s_pbase,0x120 );
Please add defines for these registers. Rather than having the quirk code throughout the driver it might be clearer to have the comp1 and comp2 register offsets stored in the driver data so you can just do the actual quirk once at probe time.
Re: [alsa-devel] [PATCH 2/5] ASoC : dwc : support dw i2s in AMD platform
Quoted 13 lines · Mark Brown
Quoted 11 lines · Alex Deucher
From: Maruthi Srinivas Bayyavarapu <[email protected]>
Vendor specific quirk was added to:
1. Support AMD platform which has two dwc controllers with different base address for playback and capture. Also, I2S_COMP_PARAM_* registers offsets differed.2. Resume audio which was active before system suspend. After 'resume', dwc need to be reconfigured with params configured during '
hw_params' callback. With this, audio usecase continues from where it got stopped because of 'suspend'.
Quoted 5 lines
This is hard to review since there are several different changes in here, one change per commit is muuch more helpful. As is I'm not 100% sure exactly what each bit of the change is intended to do. One example here is that a separate patch splitting pbase and cbase would be really helpful.
Ok, I will split into multiple patches and send again.
Quoted 15 lines
include/sound/designware_i2s.h struct i2s_platform_data { · line 48
Quoted 9 lines
include/sound/designware_i2s.h +2
-0@@ -44,6 +44,9 @@ struct i2s_platform_data {int channel;u32 snd_fmts;u32 snd_rates; +#define DW_I2S_VENDOR_AMD (1 << 0) +unsigned int quirks;I would expect to see a set of quirks with the AMD devices selecting those that apply to them rather than just a per vendor define - this is more generic and more maintainable long term. AMD may require different sets of quirks with some future device and systems from other vendors may require some but not all of the quirks that AMD requires.
Agreed. I will send a revised patch.
Quoted 9 lines
include/sound/designware_i2s.h struct i2s_platform_data { · line 51
Quoted 4 lines
include/sound/designware_i2s.h +3
-0+if (dev->quirks &DW_I2S_VENDOR_AMD ) { + comp1 =i2s_read_reg (dev->i2s_pbase,0x124 ); + comp2 =i2s_read_reg (dev->i2s_pbase,0x120 );Please add defines for these registers. Rather than having the quirk code throughout the driver it might be clearer to have the comp1 and comp2 register offsets stored in the driver data so you can just do the actual quirk once at probe time.
Agreed. I will send a revised patch.
Quoted 6 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/5 drm/amd: add ACP driver support
In reply to Alex DeucherFrom: Maruthi Bayyavarapu <[email protected]>
This adds the ACP (Audio CoProcessor) IP driver and wires it up to the amdgpu driver. The ACP block provides the DMA engine for i2s based ALSA driver. This is required for audio on APUs that utilize an i2s codec.
---
v2: integrate i2s/az check patch
v3: s/amd_acp/amdgpu_acp/
v4: update copyright notice
v5: squash multiple patches, convert to mfd
v6: major changes as below :
1. Pass ACP register base to DMA and dw i2s drivers as IORESOURCE_MEM resources.
2. add dw i2s as a new mfd cell.
v7: remove dw i2s slave setting from platform data. this
is determined in the dw driver directly now.
drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/amd/acp/Kconfig | 10 + drivers/gpu/drm/amd/acp/Makefile | 9 + drivers/gpu/drm/amd/acp/acp_hw.c | 127 +++++++++++++ drivers/gpu/drm/amd/acp/include/acp_gfx_if.h | 49 +++++ drivers/gpu/drm/amd/amdgpu/Makefile | 13 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 12 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 269 +++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h | 41 ++++ drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++ drivers/gpu/drm/amd/include/amd_shared.h | 1 + include/linux/mfd/amd_acp.h | 43 +++++ 12 files changed, 587 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/acp/Kconfig create mode 100644 drivers/gpu/drm/amd/acp/Makefile create mode 100644 drivers/gpu/drm/amd/acp/acp_hw.c create mode 100644 drivers/gpu/drm/amd/acp/include/acp_gfx_if.h create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h create mode 100644 include/linux/mfd/amd_acp.h
drivers/gpu/drm/Kconfig +2 -0
@@ -161,6 +161,8 @@ config DRM_AMDGPU source "drivers/gpu/drm/amd/amdgpu/Kconfig" +source "drivers/gpu/drm/amd/acp/Kconfig" + source "drivers/gpu/drm/nouveau/Kconfig" config DRM_I810
drivers/gpu/drm/amd/acp/Kconfig new file +10 -0
@@ -0,0 +1,10 @@ +menu "ACP Configuration" + +config DRM_AMD_ACP + bool "Enable ACP IP support" + default y + depends on MFD_CORE + help + Choose this option to enable ACP IP support for AMD SOCs. + +endmenu
drivers/gpu/drm/amd/acp/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# +# Makefile for the ACP, which is a sub-component +# of AMDSOC/AMDGPU drm driver. +# It provides the HW control for ACP related functionalities. + +ccflags-y += -Idrivers/gpu/drm/amd/include/asic_reg/acp +subdir-ccflags-y += -I$(AMDACPPATH)/ -I$(AMDACPPATH)/include + +AMD_ACP_FILES := $(AMDACPPATH)/acp_hw.o
drivers/gpu/drm/amd/acp/acp_hw.c new file +127 -0
127 lines not on this page · raw message
drivers/gpu/drm/amd/acp/include/acp_gfx_if.h new file +49 -0
49 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/Makefile +12 -1
@@ -5,7 +5,8 @@ ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/amd/include/asic_reg \ -Idrivers/gpu/drm/amd/include \ -Idrivers/gpu/drm/amd/amdgpu \ - -Idrivers/gpu/drm/amd/scheduler + -Idrivers/gpu/drm/amd/scheduler \ + -Idrivers/gpu/drm/amd/acp/include amdgpu-y := amdgpu_drv.o
@@ -89,6 +90,16 @@ amdgpu-y += \ ../scheduler/sched_fence.o \ amdgpu_sched.o +# ACP componet +ifneq ($(CONFIG_DRM_AMD_ACP),) +amdgpu-y += amdgpu_acp.o + +AMDACPPATH := ../acp +include drivers/gpu/drm/amd/acp/Makefile + +amdgpu-y += $(AMD_ACP_FILES) +endif + amdgpu-$(CONFIG_COMPAT) += amdgpu_ioc32.o amdgpu-$(CONFIG_VGA_SWITCHEROO) += amdgpu_atpx_handler.o amdgpu-$(CONFIG_ACPI) += amdgpu_acpi.o
drivers/gpu/drm/amd/amdgpu/amdgpu.h +12 -0
@@ -52,6 +52,7 @@#include "amdgpu_irq.h" #include "amdgpu_ucode.h" #include "amdgpu_gds.h" +#include "amdgpu_acp.h" #include "gpu_scheduler.h"
@@ -1930,6 +1931,13 @@ void amdgpu_cgs_destroy_device(void *cgs_device);/* +* CGS +*/ +void *amdgpu_cgs_create_device (struct amdgpu_device *adev); +void amdgpu_cgs_destroy_device (void *cgs_device); + + +/* * Core structure, functions and helpers. */ typedef uint32_t (*amdgpu_rreg_t )(struct amdgpu_device *,uint32_t );
@@ -1950,6 +1958,10 @@ struct amdgpu_device {struct pci_dev *pdev;struct rw_semaphore exclusive_lock; +#ifdef CONFIG_DRM_AMD_ACP +struct amdgpu_acp acp; +#endif +/* ASIC */ enum amd_asic_type asic_type;uint32_t family;
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c new file +269 -0
269 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.h new file +41 -0
41 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/vi.c +12 -0
@@ -71,6 +71,9 @@#include "uvd_v5_0.h" #include "uvd_v6_0.h" #include "vce_v3_0.h" +#if defined(CONFIG_DRM_AMD_ACP ) +#include "amdgpu_acp.h" +#endif /* * Indirect registers accessor
@@ -1298,6 +1301,15 @@ static const struct amdgpu_ip_block_version cz_ip_blocks[] = .rev = 0, .funcs = &vce_v3_0_ip_funcs, }, +#if defined(CONFIG_DRM_AMD_ACP ) + { + .type = AMD_IP_BLOCK_TYPE_ACP, + .major = 2, + .minor = 2, + .rev = 0, + .funcs = &acp_ip_funcs, + }, +#endif };int vi_set_ip_blocks (struct amdgpu_device *adev)
drivers/gpu/drm/amd/include/amd_shared.h +1 -0
@@ -72,6 +72,7 @@ enum amd_ip_block_type {AMD_IP_BLOCK_TYPE_SDMA ,AMD_IP_BLOCK_TYPE_UVD ,AMD_IP_BLOCK_TYPE_VCE , + AMD_IP_BLOCK_TYPE_ACP, }; enum amd_clockgating_state {
include/linux/mfd/amd_acp.h new file +43 -0
43 lines not on this page · raw message
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel