.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * hdac-ext-bus.c - HD-audio extended core bus functions. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2014-2015 Intel Corp |
---|
5 | 6 | * Author: Jeeja KP <jeeja.kp@intel.com> |
---|
6 | 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License as published by |
---|
10 | | - * the Free Software Foundation; version 2 of the License. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, but |
---|
13 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | | - * General Public License for more details. |
---|
16 | 8 | * |
---|
17 | 9 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
18 | 10 | */ |
---|
.. | .. |
---|
25 | 17 | MODULE_DESCRIPTION("HDA extended core"); |
---|
26 | 18 | MODULE_LICENSE("GPL v2"); |
---|
27 | 19 | |
---|
28 | | -static void hdac_ext_writel(u32 value, u32 __iomem *addr) |
---|
29 | | -{ |
---|
30 | | - writel(value, addr); |
---|
31 | | -} |
---|
32 | | - |
---|
33 | | -static u32 hdac_ext_readl(u32 __iomem *addr) |
---|
34 | | -{ |
---|
35 | | - return readl(addr); |
---|
36 | | -} |
---|
37 | | - |
---|
38 | | -static void hdac_ext_writew(u16 value, u16 __iomem *addr) |
---|
39 | | -{ |
---|
40 | | - writew(value, addr); |
---|
41 | | -} |
---|
42 | | - |
---|
43 | | -static u16 hdac_ext_readw(u16 __iomem *addr) |
---|
44 | | -{ |
---|
45 | | - return readw(addr); |
---|
46 | | -} |
---|
47 | | - |
---|
48 | | -static void hdac_ext_writeb(u8 value, u8 __iomem *addr) |
---|
49 | | -{ |
---|
50 | | - writeb(value, addr); |
---|
51 | | -} |
---|
52 | | - |
---|
53 | | -static u8 hdac_ext_readb(u8 __iomem *addr) |
---|
54 | | -{ |
---|
55 | | - return readb(addr); |
---|
56 | | -} |
---|
57 | | - |
---|
58 | | -static int hdac_ext_dma_alloc_pages(struct hdac_bus *bus, int type, |
---|
59 | | - size_t size, struct snd_dma_buffer *buf) |
---|
60 | | -{ |
---|
61 | | - return snd_dma_alloc_pages(type, bus->dev, size, buf); |
---|
62 | | -} |
---|
63 | | - |
---|
64 | | -static void hdac_ext_dma_free_pages(struct hdac_bus *bus, struct snd_dma_buffer *buf) |
---|
65 | | -{ |
---|
66 | | - snd_dma_free_pages(buf); |
---|
67 | | -} |
---|
68 | | - |
---|
69 | | -static const struct hdac_io_ops hdac_ext_default_io = { |
---|
70 | | - .reg_writel = hdac_ext_writel, |
---|
71 | | - .reg_readl = hdac_ext_readl, |
---|
72 | | - .reg_writew = hdac_ext_writew, |
---|
73 | | - .reg_readw = hdac_ext_readw, |
---|
74 | | - .reg_writeb = hdac_ext_writeb, |
---|
75 | | - .reg_readb = hdac_ext_readb, |
---|
76 | | - .dma_alloc_pages = hdac_ext_dma_alloc_pages, |
---|
77 | | - .dma_free_pages = hdac_ext_dma_free_pages, |
---|
78 | | -}; |
---|
79 | | - |
---|
80 | 20 | /** |
---|
81 | 21 | * snd_hdac_ext_bus_init - initialize a HD-audio extended bus |
---|
82 | | - * @ebus: the pointer to extended bus object |
---|
| 22 | + * @bus: the pointer to HDAC bus object |
---|
83 | 23 | * @dev: device pointer |
---|
84 | 24 | * @ops: bus verb operators |
---|
85 | | - * @io_ops: lowlevel I/O operators, can be NULL. If NULL core will use |
---|
86 | | - * default ops |
---|
| 25 | + * @ext_ops: operators used for ASoC HDA codec drivers |
---|
87 | 26 | * |
---|
88 | 27 | * Returns 0 if successful, or a negative error code. |
---|
89 | 28 | */ |
---|
90 | 29 | int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev, |
---|
91 | 30 | const struct hdac_bus_ops *ops, |
---|
92 | | - const struct hdac_io_ops *io_ops, |
---|
93 | 31 | const struct hdac_ext_bus_ops *ext_ops) |
---|
94 | 32 | { |
---|
95 | 33 | int ret; |
---|
96 | | - static int idx; |
---|
97 | 34 | |
---|
98 | | - /* check if io ops are provided, if not load the defaults */ |
---|
99 | | - if (io_ops == NULL) |
---|
100 | | - io_ops = &hdac_ext_default_io; |
---|
101 | | - |
---|
102 | | - ret = snd_hdac_bus_init(bus, dev, ops, io_ops); |
---|
| 35 | + ret = snd_hdac_bus_init(bus, dev, ops); |
---|
103 | 36 | if (ret < 0) |
---|
104 | 37 | return ret; |
---|
105 | 38 | |
---|
106 | 39 | bus->ext_ops = ext_ops; |
---|
107 | | - INIT_LIST_HEAD(&bus->hlink_list); |
---|
108 | | - bus->idx = idx++; |
---|
109 | | - |
---|
110 | | - mutex_init(&bus->lock); |
---|
| 40 | + /* FIXME: |
---|
| 41 | + * Currently only one bus is supported, if there is device with more |
---|
| 42 | + * buses, bus->idx should be greater than 0, but there needs to be a |
---|
| 43 | + * reliable way to always assign same number. |
---|
| 44 | + */ |
---|
| 45 | + bus->idx = 0; |
---|
111 | 46 | bus->cmd_dma_state = true; |
---|
112 | 47 | |
---|
113 | 48 | return 0; |
---|
.. | .. |
---|
116 | 51 | |
---|
117 | 52 | /** |
---|
118 | 53 | * snd_hdac_ext_bus_exit - clean up a HD-audio extended bus |
---|
119 | | - * @ebus: the pointer to extended bus object |
---|
| 54 | + * @bus: the pointer to HDAC bus object |
---|
120 | 55 | */ |
---|
121 | 56 | void snd_hdac_ext_bus_exit(struct hdac_bus *bus) |
---|
122 | 57 | { |
---|
.. | .. |
---|
127 | 62 | |
---|
128 | 63 | static void default_release(struct device *dev) |
---|
129 | 64 | { |
---|
130 | | - snd_hdac_ext_bus_device_exit(container_of(dev, struct hdac_device, dev)); |
---|
| 65 | + snd_hdac_ext_bus_device_exit(dev_to_hdac_dev(dev)); |
---|
131 | 66 | } |
---|
132 | 67 | |
---|
133 | 68 | /** |
---|
134 | 69 | * snd_hdac_ext_bus_device_init - initialize the HDA extended codec base device |
---|
135 | | - * @ebus: hdac extended bus to attach to |
---|
| 70 | + * @bus: hdac bus to attach to |
---|
136 | 71 | * @addr: codec address |
---|
| 72 | + * @hdev: hdac device to init |
---|
| 73 | + * @type: codec type (HDAC_DEV_*) to use for this device |
---|
137 | 74 | * |
---|
138 | 75 | * Returns zero for success or a negative error code. |
---|
139 | 76 | */ |
---|
140 | 77 | int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr, |
---|
141 | | - struct hdac_device *hdev) |
---|
| 78 | + struct hdac_device *hdev, int type) |
---|
142 | 79 | { |
---|
143 | 80 | char name[15]; |
---|
144 | 81 | int ret; |
---|
.. | .. |
---|
152 | 89 | dev_err(bus->dev, "device init failed for hdac device\n"); |
---|
153 | 90 | return ret; |
---|
154 | 91 | } |
---|
155 | | - hdev->type = HDA_DEV_ASOC; |
---|
| 92 | + hdev->type = type; |
---|
156 | 93 | hdev->dev.release = default_release; |
---|
157 | 94 | |
---|
158 | 95 | ret = snd_hdac_device_register(hdev); |
---|
.. | .. |
---|
179 | 116 | /** |
---|
180 | 117 | * snd_hdac_ext_bus_device_remove - remove HD-audio extended codec base devices |
---|
181 | 118 | * |
---|
182 | | - * @ebus: HD-audio extended bus |
---|
| 119 | + * @bus: the pointer to HDAC bus object |
---|
183 | 120 | */ |
---|
184 | 121 | void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus) |
---|
185 | 122 | { |
---|