ASOC: amd: acp: Add generic PDM and PCI driver support for ACP
Subsystems (3)
PATCH 1/6 ASoC: amd: acp: Add generic support for PDM controller on ACP
In reply to Ajit Kumar PandeyAdd driver module for PDM controller on ACP IP block. Expose dai ops to configure ACP_WOV_PDM_BLOCK registers on ACP. Such dai ops will be used by platform specific driver module to register dmic related dai with ASoC.
--- sound/soc/amd/acp/Kconfig | 3 + sound/soc/amd/acp/Makefile | 2 + sound/soc/amd/acp/acp-pdm.c | 181 +++++++++++++++++++++++++++ sound/soc/amd/acp/amd.h | 9 +- sound/soc/amd/acp/chip_offset_byte.h | 20 +++ 5 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 sound/soc/amd/acp/acp-pdm.c
sound/soc/amd/acp/Kconfig +3 -0
@@ -15,6 +15,9 @@ config SND_SOC_AMD_ACP_COMMON if SND_SOC_AMD_ACP_COMMON +config SND_SOC_AMD_ACP_PDM + tristate + config SND_SOC_AMD_ACP_I2S tristate
sound/soc/amd/acp/Makefile +2 -0
@@ -7,6 +7,7 @@ #common acp driver snd-acp-pcm-objs := acp-platform.o snd-acp-i2s-objs := acp-i2s.o +snd-acp-pdm-objs := acp-pdm.o #platform specific driver snd-acp-renoir-objs := acp-renoir.o
@@ -18,6 +19,7 @@ snd-acp-sof-mach-objs := acp-sof-mach.o obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o +obj-$(CONFIG_SND_SOC_AMD_ACP_PDM) += snd-acp-pdm.o obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o
sound/soc/amd/acp/acp-pdm.c new file +181 -0
181 lines not on this page · raw message
sound/soc/amd/acp/amd.h +8 -1
@@ -17,8 +17,9 @@#define I2S_SP_INSTANCE 0x00#define I2S_BT_INSTANCE 0x01 +#define DMIC_INSTANCE 0x02 -#define MEM_WINDOW_START 0x4000000 +#define MEM_WINDOW_START 0x4080000#define ACP_I2S_REG_START 0x1242400#define ACP_I2S_REG_END 0x1242810
@@ -38,6 +39,7 @@#define ACP_SRAM_SP_CP_PTE_OFFSET 0x100#define ACP_SRAM_BT_PB_PTE_OFFSET 0x200#define ACP_SRAM_BT_CP_PTE_OFFSET 0x300 +#define ACP_SRAM_PDM_PTE_OFFSET 0x400#define PAGE_SIZE_4K_ENABLE 0x2#define I2S_SP_TX_MEM_WINDOW_START 0x4000000
@@ -96,6 +98,7 @@ struct acp_dev_data { };extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops; +extern const struct snd_soc_dai_ops acp_dmic_dai_ops;int asoc_acp_i2s_probe (struct snd_soc_dai *dai);int acp_platform_register (struct device *dev);
@@ -131,6 +134,10 @@ static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int high =readl (adata->acp_base +ACP_I2S_RX_LINEARPOSITIONCNTR_HIGH ); low =readl (adata->acp_base +ACP_I2S_RX_LINEARPOSITIONCNTR_LOW );break ; +case DMIC_INSTANCE : + high =readl (adata->acp_base +ACP_WOV_RX_LINEARPOSITIONCNTR_HIGH ); + low =readl (adata->acp_base +ACP_WOV_RX_LINEARPOSITIONCNTR_LOW ); +break ;default :dev_err (adata->dev,"Invalid dai id %x\n" , dai_id);return -EINVAL ;
sound/soc/amd/acp/chip_offset_byte.h +20 -0
@@ -73,4 +73,24 @@#define ACP_BTTDM_ITER 0x280C#define ACP_BTTDM_TXFRMT 0x2810 +/* Registers from ACP_WOV_PDM block */ + +#define ACP_WOV_PDM_ENABLE 0x2C04 +#define ACP_WOV_PDM_DMA_ENABLE 0x2C08 +#define ACP_WOV_RX_RINGBUFADDR 0x2C0C +#define ACP_WOV_RX_RINGBUFSIZE 0x2C10 +#define ACP_WOV_RX_LINKPOSITIONCNTR 0x2C14 +#define ACP_WOV_RX_LINEARPOSITIONCNTR_HIGH 0x2C18 +#define ACP_WOV_RX_LINEARPOSITIONCNTR_LOW 0x2C1C +#define ACP_WOV_RX_INTR_WATERMARK_SIZE 0x2C20 +#define ACP_WOV_PDM_FIFO_FLUSH 0x2C24 +#define ACP_WOV_PDM_NO_OF_CHANNELS 0x2C28 +#define ACP_WOV_PDM_DECIMATION_FACTOR 0x2C2C +#define ACP_WOV_PDM_VAD_CTRL 0x2C30 +#define ACP_WOV_BUFFER_STATUS 0x2C58 +#define ACP_WOV_MISC_CTRL 0x2C5C +#define ACP_WOV_CLK_CTRL 0x2C60 +#define ACP_PDM_VAD_DYNAMIC_CLK_GATING_EN 0x2C64 +#define ACP_WOV_ERROR_STATUS_REGISTER 0x2C68 +#endif
Signature · 1 line
2.25.1
PATCH 2/6 ASoC: amd: acp: Add PDM controller based dmic dai for Renoir
In reply to Ajit Kumar PandeyRenoir ACP IP has a PDM controller block. Add DMIC dai instance in dai_driver struct to enable dmic capture support on Renoir platform.
--- sound/soc/amd/acp/Kconfig | 1 + sound/soc/amd/acp/acp-renoir.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)
sound/soc/amd/acp/Kconfig +1 -0
@@ -29,6 +29,7 @@ config SND_AMD_ASOC_RENOIR tristate "AMD ACP ASOC Renoir Support" select SND_SOC_AMD_ACP_PCM select SND_SOC_AMD_ACP_I2S + select SND_SOC_AMD_ACP_PDM depends on X86 && PCI help This option enables Renoir I2S support on AMD platform.
sound/soc/amd/acp/acp-renoir.c +13 -0
@@ -97,6 +97,19 @@ static struct snd_soc_dai_driver acp_renoir_dai[] = { .ops = &asoc_acp_cpu_dai_ops, .probe = &asoc_acp_i2s_probe, }, +{ + .name = "acp-pdm-dmic", + .id = DMIC_INSTANCE, + .capture = { + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .channels_min = 2, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &acp_dmic_dai_ops, +}, };static int renoir_audio_probe (struct platform_device *pdev)
Signature · 1 line
2.25.1
cover ASOC: amd: acp: Add generic PDM and PCI driver support for ACP
This patch series add a generic PDM controller driver module and PCI driver module for non dsp based audio support on ACP devices. Initial support is added for acp3x devices or Renoir platform but we will use such driver module to support upcoming platform and other acp architectures in near future.
Ajit Kumar Pandey (6):
ASoC: amd: acp: Add generic support for PDM controller on ACP
ASoC: amd: acp: Add PDM controller based dmic dai for Renoir
ASoC: amd: acp: Add generic PCI driver module for ACP device
ASoC: amd: acp: Add ACP init()/deinit() callback for Renoir.
ASoC: amd: acp: acp-legacy: Add DMIC dai link support for Renoir
ASoC: amd: renoir: Add check for acp configuration flags.
sound/soc/amd/acp/Kconfig | 10 ++ sound/soc/amd/acp/Makefile | 4 + sound/soc/amd/acp/acp-legacy-mach.c | 4 +- sound/soc/amd/acp/acp-mach-common.c | 15 +++ sound/soc/amd/acp/acp-pci.c | 158 +++++++++++++++++++++++ sound/soc/amd/acp/acp-pdm.c | 181 ++++++++++++++++++++++++++ sound/soc/amd/acp/acp-renoir.c | 183 +++++++++++++++++++++++++++ sound/soc/amd/acp/amd.h | 23 +++- sound/soc/amd/acp/chip_offset_byte.h | 26 ++++ sound/soc/amd/mach-config.h | 1 + sound/soc/amd/renoir/rn-pci-acp3x.c | 7 +- sound/soc/amd/renoir/rn_acp3x.h | 3 + 12 files changed, 611 insertions(+), 4 deletions(-) create mode 100644 sound/soc/amd/acp/acp-pci.c create mode 100644 sound/soc/amd/acp/acp-pdm.c
Signature · 1 line
2.25.1
PATCH 3/6 ASoC: amd: acp: Add generic PCI driver module for ACP device
Audio Co-processor or ACP IP block on AMD's SOC is connected via PCI bus interface, hence needs to be register as a PCI device. We have same PCI device ID across multiple SOC's but with different revision id for PCI hw. Add a generic PCI driver module for ACP that registers ACP as a PCI device and also register a platform device based on pci revision id. Any SOC's specific configuration for ACP block will be done in platform driver probe. We have added an initial support for ACP revision id 3 or ACP3X device.
--- sound/soc/amd/acp/Kconfig | 6 ++ sound/soc/amd/acp/Makefile | 2 + sound/soc/amd/acp/acp-pci.c | 158 ++++++++++++++++++++++++++++++++++++ sound/soc/amd/acp/amd.h | 14 ++++ sound/soc/amd/mach-config.h | 1 + 5 files changed, 181 insertions(+) create mode 100644 sound/soc/amd/acp/acp-pci.c
sound/soc/amd/acp/Kconfig +6 -0
@@ -25,6 +25,12 @@ config SND_SOC_AMD_ACP_PCM tristate select SND_SOC_ACPI if ACPI +config SND_SOC_AMD_ACP_PCI + tristate "AMD ACP PCI Driver Support" + depends on X86 && PCI + help + This options enables generic PCI driver for ACP device. + config SND_AMD_ASOC_RENOIR tristate "AMD ACP ASOC Renoir Support" select SND_SOC_AMD_ACP_PCM
sound/soc/amd/acp/Makefile +2 -0
@@ -8,6 +8,7 @@ snd-acp-pcm-objs := acp-platform.o snd-acp-i2s-objs := acp-i2s.o snd-acp-pdm-objs := acp-pdm.o +snd-acp-pci-objs := acp-pci.o #platform specific driver snd-acp-renoir-objs := acp-renoir.o
@@ -20,6 +21,7 @@ snd-acp-sof-mach-objs := acp-sof-mach.o obj-$(CONFIG_SND_SOC_AMD_ACP_PCM) += snd-acp-pcm.o obj-$(CONFIG_SND_SOC_AMD_ACP_I2S) += snd-acp-i2s.o obj-$(CONFIG_SND_SOC_AMD_ACP_PDM) += snd-acp-pdm.o +obj-$(CONFIG_SND_SOC_AMD_ACP_PCI) += snd-acp-pci.o obj-$(CONFIG_SND_AMD_ASOC_RENOIR) += snd-acp-renoir.o
sound/soc/amd/acp/acp-pci.c new file +158 -0
158 lines not on this page · raw message
sound/soc/amd/acp/amd.h +14 -0
@@ -12,9 +12,14 @@#define __AMD_ACP_H#include <sound/pcm.h> +#include <sound/soc.h> #include <sound/soc-acpi.h> +#include <sound/soc-dai.h> +#include "chip_offset_byte.h" +#define ACP3X_DEV 3 +#define I2S_SP_INSTANCE 0x00#define I2S_BT_INSTANCE 0x01#define DMIC_INSTANCE 0x02
@@ -70,6 +75,12 @@#define ACP_MAX_STREAM 6 +struct acp_chip_info { +char *name;/* Platform name */ +unsigned int acp_rev;/* ACP Revision id */ +void __iomem *base;/* ACP memory PCI base */ +}; +struct acp_stream {struct snd_pcm_substream *substream;int irq_bit;
@@ -106,6 +117,9 @@ int acp_platform_unregister(struct device *dev);int acp_machine_select (struct acp_dev_data *adata); +/* Machine configuration */ +int snd_amd_acp_find_config (struct pci_dev *pci); +static inline u64 acp_get_byte_count (struct acp_dev_data *adata,int dai_id,int direction) {u64 byte_count, low =0 , high =0 ;
sound/soc/amd/mach-config.h +1 -0
@@ -14,6 +14,7 @@#define FLAG_AMD_SOF BIT(1)#define FLAG_AMD_SOF_ONLY_DMIC BIT(2) +#define FLAG_AMD_LEGACY BIT(3)#define ACP_PCI_DEV_ID 0x15E2
Signature · 1 line
2.25.1
PATCH 4/6 ASoC: amd: acp: Add ACP init()/deinit() callback for Renoir.
In reply to Ajit Kumar PandeyACP hardware has PGFSM control registers that can be configured to power On/Off the ACP IP block. Add acp init()/de_init() callbacks in renoir platform driver probe()/remove() respectively to power on and off ACP IP block on ACP3X device.
--- sound/soc/amd/acp/acp-renoir.c | 170 +++++++++++++++++++++++++++ sound/soc/amd/acp/chip_offset_byte.h | 6 + 2 files changed, 176 insertions(+)
sound/soc/amd/acp/acp-renoir.c +170 -0
@@ -25,6 +25,19 @@#define DRV_NAME "acp_asoc_renoir" +#define ACP_SOFT_RST_DONE_MASK 0x00010001 + +#define ACP_PWR_ON_MASK 0x01 +#define ACP_PWR_OFF_MASK 0x00 +#define ACP_PGFSM_STAT_MASK 0x03 +#define ACP_POWERED_ON 0x00 +#define ACP_PWR_ON_IN_PROGRESS 0x01 +#define ACP_POWERED_OFF 0x02 + + +#define ACP_ERROR_MASK 0x20000000 +#define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF +static struct snd_soc_acpi_codecs amp_rt1019 = { .num_codecs =1 , .codecs = {"10EC1019" }
@@ -112,11 +125,154 @@ static struct snd_soc_dai_driver acp_renoir_dai[] = { }, }; +static int acp3x_power_on (void __iomem *base) +{ +u32 val; +int timeout =0 ; + + val =readl (base +ACP_PGFSM_STATUS ); + +if (val ==ACP_POWERED_ON ) +return 0 ; + +if ((val &ACP_PGFSM_STAT_MASK ) !=ACP_PWR_ON_IN_PROGRESS ) +writel (ACP_PWR_ON_MASK , base +ACP_PGFSM_CONTROL ); + +while (++timeout <500 ) { + val =readl (base +ACP_PGFSM_STATUS ); +if (!val) +return 0 ; +udelay (1 ); + } + +return -ETIMEDOUT ; +} + +static int acp3x_power_off (void __iomem *base) +{ +u32 val; +int timeout =0 ; + +writel (ACP_PWR_OFF_MASK , base +ACP_PGFSM_CONTROL ); + +while (++timeout <500 ) { + val =readl (base +ACP_PGFSM_STATUS ); +if ((val &ACP_PGFSM_STAT_MASK ) ==ACP_POWERED_OFF ) +return 0 ; +udelay (1 ); + } + +return -ETIMEDOUT ; +} + +static int acp3x_reset (void __iomem *base) +{ +u32 val; +int timeout =0 ; + +writel (1 , base +ACP_SOFT_RESET ); + +while (++timeout <500 ) { + val =readl (base +ACP_SOFT_RESET ); +if (val &ACP_SOFT_RST_DONE_MASK ) +break ; +cpu_relax (); + } + +writel (0 , base +ACP_SOFT_RESET ); + + timeout =0 ; +while (++timeout <500 ) { + val =readl (base +ACP_SOFT_RESET ); +if (!val) +return 0 ; +cpu_relax (); + } + +return -ETIMEDOUT ; +} + +static void acp3x_enable_interrupts (void __iomem *base) +{ +u32 ext_intr_ctrl; + +writel (0x01 , base +ACP_EXTERNAL_INTR_ENB ); + ext_intr_ctrl =readl (base +ACP_EXTERNAL_INTR_CNTL ); + ext_intr_ctrl |=ACP_ERROR_MASK ; +writel (ext_intr_ctrl, base +ACP_EXTERNAL_INTR_CNTL ); +} + +static void acp3x_disable_interrupts (void __iomem *base) +{ +writel (ACP_EXT_INTR_STAT_CLEAR_MASK , base +ACP_EXTERNAL_INTR_STAT ); +writel (0x00 , base +ACP_EXTERNAL_INTR_ENB ); +} + +static int rn_acp_init (void __iomem *base) +{ +int ret; + +/* power on */ + ret =acp3x_power_on (base); +if (ret) +return ret; + +writel (0x01 , base +ACP_CONTROL ); + +/* Reset */ + ret =acp3x_reset (base); +if (ret) +return ret; + +acp3x_enable_interrupts (base); + +return 0 ; +} + +static int rn_acp_deinit (void __iomem *base) +{ +int ret =0 ; + +acp3x_disable_interrupts (base); + +/* Reset */ + ret =acp3x_reset (base); +if (ret) +return ret; + +writel (0x00 , base +ACP_CONTROL ); + +/* power off */ + ret =acp3x_power_off (base); +if (ret) +return ret; + +return 0 ; +}static int renoir_audio_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +struct acp_chip_info *chip;struct acp_dev_data *adata;struct resource *res; +int ret; + + chip =dev_get_platdata (&pdev->dev); +if (!chip || !chip->base) { +dev_err (&pdev->dev,"ACP chip data is NULL\n" ); +return -ENODEV ; + } + +if (chip->acp_rev !=ACP3X_DEV ) { +dev_err (&pdev->dev,"Un-supported ACP Revision %d\n" , chip->acp_rev); +return -ENODEV ; + } + + ret =rn_acp_init (chip->base); +if (ret) { +dev_err (&pdev->dev,"ACP Init failed\n" ); +return -EINVAL ; + } adata =devm_kzalloc (dev,sizeof (struct acp_dev_data ),GFP_KERNEL );if (!adata)
@@ -155,6 +311,20 @@ static int renoir_audio_probe(struct platform_device *pdev)static int renoir_audio_remove (struct platform_device *pdev) {struct device *dev = &pdev->dev; +struct acp_chip_info *chip; +int ret; + + chip =dev_get_platdata (&pdev->dev); +if (!chip || !chip->base) { +dev_err (&pdev->dev,"ACP chip data is NULL\n" ); +return -ENODEV ; + } + + ret =rn_acp_deinit (chip->base); +if (ret) { +dev_err (&pdev->dev,"ACP de-init Failed\n" ); +return -EINVAL ; + }acp_platform_unregister (dev);return 0 ;
sound/soc/amd/acp/chip_offset_byte.h +6 -0
@@ -14,6 +14,12 @@#define ACPAXI2AXI_ATU_CTRL 0xC40#define ACPAXI2AXI_ATU_PAGE_SIZE_GRP_5 0xC20#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_5 0xC24 + +#define ACP_PGFSM_CONTROL 0x141C +#define ACP_PGFSM_STATUS 0x1420 +#define ACP_SOFT_RESET 0x1000 +#define ACP_CONTROL 0x1004 +#define ACP_EXTERNAL_INTR_ENB 0x1800#define ACP_EXTERNAL_INTR_CNTL 0x1804#define ACP_EXTERNAL_INTR_STAT 0x1808
Signature · 1 line
2.25.1
PATCH 5/6 ASoC: amd: acp: acp-legacy: Add DMIC dai link support for Renoir
In reply to Ajit Kumar PandeyAdd DMIC related dai link for pdm-dmic dai on Renoir platform with generic dmic codec dai.
--- sound/soc/amd/acp/acp-legacy-mach.c | 4 ++-- sound/soc/amd/acp/acp-mach-common.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-)
sound/soc/amd/acp/acp-legacy-mach.c +2 -2
@@ -23,10 +23,10 @@static struct acp_card_drvdata rt5682_rt1019_data = { .hs_cpu_id =I2S_SP , .amp_cpu_id =I2S_SP , - .dmic_cpu_id =NONE , + .dmic_cpu_id =DMIC , .hs_codec_id =RT5682 , .amp_codec_id =RT1019 , - .dmic_codec_id =NONE , + .dmic_codec_id =DMIC , .gpio_spkr_en =EN_SPKR_GPIO_GB , };
sound/soc/amd/acp/acp-mach-common.c +15 -0
@@ -438,6 +438,8 @@ SND_SOC_DAILINK_DEF(sof_sp, DAILINK_COMP_ARRAY(COMP_CPU("acp-sof-sp")));SND_SOC_DAILINK_DEF (sof_dmic,DAILINK_COMP_ARRAY (COMP_CPU ("acp-sof-dmic" ))); +SND_SOC_DAILINK_DEF (pdm_dmic, +DAILINK_COMP_ARRAY (COMP_CPU ("acp-pdm-dmic" )));int acp_sofdsp_dai_links_create (struct snd_soc_card *card) {
@@ -613,6 +615,19 @@ int acp_legacy_dai_links_create(struct snd_soc_card *card) links[i].ops = &acp_card_maxim_ops; links[i].init = acp_card_maxim_init; } + i++; + } + +if (drv_data->dmic_cpu_id ==DMIC ) { + links[i].name ="acp-dmic-codec" ; + links[i].id =DMIC_BE_ID ; + links[i].codecs = dmic_codec; + links[i].num_codecs =ARRAY_SIZE (dmic_codec); + links[i].cpus = pdm_dmic; + links[i].num_cpus =ARRAY_SIZE (pdm_dmic); + links[i].platforms = platform_component; + links[i].num_platforms =ARRAY_SIZE (platform_component); + links[i].dpcm_capture =1 ; } card->dai_link = links;
Signature · 1 line
2.25.1
PATCH 6/6 ASoC: amd: renoir: Add check for acp configuration flags.
In reply to Ajit Kumar PandeyWe have SOF and generic ACP support enabled for Renoir platforms on some machines. Since we have same PCI id used for probing, add check for machine configuration flag to avoid conflict with newer pci drivers. Such machine flag has been initialized via dmi match on few Chrome machines. If no flag is specified probe and register older platform device.
--- sound/soc/amd/renoir/rn-pci-acp3x.c | 7 ++++++- sound/soc/amd/renoir/rn_acp3x.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-)
sound/soc/amd/renoir/rn-pci-acp3x.c +6 -1
@@ -212,10 +212,15 @@ static int snd_rn_acp_probe(struct pci_dev *pci,acpi_integer dmic_status;#endif const struct dmi_system_id *dmi_id; -unsigned int irqflags; +unsigned int irqflags, flag;int ret, index;u32 addr; +/* Return if acp config flag is defined */ + flag =snd_amd_acp_find_config (pci); +if (flag) +return -ENODEV ; +/* Renoir device check */ if (pci->revision !=0x01 )return -ENODEV ;
sound/soc/amd/renoir/rn_acp3x.h +3 -0
@@ -88,3 +88,6 @@ static inline void rn_writel(u32 val, void __iomem *base_addr) {writel (val, base_addr -ACP_PHY_BASE_ADDRESS ); } + +/* Machine configuration */ +int snd_amd_acp_find_config (struct pci_dev *pci);
Signature · 1 line
2.25.1
Re: [PATCH 3/6] ASoC: amd: acp: Add generic PCI driver module for ACP device
In reply to Ajit Kumar PandeyQuoted 39 lines
sound/soc/amd/acp/acp-pci.c new file +38
-0+static int acp_pci_probe (struct pci_dev *pci,const struct pci_device_id *pci_id) +{ +struct platform_device_info pdevinfo; +struct device *dev = &pci->dev; +const struct resource *res_acp; +struct acp_chip_info *chip; +struct resource *res; +unsigned int flag, addr, num_res, i; +int ret; + + flag =snd_amd_acp_find_config (pci); +if (flag !=FLAG_AMD_LEGACY ) +return -ENODEV ; + + chip =devm_kzalloc (&pci->dev,sizeof (*chip),GFP_KERNEL ); +if (!chip) +return -ENOMEM ; + +if (pci_enable_device (pci)) { +dev_err (&pci->dev,"pci_enable_device failed\n" ); +return -ENODEV ; + } + + ret =pci_request_regions (pci,"AMD ACP3x audio" ); +if (ret <0 ) { +dev_err (&pci->dev,"pci_request_regions failed\n" ); +return -ENOMEM ; + } + +pci_set_master (pci); + +switch (pci->revision) { +case 0x01 : + res_acp = acp3x_res; + num_res =ARRAY_SIZE (acp3x_res); + chip->name ="acp_asoc_renoir" ; + chip->acp_rev =ACP3X_DEV ; +break ;
sound/soc/amd/acp/acp-pci.c line 93
Quoted 10 lines
sound/soc/amd/acp/acp-pci.c new file +10
-0+default : +dev_err (dev,"Unsupported device revision:0x%x\n" , pci->revision); +return -EINVAL ; + } + + dmic_dev =platform_device_register_data (dev,"dmic-codec" ,PLATFORM_DEVID_NONE ,NULL ,0 ); +if (IS_ERR (dmic_dev)) { +dev_err (dev,"failed to create DMIC device\n" ); +return PTR_ERR (dmic_dev); + }
Past this point, any error handling needs to useplatform_device_unregister(dmic_dev);
...
sound/soc/amd/acp/acp-pci.c line 100
Quoted 6 lines
sound/soc/amd/acp/acp-pci.c new file +6
-0+ addr =pci_resource_start (pci,0 ); + chip->base =devm_ioremap (&pci->dev, addr,pci_resource_len (pci,0 )); + + res =devm_kzalloc (&pci->dev,sizeof (struct resource ) * num_res,GFP_KERNEL ); +if (!res) +return -ENOMEM ;
...which is missed here.
Quoted 31 lines
sound/soc/amd/acp/acp-pci.c new file +31
-0+ +for (i =0 ; i < num_res; i++, res_acp++) { + res[i].name = res_acp->name; + res[i].flags = res_acp->flags; + res[i].start = addr + res_acp->start; + res[i].end = addr + res_acp->end; +if (res_acp->flags ==IORESOURCE_IRQ ) { + res[i].start = pci->irq; + res[i].end = res[i].start; + } + } + +memset (&pdevinfo,0 ,sizeof (pdevinfo)); + + pdevinfo.name = chip->name; + pdevinfo.id =0 ; + pdevinfo.parent = &pci->dev; + pdevinfo.num_res = num_res; + pdevinfo.res = &res[0 ]; + pdevinfo.data = chip; + pdevinfo.size_data =sizeof (*chip); + + pdev =platform_device_register_full (&pdevinfo); +if (IS_ERR (pdev)) { +dev_err (&pci->dev,"cannot register %s device\n" , pdevinfo.name); +platform_device_unregister (dmic_dev); + ret =PTR_ERR (pdev); + } + +return ret; +};
Re: [PATCH 3/6] ASoC: amd: acp: Add generic PCI driver module for ACP device
Quoted 55 lines · Pierre-Louis Bossart
[CAUTION: External Email]
Quoted 38 lines
sound/soc/amd/acp/acp-pci.c new file +38
-0+static int acp_pci_probe (struct pci_dev *pci,const struct pci_device_id *pci_id) +{ +struct platform_device_info pdevinfo; +struct device *dev = &pci->dev; +const struct resource *res_acp; +struct acp_chip_info *chip; +struct resource *res; +unsigned int flag, addr, num_res, i; +int ret; + + flag =snd_amd_acp_find_config (pci); +if (flag !=FLAG_AMD_LEGACY ) +return -ENODEV ; + + chip =devm_kzalloc (&pci->dev,sizeof (*chip),GFP_KERNEL ); +if (!chip) +return -ENOMEM ; + +if (pci_enable_device (pci)) { +dev_err (&pci->dev,"pci_enable_device failed\n" ); +return -ENODEV ; + } + + ret =pci_request_regions (pci,"AMD ACP3x audio" ); +if (ret <0 ) { +dev_err (&pci->dev,"pci_request_regions failed\n" ); +return -ENOMEM ; + } + +pci_set_master (pci); + +switch (pci->revision) { +case 0x01 : + res_acp = acp3x_res; + num_res =ARRAY_SIZE (acp3x_res); + chip->name ="acp_asoc_renoir" ; + chip->acp_rev =ACP3X_DEV ; +break ;sound/soc/amd/acp/acp-pci.c line 93
Quoted 10 lines
sound/soc/amd/acp/acp-pci.c new file +10
-0+default : +dev_err (dev,"Unsupported device revision:0x%x\n" , pci->revision); +return -EINVAL ; + } + + dmic_dev =platform_device_register_data (dev,"dmic-codec" ,PLATFORM_DEVID_NONE ,NULL ,0 ); +if (IS_ERR (dmic_dev)) { +dev_err (dev,"failed to create DMIC device\n" ); +return PTR_ERR (dmic_dev); + }Past this point, any error handling needs to use
platform_device_unregister(dmic_dev);
...
Quoted 8 lines
sound/soc/amd/acp/acp-pci.c line 100
Quoted 6 lines
sound/soc/amd/acp/acp-pci.c new file +6
-0+ addr =pci_resource_start (pci,0 ); + chip->base =devm_ioremap (&pci->dev, addr,pci_resource_len (pci,0 )); + + res =devm_kzalloc (&pci->dev,sizeof (struct resource ) * num_res,GFP_KERNEL ); +if (!res) +return -ENOMEM ;...which is missed here.
Thanks .. will fix this in v1 patch chain
Quoted 33 lines
Quoted 32 lines
sound/soc/amd/acp/acp-pci.c new file +31
-0+ +for (i =0 ; i < num_res; i++, res_acp++) { + res[i].name = res_acp->name; + res[i].flags = res_acp->flags; + res[i].start = addr + res_acp->start; + res[i].end = addr + res_acp->end; +if (res_acp->flags ==IORESOURCE_IRQ ) { + res[i].start = pci->irq; + res[i].end = res[i].start; + } + } + +memset (&pdevinfo,0 ,sizeof (pdevinfo)); + + pdevinfo.name = chip->name; + pdevinfo.id =0 ; + pdevinfo.parent = &pci->dev; + pdevinfo.num_res = num_res; + pdevinfo.res = &res[0 ]; + pdevinfo.data = chip; + pdevinfo.size_data =sizeof (*chip); + + pdev =platform_device_register_full (&pdevinfo); +if (IS_ERR (pdev)) { +dev_err (&pci->dev,"cannot register %s device\n" , pdevinfo.name); +platform_device_unregister (dmic_dev); + ret =PTR_ERR (pdev); + } + +return ret; +};