xref: /linux/sound/soc/amd/ps/ps-mach.c (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
14c754938SVijendar Mukunda // SPDX-License-Identifier: GPL-2.0-only
20c8327c0SSyed Saba Kareem /*
30c8327c0SSyed Saba Kareem  * Machine driver for AMD Pink Sardine platform using DMIC
40c8327c0SSyed Saba Kareem  *
50c8327c0SSyed Saba Kareem  * Copyright 2022 Advanced Micro Devices, Inc.
60c8327c0SSyed Saba Kareem  */
70c8327c0SSyed Saba Kareem 
80c8327c0SSyed Saba Kareem #include <sound/soc.h>
90c8327c0SSyed Saba Kareem #include <sound/soc-dapm.h>
100c8327c0SSyed Saba Kareem #include <linux/module.h>
110c8327c0SSyed Saba Kareem #include <sound/pcm.h>
120c8327c0SSyed Saba Kareem #include <sound/pcm_params.h>
130c8327c0SSyed Saba Kareem #include <linux/io.h>
140c8327c0SSyed Saba Kareem #include <linux/dmi.h>
150c8327c0SSyed Saba Kareem 
164b192114Ssyed saba kareem #include "acp63.h"
170c8327c0SSyed Saba Kareem 
180c8327c0SSyed Saba Kareem #define DRV_NAME "acp_ps_mach"
190c8327c0SSyed Saba Kareem 
204b192114Ssyed saba kareem SND_SOC_DAILINK_DEF(acp63_pdm,
210c8327c0SSyed Saba Kareem 		    DAILINK_COMP_ARRAY(COMP_CPU("acp_ps_pdm_dma.0")));
220c8327c0SSyed Saba Kareem 
230c8327c0SSyed Saba Kareem SND_SOC_DAILINK_DEF(dmic_codec,
240c8327c0SSyed Saba Kareem 		    DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec.0",
250c8327c0SSyed Saba Kareem 						  "dmic-hifi")));
260c8327c0SSyed Saba Kareem 
270c8327c0SSyed Saba Kareem SND_SOC_DAILINK_DEF(pdm_platform,
280c8327c0SSyed Saba Kareem 		    DAILINK_COMP_ARRAY(COMP_PLATFORM("acp_ps_pdm_dma.0")));
290c8327c0SSyed Saba Kareem 
304b192114Ssyed saba kareem static struct snd_soc_dai_link acp63_dai_pdm[] = {
310c8327c0SSyed Saba Kareem 	{
324b192114Ssyed saba kareem 		.name = "acp63-dmic-capture",
330c8327c0SSyed Saba Kareem 		.stream_name = "DMIC capture",
340c8327c0SSyed Saba Kareem 		.capture_only = 1,
354b192114Ssyed saba kareem 		SND_SOC_DAILINK_REG(acp63_pdm, dmic_codec, pdm_platform),
360c8327c0SSyed Saba Kareem 	},
370c8327c0SSyed Saba Kareem };
380c8327c0SSyed Saba Kareem 
394b192114Ssyed saba kareem static struct snd_soc_card acp63_card = {
404b192114Ssyed saba kareem 	.name = "acp63",
410c8327c0SSyed Saba Kareem 	.owner = THIS_MODULE,
424b192114Ssyed saba kareem 	.dai_link = acp63_dai_pdm,
430c8327c0SSyed Saba Kareem 	.num_links = 1,
440c8327c0SSyed Saba Kareem };
450c8327c0SSyed Saba Kareem 
acp63_probe(struct platform_device * pdev)464b192114Ssyed saba kareem static int acp63_probe(struct platform_device *pdev)
470c8327c0SSyed Saba Kareem {
484b192114Ssyed saba kareem 	struct acp63_pdm *machine = NULL;
490c8327c0SSyed Saba Kareem 	struct snd_soc_card *card;
500c8327c0SSyed Saba Kareem 	int ret;
510c8327c0SSyed Saba Kareem 
524b192114Ssyed saba kareem 	platform_set_drvdata(pdev, &acp63_card);
530c8327c0SSyed Saba Kareem 	card = platform_get_drvdata(pdev);
544b192114Ssyed saba kareem 	acp63_card.dev = &pdev->dev;
550c8327c0SSyed Saba Kareem 
560c8327c0SSyed Saba Kareem 	snd_soc_card_set_drvdata(card, machine);
570c8327c0SSyed Saba Kareem 	ret = devm_snd_soc_register_card(&pdev->dev, card);
580c8327c0SSyed Saba Kareem 	if (ret) {
590c8327c0SSyed Saba Kareem 		return dev_err_probe(&pdev->dev, ret,
600c8327c0SSyed Saba Kareem 				"snd_soc_register_card(%s) failed\n",
610c8327c0SSyed Saba Kareem 				card->name);
620c8327c0SSyed Saba Kareem 	}
630c8327c0SSyed Saba Kareem 
640c8327c0SSyed Saba Kareem 	return 0;
650c8327c0SSyed Saba Kareem }
660c8327c0SSyed Saba Kareem 
674b192114Ssyed saba kareem static struct platform_driver acp63_mach_driver = {
680c8327c0SSyed Saba Kareem 	.driver = {
690c8327c0SSyed Saba Kareem 		.name = "acp_ps_mach",
700c8327c0SSyed Saba Kareem 		.pm = &snd_soc_pm_ops,
710c8327c0SSyed Saba Kareem 	},
724b192114Ssyed saba kareem 	.probe = acp63_probe,
730c8327c0SSyed Saba Kareem };
740c8327c0SSyed Saba Kareem 
754b192114Ssyed saba kareem module_platform_driver(acp63_mach_driver);
760c8327c0SSyed Saba Kareem 
770c8327c0SSyed Saba Kareem MODULE_AUTHOR("Syed.SabaKareem@amd.com");
78*fe833e43SJeff Johnson MODULE_DESCRIPTION("AMD Pink Sardine support for DMIC");
790c8327c0SSyed Saba Kareem MODULE_LICENSE("GPL v2");
800c8327c0SSyed Saba Kareem MODULE_ALIAS("platform:" DRV_NAME);
81