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) 2021 Advanced Micro Devices, Inc. All rights reserved. 7 * 8 * Author: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> 9 */ 10 #ifndef __ACP_MACH_H 11 #define __ACP_MACH_H 12 13 #include <sound/core.h> 14 #include <sound/jack.h> 15 #include <sound/pcm_params.h> 16 #include <sound/soc-dapm.h> 17 #include <linux/input.h> 18 #include <linux/module.h> 19 #include <sound/soc.h> 20 21 #define TDM_CHANNELS 8 22 23 #define ACP_OPS(priv, cb) ((priv)->ops.cb) 24 25 #define acp_get_drvdata(card) ((struct acp_card_drvdata *)(card)->drvdata) 26 27 enum be_id { 28 HEADSET_BE_ID = 0, 29 AMP_BE_ID, 30 DMIC_BE_ID, 31 }; 32 33 enum cpu_endpoints { 34 NONE = 0, 35 I2S_HS, 36 I2S_SP, 37 I2S_BT, 38 DMIC, 39 }; 40 41 enum codec_endpoints { 42 DUMMY = 0, 43 RT5682, 44 RT1019, 45 MAX98360A, 46 RT5682S, 47 NAU8825, 48 NAU8821, 49 MAX98388, 50 ES83XX, 51 }; 52 53 enum platform_end_point { 54 RENOIR = 0, 55 REMBRANDT, 56 ACP63, 57 ACP70, 58 }; 59 60 struct acp_mach_ops { 61 int (*probe)(struct snd_soc_card *card); 62 int (*configure_link)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 63 int (*configure_widgets)(struct snd_soc_card *card); 64 int (*suspend_pre)(struct snd_soc_card *card); 65 int (*resume_post)(struct snd_soc_card *card); 66 }; 67 68 struct acp_card_drvdata { 69 unsigned int hs_cpu_id; 70 unsigned int amp_cpu_id; 71 unsigned int dmic_cpu_id; 72 unsigned int hs_codec_id; 73 unsigned int amp_codec_id; 74 unsigned int dmic_codec_id; 75 unsigned int dai_fmt; 76 unsigned int platform; 77 struct clk *wclk; 78 struct clk *bclk; 79 struct acp_mach_ops ops; 80 struct snd_soc_acpi_mach *acpi_mach; 81 void *mach_priv; 82 bool soc_mclk; 83 bool tdm_mode; 84 }; 85 86 int acp_sofdsp_dai_links_create(struct snd_soc_card *card); 87 int acp_legacy_dai_links_create(struct snd_soc_card *card); 88 extern const struct dmi_system_id acp_quirk_table[]; 89 90 static inline int acp_ops_probe(struct snd_soc_card *card) 91 { 92 int ret = 1; 93 struct acp_card_drvdata *priv = acp_get_drvdata(card); 94 95 if (ACP_OPS(priv, probe)) 96 ret = ACP_OPS(priv, probe)(card); 97 return ret; 98 } 99 100 static inline int acp_ops_configure_link(struct snd_soc_card *card, 101 struct snd_soc_dai_link *dai_link) 102 { 103 int ret = 1; 104 struct acp_card_drvdata *priv = acp_get_drvdata(card); 105 106 if (ACP_OPS(priv, configure_link)) 107 ret = ACP_OPS(priv, configure_link)(card, dai_link); 108 return ret; 109 } 110 111 static inline int acp_ops_configure_widgets(struct snd_soc_card *card) 112 { 113 int ret = 1; 114 struct acp_card_drvdata *priv = acp_get_drvdata(card); 115 116 if (ACP_OPS(priv, configure_widgets)) 117 ret = ACP_OPS(priv, configure_widgets)(card); 118 return ret; 119 } 120 121 static inline int acp_ops_suspend_pre(struct snd_soc_card *card) 122 { 123 int ret = 1; 124 struct acp_card_drvdata *priv = acp_get_drvdata(card); 125 126 if (ACP_OPS(priv, suspend_pre)) 127 ret = ACP_OPS(priv, suspend_pre)(card); 128 return ret; 129 } 130 131 static inline int acp_ops_resume_post(struct snd_soc_card *card) 132 { 133 int ret = 1; 134 struct acp_card_drvdata *priv = acp_get_drvdata(card); 135 136 if (ACP_OPS(priv, resume_post)) 137 ret = ACP_OPS(priv, resume_post)(card); 138 return ret; 139 } 140 141 #endif 142