1393347ccSVijendar Mukunda // SPDX-License-Identifier: GPL-2.0-only
2393347ccSVijendar Mukunda // Copyright(c) 2024 Advanced Micro Devices, Inc.
3393347ccSVijendar Mukunda
4393347ccSVijendar Mukunda /*
5393347ccSVijendar Mukunda * acp-sdw-mach-common - Common machine driver helper functions for
6393347ccSVijendar Mukunda * legacy(No DSP) stack and SOF stack.
7393347ccSVijendar Mukunda */
8393347ccSVijendar Mukunda
9393347ccSVijendar Mukunda #include <linux/device.h>
10393347ccSVijendar Mukunda #include <linux/module.h>
11393347ccSVijendar Mukunda #include "soc_amd_sdw_common.h"
12393347ccSVijendar Mukunda
get_acp63_cpu_pin_id(u32 sdw_link_id,int be_id,int * cpu_pin_id,struct device * dev)13393347ccSVijendar Mukunda int get_acp63_cpu_pin_id(u32 sdw_link_id, int be_id, int *cpu_pin_id, struct device *dev)
14393347ccSVijendar Mukunda {
15393347ccSVijendar Mukunda switch (sdw_link_id) {
16393347ccSVijendar Mukunda case AMD_SDW0:
17393347ccSVijendar Mukunda switch (be_id) {
18393347ccSVijendar Mukunda case SOC_SDW_JACK_OUT_DAI_ID:
19393347ccSVijendar Mukunda *cpu_pin_id = ACP63_SW0_AUDIO0_TX;
20393347ccSVijendar Mukunda break;
21393347ccSVijendar Mukunda case SOC_SDW_JACK_IN_DAI_ID:
22393347ccSVijendar Mukunda *cpu_pin_id = ACP63_SW0_AUDIO0_RX;
23393347ccSVijendar Mukunda break;
24393347ccSVijendar Mukunda case SOC_SDW_AMP_OUT_DAI_ID:
25393347ccSVijendar Mukunda *cpu_pin_id = ACP63_SW0_AUDIO1_TX;
26393347ccSVijendar Mukunda break;
27393347ccSVijendar Mukunda case SOC_SDW_AMP_IN_DAI_ID:
28393347ccSVijendar Mukunda *cpu_pin_id = ACP63_SW0_AUDIO1_RX;
29393347ccSVijendar Mukunda break;
30393347ccSVijendar Mukunda case SOC_SDW_DMIC_DAI_ID:
31393347ccSVijendar Mukunda *cpu_pin_id = ACP63_SW0_AUDIO2_RX;
32393347ccSVijendar Mukunda break;
33393347ccSVijendar Mukunda default:
34393347ccSVijendar Mukunda dev_err(dev, "Invalid be id:%d\n", be_id);
35393347ccSVijendar Mukunda return -EINVAL;
36393347ccSVijendar Mukunda }
37393347ccSVijendar Mukunda break;
38393347ccSVijendar Mukunda case AMD_SDW1:
39393347ccSVijendar Mukunda switch (be_id) {
40393347ccSVijendar Mukunda case SOC_SDW_JACK_OUT_DAI_ID:
41393347ccSVijendar Mukunda case SOC_SDW_AMP_OUT_DAI_ID:
42393347ccSVijendar Mukunda *cpu_pin_id = ACP63_SW1_AUDIO0_TX;
43393347ccSVijendar Mukunda break;
44393347ccSVijendar Mukunda case SOC_SDW_JACK_IN_DAI_ID:
45393347ccSVijendar Mukunda case SOC_SDW_AMP_IN_DAI_ID:
46393347ccSVijendar Mukunda case SOC_SDW_DMIC_DAI_ID:
47393347ccSVijendar Mukunda *cpu_pin_id = ACP63_SW1_AUDIO0_RX;
48393347ccSVijendar Mukunda break;
49393347ccSVijendar Mukunda default:
50393347ccSVijendar Mukunda dev_err(dev, "invalid be_id:%d\n", be_id);
51393347ccSVijendar Mukunda return -EINVAL;
52393347ccSVijendar Mukunda }
53393347ccSVijendar Mukunda break;
54393347ccSVijendar Mukunda default:
55393347ccSVijendar Mukunda dev_err(dev, "Invalid link id:%d\n", sdw_link_id);
56393347ccSVijendar Mukunda return -EINVAL;
57393347ccSVijendar Mukunda }
58393347ccSVijendar Mukunda return 0;
59393347ccSVijendar Mukunda }
60*cdd30ebbSPeter Zijlstra EXPORT_SYMBOL_NS_GPL(get_acp63_cpu_pin_id, "SND_SOC_AMD_SDW_MACH");
61393347ccSVijendar Mukunda
62393347ccSVijendar Mukunda MODULE_DESCRIPTION("AMD SoundWire Common Machine driver");
63393347ccSVijendar Mukunda MODULE_AUTHOR("Vijendar Mukunda <Vijendar.Mukunda@amd.com>");
64393347ccSVijendar Mukunda MODULE_LICENSE("GPL");
65