xref: /linux/sound/soc/sdw_utils/soc_sdw_rt_amp.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1ccc96ae2SVijendar Mukunda // SPDX-License-Identifier: GPL-2.0-only
2ccc96ae2SVijendar Mukunda // This file incorporates work covered by the following copyright notice:
3ccc96ae2SVijendar Mukunda // Copyright (c) 2022 Intel Corporation
4ccc96ae2SVijendar Mukunda // Copyright (c) 2024 Advanced Micro Devices, Inc.
5ccc96ae2SVijendar Mukunda 
6ccc96ae2SVijendar Mukunda /*
7ccc96ae2SVijendar Mukunda  *  soc_sdw_rt_amp - Helpers to handle RT1308/RT1316/RT1318 from generic machine driver
8ccc96ae2SVijendar Mukunda  */
9ccc96ae2SVijendar Mukunda 
10ccc96ae2SVijendar Mukunda #include <linux/device.h>
11ccc96ae2SVijendar Mukunda #include <linux/errno.h>
12ccc96ae2SVijendar Mukunda #include <sound/control.h>
13ccc96ae2SVijendar Mukunda #include <sound/soc.h>
14ccc96ae2SVijendar Mukunda #include <sound/soc-acpi.h>
15ccc96ae2SVijendar Mukunda #include <sound/soc-dapm.h>
16ccc96ae2SVijendar Mukunda #include <linux/soundwire/sdw.h>
17ccc96ae2SVijendar Mukunda #include <linux/soundwire/sdw_type.h>
18ccc96ae2SVijendar Mukunda #include <linux/dmi.h>
19ccc96ae2SVijendar Mukunda #include <sound/soc_sdw_utils.h>
20ccc96ae2SVijendar Mukunda #include "soc_sdw_rt_amp_coeff_tables.h"
21ccc96ae2SVijendar Mukunda #include "../codecs/rt1308.h"
22ccc96ae2SVijendar Mukunda 
23ccc96ae2SVijendar Mukunda #define CODEC_NAME_SIZE	7
24ccc96ae2SVijendar Mukunda 
25ccc96ae2SVijendar Mukunda /* choose a larger value to resolve compatibility issues */
26ccc96ae2SVijendar Mukunda #define RT_AMP_MAX_BQ_REG RT1316_MAX_BQ_REG
27ccc96ae2SVijendar Mukunda 
28ccc96ae2SVijendar Mukunda struct rt_amp_platform_data {
29ccc96ae2SVijendar Mukunda 	const unsigned char *bq_params;
30ccc96ae2SVijendar Mukunda 	const unsigned int bq_params_cnt;
31ccc96ae2SVijendar Mukunda };
32ccc96ae2SVijendar Mukunda 
33ccc96ae2SVijendar Mukunda static const struct rt_amp_platform_data dell_0a5d_platform_data = {
34ccc96ae2SVijendar Mukunda 	.bq_params = dell_0a5d_bq_params,
35ccc96ae2SVijendar Mukunda 	.bq_params_cnt = ARRAY_SIZE(dell_0a5d_bq_params),
36ccc96ae2SVijendar Mukunda };
37ccc96ae2SVijendar Mukunda 
38ccc96ae2SVijendar Mukunda static const struct rt_amp_platform_data dell_0b00_platform_data = {
39ccc96ae2SVijendar Mukunda 	.bq_params = dell_0b00_bq_params,
40ccc96ae2SVijendar Mukunda 	.bq_params_cnt = ARRAY_SIZE(dell_0b00_bq_params),
41ccc96ae2SVijendar Mukunda };
42ccc96ae2SVijendar Mukunda 
43ccc96ae2SVijendar Mukunda static const struct dmi_system_id dmi_platform_data[] = {
44ccc96ae2SVijendar Mukunda 	/* CometLake devices */
45ccc96ae2SVijendar Mukunda 	{
46ccc96ae2SVijendar Mukunda 		.matches = {
47ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
48ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0990")
49ccc96ae2SVijendar Mukunda 		},
50ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0a5d_platform_data,
51ccc96ae2SVijendar Mukunda 	},
52ccc96ae2SVijendar Mukunda 	{
53ccc96ae2SVijendar Mukunda 		.matches = {
54ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
55ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "098F")
56ccc96ae2SVijendar Mukunda 		},
57ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0a5d_platform_data,
58ccc96ae2SVijendar Mukunda 	},
59ccc96ae2SVijendar Mukunda 	/* TigerLake devices */
60ccc96ae2SVijendar Mukunda 	{
61ccc96ae2SVijendar Mukunda 		.matches = {
62ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
63ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A5D")
64ccc96ae2SVijendar Mukunda 		},
65ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0a5d_platform_data,
66ccc96ae2SVijendar Mukunda 	},
67ccc96ae2SVijendar Mukunda 	{
68ccc96ae2SVijendar Mukunda 		.matches = {
69ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
70ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0A5E")
71ccc96ae2SVijendar Mukunda 		},
72ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0a5d_platform_data,
73ccc96ae2SVijendar Mukunda 	},
74ccc96ae2SVijendar Mukunda 	/* AlderLake devices */
75ccc96ae2SVijendar Mukunda 	{
76ccc96ae2SVijendar Mukunda 		.matches = {
77ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
78ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0B00")
79ccc96ae2SVijendar Mukunda 		},
80ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0b00_platform_data,
81ccc96ae2SVijendar Mukunda 	},
82ccc96ae2SVijendar Mukunda 	{
83ccc96ae2SVijendar Mukunda 		.matches = {
84ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
85ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0B01")
86ccc96ae2SVijendar Mukunda 		},
87ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0b00_platform_data,
88ccc96ae2SVijendar Mukunda 	},
89ccc96ae2SVijendar Mukunda 	{
90ccc96ae2SVijendar Mukunda 		.matches = {
91ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
92ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0AFF")
93ccc96ae2SVijendar Mukunda 		},
94ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0b00_platform_data,
95ccc96ae2SVijendar Mukunda 	},
96ccc96ae2SVijendar Mukunda 	{
97ccc96ae2SVijendar Mukunda 		.matches = {
98ccc96ae2SVijendar Mukunda 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc"),
99ccc96ae2SVijendar Mukunda 			DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "0AFE")
100ccc96ae2SVijendar Mukunda 		},
101ccc96ae2SVijendar Mukunda 		.driver_data = (void *)&dell_0b00_platform_data,
102ccc96ae2SVijendar Mukunda 	},
103ccc96ae2SVijendar Mukunda 	{},
104ccc96ae2SVijendar Mukunda };
105ccc96ae2SVijendar Mukunda 
rt_amp_add_device_props(struct device * sdw_dev)106ccc96ae2SVijendar Mukunda static int rt_amp_add_device_props(struct device *sdw_dev)
107ccc96ae2SVijendar Mukunda {
108ccc96ae2SVijendar Mukunda 	struct property_entry props[3] = {};
109ccc96ae2SVijendar Mukunda 	struct fwnode_handle *fwnode;
110ccc96ae2SVijendar Mukunda 	const struct dmi_system_id *dmi_data;
111ccc96ae2SVijendar Mukunda 	const struct rt_amp_platform_data *pdata;
112ccc96ae2SVijendar Mukunda 	unsigned char params[RT_AMP_MAX_BQ_REG];
113ccc96ae2SVijendar Mukunda 	int ret;
114ccc96ae2SVijendar Mukunda 
115ccc96ae2SVijendar Mukunda 	dmi_data = dmi_first_match(dmi_platform_data);
116ccc96ae2SVijendar Mukunda 	if (!dmi_data)
117ccc96ae2SVijendar Mukunda 		return 0;
118ccc96ae2SVijendar Mukunda 
119ccc96ae2SVijendar Mukunda 	pdata = dmi_data->driver_data;
120ccc96ae2SVijendar Mukunda 	memcpy(&params, pdata->bq_params, sizeof(unsigned char) * pdata->bq_params_cnt);
121ccc96ae2SVijendar Mukunda 
122ccc96ae2SVijendar Mukunda 	props[0] = PROPERTY_ENTRY_U8_ARRAY("realtek,bq-params", params);
123ccc96ae2SVijendar Mukunda 	props[1] = PROPERTY_ENTRY_U32("realtek,bq-params-cnt", pdata->bq_params_cnt);
124ccc96ae2SVijendar Mukunda 
125ccc96ae2SVijendar Mukunda 	fwnode = fwnode_create_software_node(props, NULL);
126ccc96ae2SVijendar Mukunda 	if (IS_ERR(fwnode))
127ccc96ae2SVijendar Mukunda 		return PTR_ERR(fwnode);
128ccc96ae2SVijendar Mukunda 
129ccc96ae2SVijendar Mukunda 	ret = device_add_software_node(sdw_dev, to_software_node(fwnode));
130ccc96ae2SVijendar Mukunda 
131ccc96ae2SVijendar Mukunda 	fwnode_handle_put(fwnode);
132ccc96ae2SVijendar Mukunda 
133ccc96ae2SVijendar Mukunda 	return ret;
134ccc96ae2SVijendar Mukunda }
135ccc96ae2SVijendar Mukunda 
136ccc96ae2SVijendar Mukunda /*
137ccc96ae2SVijendar Mukunda  * dapm routes for rt1308/rt1316/rt1318 will be registered dynamically
138ccc96ae2SVijendar Mukunda  * according to the number of rt1308/rt1316/rt1318 used. The first two
139ccc96ae2SVijendar Mukunda  * entries will be registered for one codec case, and the last two entries
140ccc96ae2SVijendar Mukunda  * are also registered if two 1308s/1316s/1318s are used.
141ccc96ae2SVijendar Mukunda  */
142ccc96ae2SVijendar Mukunda static const struct snd_soc_dapm_route rt1308_map[] = {
143ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1308-1 SPOL" },
144ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1308-1 SPOR" },
145ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1308-2 SPOL" },
146ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1308-2 SPOR" },
147ccc96ae2SVijendar Mukunda };
148ccc96ae2SVijendar Mukunda 
149ccc96ae2SVijendar Mukunda static const struct snd_soc_dapm_route rt1316_map[] = {
150ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1316-1 SPOL" },
151ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1316-1 SPOR" },
152ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1316-2 SPOL" },
153ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1316-2 SPOR" },
154ccc96ae2SVijendar Mukunda };
155ccc96ae2SVijendar Mukunda 
156ccc96ae2SVijendar Mukunda static const struct snd_soc_dapm_route rt1318_map[] = {
157ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1318-1 SPOL" },
158ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1318-1 SPOR" },
159ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1318-2 SPOL" },
160ccc96ae2SVijendar Mukunda 	{ "Speaker", NULL, "rt1318-2 SPOR" },
161ccc96ae2SVijendar Mukunda };
162ccc96ae2SVijendar Mukunda 
163*1ab959beSBard Liao static const struct snd_soc_dapm_route rt1320_map[] = {
164*1ab959beSBard Liao 	{ "Speaker", NULL, "rt1320-1 SPOL" },
165*1ab959beSBard Liao 	{ "Speaker", NULL, "rt1320-1 SPOR" },
166*1ab959beSBard Liao 	{ "Speaker", NULL, "rt1320-2 SPOL" },
167*1ab959beSBard Liao 	{ "Speaker", NULL, "rt1320-2 SPOR" },
168*1ab959beSBard Liao };
169*1ab959beSBard Liao 
get_codec_name_and_route(struct snd_soc_dai * dai,char * codec_name)170ccc96ae2SVijendar Mukunda static const struct snd_soc_dapm_route *get_codec_name_and_route(struct snd_soc_dai *dai,
171ccc96ae2SVijendar Mukunda 								 char *codec_name)
172ccc96ae2SVijendar Mukunda {
173ccc96ae2SVijendar Mukunda 	/* get the codec name */
174ccc96ae2SVijendar Mukunda 	snprintf(codec_name, CODEC_NAME_SIZE, "%s", dai->name);
175ccc96ae2SVijendar Mukunda 
176ccc96ae2SVijendar Mukunda 	/* choose the right codec's map  */
177ccc96ae2SVijendar Mukunda 	if (strcmp(codec_name, "rt1308") == 0)
178ccc96ae2SVijendar Mukunda 		return rt1308_map;
179ccc96ae2SVijendar Mukunda 	else if (strcmp(codec_name, "rt1316") == 0)
180ccc96ae2SVijendar Mukunda 		return rt1316_map;
181*1ab959beSBard Liao 	else if (strcmp(codec_name, "rt1318") == 0)
182ccc96ae2SVijendar Mukunda 		return rt1318_map;
183*1ab959beSBard Liao 	else
184*1ab959beSBard Liao 		return rt1320_map;
185ccc96ae2SVijendar Mukunda }
186ccc96ae2SVijendar Mukunda 
asoc_sdw_rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime * rtd,struct snd_soc_dai * dai)187ccc96ae2SVijendar Mukunda int asoc_sdw_rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
188ccc96ae2SVijendar Mukunda {
189ccc96ae2SVijendar Mukunda 	struct snd_soc_card *card = rtd->card;
190ccc96ae2SVijendar Mukunda 	const struct snd_soc_dapm_route *rt_amp_map;
191ccc96ae2SVijendar Mukunda 	char codec_name[CODEC_NAME_SIZE];
192ccc96ae2SVijendar Mukunda 	struct snd_soc_dai *codec_dai;
193ccc96ae2SVijendar Mukunda 	int ret;
194ccc96ae2SVijendar Mukunda 	int i;
195ccc96ae2SVijendar Mukunda 
196ccc96ae2SVijendar Mukunda 	rt_amp_map = get_codec_name_and_route(dai, codec_name);
197ccc96ae2SVijendar Mukunda 
198ccc96ae2SVijendar Mukunda 	card->components = devm_kasprintf(card->dev, GFP_KERNEL,
199ccc96ae2SVijendar Mukunda 					  "%s spk:%s",
200ccc96ae2SVijendar Mukunda 					  card->components, codec_name);
201ccc96ae2SVijendar Mukunda 	if (!card->components)
202ccc96ae2SVijendar Mukunda 		return -ENOMEM;
203ccc96ae2SVijendar Mukunda 
204ccc96ae2SVijendar Mukunda 	for_each_rtd_codec_dais(rtd, i, codec_dai) {
205ccc96ae2SVijendar Mukunda 		if (strstr(codec_dai->component->name_prefix, "-1"))
206ccc96ae2SVijendar Mukunda 			ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map, 2);
207ccc96ae2SVijendar Mukunda 		else if (strstr(codec_dai->component->name_prefix, "-2"))
208ccc96ae2SVijendar Mukunda 			ret = snd_soc_dapm_add_routes(&card->dapm, rt_amp_map + 2, 2);
209ccc96ae2SVijendar Mukunda 	}
210ccc96ae2SVijendar Mukunda 
211ccc96ae2SVijendar Mukunda 	return ret;
212ccc96ae2SVijendar Mukunda }
213ccc96ae2SVijendar Mukunda EXPORT_SYMBOL_NS(asoc_sdw_rt_amp_spk_rtd_init, SND_SOC_SDW_UTILS);
214ccc96ae2SVijendar Mukunda 
rt1308_i2s_hw_params(struct snd_pcm_substream * substream,struct snd_pcm_hw_params * params)215ccc96ae2SVijendar Mukunda static int rt1308_i2s_hw_params(struct snd_pcm_substream *substream,
216ccc96ae2SVijendar Mukunda 				struct snd_pcm_hw_params *params)
217ccc96ae2SVijendar Mukunda {
218ccc96ae2SVijendar Mukunda 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
219ccc96ae2SVijendar Mukunda 	struct snd_soc_card *card = rtd->card;
220ccc96ae2SVijendar Mukunda 	struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
221ccc96ae2SVijendar Mukunda 	int clk_id, clk_freq, pll_out;
222ccc96ae2SVijendar Mukunda 	int err;
223ccc96ae2SVijendar Mukunda 
224ccc96ae2SVijendar Mukunda 	clk_id = RT1308_PLL_S_MCLK;
225ccc96ae2SVijendar Mukunda 	clk_freq = 38400000;
226ccc96ae2SVijendar Mukunda 
227ccc96ae2SVijendar Mukunda 	pll_out = params_rate(params) * 512;
228ccc96ae2SVijendar Mukunda 
229ccc96ae2SVijendar Mukunda 	/* Set rt1308 pll */
230ccc96ae2SVijendar Mukunda 	err = snd_soc_dai_set_pll(codec_dai, 0, clk_id, clk_freq, pll_out);
231ccc96ae2SVijendar Mukunda 	if (err < 0) {
232ccc96ae2SVijendar Mukunda 		dev_err(card->dev, "Failed to set RT1308 PLL: %d\n", err);
233ccc96ae2SVijendar Mukunda 		return err;
234ccc96ae2SVijendar Mukunda 	}
235ccc96ae2SVijendar Mukunda 
236ccc96ae2SVijendar Mukunda 	/* Set rt1308 sysclk */
237ccc96ae2SVijendar Mukunda 	err = snd_soc_dai_set_sysclk(codec_dai, RT1308_FS_SYS_S_PLL, pll_out,
238ccc96ae2SVijendar Mukunda 				     SND_SOC_CLOCK_IN);
239ccc96ae2SVijendar Mukunda 	if (err < 0) {
240ccc96ae2SVijendar Mukunda 		dev_err(card->dev, "Failed to set RT1308 SYSCLK: %d\n", err);
241ccc96ae2SVijendar Mukunda 		return err;
242ccc96ae2SVijendar Mukunda 	}
243ccc96ae2SVijendar Mukunda 
244ccc96ae2SVijendar Mukunda 	return 0;
245ccc96ae2SVijendar Mukunda }
246ccc96ae2SVijendar Mukunda 
247ccc96ae2SVijendar Mukunda /* machine stream operations */
248ccc96ae2SVijendar Mukunda const struct snd_soc_ops soc_sdw_rt1308_i2s_ops = {
249ccc96ae2SVijendar Mukunda 	.hw_params = rt1308_i2s_hw_params,
250ccc96ae2SVijendar Mukunda };
251ccc96ae2SVijendar Mukunda EXPORT_SYMBOL_NS(soc_sdw_rt1308_i2s_ops, SND_SOC_SDW_UTILS);
252ccc96ae2SVijendar Mukunda 
asoc_sdw_rt_amp_exit(struct snd_soc_card * card,struct snd_soc_dai_link * dai_link)253ccc96ae2SVijendar Mukunda int asoc_sdw_rt_amp_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
254ccc96ae2SVijendar Mukunda {
255ccc96ae2SVijendar Mukunda 	struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
256ccc96ae2SVijendar Mukunda 
257ccc96ae2SVijendar Mukunda 	if (ctx->amp_dev1) {
258ccc96ae2SVijendar Mukunda 		device_remove_software_node(ctx->amp_dev1);
259ccc96ae2SVijendar Mukunda 		put_device(ctx->amp_dev1);
260ccc96ae2SVijendar Mukunda 	}
261ccc96ae2SVijendar Mukunda 
262ccc96ae2SVijendar Mukunda 	if (ctx->amp_dev2) {
263ccc96ae2SVijendar Mukunda 		device_remove_software_node(ctx->amp_dev2);
264ccc96ae2SVijendar Mukunda 		put_device(ctx->amp_dev2);
265ccc96ae2SVijendar Mukunda 	}
266ccc96ae2SVijendar Mukunda 
267ccc96ae2SVijendar Mukunda 	return 0;
268ccc96ae2SVijendar Mukunda }
269ccc96ae2SVijendar Mukunda EXPORT_SYMBOL_NS(asoc_sdw_rt_amp_exit, SND_SOC_SDW_UTILS);
270ccc96ae2SVijendar Mukunda 
asoc_sdw_rt_amp_init(struct snd_soc_card * card,struct snd_soc_dai_link * dai_links,struct asoc_sdw_codec_info * info,bool playback)271ccc96ae2SVijendar Mukunda int asoc_sdw_rt_amp_init(struct snd_soc_card *card,
272ccc96ae2SVijendar Mukunda 			 struct snd_soc_dai_link *dai_links,
273ccc96ae2SVijendar Mukunda 			 struct asoc_sdw_codec_info *info,
274ccc96ae2SVijendar Mukunda 			 bool playback)
275ccc96ae2SVijendar Mukunda {
276ccc96ae2SVijendar Mukunda 	struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
277ccc96ae2SVijendar Mukunda 	struct device *sdw_dev1, *sdw_dev2;
278ccc96ae2SVijendar Mukunda 	int ret;
279ccc96ae2SVijendar Mukunda 
280ccc96ae2SVijendar Mukunda 	/* Count amp number and do init on playback link only. */
281ccc96ae2SVijendar Mukunda 	if (!playback)
282ccc96ae2SVijendar Mukunda 		return 0;
283ccc96ae2SVijendar Mukunda 
284ccc96ae2SVijendar Mukunda 	info->amp_num++;
285ccc96ae2SVijendar Mukunda 
286ccc96ae2SVijendar Mukunda 	if (info->amp_num == 2) {
287ccc96ae2SVijendar Mukunda 		sdw_dev1 = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[0].name);
288ccc96ae2SVijendar Mukunda 		if (!sdw_dev1)
289ccc96ae2SVijendar Mukunda 			return -EPROBE_DEFER;
290ccc96ae2SVijendar Mukunda 
291ccc96ae2SVijendar Mukunda 		ret = rt_amp_add_device_props(sdw_dev1);
292ccc96ae2SVijendar Mukunda 		if (ret < 0) {
293ccc96ae2SVijendar Mukunda 			put_device(sdw_dev1);
294ccc96ae2SVijendar Mukunda 			return ret;
295ccc96ae2SVijendar Mukunda 		}
296ccc96ae2SVijendar Mukunda 		ctx->amp_dev1 = sdw_dev1;
297ccc96ae2SVijendar Mukunda 
298ccc96ae2SVijendar Mukunda 		sdw_dev2 = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[1].name);
299ccc96ae2SVijendar Mukunda 		if (!sdw_dev2)
300ccc96ae2SVijendar Mukunda 			return -EPROBE_DEFER;
301ccc96ae2SVijendar Mukunda 
302ccc96ae2SVijendar Mukunda 		ret = rt_amp_add_device_props(sdw_dev2);
303ccc96ae2SVijendar Mukunda 		if (ret < 0) {
304ccc96ae2SVijendar Mukunda 			put_device(sdw_dev2);
305ccc96ae2SVijendar Mukunda 			return ret;
306ccc96ae2SVijendar Mukunda 		}
307ccc96ae2SVijendar Mukunda 		ctx->amp_dev2 = sdw_dev2;
308ccc96ae2SVijendar Mukunda 	}
309ccc96ae2SVijendar Mukunda 
310ccc96ae2SVijendar Mukunda 	return 0;
311ccc96ae2SVijendar Mukunda }
312ccc96ae2SVijendar Mukunda EXPORT_SYMBOL_NS(asoc_sdw_rt_amp_init, SND_SOC_SDW_UTILS);
313