Skip to content

Commit d0dab6b

Browse files
Venkata-Prasad-Potturubroonie
authored andcommitted
ASoC: SOF: amd: Add sof support for vangogh platform
Add pci driver and platform driver to enable SOF support on ACP5x architecture based Vangogh platform. Signed-off-by: Venkata Prasad Potturu <venkataprasad.potturu@amd.com> Link: https://lore.kernel.org/r/20230809123534.287707-1-venkataprasad.potturu@amd.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 919a4a9 commit d0dab6b

6 files changed

Lines changed: 290 additions & 4 deletions

File tree

sound/soc/sof/amd/Kconfig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file is provided under a dual BSD/GPLv2 license. When using or
33
# redistributing this file, you may do so under either license.
44
#
5-
# Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
5+
# Copyright(c) 2021, 2023 Advanced Micro Devices, Inc. All rights reserved.
66

77
config SND_SOC_SOF_AMD_TOPLEVEL
88
tristate "SOF support for AMD audio DSPs"
@@ -34,6 +34,16 @@ config SND_SOC_SOF_AMD_RENOIR
3434
help
3535
Select this option for SOF support on AMD Renoir platform
3636

37+
config SND_SOC_SOF_AMD_VANGOGH
38+
tristate "SOF support for VANGOGH"
39+
depends on SND_SOC_SOF_PCI
40+
select SND_SOC_SOF_AMD_COMMON
41+
help
42+
Select this option for SOF support
43+
on AMD Vangogh platform.
44+
Say Y if you want to enable SOF on Vangogh.
45+
If unsure select "N".
46+
3747
config SND_SOC_SOF_AMD_REMBRANDT
3848
tristate "SOF support for REMBRANDT"
3949
depends on SND_SOC_SOF_PCI

sound/soc/sof/amd/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
# This file is provided under a dual BSD/GPLv2 license. When using or
33
# redistributing this file, you may do so under either license.
44
#
5-
# Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
5+
# Copyright(c) 2021, 2023 Advanced Micro Devices, Inc. All rights reserved.
66

77
snd-sof-amd-acp-objs := acp.o acp-loader.o acp-ipc.o acp-pcm.o acp-stream.o acp-trace.o acp-common.o
88
snd-sof-amd-acp-$(CONFIG_SND_SOC_SOF_ACP_PROBES) = acp-probes.o
99
snd-sof-amd-renoir-objs := pci-rn.o renoir.o
1010
snd-sof-amd-rembrandt-objs := pci-rmb.o rembrandt.o
11+
snd-sof-amd-vangogh-objs := pci-vangogh.o vangogh.o
1112

1213
obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o
1314
obj-$(CONFIG_SND_SOC_SOF_AMD_RENOIR) +=snd-sof-amd-renoir.o
1415
obj-$(CONFIG_SND_SOC_SOF_AMD_REMBRANDT) +=snd-sof-amd-rembrandt.o
16+
obj-$(CONFIG_SND_SOC_SOF_AMD_VANGOGH) +=snd-sof-amd-vangogh.o

sound/soc/sof/amd/acp-dsp-offset.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* This file is provided under a dual BSD/GPLv2 license. When using or
44
* redistributing this file, you may do so under either license.
55
*
6-
* Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
6+
* Copyright(c) 2021, 2023 Advanced Micro Devices, Inc. All rights reserved.
77
*
88
* Author: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
99
*/
@@ -49,27 +49,33 @@
4949
#define ACP_CONTROL 0x1004
5050

5151
#define ACP3X_I2S_PIN_CONFIG 0x1400
52+
#define ACP5X_I2S_PIN_CONFIG 0x1400
5253
#define ACP6X_I2S_PIN_CONFIG 0x1440
5354

5455
/* Registers offsets from ACP_PGFSM block */
5556
#define ACP3X_PGFSM_BASE 0x141C
57+
#define ACP5X_PGFSM_BASE 0x1424
5658
#define ACP6X_PGFSM_BASE 0x1024
5759
#define PGFSM_CONTROL_OFFSET 0x0
5860
#define PGFSM_STATUS_OFFSET 0x4
5961
#define ACP3X_CLKMUX_SEL 0x1424
62+
#define ACP5X_CLKMUX_SEL 0x142C
6063
#define ACP6X_CLKMUX_SEL 0x102C
6164

6265
/* Registers from ACP_INTR block */
6366
#define ACP3X_EXT_INTR_STAT 0x1808
67+
#define ACP5X_EXT_INTR_STAT 0x1808
6468
#define ACP6X_EXT_INTR_STAT 0x1A0C
6569

6670
#define ACP3X_DSP_SW_INTR_BASE 0x1814
71+
#define ACP5X_DSP_SW_INTR_BASE 0x1814
6772
#define ACP6X_DSP_SW_INTR_BASE 0x1808
6873
#define DSP_SW_INTR_CNTL_OFFSET 0x0
6974
#define DSP_SW_INTR_STAT_OFFSET 0x4
7075
#define DSP_SW_INTR_TRIG_OFFSET 0x8
7176
#define ACP_ERROR_STATUS 0x18C4
7277
#define ACP3X_AXI2DAGB_SEM_0 0x1880
78+
#define ACP5X_AXI2DAGB_SEM_0 0x1884
7379
#define ACP6X_AXI2DAGB_SEM_0 0x1874
7480

7581
/* Registers from ACP_SHA block */

sound/soc/sof/amd/acp.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* This file is provided under a dual BSD/GPLv2 license. When using or
44
* redistributing this file, you may do so under either license.
55
*
6-
* Copyright(c) 2021 Advanced Micro Devices, Inc. All rights reserved.
6+
* Copyright(c) 2021, 2023 Advanced Micro Devices, Inc. All rights reserved.
77
*
88
* Author: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com>
99
*/
@@ -32,6 +32,7 @@
3232

3333
#define ACP_DSP_INTR_EN_MASK 0x00000001
3434
#define ACP3X_SRAM_PTE_OFFSET 0x02050000
35+
#define ACP5X_SRAM_PTE_OFFSET 0x02050000
3536
#define ACP6X_SRAM_PTE_OFFSET 0x03800000
3637
#define PAGE_SIZE_4K_ENABLE 0x2
3738
#define ACP_PAGE_SIZE 0x1000
@@ -56,9 +57,11 @@
5657
#define ACP_DSP_TO_HOST_IRQ 0x04
5758

5859
#define ACP_RN_PCI_ID 0x01
60+
#define ACP_VANGOGH_PCI_ID 0x50
5961
#define ACP_RMB_PCI_ID 0x6F
6062

6163
#define HOST_BRIDGE_CZN 0x1630
64+
#define HOST_BRIDGE_VGH 0x1645
6265
#define HOST_BRIDGE_RMB 0x14B5
6366
#define ACP_SHA_STAT 0x8000
6467
#define ACP_PSP_TIMEOUT_US 1000000
@@ -163,6 +166,7 @@ struct acp_dsp_stream {
163166

164167
struct sof_amd_acp_desc {
165168
unsigned int rev;
169+
const char *name;
166170
unsigned int host_bridge_id;
167171
u32 pgfsm_base;
168172
u32 ext_intr_stat;
@@ -253,6 +257,8 @@ extern struct snd_sof_dsp_ops sof_acp_common_ops;
253257

254258
extern struct snd_sof_dsp_ops sof_renoir_ops;
255259
int sof_renoir_ops_init(struct snd_sof_dev *sdev);
260+
extern struct snd_sof_dsp_ops sof_vangogh_ops;
261+
int sof_vangogh_ops_init(struct snd_sof_dev *sdev);
256262
extern struct snd_sof_dsp_ops sof_rembrandt_ops;
257263
int sof_rembrandt_ops_init(struct snd_sof_dev *sdev);
258264

@@ -282,4 +288,5 @@ static inline const struct sof_amd_acp_desc *get_chip_info(struct snd_sof_pdata
282288
int acp_probes_register(struct snd_sof_dev *sdev);
283289
void acp_probes_unregister(struct snd_sof_dev *sdev);
284290

291+
extern struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[];
285292
#endif

sound/soc/sof/amd/pci-vangogh.c

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2+
//
3+
// This file is provided under a dual BSD/GPLv2 license. When using or
4+
// redistributing this file, you may do so under either license.
5+
//
6+
// Copyright(c) 2023 Advanced Micro Devices, Inc. All rights reserved.
7+
//
8+
// Authors: Venkata Prasad Potturu <venkataprasad.potturu@amd.com>
9+
10+
/*.
11+
* PCI interface for Vangogh ACP device
12+
*/
13+
14+
#include <linux/module.h>
15+
#include <linux/pci.h>
16+
#include <linux/platform_device.h>
17+
#include <sound/sof.h>
18+
#include <sound/soc-acpi.h>
19+
20+
#include "../ops.h"
21+
#include "../sof-pci-dev.h"
22+
#include "../../amd/mach-config.h"
23+
#include "acp.h"
24+
#include "acp-dsp-offset.h"
25+
26+
#define ACP5X_FUTURE_REG_ACLK_0 0x1864
27+
28+
static const struct sof_amd_acp_desc vangogh_chip_info = {
29+
.rev = 5,
30+
.name = "vangogh",
31+
.host_bridge_id = HOST_BRIDGE_VGH,
32+
.pgfsm_base = ACP5X_PGFSM_BASE,
33+
.ext_intr_stat = ACP5X_EXT_INTR_STAT,
34+
.dsp_intr_base = ACP5X_DSP_SW_INTR_BASE,
35+
.sram_pte_offset = ACP5X_SRAM_PTE_OFFSET,
36+
.hw_semaphore_offset = ACP5X_AXI2DAGB_SEM_0,
37+
.acp_clkmux_sel = ACP5X_CLKMUX_SEL,
38+
.probe_reg_offset = ACP5X_FUTURE_REG_ACLK_0,
39+
};
40+
41+
static const struct sof_dev_desc vangogh_desc = {
42+
.machines = snd_soc_acpi_amd_vangogh_sof_machines,
43+
.resindex_lpe_base = 0,
44+
.resindex_pcicfg_base = -1,
45+
.resindex_imr_base = -1,
46+
.irqindex_host_ipc = -1,
47+
.chip_info = &vangogh_chip_info,
48+
.ipc_supported_mask = BIT(SOF_IPC),
49+
.ipc_default = SOF_IPC,
50+
.default_fw_path = {
51+
[SOF_IPC] = "amd/sof",
52+
},
53+
.default_tplg_path = {
54+
[SOF_IPC] = "amd/sof-tplg",
55+
},
56+
.default_fw_filename = {
57+
[SOF_IPC] = "sof-vangogh.ri",
58+
},
59+
.nocodec_tplg_filename = "sof-acp.tplg",
60+
.ops = &sof_vangogh_ops,
61+
.ops_init = sof_vangogh_ops_init,
62+
};
63+
64+
static int acp_pci_vgh_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
65+
{
66+
unsigned int flag;
67+
68+
if (pci->revision != ACP_VANGOGH_PCI_ID)
69+
return -ENODEV;
70+
71+
flag = snd_amd_acp_find_config(pci);
72+
if (flag != FLAG_AMD_SOF && flag != FLAG_AMD_SOF_ONLY_DMIC)
73+
return -ENODEV;
74+
75+
return sof_pci_probe(pci, pci_id);
76+
};
77+
78+
static void acp_pci_vgh_remove(struct pci_dev *pci)
79+
{
80+
sof_pci_remove(pci);
81+
}
82+
83+
/* PCI IDs */
84+
static const struct pci_device_id vgh_pci_ids[] = {
85+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_PCI_DEV_ID),
86+
.driver_data = (unsigned long)&vangogh_desc},
87+
{ 0, }
88+
};
89+
MODULE_DEVICE_TABLE(pci, vgh_pci_ids);
90+
91+
/* pci_driver definition */
92+
static struct pci_driver snd_sof_pci_amd_vgh_driver = {
93+
.name = KBUILD_MODNAME,
94+
.id_table = vgh_pci_ids,
95+
.probe = acp_pci_vgh_probe,
96+
.remove = acp_pci_vgh_remove,
97+
.driver = {
98+
.pm = &sof_pci_pm,
99+
},
100+
};
101+
module_pci_driver(snd_sof_pci_amd_vgh_driver);
102+
103+
MODULE_LICENSE("Dual BSD/GPL");
104+
MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
105+
MODULE_IMPORT_NS(SND_SOC_SOF_PCI_DEV);

0 commit comments

Comments
 (0)