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