mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
ASoC: amd: acp: Add pci legacy driver support for acp7.0 platform
Add pci legacy driver support and create platform driver for acp7.0 platform. Signed-off-by: Syed Saba Kareem <Syed.SabaKareem@amd.com> Link: https://lore.kernel.org/r/20231021145110.478744-12-Syed.SabaKareem@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
caa126f2b0
commit
e84db124cb
@ -19,6 +19,7 @@
|
||||
#define ACP_RENOIR_PDM_ADDR 0x02
|
||||
#define ACP_REMBRANDT_PDM_ADDR 0x03
|
||||
#define ACP63_PDM_ADDR 0x02
|
||||
#define ACP70_PDM_ADDR 0x02
|
||||
|
||||
void acp_enable_interrupts(struct acp_dev_data *adata)
|
||||
{
|
||||
@ -268,6 +269,10 @@ static int acp_power_on(struct acp_chip_info *chip)
|
||||
acp_pgfsm_stat_reg = ACP63_PGFSM_STATUS;
|
||||
acp_pgfsm_ctrl_reg = ACP63_PGFSM_CONTROL;
|
||||
break;
|
||||
case ACP70_DEV:
|
||||
acp_pgfsm_stat_reg = ACP70_PGFSM_STATUS;
|
||||
acp_pgfsm_ctrl_reg = ACP70_PGFSM_CONTROL;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -329,7 +334,8 @@ int acp_deinit(struct acp_chip_info *chip)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
writel(0, chip->base + ACP_CONTROL);
|
||||
if (chip->acp_rev != ACP70_DEV)
|
||||
writel(0, chip->base + ACP_CONTROL);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(acp_deinit, SND_SOC_ACP_COMMON);
|
||||
@ -385,6 +391,9 @@ int check_acp_pdm(struct pci_dev *pci, struct acp_chip_info *chip)
|
||||
case ACP63_DEV:
|
||||
pdm_addr = ACP63_PDM_ADDR;
|
||||
break;
|
||||
case ACP70_DEV:
|
||||
pdm_addr = ACP70_PDM_ADDR;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ enum platform_end_point {
|
||||
RENOIR = 0,
|
||||
REMBRANDT,
|
||||
ACP63,
|
||||
ACP70,
|
||||
};
|
||||
|
||||
struct acp_mach_ops {
|
||||
|
@ -91,6 +91,10 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
|
||||
chip->name = "acp_asoc_acp63";
|
||||
chip->acp_rev = ACP63_DEV;
|
||||
break;
|
||||
case 0x70:
|
||||
chip->name = "acp_asoc_acp70";
|
||||
chip->acp_rev = ACP70_DEV;
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "Unsupported device revision:0x%x\n", pci->revision);
|
||||
ret = -EINVAL;
|
||||
|
254
sound/soc/amd/acp/acp70.c
Normal file
254
sound/soc/amd/acp/acp70.c
Normal file
@ -0,0 +1,254 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
|
||||
//
|
||||
// This file is provided under a dual BSD/GPLv2 license. When using or
|
||||
// redistributing this file, you may do so under either license.
|
||||
//
|
||||
// Copyright(c) 2023 Advanced Micro Devices, Inc.
|
||||
//
|
||||
// Authors: Syed Saba kareem <syed.sabakareem@amd.com>
|
||||
/*
|
||||
* Hardware interface for ACP7.0 block
|
||||
*/
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/io.h>
|
||||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc.h>
|
||||
#include <sound/soc-dai.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/pci.h>
|
||||
#include "amd.h"
|
||||
#include "acp-mach.h"
|
||||
|
||||
#define DRV_NAME "acp_asoc_acp70"
|
||||
|
||||
static struct acp_resource rsrc = {
|
||||
.offset = 0,
|
||||
.no_of_ctrls = 2,
|
||||
.irqp_used = 1,
|
||||
.soc_mclk = true,
|
||||
.irq_reg_offset = 0x1a00,
|
||||
.i2s_pin_cfg_offset = 0x1440,
|
||||
.i2s_mode = 0x0a,
|
||||
.scratch_reg_offset = 0x12800,
|
||||
.sram_pte_offset = 0x03802800,
|
||||
};
|
||||
|
||||
static struct snd_soc_acpi_mach snd_soc_acpi_amd_acp70_acp_machines[] = {
|
||||
{
|
||||
.id = "AMDI0029",
|
||||
.drv_name = "acp70-acp",
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
static struct snd_soc_dai_driver acp70_dai[] = {
|
||||
{
|
||||
.name = "acp-i2s-sp",
|
||||
.id = I2S_SP_INSTANCE,
|
||||
.playback = {
|
||||
.stream_name = "I2S SP Playback",
|
||||
.rates = SNDRV_PCM_RATE_8000_96000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
|
||||
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
.channels_min = 2,
|
||||
.channels_max = 8,
|
||||
.rate_min = 8000,
|
||||
.rate_max = 96000,
|
||||
},
|
||||
.capture = {
|
||||
.stream_name = "I2S SP Capture",
|
||||
.rates = SNDRV_PCM_RATE_8000_48000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
|
||||
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
.channels_min = 2,
|
||||
.channels_max = 2,
|
||||
.rate_min = 8000,
|
||||
.rate_max = 48000,
|
||||
},
|
||||
.ops = &asoc_acp_cpu_dai_ops,
|
||||
},
|
||||
{
|
||||
.name = "acp-i2s-bt",
|
||||
.id = I2S_BT_INSTANCE,
|
||||
.playback = {
|
||||
.stream_name = "I2S BT Playback",
|
||||
.rates = SNDRV_PCM_RATE_8000_96000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
|
||||
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
.channels_min = 2,
|
||||
.channels_max = 8,
|
||||
.rate_min = 8000,
|
||||
.rate_max = 96000,
|
||||
},
|
||||
.capture = {
|
||||
.stream_name = "I2S BT Capture",
|
||||
.rates = SNDRV_PCM_RATE_8000_48000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
|
||||
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
.channels_min = 2,
|
||||
.channels_max = 2,
|
||||
.rate_min = 8000,
|
||||
.rate_max = 48000,
|
||||
},
|
||||
.ops = &asoc_acp_cpu_dai_ops,
|
||||
},
|
||||
{
|
||||
.name = "acp-i2s-hs",
|
||||
.id = I2S_HS_INSTANCE,
|
||||
.playback = {
|
||||
.stream_name = "I2S HS Playback",
|
||||
.rates = SNDRV_PCM_RATE_8000_96000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
|
||||
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
.channels_min = 2,
|
||||
.channels_max = 8,
|
||||
.rate_min = 8000,
|
||||
.rate_max = 96000,
|
||||
},
|
||||
.capture = {
|
||||
.stream_name = "I2S HS Capture",
|
||||
.rates = SNDRV_PCM_RATE_8000_48000,
|
||||
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
|
||||
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
|
||||
.channels_min = 2,
|
||||
.channels_max = 8,
|
||||
.rate_min = 8000,
|
||||
.rate_max = 48000,
|
||||
},
|
||||
.ops = &asoc_acp_cpu_dai_ops,
|
||||
},
|
||||
{
|
||||
.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 acp_acp70_audio_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct acp_chip_info *chip;
|
||||
struct acp_dev_data *adata;
|
||||
struct resource *res;
|
||||
|
||||
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 != ACP70_DEV) {
|
||||
dev_err(&pdev->dev, "Un-supported ACP Revision %d\n", chip->acp_rev);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
adata = devm_kzalloc(dev, sizeof(struct acp_dev_data), GFP_KERNEL);
|
||||
if (!adata)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "acp_mem");
|
||||
if (!res) {
|
||||
dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
adata->acp_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
|
||||
if (!adata->acp_base)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "acp_dai_irq");
|
||||
if (!res) {
|
||||
dev_err(&pdev->dev, "IORESOURCE_IRQ FAILED\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
adata->i2s_irq = res->start;
|
||||
adata->dev = dev;
|
||||
adata->dai_driver = acp70_dai;
|
||||
adata->num_dai = ARRAY_SIZE(acp70_dai);
|
||||
adata->rsrc = &rsrc;
|
||||
adata->machines = snd_soc_acpi_amd_acp70_acp_machines;
|
||||
adata->platform = ACP70;
|
||||
adata->flag = chip->flag;
|
||||
acp_machine_select(adata);
|
||||
|
||||
dev_set_drvdata(dev, adata);
|
||||
acp_enable_interrupts(adata);
|
||||
acp_platform_register(dev);
|
||||
pm_runtime_set_autosuspend_delay(&pdev->dev, ACP_SUSPEND_DELAY_MS);
|
||||
pm_runtime_use_autosuspend(&pdev->dev);
|
||||
pm_runtime_mark_last_busy(&pdev->dev);
|
||||
pm_runtime_set_active(&pdev->dev);
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void acp_acp70_audio_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct acp_dev_data *adata = dev_get_drvdata(dev);
|
||||
|
||||
acp_disable_interrupts(adata);
|
||||
acp_platform_unregister(dev);
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
}
|
||||
|
||||
static int __maybe_unused acp70_pcm_resume(struct device *dev)
|
||||
{
|
||||
struct acp_dev_data *adata = dev_get_drvdata(dev);
|
||||
struct acp_stream *stream;
|
||||
struct snd_pcm_substream *substream;
|
||||
snd_pcm_uframes_t buf_in_frames;
|
||||
u64 buf_size;
|
||||
|
||||
spin_lock(&adata->acp_lock);
|
||||
list_for_each_entry(stream, &adata->stream_list, list) {
|
||||
if (stream) {
|
||||
substream = stream->substream;
|
||||
if (substream && substream->runtime) {
|
||||
buf_in_frames = (substream->runtime->buffer_size);
|
||||
buf_size = frames_to_bytes(substream->runtime, buf_in_frames);
|
||||
config_pte_for_stream(adata, stream);
|
||||
config_acp_dma(adata, stream, buf_size);
|
||||
if (stream->dai_id)
|
||||
restore_acp_i2s_params(substream, adata, stream);
|
||||
else
|
||||
restore_acp_pdm_params(substream, adata);
|
||||
}
|
||||
}
|
||||
}
|
||||
spin_unlock(&adata->acp_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops acp70_dma_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(NULL, acp70_pcm_resume)
|
||||
};
|
||||
|
||||
static struct platform_driver acp70_driver = {
|
||||
.probe = acp_acp70_audio_probe,
|
||||
.remove_new = acp_acp70_audio_remove,
|
||||
.driver = {
|
||||
.name = "acp_asoc_acp70",
|
||||
.pm = &acp70_dma_pm_ops,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(acp70_driver);
|
||||
|
||||
MODULE_DESCRIPTION("AMD ACP ACP70 Driver");
|
||||
MODULE_IMPORT_NS(SND_SOC_ACP_COMMON);
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
MODULE_ALIAS("platform:" DRV_NAME);
|
@ -21,6 +21,7 @@
|
||||
#define ACP3X_DEV 3
|
||||
#define ACP6X_DEV 6
|
||||
#define ACP63_DEV 0x63
|
||||
#define ACP70_DEV 0x70
|
||||
|
||||
#define DMIC_INSTANCE 0x00
|
||||
#define I2S_SP_INSTANCE 0x01
|
||||
@ -99,6 +100,9 @@
|
||||
#define ACP63_PGFSM_CONTROL ACP6X_PGFSM_CONTROL
|
||||
#define ACP63_PGFSM_STATUS ACP6X_PGFSM_STATUS
|
||||
|
||||
#define ACP70_PGFSM_CONTROL ACP6X_PGFSM_CONTROL
|
||||
#define ACP70_PGFSM_STATUS ACP6X_PGFSM_STATUS
|
||||
|
||||
#define ACP_SOFT_RST_DONE_MASK 0x00010001
|
||||
|
||||
#define ACP_PGFSM_CNTL_POWER_ON_MASK 0xffffffff
|
||||
|
Loading…
Reference in New Issue
Block a user