mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-31 22:23:05 +00:00
ASoC: amd: acp: Implement acp_common_hw_ops support for acp platforms
Implement acp common hardware ops for acp_init and acp_deinit funcions to support commons ops for all platforms. Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com> Link: https://patch.msgid.link/20250310183201.11979-3-venkataprasad.potturu@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
c3d5d331c9
commit
8ae746fe51
@ -21,6 +21,12 @@
|
||||
#define ACP63_PDM_ADDR 0x02
|
||||
#define ACP70_PDM_ADDR 0x02
|
||||
|
||||
const struct snd_acp_hw_ops acp_common_hw_ops = {
|
||||
/* ACP hardware initilizations */
|
||||
.acp_init = acp_init,
|
||||
.acp_deinit = acp_deinit,
|
||||
};
|
||||
EXPORT_SYMBOL_NS_GPL(acp_common_hw_ops, "SND_SOC_ACP_COMMON");
|
||||
void acp_enable_interrupts(struct acp_dev_data *adata)
|
||||
{
|
||||
struct acp_resource *rsrc = adata->rsrc;
|
||||
@ -463,5 +469,49 @@ void check_acp_config(struct pci_dev *pci, struct acp_chip_info *chip)
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(check_acp_config, "SND_SOC_ACP_COMMON");
|
||||
|
||||
struct snd_acp_hw_ops acp31_common_hw_ops;
|
||||
EXPORT_SYMBOL_NS_GPL(acp31_common_hw_ops, "SND_SOC_ACP_COMMON");
|
||||
int acp31_hw_ops_init(struct acp_chip_info *chip)
|
||||
{
|
||||
memcpy(&acp31_common_hw_ops, &acp_common_hw_ops, sizeof(acp_common_hw_ops));
|
||||
chip->acp_hw_ops = &acp31_common_hw_ops;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(acp31_hw_ops_init, "SND_SOC_ACP_COMMON");
|
||||
|
||||
struct snd_acp_hw_ops acp6x_common_hw_ops;
|
||||
EXPORT_SYMBOL_NS_GPL(acp6x_common_hw_ops, "SND_SOC_ACP_COMMON");
|
||||
int acp6x_hw_ops_init(struct acp_chip_info *chip)
|
||||
{
|
||||
memcpy(&acp6x_common_hw_ops, &acp_common_hw_ops, sizeof(acp_common_hw_ops));
|
||||
chip->acp_hw_ops = &acp6x_common_hw_ops;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(acp6x_hw_ops_init, "SND_SOC_ACP_COMMON");
|
||||
|
||||
struct snd_acp_hw_ops acp63_common_hw_ops;
|
||||
EXPORT_SYMBOL_NS_GPL(acp63_common_hw_ops, "SND_SOC_ACP_COMMON");
|
||||
int acp63_hw_ops_init(struct acp_chip_info *chip)
|
||||
{
|
||||
memcpy(&acp63_common_hw_ops, &acp_common_hw_ops, sizeof(acp_common_hw_ops));
|
||||
chip->acp_hw_ops = &acp63_common_hw_ops;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(acp63_hw_ops_init, "SND_SOC_ACP_COMMON");
|
||||
|
||||
struct snd_acp_hw_ops acp70_common_hw_ops;
|
||||
EXPORT_SYMBOL_NS_GPL(acp70_common_hw_ops, "SND_SOC_ACP_COMMON");
|
||||
int acp70_hw_ops_init(struct acp_chip_info *chip)
|
||||
{
|
||||
memcpy(&acp70_common_hw_ops, &acp_common_hw_ops, sizeof(acp_common_hw_ops));
|
||||
chip->acp_hw_ops = &acp70_common_hw_ops;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(acp70_hw_ops_init, "SND_SOC_ACP_COMMON");
|
||||
|
||||
MODULE_DESCRIPTION("AMD ACP legacy common features");
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
|
@ -81,16 +81,20 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
|
||||
switch (pci->revision) {
|
||||
case 0x01:
|
||||
chip->name = "acp_asoc_renoir";
|
||||
chip->acp_hw_ops_init = acp31_hw_ops_init;
|
||||
break;
|
||||
case 0x6f:
|
||||
chip->name = "acp_asoc_rembrandt";
|
||||
chip->acp_hw_ops_init = acp6x_hw_ops_init;
|
||||
break;
|
||||
case 0x63:
|
||||
chip->name = "acp_asoc_acp63";
|
||||
chip->acp_hw_ops_init = acp63_hw_ops_init;
|
||||
break;
|
||||
case 0x70:
|
||||
case 0x71:
|
||||
chip->name = "acp_asoc_acp70";
|
||||
chip->acp_hw_ops_init = acp70_hw_ops_init;
|
||||
break;
|
||||
default:
|
||||
dev_err(dev, "Unsupported device revision:0x%x\n", pci->revision);
|
||||
@ -112,7 +116,8 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
|
||||
goto unregister_dmic_dev;
|
||||
}
|
||||
|
||||
ret = acp_init(chip);
|
||||
chip->acp_hw_ops_init(chip);
|
||||
ret = acp_hw_init(chip);
|
||||
if (ret)
|
||||
goto unregister_dmic_dev;
|
||||
|
||||
@ -179,7 +184,7 @@ static int __maybe_unused snd_acp_suspend(struct device *dev)
|
||||
int ret;
|
||||
|
||||
chip = dev_get_drvdata(dev);
|
||||
ret = acp_deinit(chip);
|
||||
ret = acp_hw_deinit(chip);
|
||||
if (ret)
|
||||
dev_err(dev, "ACP de-init failed\n");
|
||||
return ret;
|
||||
@ -193,7 +198,7 @@ static int __maybe_unused snd_acp_resume(struct device *dev)
|
||||
int ret;
|
||||
|
||||
chip = dev_get_drvdata(dev);
|
||||
ret = acp_init(chip);
|
||||
ret = acp_hw_init(chip);
|
||||
if (ret)
|
||||
dev_err(dev, "ACP init failed\n");
|
||||
if (chip->chip_pdev) {
|
||||
@ -222,7 +227,7 @@ static void acp_pci_remove(struct pci_dev *pci)
|
||||
platform_device_unregister(dmic_dev);
|
||||
if (pdev)
|
||||
platform_device_unregister(pdev);
|
||||
ret = acp_deinit(chip);
|
||||
ret = acp_hw_deinit(chip);
|
||||
if (ret)
|
||||
dev_err(&pci->dev, "ACP de-init failed\n");
|
||||
}
|
||||
|
@ -142,6 +142,8 @@ struct acp_chip_info {
|
||||
char *name; /* Platform name */
|
||||
unsigned int acp_rev; /* ACP Revision id */
|
||||
void __iomem *base; /* ACP memory PCI base */
|
||||
struct snd_acp_hw_ops *acp_hw_ops;
|
||||
int (*acp_hw_ops_init)(struct acp_chip_info *chip);
|
||||
struct platform_device *chip_pdev;
|
||||
unsigned int flag; /* Distinguish b/w Legacy or Only PDM */
|
||||
bool is_pdm_dev; /* flag set to true when ACP PDM controller exists */
|
||||
@ -203,6 +205,17 @@ struct acp_dev_data {
|
||||
unsigned int flag;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct snd_acp_hw_ops - ACP PCI driver platform specific ops
|
||||
* @acp_init: ACP initialization
|
||||
* @acp_deinit: ACP de-initialization
|
||||
*/
|
||||
struct snd_acp_hw_ops {
|
||||
/* ACP hardware initilizations */
|
||||
int (*acp_init)(struct acp_chip_info *chip);
|
||||
int (*acp_deinit)(struct acp_chip_info *chip);
|
||||
};
|
||||
|
||||
enum acp_config {
|
||||
ACP_CONFIG_0 = 0,
|
||||
ACP_CONFIG_1,
|
||||
@ -239,6 +252,15 @@ int acp_init(struct acp_chip_info *chip);
|
||||
int acp_deinit(struct acp_chip_info *chip);
|
||||
void acp_enable_interrupts(struct acp_dev_data *adata);
|
||||
void acp_disable_interrupts(struct acp_dev_data *adata);
|
||||
|
||||
extern struct snd_acp_hw_ops acp31_common_hw_ops;
|
||||
extern struct snd_acp_hw_ops acp6x_common_hw_ops;
|
||||
extern struct snd_acp_hw_ops acp63_common_hw_ops;
|
||||
extern struct snd_acp_hw_ops acp70_common_hw_ops;
|
||||
extern int acp31_hw_ops_init(struct acp_chip_info *chip);
|
||||
extern int acp6x_hw_ops_init(struct acp_chip_info *chip);
|
||||
extern int acp63_hw_ops_init(struct acp_chip_info *chip);
|
||||
extern int acp70_hw_ops_init(struct acp_chip_info *chip);
|
||||
/* Machine configuration */
|
||||
int snd_amd_acp_find_config(struct pci_dev *pci);
|
||||
|
||||
@ -252,6 +274,20 @@ int restore_acp_i2s_params(struct snd_pcm_substream *substream,
|
||||
|
||||
void check_acp_config(struct pci_dev *pci, struct acp_chip_info *chip);
|
||||
|
||||
static inline int acp_hw_init(struct acp_chip_info *chip)
|
||||
{
|
||||
if (chip && chip->acp_hw_ops && chip->acp_hw_ops->acp_init)
|
||||
return chip->acp_hw_ops->acp_init(chip);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int acp_hw_deinit(struct acp_chip_info *chip)
|
||||
{
|
||||
if (chip && chip->acp_hw_ops && chip->acp_hw_ops->acp_deinit)
|
||||
return chip->acp_hw_ops->acp_deinit(chip);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline u64 acp_get_byte_count(struct acp_dev_data *adata, int dai_id, int direction)
|
||||
{
|
||||
u64 byte_count = 0, low = 0, high = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user