ALSA: hda: Direct MMIO accesses
[linux-2.6-block.git] / sound / soc / sof / intel / hda-bus.c
CommitLineData
78ad1f07
KJ
1// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2//
3// This file is provided under a dual BSD/GPLv2 license. When using or
4// redistributing this file, you may do so under either license.
5//
6// Copyright(c) 2018 Intel Corporation. All rights reserved.
7//
8// Authors: Keyon Jie <yang.jie@linux.intel.com>
9
10#include <linux/io.h>
11#include <sound/hdaudio.h>
12#include "../sof-priv.h"
13#include "hda.h"
14
15#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
16
17static const struct hdac_bus_ops bus_ops = {
18 .command = snd_hdac_bus_send_cmd,
19 .get_response = snd_hdac_bus_get_response,
20};
21
22#endif
23
78ad1f07
KJ
24/*
25 * This can be used for both with/without hda link support.
26 */
27void sof_hda_bus_init(struct hdac_bus *bus, struct device *dev,
28 const struct hdac_ext_bus_ops *ext_ops)
29{
78ad1f07
KJ
30 memset(bus, 0, sizeof(*bus));
31 bus->dev = dev;
32
78ad1f07
KJ
33 INIT_LIST_HEAD(&bus->stream_list);
34
35 bus->irq = -1;
36 bus->ext_ops = ext_ops;
d1a6459f
ZY
37
38 /*
39 * There is only one HDA bus atm. keep the index as 0.
40 * Need to fix when there are more than one HDA bus.
41 */
42 bus->idx = 0;
78ad1f07
KJ
43
44 spin_lock_init(&bus->reg_lock);
45
46#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA)
47 INIT_LIST_HEAD(&bus->codec_list);
48 INIT_LIST_HEAD(&bus->hlink_list);
49
50 mutex_init(&bus->cmd_mutex);
51 mutex_init(&bus->lock);
52 bus->ops = &bus_ops;
53 INIT_WORK(&bus->unsol_work, snd_hdac_bus_process_unsol_events);
54 bus->cmd_dma_state = true;
55#endif
56
57}