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 #include "acp_common.h" 22 23 #define TDM_CHANNELS 8 24 25 #define ACP_OPS(priv, cb) ((priv)->ops.cb) 26 27 #define acp_get_drvdata(card) ((struct acp_card_drvdata *)(card)->drvdata) 28 29 enum be_id { 30 HEADSET_BE_ID = 0, 31 AMP_BE_ID, 32 DMIC_BE_ID, 33 BT_BE_ID, 34 }; 35 36 enum cpu_endpoints { 37 NONE = 0, 38 I2S_HS, 39 I2S_SP, 40 I2S_BT, 41 DMIC, 42 }; 43 44 enum codec_endpoints { 45 DUMMY = 0, 46 RT5682, 47 RT1019, 48 MAX98360A, 49 RT5682S, 50 NAU8825, 51 NAU8821, 52 MAX98388, 53 ES83XX, 54 }; 55 56 struct acp_mach_ops { 57 int (*probe)(struct snd_soc_card *card); 58 int (*configure_link)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); 59 int (*configure_widgets)(struct snd_soc_card *card); 60 int (*suspend_pre)(struct snd_soc_card *card); 61 int (*resume_post)(struct snd_soc_card *card); 62 }; 63 64 struct acp_card_drvdata { 65 unsigned int hs_cpu_id; 66 unsigned int amp_cpu_id; 67 unsigned int bt_cpu_id; 68 unsigned int dmic_cpu_id; 69 unsigned int hs_codec_id; 70 unsigned int amp_codec_id; 71 unsigned int bt_codec_id; 72 unsigned int dmic_codec_id; 73 unsigned int dai_fmt; 74 unsigned int acp_rev; 75 struct clk *wclk; 76 struct clk *bclk; 77 struct acp_mach_ops ops; 78 struct snd_soc_acpi_mach *acpi_mach; 79 void *mach_priv; 80 bool soc_mclk; 81 bool tdm_mode; 82 }; 83 84 int acp_sofdsp_dai_links_create(struct snd_soc_card *card); 85 int acp_legacy_dai_links_create(struct snd_soc_card *card); 86 extern const struct dmi_system_id acp_quirk_table[]; 87 88 static inline int acp_ops_probe(struct snd_soc_card *card) 89 { 90 int ret = 1; 91 struct acp_card_drvdata *priv = acp_get_drvdata(card); 92 93 if (ACP_OPS(priv, probe)) 94 ret = ACP_OPS(priv, probe)(card); 95 return ret; 96 } 97 98 static inline int acp_ops_configure_link(struct snd_soc_card *card, 99 struct snd_soc_dai_link *dai_link) 100 { 101 int ret = 1; 102 struct acp_card_drvdata *priv = acp_get_drvdata(card); 103 104 if (ACP_OPS(priv, configure_link)) 105 ret = ACP_OPS(priv, configure_link)(card, dai_link); 106 return ret; 107 } 108 109 static inline int acp_ops_configure_widgets(struct snd_soc_card *card) 110 { 111 int ret = 1; 112 struct acp_card_drvdata *priv = acp_get_drvdata(card); 113 114 if (ACP_OPS(priv, configure_widgets)) 115 ret = ACP_OPS(priv, configure_widgets)(card); 116 return ret; 117 } 118 119 static inline int acp_ops_suspend_pre(struct snd_soc_card *card) 120 { 121 int ret = 1; 122 struct acp_card_drvdata *priv = acp_get_drvdata(card); 123 124 if (ACP_OPS(priv, suspend_pre)) 125 ret = ACP_OPS(priv, suspend_pre)(card); 126 return ret; 127 } 128 129 static inline int acp_ops_resume_post(struct snd_soc_card *card) 130 { 131 int ret = 1; 132 struct acp_card_drvdata *priv = acp_get_drvdata(card); 133 134 if (ACP_OPS(priv, resume_post)) 135 ret = ACP_OPS(priv, resume_post)(card); 136 return ret; 137 } 138 139 #endif 140