Skip to content

Commit fc902a8

Browse files
vijendarmukundaplbossart
authored andcommitted
ASoC: SOF: amd: add support for acp6.3 based platform
Add SOF support for ACP6.3 version based platform Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
1 parent a6c6ae9 commit fc902a8

5 files changed

Lines changed: 267 additions & 0 deletions

File tree

sound/soc/sof/amd/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,13 @@ config SND_SOC_SOF_ACP_PROBES
6060
This option is not user-selectable but automatically handled by
6161
'select' statements at a higher level
6262

63+
config SND_SOC_SOF_AMD_ACP63
64+
tristate "SOF support for ACP6.3 platform"
65+
depends on SND_SOC_SOF_PCI
66+
select SND_SOC_SOF_AMD_COMMON
67+
help
68+
Select this option for SOF support on
69+
AMD ACP6.3 version based platforms.
70+
Say Y if you want to enable SOF on ACP6.3 based platform.
71+
If unsure select "N".
6372
endif

sound/soc/sof/amd/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ 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
1111
snd-sof-amd-vangogh-objs := pci-vangogh.o vangogh.o
12+
snd-sof-amd-acp63-objs := pci-acp63.o acp63.o
1213

1314
obj-$(CONFIG_SND_SOC_SOF_AMD_COMMON) += snd-sof-amd-acp.o
1415
obj-$(CONFIG_SND_SOC_SOF_AMD_RENOIR) +=snd-sof-amd-renoir.o
1516
obj-$(CONFIG_SND_SOC_SOF_AMD_REMBRANDT) +=snd-sof-amd-rembrandt.o
1617
obj-$(CONFIG_SND_SOC_SOF_AMD_VANGOGH) +=snd-sof-amd-vangogh.o
18+
obj-$(CONFIG_SND_SOC_SOF_AMD_ACP63) +=snd-sof-amd-acp63.o

sound/soc/sof/amd/acp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,12 @@
6262
#define ACP_RN_PCI_ID 0x01
6363
#define ACP_VANGOGH_PCI_ID 0x50
6464
#define ACP_RMB_PCI_ID 0x6F
65+
#define ACP63_PCI_ID 0x63
6566

6667
#define HOST_BRIDGE_CZN 0x1630
6768
#define HOST_BRIDGE_VGH 0x1645
6869
#define HOST_BRIDGE_RMB 0x14B5
70+
#define HOST_BRIDGE_ACP63 0x14E8
6971
#define ACP_SHA_STAT 0x8000
7072
#define ACP_PSP_TIMEOUT_US 1000000
7173
#define ACP_EXT_INTR_ERROR_STAT 0x20000000
@@ -273,6 +275,8 @@ extern struct snd_sof_dsp_ops sof_vangogh_ops;
273275
int sof_vangogh_ops_init(struct snd_sof_dev *sdev);
274276
extern struct snd_sof_dsp_ops sof_rembrandt_ops;
275277
int sof_rembrandt_ops_init(struct snd_sof_dev *sdev);
278+
extern struct snd_sof_dsp_ops sof_acp63_ops;
279+
int sof_acp63_ops_init(struct snd_sof_dev *sdev);
276280

277281
struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev);
278282
/* Machine configuration */

sound/soc/sof/amd/acp63.c

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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.
7+
//
8+
// Authors: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
9+
10+
/*
11+
* Hardware interface for Audio DSP on ACP6.3 version based platform
12+
*/
13+
14+
#include <linux/platform_device.h>
15+
#include <linux/module.h>
16+
17+
#include "../ops.h"
18+
#include "../sof-audio.h"
19+
#include "acp.h"
20+
#include "acp-dsp-offset.h"
21+
22+
#define I2S_HS_INSTANCE 0
23+
#define I2S_BT_INSTANCE 1
24+
#define I2S_SP_INSTANCE 2
25+
#define PDM_DMIC_INSTANCE 3
26+
#define I2S_HS_VIRTUAL_INSTANCE 4
27+
28+
static struct snd_soc_dai_driver acp63_sof_dai[] = {
29+
[I2S_HS_INSTANCE] = {
30+
.id = I2S_HS_INSTANCE,
31+
.name = "acp-sof-hs",
32+
.playback = {
33+
.rates = SNDRV_PCM_RATE_8000_96000,
34+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
35+
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
36+
.channels_min = 2,
37+
.channels_max = 8,
38+
.rate_min = 8000,
39+
.rate_max = 96000,
40+
},
41+
.capture = {
42+
.rates = SNDRV_PCM_RATE_8000_48000,
43+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
44+
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
45+
/* Supporting only stereo for I2S HS controller capture */
46+
.channels_min = 2,
47+
.channels_max = 2,
48+
.rate_min = 8000,
49+
.rate_max = 48000,
50+
},
51+
},
52+
53+
[I2S_BT_INSTANCE] = {
54+
.id = I2S_BT_INSTANCE,
55+
.name = "acp-sof-bt",
56+
.playback = {
57+
.rates = SNDRV_PCM_RATE_8000_96000,
58+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
59+
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
60+
.channels_min = 2,
61+
.channels_max = 8,
62+
.rate_min = 8000,
63+
.rate_max = 96000,
64+
},
65+
.capture = {
66+
.rates = SNDRV_PCM_RATE_8000_48000,
67+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
68+
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
69+
/* Supporting only stereo for I2S BT controller capture */
70+
.channels_min = 2,
71+
.channels_max = 2,
72+
.rate_min = 8000,
73+
.rate_max = 48000,
74+
},
75+
},
76+
77+
[I2S_SP_INSTANCE] = {
78+
.id = I2S_SP_INSTANCE,
79+
.name = "acp-sof-sp",
80+
.playback = {
81+
.rates = SNDRV_PCM_RATE_8000_96000,
82+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
83+
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
84+
.channels_min = 2,
85+
.channels_max = 8,
86+
.rate_min = 8000,
87+
.rate_max = 96000,
88+
},
89+
.capture = {
90+
.rates = SNDRV_PCM_RATE_8000_48000,
91+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
92+
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
93+
/* Supporting only stereo for I2S SP controller capture */
94+
.channels_min = 2,
95+
.channels_max = 2,
96+
.rate_min = 8000,
97+
.rate_max = 48000,
98+
},
99+
},
100+
101+
[PDM_DMIC_INSTANCE] = {
102+
.id = PDM_DMIC_INSTANCE,
103+
.name = "acp-sof-dmic",
104+
.capture = {
105+
.rates = SNDRV_PCM_RATE_8000_48000,
106+
.formats = SNDRV_PCM_FMTBIT_S32_LE,
107+
.channels_min = 2,
108+
.channels_max = 4,
109+
.rate_min = 8000,
110+
.rate_max = 48000,
111+
},
112+
},
113+
114+
[I2S_HS_VIRTUAL_INSTANCE] = {
115+
.id = I2S_HS_VIRTUAL_INSTANCE,
116+
.name = "acp-sof-hs-virtual",
117+
.playback = {
118+
.rates = SNDRV_PCM_RATE_8000_96000,
119+
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 |
120+
SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_LE,
121+
.channels_min = 2,
122+
.channels_max = 8,
123+
.rate_min = 8000,
124+
.rate_max = 96000,
125+
},
126+
},
127+
};
128+
129+
/* Phoenix ops */
130+
struct snd_sof_dsp_ops sof_acp63_ops;
131+
EXPORT_SYMBOL_NS(sof_acp63_ops, SND_SOC_SOF_AMD_COMMON);
132+
133+
int sof_acp63_ops_init(struct snd_sof_dev *sdev)
134+
{
135+
/* common defaults */
136+
memcpy(&sof_acp63_ops, &sof_acp_common_ops, sizeof(struct snd_sof_dsp_ops));
137+
138+
sof_acp63_ops.drv = acp63_sof_dai;
139+
sof_acp63_ops.num_drv = ARRAY_SIZE(acp63_sof_dai);
140+
141+
return 0;
142+
}
143+
144+
MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
145+
MODULE_DESCRIPTION("ACP63 SOF Driver");
146+
MODULE_LICENSE("Dual BSD/GPL");

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

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
9+
10+
/*.
11+
* PCI interface for ACP6.3 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 ACP6X_FUTURE_REG_ACLK_0 0x1854
27+
#define ACP6x_REG_START 0x1240000
28+
#define ACP6x_REG_END 0x125C000
29+
30+
static const struct sof_amd_acp_desc acp63_chip_info = {
31+
.rev = 6,
32+
.host_bridge_id = HOST_BRIDGE_ACP63,
33+
.pgfsm_base = ACP6X_PGFSM_BASE,
34+
.ext_intr_stat = ACP6X_EXT_INTR_STAT,
35+
.dsp_intr_base = ACP6X_DSP_SW_INTR_BASE,
36+
.sram_pte_offset = ACP6X_SRAM_PTE_OFFSET,
37+
.hw_semaphore_offset = ACP6X_AXI2DAGB_SEM_0,
38+
.fusion_dsp_offset = ACP6X_DSP_FUSION_RUNSTALL,
39+
.probe_reg_offset = ACP6X_FUTURE_REG_ACLK_0,
40+
};
41+
42+
static const struct sof_dev_desc acp63_desc = {
43+
.machines = snd_soc_acpi_amd_acp63_sof_machines,
44+
.resindex_lpe_base = 0,
45+
.resindex_pcicfg_base = -1,
46+
.resindex_imr_base = -1,
47+
.irqindex_host_ipc = -1,
48+
.chip_info = &acp63_chip_info,
49+
.ipc_supported_mask = BIT(SOF_IPC_TYPE_3),
50+
.ipc_default = SOF_IPC_TYPE_3,
51+
.default_fw_path = {
52+
[SOF_IPC_TYPE_3] = "amd/sof",
53+
},
54+
.default_tplg_path = {
55+
[SOF_IPC_TYPE_3] = "amd/sof-tplg",
56+
},
57+
.default_fw_filename = {
58+
[SOF_IPC_TYPE_3] = "sof-acp_6_3.ri",
59+
},
60+
.nocodec_tplg_filename = "sof-acp.tplg",
61+
.ops = &sof_acp63_ops,
62+
.ops_init = sof_acp63_ops_init,
63+
};
64+
65+
static int acp63_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
66+
{
67+
unsigned int flag;
68+
69+
if (pci->revision != ACP63_PCI_ID)
70+
return -ENODEV;
71+
72+
flag = snd_amd_acp_find_config(pci);
73+
if (flag != FLAG_AMD_SOF && flag != FLAG_AMD_SOF_ONLY_DMIC)
74+
return -ENODEV;
75+
76+
return sof_pci_probe(pci, pci_id);
77+
};
78+
79+
static void acp63_pci_remove(struct pci_dev *pci)
80+
{
81+
sof_pci_remove(pci);
82+
}
83+
84+
/* PCI IDs */
85+
static const struct pci_device_id acp63_pci_ids[] = {
86+
{ PCI_DEVICE(PCI_VENDOR_ID_AMD, ACP_PCI_DEV_ID),
87+
.driver_data = (unsigned long)&acp63_desc},
88+
{ 0, }
89+
};
90+
MODULE_DEVICE_TABLE(pci, acp63_pci_ids);
91+
92+
/* pci_driver definition */
93+
static struct pci_driver snd_sof_pci_amd_acp63_driver = {
94+
.name = KBUILD_MODNAME,
95+
.id_table = acp63_pci_ids,
96+
.probe = acp63_pci_probe,
97+
.remove = acp63_pci_remove,
98+
.driver = {
99+
.pm = &sof_pci_pm,
100+
},
101+
};
102+
module_pci_driver(snd_sof_pci_amd_acp63_driver);
103+
104+
MODULE_LICENSE("Dual BSD/GPL");
105+
MODULE_IMPORT_NS(SND_SOC_SOF_AMD_COMMON);
106+
MODULE_IMPORT_NS(SND_SOC_SOF_PCI_DEV);

0 commit comments

Comments
 (0)