1 // SPDX-License-Identifier: GPL-2.0-only 2 // Copyright(c) 2024 Advanced Micro Devices, Inc. 3 4 /* 5 * acp-sdw-mach-common - Common machine driver helper functions for 6 * legacy(No DSP) stack and SOF stack. 7 */ 8 9 #include <linux/device.h> 10 #include <linux/module.h> 11 #include "soc_amd_sdw_common.h" 12 13 int get_acp63_cpu_pin_id(u32 sdw_link_id, int be_id, int *cpu_pin_id, struct device *dev) 14 { 15 switch (sdw_link_id) { 16 case AMD_SDW0: 17 switch (be_id) { 18 case SOC_SDW_JACK_OUT_DAI_ID: 19 *cpu_pin_id = ACP63_SW0_AUDIO0_TX; 20 break; 21 case SOC_SDW_JACK_IN_DAI_ID: 22 *cpu_pin_id = ACP63_SW0_AUDIO0_RX; 23 break; 24 case SOC_SDW_AMP_OUT_DAI_ID: 25 *cpu_pin_id = ACP63_SW0_AUDIO1_TX; 26 break; 27 case SOC_SDW_AMP_IN_DAI_ID: 28 *cpu_pin_id = ACP63_SW0_AUDIO1_RX; 29 break; 30 case SOC_SDW_DMIC_DAI_ID: 31 *cpu_pin_id = ACP63_SW0_AUDIO2_RX; 32 break; 33 default: 34 dev_err(dev, "Invalid be id:%d\n", be_id); 35 return -EINVAL; 36 } 37 break; 38 case AMD_SDW1: 39 switch (be_id) { 40 case SOC_SDW_JACK_OUT_DAI_ID: 41 case SOC_SDW_AMP_OUT_DAI_ID: 42 *cpu_pin_id = ACP63_SW1_AUDIO0_TX; 43 break; 44 case SOC_SDW_JACK_IN_DAI_ID: 45 case SOC_SDW_AMP_IN_DAI_ID: 46 case SOC_SDW_DMIC_DAI_ID: 47 *cpu_pin_id = ACP63_SW1_AUDIO0_RX; 48 break; 49 default: 50 dev_err(dev, "invalid be_id:%d\n", be_id); 51 return -EINVAL; 52 } 53 break; 54 default: 55 dev_err(dev, "Invalid link id:%d\n", sdw_link_id); 56 return -EINVAL; 57 } 58 return 0; 59 } 60 EXPORT_SYMBOL_NS_GPL(get_acp63_cpu_pin_id, SND_SOC_AMD_SDW_MACH); 61 62 MODULE_DESCRIPTION("AMD SoundWire Common Machine driver"); 63 MODULE_AUTHOR("Vijendar Mukunda <Vijendar.Mukunda@amd.com>"); 64 MODULE_LICENSE("GPL"); 65