Commit b585692f authored by Ajit Kumar Pandey's avatar Ajit Kumar Pandey Committed by Mark Brown

ASoC: SOF: amd: Add SOF pm ops callback for Renoir

Add SOF PM ops callback in renoir dsp ops to power off and on ACP
IP block during system suspend and resume on Renoir platform.
Signed-off-by: default avatarAjit Kumar Pandey <AjitKumar.Pandey@amd.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220606210212.146626-2-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f2906aa8
...@@ -46,12 +46,14 @@ ...@@ -46,12 +46,14 @@
#define ACPAXI2AXI_ATU_BASE_ADDR_GRP_8 0xC3C #define ACPAXI2AXI_ATU_BASE_ADDR_GRP_8 0xC3C
#define ACPAXI2AXI_ATU_CTRL 0xC40 #define ACPAXI2AXI_ATU_CTRL 0xC40
#define ACP_SOFT_RESET 0x1000 #define ACP_SOFT_RESET 0x1000
#define ACP_CONTROL 0x1004
#define ACP_I2S_PIN_CONFIG 0x1400 #define ACP_I2S_PIN_CONFIG 0x1400
/* Registers from ACP_PGFSM block */ /* Registers from ACP_PGFSM block */
#define ACP_PGFSM_CONTROL 0x141C #define ACP_PGFSM_CONTROL 0x141C
#define ACP_PGFSM_STATUS 0x1420 #define ACP_PGFSM_STATUS 0x1420
#define ACP_CLKMUX_SEL 0x1424
/* Registers from ACP_INTR block */ /* Registers from ACP_INTR block */
#define ACP_EXTERNAL_INTR_ENB 0x1800 #define ACP_EXTERNAL_INTR_ENB 0x1800
......
...@@ -413,10 +413,46 @@ static int acp_init(struct snd_sof_dev *sdev) ...@@ -413,10 +413,46 @@ static int acp_init(struct snd_sof_dev *sdev)
dev_err(sdev->dev, "ACP power on failed\n"); dev_err(sdev->dev, "ACP power on failed\n");
return ret; return ret;
} }
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_CONTROL, 0x01);
/* Reset */ /* Reset */
return acp_reset(sdev); return acp_reset(sdev);
} }
int amd_sof_acp_suspend(struct snd_sof_dev *sdev, u32 target_state)
{
int ret;
ret = acp_reset(sdev);
if (ret) {
dev_err(sdev->dev, "ACP Reset failed\n");
return ret;
}
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_CONTROL, 0x00);
return 0;
}
EXPORT_SYMBOL_NS(amd_sof_acp_suspend, SND_SOC_SOF_AMD_COMMON);
int amd_sof_acp_resume(struct snd_sof_dev *sdev)
{
int ret;
ret = acp_init(sdev);
if (ret) {
dev_err(sdev->dev, "ACP Init failed\n");
return ret;
}
snd_sof_dsp_write(sdev, ACP_DSP_BAR, ACP_CLKMUX_SEL, 0x03);
ret = acp_memory_init(sdev);
return ret;
}
EXPORT_SYMBOL_NS(amd_sof_acp_resume, SND_SOC_SOF_AMD_COMMON);
int amd_sof_acp_probe(struct snd_sof_dev *sdev) int amd_sof_acp_probe(struct snd_sof_dev *sdev)
{ {
struct pci_dev *pci = to_pci_dev(sdev->dev); struct pci_dev *pci = to_pci_dev(sdev->dev);
......
...@@ -216,6 +216,10 @@ int acp_sof_trace_init(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab, ...@@ -216,6 +216,10 @@ int acp_sof_trace_init(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
struct sof_ipc_dma_trace_params_ext *dtrace_params); struct sof_ipc_dma_trace_params_ext *dtrace_params);
int acp_sof_trace_release(struct snd_sof_dev *sdev); int acp_sof_trace_release(struct snd_sof_dev *sdev);
/* PM Callbacks */
int amd_sof_acp_suspend(struct snd_sof_dev *sdev, u32 target_state);
int amd_sof_acp_resume(struct snd_sof_dev *sdev);
struct sof_amd_acp_desc { struct sof_amd_acp_desc {
unsigned int host_bridge_id; unsigned int host_bridge_id;
}; };
......
...@@ -49,6 +49,7 @@ static const struct sof_amd_acp_desc renoir_chip_info = { ...@@ -49,6 +49,7 @@ static const struct sof_amd_acp_desc renoir_chip_info = {
static const struct sof_dev_desc renoir_desc = { static const struct sof_dev_desc renoir_desc = {
.machines = snd_soc_acpi_amd_sof_machines, .machines = snd_soc_acpi_amd_sof_machines,
.use_acpi_target_states = true,
.resindex_lpe_base = 0, .resindex_lpe_base = 0,
.resindex_pcicfg_base = -1, .resindex_pcicfg_base = -1,
.resindex_imr_base = -1, .resindex_imr_base = -1,
...@@ -166,6 +167,9 @@ static struct pci_driver snd_sof_pci_amd_rn_driver = { ...@@ -166,6 +167,9 @@ static struct pci_driver snd_sof_pci_amd_rn_driver = {
.id_table = rn_pci_ids, .id_table = rn_pci_ids,
.probe = acp_pci_rn_probe, .probe = acp_pci_rn_probe,
.remove = acp_pci_rn_remove, .remove = acp_pci_rn_remove,
.driver = {
.pm = &sof_pci_pm,
},
}; };
module_pci_driver(snd_sof_pci_amd_rn_driver); module_pci_driver(snd_sof_pci_amd_rn_driver);
......
...@@ -173,6 +173,10 @@ struct snd_sof_dsp_ops sof_renoir_ops = { ...@@ -173,6 +173,10 @@ struct snd_sof_dsp_ops sof_renoir_ops = {
/* Trace Logger */ /* Trace Logger */
.trace_init = acp_sof_trace_init, .trace_init = acp_sof_trace_init,
.trace_release = acp_sof_trace_release, .trace_release = acp_sof_trace_release,
/* PM */
.suspend = amd_sof_acp_suspend,
.resume = amd_sof_acp_resume,
}; };
EXPORT_SYMBOL(sof_renoir_ops); EXPORT_SYMBOL(sof_renoir_ops);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment