]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: SOF: amd: Use AMD_NODE
authorMario Limonciello <mario.limonciello@amd.com>
Mon, 17 Feb 2025 23:17:45 +0000 (17:17 -0600)
committerMark Brown <broonie@kernel.org>
Tue, 18 Feb 2025 23:15:17 +0000 (23:15 +0000)
All consumers of SMN in the kernel should be doing it through the
functions provided by AMD_NODE.

Stop using the local SMN read/write symbols and switch to the AMD_NODE
provided ones.

Tested by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patch.msgid.link/20250217231747.1656228-6-superm1@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/amd/Kconfig
sound/soc/sof/amd/acp.c
sound/soc/sof/amd/acp.h
sound/soc/sof/amd/pci-rmb.c
sound/soc/sof/amd/pci-rn.c
sound/soc/sof/amd/pci-vangogh.c

index f4cafe801017800181d412eac1ec9f8c27871a2e..28216c8c1cf972c65994e5143e8473b733373673 100644 (file)
@@ -25,6 +25,7 @@ config SND_SOC_SOF_AMD_COMMON
        select SND_SOC_SOF_ACP_PROBES
        select SND_SOC_ACPI_AMD_MATCH
        select SND_SOC_ACPI if ACPI
+       depends on AMD_NODE
        help
          This option is not user-selectable but automatically handled by
          'select' statements at a higher level
index 33648ff8b83365e76d7d90e52c2cb8f884a2fe72..7007014423a447ae0bdbcb281c7bb668554ffb7e 100644 (file)
@@ -16,6 +16,8 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 
+#include <asm/amd_node.h>
+
 #include "../ops.h"
 #include "acp.h"
 #include "acp-dsp-offset.h"
@@ -42,24 +44,6 @@ const struct dmi_system_id acp_sof_quirk_table[] = {
 };
 EXPORT_SYMBOL_GPL(acp_sof_quirk_table);
 
-static int smn_write(struct pci_dev *dev, u32 smn_addr, u32 data)
-{
-       pci_write_config_dword(dev, 0x60, smn_addr);
-       pci_write_config_dword(dev, 0x64, data);
-
-       return 0;
-}
-
-static int smn_read(struct pci_dev *dev, u32 smn_addr)
-{
-       u32 data = 0;
-
-       pci_write_config_dword(dev, 0x60, smn_addr);
-       pci_read_config_dword(dev, 0x64, &data);
-
-       return data;
-}
-
 static void init_dma_descriptor(struct acp_dev_data *adata)
 {
        struct snd_sof_dev *sdev = adata->dev;
@@ -208,11 +192,11 @@ int configure_and_run_dma(struct acp_dev_data *adata, unsigned int src_addr,
 static int psp_mbox_ready(struct acp_dev_data *adata, bool ack)
 {
        struct snd_sof_dev *sdev = adata->dev;
-       int ret;
-       u32 data;
+       int ret, data;
+
+       ret = read_poll_timeout(smn_read_register, data, data > 0 && data & MBOX_READY_MASK,
+                               MBOX_DELAY_US, ACP_PSP_TIMEOUT_US, false, MP0_C2PMSG_114_REG);
 
-       ret = read_poll_timeout(smn_read, data, data & MBOX_READY_MASK, MBOX_DELAY_US,
-                               ACP_PSP_TIMEOUT_US, false, adata->smn_dev, MP0_C2PMSG_114_REG);
        if (!ret)
                return 0;
 
@@ -240,8 +224,8 @@ static int psp_send_cmd(struct acp_dev_data *adata, int cmd)
                return -EINVAL;
 
        /* Get a non-zero Doorbell value from PSP */
-       ret = read_poll_timeout(smn_read, data, data, MBOX_DELAY_US, ACP_PSP_TIMEOUT_US, false,
-                               adata->smn_dev, MP0_C2PMSG_73_REG);
+       ret = read_poll_timeout(smn_read_register, data, data > 0, MBOX_DELAY_US,
+                               ACP_PSP_TIMEOUT_US, false, MP0_C2PMSG_73_REG);
 
        if (ret) {
                dev_err(sdev->dev, "Failed to get Doorbell from MBOX %x\n", MP0_C2PMSG_73_REG);
@@ -253,10 +237,14 @@ static int psp_send_cmd(struct acp_dev_data *adata, int cmd)
        if (ret)
                return ret;
 
-       smn_write(adata->smn_dev, MP0_C2PMSG_114_REG, cmd);
+       ret = amd_smn_write(0, MP0_C2PMSG_114_REG, cmd);
+       if (ret)
+               return ret;
 
        /* Ring the Doorbell for PSP */
-       smn_write(adata->smn_dev, MP0_C2PMSG_73_REG, data);
+       ret = amd_smn_write(0, MP0_C2PMSG_73_REG, data);
+       if (ret)
+               return ret;
 
        /* Check MBOX ready as PSP ack */
        ret = psp_mbox_ready(adata, 1);
@@ -770,16 +758,10 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
        adata->pci_rev = pci->revision;
        mutex_init(&adata->acp_lock);
        sdev->pdata->hw_pdata = adata;
-       adata->smn_dev = pci_get_device(PCI_VENDOR_ID_AMD, chip->host_bridge_id, NULL);
-       if (!adata->smn_dev) {
-               dev_err(sdev->dev, "Failed to get host bridge device\n");
-               ret = -ENODEV;
-               goto unregister_dev;
-       }
 
        ret = acp_init(sdev);
        if (ret < 0)
-               goto free_smn_dev;
+               goto unregister_dev;
 
        sdev->ipc_irq = pci->irq;
        ret = request_threaded_irq(sdev->ipc_irq, acp_irq_handler, acp_irq_thread,
@@ -787,7 +769,7 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
        if (ret < 0) {
                dev_err(sdev->dev, "failed to register IRQ %d\n",
                        sdev->ipc_irq);
-               goto free_smn_dev;
+               goto unregister_dev;
        }
 
        /* scan SoundWire capabilities exposed by DSDT */
@@ -800,7 +782,6 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
        if (ret < 0) {
                dev_err(sdev->dev, "error: SoundWire probe error\n");
                free_irq(sdev->ipc_irq, sdev);
-               pci_dev_put(adata->smn_dev);
                return ret;
        }
 
@@ -846,8 +827,6 @@ skip_soundwire:
 
 free_ipc_irq:
        free_irq(sdev->ipc_irq, sdev);
-free_smn_dev:
-       pci_dev_put(adata->smn_dev);
 unregister_dev:
        platform_device_unregister(adata->dmic_dev);
        return ret;
@@ -858,9 +837,6 @@ void amd_sof_acp_remove(struct snd_sof_dev *sdev)
 {
        struct acp_dev_data *adata = sdev->pdata->hw_pdata;
 
-       if (adata->smn_dev)
-               pci_dev_put(adata->smn_dev);
-
        if (adata->sdw)
                amd_sof_sdw_exit(sdev);
 
index 800594440f73914e7b8ccaf86369ac686e1da630..51433010635770e6a9a2e532fb7e2a243b7df53f 100644 (file)
@@ -255,7 +255,6 @@ struct acp_dev_data {
        struct dma_descriptor dscr_info[ACP_MAX_DESC];
        struct acp_dsp_stream stream_buf[ACP_MAX_STREAM];
        struct acp_dsp_stream *dtrace_stream;
-       struct pci_dev *smn_dev;
        struct acp_dsp_stream *probe_stream;
        bool enable_fw_debug;
        bool is_dram_in_use;
index cbb4d528266442f6481a9fea5c7074f75820fc50..0233b6ba2d2e224a6fcb2f272d332f45eee1d464 100644 (file)
@@ -28,7 +28,6 @@
 #define ACP6X_FUTURE_REG_ACLK_0        0x1854
 
 static const struct sof_amd_acp_desc rembrandt_chip_info = {
-       .host_bridge_id = HOST_BRIDGE_RMB,
        .pgfsm_base     = ACP6X_PGFSM_BASE,
        .ext_intr_stat  = ACP6X_EXT_INTR_STAT,
        .dsp_intr_base  = ACP6X_DSP_SW_INTR_BASE,
index b7d558cb1fd7a7fd2f071b9394588f1a9100e9c5..4a36029a00decebfa225cd2647123972b0384603 100644 (file)
@@ -28,7 +28,6 @@
 #define ACP3X_FUTURE_REG_ACLK_0        0x1860
 
 static const struct sof_amd_acp_desc renoir_chip_info = {
-       .host_bridge_id = HOST_BRIDGE_CZN,
        .pgfsm_base     = ACP3X_PGFSM_BASE,
        .ext_intr_stat  = ACP3X_EXT_INTR_STAT,
        .dsp_intr_base  = ACP3X_DSP_SW_INTR_BASE,
index 53f64d6bc91bae9e2ec506384a83b209a296860f..18734cd21abf3bbb9a1bd021c62e6a8df29e4748 100644 (file)
@@ -27,7 +27,6 @@
 
 static const struct sof_amd_acp_desc vangogh_chip_info = {
        .name           = "vangogh",
-       .host_bridge_id = HOST_BRIDGE_VGH,
        .pgfsm_base     = ACP5X_PGFSM_BASE,
        .ext_intr_stat  = ACP5X_EXT_INTR_STAT,
        .dsp_intr_base  = ACP5X_DSP_SW_INTR_BASE,