xref: /OK3568_Linux_fs/kernel/sound/soc/sof/intel/hda-bus.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2*4882a593Smuzhiyun //
3*4882a593Smuzhiyun // This file is provided under a dual BSD/GPLv2 license.  When using or
4*4882a593Smuzhiyun // redistributing this file, you may do so under either license.
5*4882a593Smuzhiyun //
6*4882a593Smuzhiyun // Copyright(c) 2018 Intel Corporation. All rights reserved.
7*4882a593Smuzhiyun //
8*4882a593Smuzhiyun // Authors: Keyon Jie <yang.jie@linux.intel.com>
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <linux/io.h>
11*4882a593Smuzhiyun #include <sound/hdaudio.h>
12*4882a593Smuzhiyun #include "../sof-priv.h"
13*4882a593Smuzhiyun #include "hda.h"
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
16*4882a593Smuzhiyun #include "../../codecs/hdac_hda.h"
17*4882a593Smuzhiyun #define sof_hda_ext_ops	snd_soc_hdac_hda_get_ops()
18*4882a593Smuzhiyun #else
19*4882a593Smuzhiyun #define sof_hda_ext_ops	NULL
20*4882a593Smuzhiyun #endif
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun /*
23*4882a593Smuzhiyun  * This can be used for both with/without hda link support.
24*4882a593Smuzhiyun  */
sof_hda_bus_init(struct hdac_bus * bus,struct device * dev)25*4882a593Smuzhiyun void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev)
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
28*4882a593Smuzhiyun 	snd_hdac_ext_bus_init(bus, dev, NULL, sof_hda_ext_ops);
29*4882a593Smuzhiyun #else /* CONFIG_SND_SOC_SOF_HDA */
30*4882a593Smuzhiyun 	memset(bus, 0, sizeof(*bus));
31*4882a593Smuzhiyun 	bus->dev = dev;
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun 	INIT_LIST_HEAD(&bus->stream_list);
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun 	bus->irq = -1;
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun 	/*
38*4882a593Smuzhiyun 	 * There is only one HDA bus atm. keep the index as 0.
39*4882a593Smuzhiyun 	 * Need to fix when there are more than one HDA bus.
40*4882a593Smuzhiyun 	 */
41*4882a593Smuzhiyun 	bus->idx = 0;
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun 	spin_lock_init(&bus->reg_lock);
44*4882a593Smuzhiyun #endif /* CONFIG_SND_SOC_SOF_HDA */
45*4882a593Smuzhiyun }
46