mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
ASoC: amd: add Renoir ACP PCI driver
ACP is a PCI audio device. This patch adds PCI driver to bind to this device and get PCI resources. Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200518171704.24999-3-Vijendar.Mukunda@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
9b5e98e214
commit
1eb2852efe
87
sound/soc/amd/renoir/rn-pci-acp3x.c
Normal file
87
sound/soc/amd/renoir/rn-pci-acp3x.c
Normal file
@ -0,0 +1,87 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
//
|
||||
// AMD Renoir ACP PCI Driver
|
||||
//
|
||||
//Copyright 2020 Advanced Micro Devices, Inc.
|
||||
|
||||
#include <linux/pci.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
#include "rn_acp3x.h"
|
||||
|
||||
struct acp_dev_data {
|
||||
void __iomem *acp_base;
|
||||
};
|
||||
|
||||
static int snd_rn_acp_probe(struct pci_dev *pci,
|
||||
const struct pci_device_id *pci_id)
|
||||
{
|
||||
struct acp_dev_data *adata;
|
||||
int ret;
|
||||
u32 addr;
|
||||
|
||||
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");
|
||||
goto disable_pci;
|
||||
}
|
||||
|
||||
adata = devm_kzalloc(&pci->dev, sizeof(struct acp_dev_data),
|
||||
GFP_KERNEL);
|
||||
if (!adata) {
|
||||
ret = -ENOMEM;
|
||||
goto release_regions;
|
||||
}
|
||||
|
||||
addr = pci_resource_start(pci, 0);
|
||||
adata->acp_base = devm_ioremap(&pci->dev, addr,
|
||||
pci_resource_len(pci, 0));
|
||||
if (!adata->acp_base) {
|
||||
ret = -ENOMEM;
|
||||
goto release_regions;
|
||||
}
|
||||
pci_set_master(pci);
|
||||
pci_set_drvdata(pci, adata);
|
||||
return 0;
|
||||
|
||||
release_regions:
|
||||
pci_release_regions(pci);
|
||||
disable_pci:
|
||||
pci_disable_device(pci);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void snd_rn_acp_remove(struct pci_dev *pci)
|
||||
{
|
||||
pci_disable_msi(pci);
|
||||
pci_release_regions(pci);
|
||||
pci_disable_device(pci);
|
||||
}
|
||||
|
||||
static const struct pci_device_id snd_rn_acp_ids[] = {
|
||||
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_DEVICE_ID),
|
||||
.class = PCI_CLASS_MULTIMEDIA_OTHER << 8,
|
||||
.class_mask = 0xffffff },
|
||||
{ 0, },
|
||||
};
|
||||
MODULE_DEVICE_TABLE(pci, snd_rn_acp_ids);
|
||||
|
||||
static struct pci_driver rn_acp_driver = {
|
||||
.name = KBUILD_MODNAME,
|
||||
.id_table = snd_rn_acp_ids,
|
||||
.probe = snd_rn_acp_probe,
|
||||
.remove = snd_rn_acp_remove,
|
||||
};
|
||||
|
||||
module_pci_driver(rn_acp_driver);
|
||||
|
||||
MODULE_AUTHOR("Vijendar.Mukunda@amd.com");
|
||||
MODULE_DESCRIPTION("AMD ACP Renoir PCI driver");
|
||||
MODULE_LICENSE("GPL v2");
|
21
sound/soc/amd/renoir/rn_acp3x.h
Normal file
21
sound/soc/amd/renoir/rn_acp3x.h
Normal file
@ -0,0 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* AMD ALSA SoC PDM Driver
|
||||
*
|
||||
* Copyright 2020 Advanced Micro Devices, Inc.
|
||||
*/
|
||||
|
||||
#include "rn_chip_offset_byte.h"
|
||||
|
||||
#define ACP_PHY_BASE_ADDRESS 0x1240000
|
||||
#define ACP_DEVICE_ID 0x15E2
|
||||
|
||||
static inline u32 rn_readl(void __iomem *base_addr)
|
||||
{
|
||||
return readl(base_addr - ACP_PHY_BASE_ADDRESS);
|
||||
}
|
||||
|
||||
static inline void rn_writel(u32 val, void __iomem *base_addr)
|
||||
{
|
||||
writel(val, base_addr - ACP_PHY_BASE_ADDRESS);
|
||||
}
|
Loading…
Reference in New Issue
Block a user