Skip to content

Commit 6e60db7

Browse files
Venkata-Prasad-Potturubroonie
authored andcommitted
ASoC: amd: acp: Refactor acp machine select
Refactor and move acp machine select function from acp platform driver to acp pci driver and assign platform specific acpi machines to chip->machines. Signed-off-by: Venkata Prasad Potturu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a8b9d2d commit 6e60db7

File tree

8 files changed

+114
-124
lines changed

8 files changed

+114
-124
lines changed

sound/soc/amd/acp/acp-legacy-common.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <linux/pci.h>
1717
#include <linux/export.h>
1818

19+
#include "../mach-config.h"
20+
1921
#define ACP_RENOIR_PDM_ADDR 0x02
2022
#define ACP_REMBRANDT_PDM_ADDR 0x03
2123
#define ACP63_PDM_ADDR 0x02
@@ -350,6 +352,32 @@ int acp_deinit(struct acp_chip_info *chip)
350352
return 0;
351353
}
352354
EXPORT_SYMBOL_NS_GPL(acp_deinit, "SND_SOC_ACP_COMMON");
355+
int acp_machine_select(struct acp_chip_info *chip)
356+
{
357+
struct snd_soc_acpi_mach *mach;
358+
int size, platform;
359+
360+
if (chip->flag == FLAG_AMD_LEGACY_ONLY_DMIC) {
361+
platform = chip->acp_rev;
362+
chip->mach_dev = platform_device_register_data(chip->dev, "acp-pdm-mach",
363+
PLATFORM_DEVID_NONE, &platform,
364+
sizeof(platform));
365+
} else {
366+
size = sizeof(*chip->machines);
367+
mach = snd_soc_acpi_find_machine(chip->machines);
368+
if (!mach) {
369+
dev_err(chip->dev, "warning: No matching ASoC machine driver found\n");
370+
return -EINVAL;
371+
}
372+
mach->mach_params.subsystem_rev = chip->acp_rev;
373+
chip->mach_dev = platform_device_register_data(chip->dev, mach->drv_name,
374+
PLATFORM_DEVID_NONE, mach, size);
375+
}
376+
if (IS_ERR(chip->mach_dev))
377+
dev_warn(chip->dev, "Unable to register Machine device\n");
378+
return 0;
379+
}
380+
EXPORT_SYMBOL_NS_GPL(acp_machine_select, "SND_SOC_ACP_COMMON");
353381

354382
static void check_acp3x_config(struct acp_chip_info *chip)
355383
{

sound/soc/amd/acp/acp-pci.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,23 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
127127
case 0x01:
128128
chip->name = "acp_asoc_renoir";
129129
chip->acp_hw_ops_init = acp31_hw_ops_init;
130+
chip->machines = snd_soc_acpi_amd_acp_machines;
130131
break;
131132
case 0x6f:
132133
chip->name = "acp_asoc_rembrandt";
133134
chip->acp_hw_ops_init = acp6x_hw_ops_init;
135+
chip->machines = snd_soc_acpi_amd_rmb_acp_machines;
134136
break;
135137
case 0x63:
136138
chip->name = "acp_asoc_acp63";
137139
chip->acp_hw_ops_init = acp63_hw_ops_init;
140+
chip->machines = snd_soc_acpi_amd_acp63_acp_machines;
138141
break;
139142
case 0x70:
140143
case 0x71:
141144
chip->name = "acp_asoc_acp70";
142145
chip->acp_hw_ops_init = acp70_hw_ops_init;
146+
chip->machines = snd_soc_acpi_amd_acp70_acp_machines;
143147
break;
144148
default:
145149
dev_err(dev, "Unsupported device revision:0x%x\n", pci->revision);
@@ -175,6 +179,7 @@ static int acp_pci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id
175179
chip->chip_pdev = chip->acp_plat_dev;
176180
chip->dev = &chip->acp_plat_dev->dev;
177181

182+
acp_machine_select(chip);
178183
skip_pdev_creation:
179184
dev_set_drvdata(&pci->dev, chip);
180185
pm_runtime_set_autosuspend_delay(&pci->dev, 2000);
@@ -242,6 +247,8 @@ static void acp_pci_remove(struct pci_dev *pci)
242247
platform_device_unregister(chip->dmic_codec_dev);
243248
if (chip->acp_plat_dev)
244249
platform_device_unregister(chip->acp_plat_dev);
250+
if (chip->mach_dev)
251+
platform_device_unregister(chip->mach_dev);
245252

246253
ret = acp_hw_deinit(chip);
247254
if (ret)

sound/soc/amd/acp/acp-platform.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <linux/dma-mapping.h>
2222

2323
#include "amd.h"
24-
#include "../mach-config.h"
2524
#include "acp-mach.h"
2625

2726
#define DRV_NAME "acp_i2s_dma"
@@ -108,33 +107,6 @@ static const struct snd_pcm_hardware acp6x_pcm_hardware_capture = {
108107
.periods_max = CAPTURE_MAX_NUM_PERIODS,
109108
};
110109

111-
int acp_machine_select(struct acp_dev_data *adata)
112-
{
113-
struct snd_soc_acpi_mach *mach;
114-
int size, platform;
115-
116-
if (adata->flag == FLAG_AMD_LEGACY_ONLY_DMIC) {
117-
platform = adata->acp_rev;
118-
adata->mach_dev = platform_device_register_data(adata->dev, "acp-pdm-mach",
119-
PLATFORM_DEVID_NONE, &platform,
120-
sizeof(platform));
121-
} else {
122-
size = sizeof(*adata->machines);
123-
mach = snd_soc_acpi_find_machine(adata->machines);
124-
if (!mach) {
125-
dev_err(adata->dev, "warning: No matching ASoC machine driver found\n");
126-
return -EINVAL;
127-
}
128-
mach->mach_params.subsystem_rev = adata->acp_rev;
129-
adata->mach_dev = platform_device_register_data(adata->dev, mach->drv_name,
130-
PLATFORM_DEVID_NONE, mach, size);
131-
}
132-
if (IS_ERR(adata->mach_dev))
133-
dev_warn(adata->dev, "Unable to register Machine device\n");
134-
return 0;
135-
}
136-
EXPORT_SYMBOL_NS_GPL(acp_machine_select, "SND_SOC_ACP_COMMON");
137-
138110
static irqreturn_t i2s_irq_handler(int irq, void *data)
139111
{
140112
struct acp_dev_data *adata = data;

sound/soc/amd/acp/acp-rembrandt.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,6 @@ static struct acp_resource rsrc = {
4444
.sram_pte_offset = 0x03802800,
4545
};
4646

47-
static struct snd_soc_acpi_codecs amp_rt1019 = {
48-
.num_codecs = 1,
49-
.codecs = {"10EC1019"}
50-
};
51-
52-
static struct snd_soc_acpi_codecs amp_max = {
53-
.num_codecs = 1,
54-
.codecs = {"MX98360A"}
55-
};
56-
57-
static struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_acp_machines[] = {
58-
{
59-
.id = "10508825",
60-
.drv_name = "rmb-nau8825-max",
61-
.machine_quirk = snd_soc_acpi_codec_list,
62-
.quirk_data = &amp_max,
63-
},
64-
{
65-
.id = "AMDI0007",
66-
.drv_name = "rembrandt-acp",
67-
},
68-
{
69-
.id = "RTL5682",
70-
.drv_name = "rmb-rt5682s-rt1019",
71-
.machine_quirk = snd_soc_acpi_codec_list,
72-
.quirk_data = &amp_rt1019,
73-
},
74-
{},
75-
};
76-
7747
static struct snd_soc_dai_driver acp_rmb_dai[] = {
7848
{
7949
.name = "acp-i2s-sp",
@@ -230,8 +200,6 @@ static int rembrandt_audio_probe(struct platform_device *pdev)
230200
adata->acp_rev = chip->acp_rev;
231201
adata->flag = chip->flag;
232202
adata->is_i2s_config = chip->is_i2s_config;
233-
adata->machines = snd_soc_acpi_amd_rmb_acp_machines;
234-
acp_machine_select(adata);
235203

236204
dev_set_drvdata(dev, adata);
237205

sound/soc/amd/acp/acp-renoir.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,6 @@ static struct acp_resource rsrc = {
3636
.sram_pte_offset = 0x02052800,
3737
};
3838

39-
static struct snd_soc_acpi_codecs amp_rt1019 = {
40-
.num_codecs = 1,
41-
.codecs = {"10EC1019"}
42-
};
43-
44-
static struct snd_soc_acpi_codecs amp_max = {
45-
.num_codecs = 1,
46-
.codecs = {"MX98360A"}
47-
};
48-
49-
static struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[] = {
50-
{
51-
.id = "10EC5682",
52-
.drv_name = "acp3xalc56821019",
53-
.machine_quirk = snd_soc_acpi_codec_list,
54-
.quirk_data = &amp_rt1019,
55-
},
56-
{
57-
.id = "RTL5682",
58-
.drv_name = "acp3xalc5682sm98360",
59-
.machine_quirk = snd_soc_acpi_codec_list,
60-
.quirk_data = &amp_max,
61-
},
62-
{
63-
.id = "RTL5682",
64-
.drv_name = "acp3xalc5682s1019",
65-
.machine_quirk = snd_soc_acpi_codec_list,
66-
.quirk_data = &amp_rt1019,
67-
},
68-
{
69-
.id = "AMDI1019",
70-
.drv_name = "renoir-acp",
71-
},
72-
{
73-
.id = "ESSX8336",
74-
.drv_name = "acp3x-es83xx",
75-
},
76-
{},
77-
};
7839

7940
static struct snd_soc_dai_driver acp_renoir_dai[] = {
8041
{
@@ -188,9 +149,6 @@ static int renoir_audio_probe(struct platform_device *pdev)
188149
adata->acp_rev = chip->acp_rev;
189150
adata->flag = chip->flag;
190151

191-
adata->machines = snd_soc_acpi_amd_acp_machines;
192-
acp_machine_select(adata);
193-
194152
dev_set_drvdata(dev, adata);
195153
acp_enable_interrupts(adata);
196154
acp_platform_register(dev);

sound/soc/amd/acp/acp63.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,6 @@ static struct acp_resource rsrc = {
6262
.sram_pte_offset = 0x03802800,
6363
};
6464

65-
static struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_acp_machines[] = {
66-
{
67-
.id = "AMDI0052",
68-
.drv_name = "acp63-acp",
69-
},
70-
{},
71-
};
72-
7365
static struct snd_soc_dai_driver acp63_dai[] = {
7466
{
7567
.name = "acp-i2s-sp",
@@ -259,8 +251,6 @@ static int acp63_audio_probe(struct platform_device *pdev)
259251
adata->acp_rev = chip->acp_rev;
260252
adata->flag = chip->flag;
261253
adata->is_i2s_config = chip->is_i2s_config;
262-
adata->machines = snd_soc_acpi_amd_acp63_acp_machines;
263-
acp_machine_select(adata);
264254
dev_set_drvdata(dev, adata);
265255

266256
if (chip->is_i2s_config && rsrc.soc_mclk) {

sound/soc/amd/acp/acp70.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ static struct acp_resource rsrc = {
4040
.sram_pte_offset = 0x03800000,
4141
};
4242

43-
static struct snd_soc_acpi_mach snd_soc_acpi_amd_acp70_acp_machines[] = {
44-
{
45-
.id = "AMDI0029",
46-
.drv_name = "acp70-acp",
47-
},
48-
{},
49-
};
50-
5143
static struct snd_soc_dai_driver acp70_dai[] = {
5244
{
5345
.name = "acp-i2s-sp",
@@ -187,10 +179,8 @@ static int acp_acp70_audio_probe(struct platform_device *pdev)
187179
adata->dai_driver = acp70_dai;
188180
adata->num_dai = ARRAY_SIZE(acp70_dai);
189181
adata->rsrc = &rsrc;
190-
adata->machines = snd_soc_acpi_amd_acp70_acp_machines;
191182
adata->acp_rev = chip->acp_rev;
192183
adata->flag = chip->flag;
193-
acp_machine_select(adata);
194184

195185
dev_set_drvdata(dev, adata);
196186

sound/soc/amd/acp/amd.h

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ struct acp_chip_info {
149149
struct platform_device *chip_pdev;
150150
struct platform_device *dmic_codec_dev;
151151
struct platform_device *acp_plat_dev;
152+
struct platform_device *mach_dev;
153+
struct snd_soc_acpi_mach *machines;
152154
u32 addr;
153155
unsigned int flag; /* Distinguish b/w Legacy or Only PDM */
154156
bool is_pdm_dev; /* flag set to true when ACP PDM controller exists */
@@ -195,7 +197,6 @@ struct acp_dev_data {
195197
struct list_head stream_list;
196198
spinlock_t acp_lock;
197199

198-
struct snd_soc_acpi_mach *machines;
199200
struct platform_device *mach_dev;
200201

201202
u32 bclk_div;
@@ -245,13 +246,89 @@ enum acp_config {
245246
ACP_CONFIG_20,
246247
};
247248

249+
struct snd_soc_acpi_codecs amp_rt1019 = {
250+
.num_codecs = 1,
251+
.codecs = {"10EC1019"}
252+
};
253+
254+
struct snd_soc_acpi_codecs amp_max = {
255+
.num_codecs = 1,
256+
.codecs = {"MX98360A"}
257+
};
258+
259+
struct snd_soc_acpi_mach snd_soc_acpi_amd_acp_machines[] = {
260+
{
261+
.id = "10EC5682",
262+
.drv_name = "acp3xalc56821019",
263+
.machine_quirk = snd_soc_acpi_codec_list,
264+
.quirk_data = &amp_rt1019,
265+
},
266+
{
267+
.id = "RTL5682",
268+
.drv_name = "acp3xalc5682sm98360",
269+
.machine_quirk = snd_soc_acpi_codec_list,
270+
.quirk_data = &amp_max,
271+
},
272+
{
273+
.id = "RTL5682",
274+
.drv_name = "acp3xalc5682s1019",
275+
.machine_quirk = snd_soc_acpi_codec_list,
276+
.quirk_data = &amp_rt1019,
277+
},
278+
{
279+
.id = "AMDI1019",
280+
.drv_name = "renoir-acp",
281+
},
282+
{
283+
.id = "ESSX8336",
284+
.drv_name = "acp3x-es83xx",
285+
},
286+
{},
287+
};
288+
289+
struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_acp_machines[] = {
290+
{
291+
.id = "10508825",
292+
.drv_name = "rmb-nau8825-max",
293+
.machine_quirk = snd_soc_acpi_codec_list,
294+
.quirk_data = &amp_max,
295+
},
296+
{
297+
.id = "AMDI0007",
298+
.drv_name = "rembrandt-acp",
299+
},
300+
{
301+
.id = "RTL5682",
302+
.drv_name = "rmb-rt5682s-rt1019",
303+
.machine_quirk = snd_soc_acpi_codec_list,
304+
.quirk_data = &amp_rt1019,
305+
},
306+
{},
307+
};
308+
309+
struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_acp_machines[] = {
310+
{
311+
.id = "AMDI0052",
312+
.drv_name = "acp63-acp",
313+
},
314+
{},
315+
};
316+
317+
struct snd_soc_acpi_mach snd_soc_acpi_amd_acp70_acp_machines[] = {
318+
{
319+
.id = "AMDI0029",
320+
.drv_name = "acp70-acp",
321+
},
322+
{},
323+
};
324+
248325
extern const struct snd_soc_dai_ops asoc_acp_cpu_dai_ops;
249326
extern const struct snd_soc_dai_ops acp_dmic_dai_ops;
250327

251328
int acp_platform_register(struct device *dev);
252329
int acp_platform_unregister(struct device *dev);
253330

254-
int acp_machine_select(struct acp_dev_data *adata);
331+
int acp_machine_select(struct acp_chip_info *chip);
255332

256333
int acp_init(struct acp_chip_info *chip);
257334
int acp_deinit(struct acp_chip_info *chip);

0 commit comments

Comments
 (0)