xref: /linux/sound/soc/amd/ps/ps-mach.c (revision 0c8327c07b2ecc4a4443b1dae407f0d4854b5ae1)
1*0c8327c0SSyed Saba Kareem // SPDX-License-Identifier: GPL-2.0+
2*0c8327c0SSyed Saba Kareem /*
3*0c8327c0SSyed Saba Kareem  * Machine driver for AMD Pink Sardine platform using DMIC
4*0c8327c0SSyed Saba Kareem  *
5*0c8327c0SSyed Saba Kareem  * Copyright 2022 Advanced Micro Devices, Inc.
6*0c8327c0SSyed Saba Kareem  */
7*0c8327c0SSyed Saba Kareem 
8*0c8327c0SSyed Saba Kareem #include <sound/soc.h>
9*0c8327c0SSyed Saba Kareem #include <sound/soc-dapm.h>
10*0c8327c0SSyed Saba Kareem #include <linux/module.h>
11*0c8327c0SSyed Saba Kareem #include <sound/pcm.h>
12*0c8327c0SSyed Saba Kareem #include <sound/pcm_params.h>
13*0c8327c0SSyed Saba Kareem #include <linux/io.h>
14*0c8327c0SSyed Saba Kareem #include <linux/dmi.h>
15*0c8327c0SSyed Saba Kareem 
16*0c8327c0SSyed Saba Kareem #include "acp62.h"
17*0c8327c0SSyed Saba Kareem 
18*0c8327c0SSyed Saba Kareem #define DRV_NAME "acp_ps_mach"
19*0c8327c0SSyed Saba Kareem 
20*0c8327c0SSyed Saba Kareem SND_SOC_DAILINK_DEF(acp62_pdm,
21*0c8327c0SSyed Saba Kareem 		    DAILINK_COMP_ARRAY(COMP_CPU("acp_ps_pdm_dma.0")));
22*0c8327c0SSyed Saba Kareem 
23*0c8327c0SSyed Saba Kareem SND_SOC_DAILINK_DEF(dmic_codec,
24*0c8327c0SSyed Saba Kareem 		    DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec.0",
25*0c8327c0SSyed Saba Kareem 						  "dmic-hifi")));
26*0c8327c0SSyed Saba Kareem 
27*0c8327c0SSyed Saba Kareem SND_SOC_DAILINK_DEF(pdm_platform,
28*0c8327c0SSyed Saba Kareem 		    DAILINK_COMP_ARRAY(COMP_PLATFORM("acp_ps_pdm_dma.0")));
29*0c8327c0SSyed Saba Kareem 
30*0c8327c0SSyed Saba Kareem static struct snd_soc_dai_link acp62_dai_pdm[] = {
31*0c8327c0SSyed Saba Kareem 	{
32*0c8327c0SSyed Saba Kareem 		.name = "acp62-dmic-capture",
33*0c8327c0SSyed Saba Kareem 		.stream_name = "DMIC capture",
34*0c8327c0SSyed Saba Kareem 		.capture_only = 1,
35*0c8327c0SSyed Saba Kareem 		SND_SOC_DAILINK_REG(acp62_pdm, dmic_codec, pdm_platform),
36*0c8327c0SSyed Saba Kareem 	},
37*0c8327c0SSyed Saba Kareem };
38*0c8327c0SSyed Saba Kareem 
39*0c8327c0SSyed Saba Kareem static struct snd_soc_card acp62_card = {
40*0c8327c0SSyed Saba Kareem 	.name = "acp62",
41*0c8327c0SSyed Saba Kareem 	.owner = THIS_MODULE,
42*0c8327c0SSyed Saba Kareem 	.dai_link = acp62_dai_pdm,
43*0c8327c0SSyed Saba Kareem 	.num_links = 1,
44*0c8327c0SSyed Saba Kareem };
45*0c8327c0SSyed Saba Kareem 
46*0c8327c0SSyed Saba Kareem static int acp62_probe(struct platform_device *pdev)
47*0c8327c0SSyed Saba Kareem {
48*0c8327c0SSyed Saba Kareem 	struct acp62_pdm *machine = NULL;
49*0c8327c0SSyed Saba Kareem 	struct snd_soc_card *card;
50*0c8327c0SSyed Saba Kareem 	int ret;
51*0c8327c0SSyed Saba Kareem 
52*0c8327c0SSyed Saba Kareem 	platform_set_drvdata(pdev, &acp62_card);
53*0c8327c0SSyed Saba Kareem 	card = platform_get_drvdata(pdev);
54*0c8327c0SSyed Saba Kareem 	acp62_card.dev = &pdev->dev;
55*0c8327c0SSyed Saba Kareem 
56*0c8327c0SSyed Saba Kareem 	snd_soc_card_set_drvdata(card, machine);
57*0c8327c0SSyed Saba Kareem 	ret = devm_snd_soc_register_card(&pdev->dev, card);
58*0c8327c0SSyed Saba Kareem 	if (ret) {
59*0c8327c0SSyed Saba Kareem 		return dev_err_probe(&pdev->dev, ret,
60*0c8327c0SSyed Saba Kareem 				"snd_soc_register_card(%s) failed\n",
61*0c8327c0SSyed Saba Kareem 				card->name);
62*0c8327c0SSyed Saba Kareem 	}
63*0c8327c0SSyed Saba Kareem 
64*0c8327c0SSyed Saba Kareem 	return 0;
65*0c8327c0SSyed Saba Kareem }
66*0c8327c0SSyed Saba Kareem 
67*0c8327c0SSyed Saba Kareem static struct platform_driver acp62_mach_driver = {
68*0c8327c0SSyed Saba Kareem 	.driver = {
69*0c8327c0SSyed Saba Kareem 		.name = "acp_ps_mach",
70*0c8327c0SSyed Saba Kareem 		.pm = &snd_soc_pm_ops,
71*0c8327c0SSyed Saba Kareem 	},
72*0c8327c0SSyed Saba Kareem 	.probe = acp62_probe,
73*0c8327c0SSyed Saba Kareem };
74*0c8327c0SSyed Saba Kareem 
75*0c8327c0SSyed Saba Kareem module_platform_driver(acp62_mach_driver);
76*0c8327c0SSyed Saba Kareem 
77*0c8327c0SSyed Saba Kareem MODULE_AUTHOR("Syed.SabaKareem@amd.com");
78*0c8327c0SSyed Saba Kareem MODULE_LICENSE("GPL v2");
79*0c8327c0SSyed Saba Kareem MODULE_ALIAS("platform:" DRV_NAME);
80