1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Machine driver for AMD Yellow Carp platform using DMIC 4 * 5 * Copyright 2021 Advanced Micro Devices, Inc. 6 */ 7 8 #include <sound/soc.h> 9 #include <sound/soc-dapm.h> 10 #include <linux/module.h> 11 #include <sound/pcm.h> 12 #include <sound/pcm_params.h> 13 #include <linux/io.h> 14 #include <linux/dmi.h> 15 16 #include "acp6x.h" 17 18 #define DRV_NAME "acp_yc_mach" 19 20 SND_SOC_DAILINK_DEF(acp6x_pdm, 21 DAILINK_COMP_ARRAY(COMP_CPU("acp_yc_pdm_dma.0"))); 22 23 SND_SOC_DAILINK_DEF(dmic_codec, 24 DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec.0", 25 "dmic-hifi"))); 26 27 SND_SOC_DAILINK_DEF(pdm_platform, 28 DAILINK_COMP_ARRAY(COMP_PLATFORM("acp_yc_pdm_dma.0"))); 29 30 static struct snd_soc_dai_link acp6x_dai_pdm[] = { 31 { 32 .name = "acp6x-dmic-capture", 33 .stream_name = "DMIC capture", 34 .capture_only = 1, 35 SND_SOC_DAILINK_REG(acp6x_pdm, dmic_codec, pdm_platform), 36 }, 37 }; 38 39 static struct snd_soc_card acp6x_card = { 40 .name = "acp6x", 41 .owner = THIS_MODULE, 42 .dai_link = acp6x_dai_pdm, 43 .num_links = 1, 44 }; 45 46 static const struct dmi_system_id yc_acp_quirk_table[] = { 47 { 48 .matches = { 49 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 50 DMI_MATCH(DMI_PRODUCT_NAME, "21D2"), 51 } 52 }, 53 { 54 .matches = { 55 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 56 DMI_MATCH(DMI_PRODUCT_NAME, "21D3"), 57 } 58 }, 59 { 60 .matches = { 61 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 62 DMI_MATCH(DMI_PRODUCT_NAME, "21D4"), 63 } 64 }, 65 { 66 .matches = { 67 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 68 DMI_MATCH(DMI_PRODUCT_NAME, "21D5"), 69 } 70 }, 71 { 72 .matches = { 73 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 74 DMI_MATCH(DMI_PRODUCT_NAME, "21CF"), 75 } 76 }, 77 { 78 .matches = { 79 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 80 DMI_MATCH(DMI_PRODUCT_NAME, "21CG"), 81 } 82 }, 83 { 84 .matches = { 85 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 86 DMI_MATCH(DMI_PRODUCT_NAME, "21CQ"), 87 } 88 }, 89 { 90 .matches = { 91 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 92 DMI_MATCH(DMI_PRODUCT_NAME, "21CR"), 93 } 94 }, 95 { 96 .matches = { 97 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 98 DMI_MATCH(DMI_PRODUCT_NAME, "21AW"), 99 } 100 }, 101 { 102 .matches = { 103 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 104 DMI_MATCH(DMI_PRODUCT_NAME, "21AX"), 105 } 106 }, 107 { 108 .matches = { 109 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 110 DMI_MATCH(DMI_PRODUCT_NAME, "21BN"), 111 } 112 }, 113 { 114 .matches = { 115 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 116 DMI_MATCH(DMI_PRODUCT_NAME, "21BQ"), 117 } 118 }, 119 { 120 .matches = { 121 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 122 DMI_MATCH(DMI_PRODUCT_NAME, "21CH"), 123 } 124 }, 125 { 126 .matches = { 127 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 128 DMI_MATCH(DMI_PRODUCT_NAME, "21CJ"), 129 } 130 }, 131 { 132 .matches = { 133 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 134 DMI_MATCH(DMI_PRODUCT_NAME, "21CK"), 135 } 136 }, 137 { 138 .matches = { 139 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 140 DMI_MATCH(DMI_PRODUCT_NAME, "21CL"), 141 } 142 }, 143 { 144 .matches = { 145 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 146 DMI_MATCH(DMI_PRODUCT_NAME, "21D8"), 147 } 148 }, 149 { 150 .matches = { 151 DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), 152 DMI_MATCH(DMI_PRODUCT_NAME, "21D9"), 153 } 154 }, 155 {} 156 }; 157 158 static int acp6x_probe(struct platform_device *pdev) 159 { 160 struct acp6x_pdm *machine = NULL; 161 struct snd_soc_card *card; 162 int ret; 163 const struct dmi_system_id *dmi_id; 164 165 dmi_id = dmi_first_match(yc_acp_quirk_table); 166 if (!dmi_id) 167 return -ENODEV; 168 card = &acp6x_card; 169 acp6x_card.dev = &pdev->dev; 170 171 platform_set_drvdata(pdev, card); 172 snd_soc_card_set_drvdata(card, machine); 173 ret = devm_snd_soc_register_card(&pdev->dev, card); 174 if (ret) { 175 return dev_err_probe(&pdev->dev, ret, 176 "snd_soc_register_card(%s) failed\n", 177 card->name); 178 } 179 return 0; 180 } 181 182 static struct platform_driver acp6x_mach_driver = { 183 .driver = { 184 .name = "acp_yc_mach", 185 .pm = &snd_soc_pm_ops, 186 }, 187 .probe = acp6x_probe, 188 }; 189 190 module_platform_driver(acp6x_mach_driver); 191 192 MODULE_AUTHOR("Vijendar.Mukunda@amd.com"); 193 MODULE_LICENSE("GPL v2"); 194 MODULE_ALIAS("platform:" DRV_NAME); 195