184369fbeSSuman Anna // SPDX-License-Identifier: GPL-2.0
2caf989c3SBjorn Andersson /*
3caf989c3SBjorn Andersson * Copyright (c) 2016, Linaro Ltd
4caf989c3SBjorn Andersson */
5caf989c3SBjorn Andersson
6caf989c3SBjorn Andersson #include <linux/io.h>
7caf989c3SBjorn Andersson #include <linux/module.h>
8caf989c3SBjorn Andersson #include <linux/of.h>
9caf989c3SBjorn Andersson #include <linux/of_address.h>
10f424d1cbSBjorn Andersson #include <linux/of_irq.h>
11caf989c3SBjorn Andersson #include <linux/interrupt.h>
12caf989c3SBjorn Andersson #include <linux/platform_device.h>
13f424d1cbSBjorn Andersson #include <linux/mailbox_client.h>
14caf989c3SBjorn Andersson #include <linux/mfd/syscon.h>
15caf989c3SBjorn Andersson #include <linux/slab.h>
16caf989c3SBjorn Andersson #include <linux/rpmsg.h>
17caf989c3SBjorn Andersson #include <linux/idr.h>
18caf989c3SBjorn Andersson #include <linux/circ_buf.h>
19caf989c3SBjorn Andersson #include <linux/soc/qcom/smem.h>
20caf989c3SBjorn Andersson #include <linux/sizes.h>
21caf989c3SBjorn Andersson #include <linux/delay.h>
22caf989c3SBjorn Andersson #include <linux/regmap.h>
23caf989c3SBjorn Andersson #include <linux/workqueue.h>
24caf989c3SBjorn Andersson #include <linux/list.h>
25caf989c3SBjorn Andersson
26caf989c3SBjorn Andersson #include <linux/rpmsg/qcom_glink.h>
27caf989c3SBjorn Andersson
28caf989c3SBjorn Andersson #include "qcom_glink_native.h"
29caf989c3SBjorn Andersson
30caf989c3SBjorn Andersson #define FIFO_FULL_RESERVE 8
31caf989c3SBjorn Andersson #define FIFO_ALIGNMENT 8
32caf989c3SBjorn Andersson #define TX_BLOCKED_CMD_RESERVE 8 /* size of struct read_notif_request */
33caf989c3SBjorn Andersson
34caf989c3SBjorn Andersson #define SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR 478
35caf989c3SBjorn Andersson #define SMEM_GLINK_NATIVE_XPRT_FIFO_0 479
36caf989c3SBjorn Andersson #define SMEM_GLINK_NATIVE_XPRT_FIFO_1 480
37caf989c3SBjorn Andersson
38ab9fdd41SBjorn Andersson struct qcom_glink_smem {
39ab9fdd41SBjorn Andersson struct device dev;
40ab9fdd41SBjorn Andersson
41f424d1cbSBjorn Andersson int irq;
42ab9fdd41SBjorn Andersson struct qcom_glink *glink;
43ab9fdd41SBjorn Andersson
44f424d1cbSBjorn Andersson struct mbox_client mbox_client;
45f424d1cbSBjorn Andersson struct mbox_chan *mbox_chan;
46f424d1cbSBjorn Andersson
47ab9fdd41SBjorn Andersson u32 remote_pid;
48ab9fdd41SBjorn Andersson };
49ab9fdd41SBjorn Andersson
50caf989c3SBjorn Andersson struct glink_smem_pipe {
51caf989c3SBjorn Andersson struct qcom_glink_pipe native;
52caf989c3SBjorn Andersson
53caf989c3SBjorn Andersson __le32 *tail;
54caf989c3SBjorn Andersson __le32 *head;
55caf989c3SBjorn Andersson
56caf989c3SBjorn Andersson void *fifo;
57caf989c3SBjorn Andersson
58ab9fdd41SBjorn Andersson struct qcom_glink_smem *smem;
59caf989c3SBjorn Andersson };
60caf989c3SBjorn Andersson
61caf989c3SBjorn Andersson #define to_smem_pipe(p) container_of(p, struct glink_smem_pipe, native)
62caf989c3SBjorn Andersson
glink_smem_rx_avail(struct qcom_glink_pipe * np)63caf989c3SBjorn Andersson static size_t glink_smem_rx_avail(struct qcom_glink_pipe *np)
64caf989c3SBjorn Andersson {
65caf989c3SBjorn Andersson struct glink_smem_pipe *pipe = to_smem_pipe(np);
66ab9fdd41SBjorn Andersson struct qcom_glink_smem *smem = pipe->smem;
67caf989c3SBjorn Andersson size_t len;
68caf989c3SBjorn Andersson void *fifo;
69caf989c3SBjorn Andersson u32 head;
70caf989c3SBjorn Andersson u32 tail;
71caf989c3SBjorn Andersson
72caf989c3SBjorn Andersson if (!pipe->fifo) {
73ab9fdd41SBjorn Andersson fifo = qcom_smem_get(smem->remote_pid,
74caf989c3SBjorn Andersson SMEM_GLINK_NATIVE_XPRT_FIFO_1, &len);
75caf989c3SBjorn Andersson if (IS_ERR(fifo)) {
76caf989c3SBjorn Andersson pr_err("failed to acquire RX fifo handle: %ld\n",
77caf989c3SBjorn Andersson PTR_ERR(fifo));
78caf989c3SBjorn Andersson return 0;
79caf989c3SBjorn Andersson }
80caf989c3SBjorn Andersson
81caf989c3SBjorn Andersson pipe->fifo = fifo;
82caf989c3SBjorn Andersson pipe->native.length = len;
83caf989c3SBjorn Andersson }
84caf989c3SBjorn Andersson
85caf989c3SBjorn Andersson head = le32_to_cpu(*pipe->head);
86caf989c3SBjorn Andersson tail = le32_to_cpu(*pipe->tail);
87caf989c3SBjorn Andersson
88caf989c3SBjorn Andersson if (head < tail)
89caf989c3SBjorn Andersson return pipe->native.length - tail + head;
90caf989c3SBjorn Andersson else
91caf989c3SBjorn Andersson return head - tail;
92caf989c3SBjorn Andersson }
93caf989c3SBjorn Andersson
glink_smem_rx_peek(struct qcom_glink_pipe * np,void * data,unsigned int offset,size_t count)94*a8f500c6SBjorn Andersson static void glink_smem_rx_peek(struct qcom_glink_pipe *np,
95b88eee97SBjorn Andersson void *data, unsigned int offset, size_t count)
96caf989c3SBjorn Andersson {
97caf989c3SBjorn Andersson struct glink_smem_pipe *pipe = to_smem_pipe(np);
98caf989c3SBjorn Andersson size_t len;
99caf989c3SBjorn Andersson u32 tail;
100caf989c3SBjorn Andersson
101caf989c3SBjorn Andersson tail = le32_to_cpu(*pipe->tail);
102b88eee97SBjorn Andersson tail += offset;
103b88eee97SBjorn Andersson if (tail >= pipe->native.length)
104b88eee97SBjorn Andersson tail -= pipe->native.length;
105caf989c3SBjorn Andersson
106caf989c3SBjorn Andersson len = min_t(size_t, count, pipe->native.length - tail);
107928002a5SArun Kumar Neelakantam if (len)
108928002a5SArun Kumar Neelakantam memcpy_fromio(data, pipe->fifo + tail, len);
109caf989c3SBjorn Andersson
110928002a5SArun Kumar Neelakantam if (len != count)
111928002a5SArun Kumar Neelakantam memcpy_fromio(data + len, pipe->fifo, (count - len));
112caf989c3SBjorn Andersson }
113caf989c3SBjorn Andersson
glink_smem_rx_advance(struct qcom_glink_pipe * np,size_t count)114caf989c3SBjorn Andersson static void glink_smem_rx_advance(struct qcom_glink_pipe *np,
115caf989c3SBjorn Andersson size_t count)
116caf989c3SBjorn Andersson {
117caf989c3SBjorn Andersson struct glink_smem_pipe *pipe = to_smem_pipe(np);
118caf989c3SBjorn Andersson u32 tail;
119caf989c3SBjorn Andersson
120caf989c3SBjorn Andersson tail = le32_to_cpu(*pipe->tail);
121caf989c3SBjorn Andersson
122caf989c3SBjorn Andersson tail += count;
1234623e8bfSChris Lew if (tail >= pipe->native.length)
124caf989c3SBjorn Andersson tail -= pipe->native.length;
125caf989c3SBjorn Andersson
126caf989c3SBjorn Andersson *pipe->tail = cpu_to_le32(tail);
127caf989c3SBjorn Andersson }
128caf989c3SBjorn Andersson
glink_smem_tx_avail(struct qcom_glink_pipe * np)129caf989c3SBjorn Andersson static size_t glink_smem_tx_avail(struct qcom_glink_pipe *np)
130caf989c3SBjorn Andersson {
131caf989c3SBjorn Andersson struct glink_smem_pipe *pipe = to_smem_pipe(np);
132caf989c3SBjorn Andersson u32 head;
133caf989c3SBjorn Andersson u32 tail;
134caf989c3SBjorn Andersson u32 avail;
135caf989c3SBjorn Andersson
136caf989c3SBjorn Andersson head = le32_to_cpu(*pipe->head);
137caf989c3SBjorn Andersson tail = le32_to_cpu(*pipe->tail);
138caf989c3SBjorn Andersson
139caf989c3SBjorn Andersson if (tail <= head)
140caf989c3SBjorn Andersson avail = pipe->native.length - head + tail;
141caf989c3SBjorn Andersson else
142caf989c3SBjorn Andersson avail = tail - head;
143caf989c3SBjorn Andersson
144caf989c3SBjorn Andersson if (avail < (FIFO_FULL_RESERVE + TX_BLOCKED_CMD_RESERVE))
145caf989c3SBjorn Andersson avail = 0;
146caf989c3SBjorn Andersson else
147caf989c3SBjorn Andersson avail -= FIFO_FULL_RESERVE + TX_BLOCKED_CMD_RESERVE;
148caf989c3SBjorn Andersson
149caf989c3SBjorn Andersson return avail;
150caf989c3SBjorn Andersson }
151caf989c3SBjorn Andersson
glink_smem_tx_write_one(struct glink_smem_pipe * pipe,unsigned int head,const void * data,size_t count)152caf989c3SBjorn Andersson static unsigned int glink_smem_tx_write_one(struct glink_smem_pipe *pipe,
153caf989c3SBjorn Andersson unsigned int head,
154caf989c3SBjorn Andersson const void *data, size_t count)
155caf989c3SBjorn Andersson {
156caf989c3SBjorn Andersson size_t len;
157caf989c3SBjorn Andersson
158caf989c3SBjorn Andersson len = min_t(size_t, count, pipe->native.length - head);
159caf989c3SBjorn Andersson if (len)
160caf989c3SBjorn Andersson memcpy(pipe->fifo + head, data, len);
161caf989c3SBjorn Andersson
162caf989c3SBjorn Andersson if (len != count)
163caf989c3SBjorn Andersson memcpy(pipe->fifo, data + len, count - len);
164caf989c3SBjorn Andersson
165caf989c3SBjorn Andersson head += count;
166caf989c3SBjorn Andersson if (head >= pipe->native.length)
167caf989c3SBjorn Andersson head -= pipe->native.length;
168caf989c3SBjorn Andersson
169caf989c3SBjorn Andersson return head;
170caf989c3SBjorn Andersson }
171caf989c3SBjorn Andersson
glink_smem_tx_write(struct qcom_glink_pipe * glink_pipe,const void * hdr,size_t hlen,const void * data,size_t dlen)172caf989c3SBjorn Andersson static void glink_smem_tx_write(struct qcom_glink_pipe *glink_pipe,
173caf989c3SBjorn Andersson const void *hdr, size_t hlen,
174caf989c3SBjorn Andersson const void *data, size_t dlen)
175caf989c3SBjorn Andersson {
176caf989c3SBjorn Andersson struct glink_smem_pipe *pipe = to_smem_pipe(glink_pipe);
177caf989c3SBjorn Andersson unsigned int head;
178caf989c3SBjorn Andersson
179caf989c3SBjorn Andersson head = le32_to_cpu(*pipe->head);
180caf989c3SBjorn Andersson
181caf989c3SBjorn Andersson head = glink_smem_tx_write_one(pipe, head, hdr, hlen);
182caf989c3SBjorn Andersson head = glink_smem_tx_write_one(pipe, head, data, dlen);
183caf989c3SBjorn Andersson
184caf989c3SBjorn Andersson /* Ensure head is always aligned to 8 bytes */
185caf989c3SBjorn Andersson head = ALIGN(head, 8);
186caf989c3SBjorn Andersson if (head >= pipe->native.length)
187caf989c3SBjorn Andersson head -= pipe->native.length;
188caf989c3SBjorn Andersson
1899d324973SBjorn Andersson /* Ensure ordering of fifo and head update */
1909d324973SBjorn Andersson wmb();
1919d324973SBjorn Andersson
192caf989c3SBjorn Andersson *pipe->head = cpu_to_le32(head);
193caf989c3SBjorn Andersson }
194caf989c3SBjorn Andersson
glink_smem_tx_kick(struct qcom_glink_pipe * glink_pipe)195f424d1cbSBjorn Andersson static void glink_smem_tx_kick(struct qcom_glink_pipe *glink_pipe)
196f424d1cbSBjorn Andersson {
197f424d1cbSBjorn Andersson struct glink_smem_pipe *pipe = to_smem_pipe(glink_pipe);
198f424d1cbSBjorn Andersson struct qcom_glink_smem *smem = pipe->smem;
199f424d1cbSBjorn Andersson
200f424d1cbSBjorn Andersson mbox_send_message(smem->mbox_chan, NULL);
201f424d1cbSBjorn Andersson mbox_client_txdone(smem->mbox_chan, 0);
202f424d1cbSBjorn Andersson }
203f424d1cbSBjorn Andersson
qcom_glink_smem_intr(int irq,void * data)204f424d1cbSBjorn Andersson static irqreturn_t qcom_glink_smem_intr(int irq, void *data)
205f424d1cbSBjorn Andersson {
206f424d1cbSBjorn Andersson struct qcom_glink_smem *smem = data;
207f424d1cbSBjorn Andersson
208f424d1cbSBjorn Andersson qcom_glink_native_rx(smem->glink);
209f424d1cbSBjorn Andersson
210f424d1cbSBjorn Andersson return IRQ_HANDLED;
211f424d1cbSBjorn Andersson }
212f424d1cbSBjorn Andersson
qcom_glink_smem_release(struct device * dev)213caf989c3SBjorn Andersson static void qcom_glink_smem_release(struct device *dev)
214caf989c3SBjorn Andersson {
215ab9fdd41SBjorn Andersson struct qcom_glink_smem *smem = container_of(dev, struct qcom_glink_smem, dev);
216ab9fdd41SBjorn Andersson
217ab9fdd41SBjorn Andersson kfree(smem);
218caf989c3SBjorn Andersson }
219caf989c3SBjorn Andersson
qcom_glink_smem_register(struct device * parent,struct device_node * node)220ab9fdd41SBjorn Andersson struct qcom_glink_smem *qcom_glink_smem_register(struct device *parent,
221caf989c3SBjorn Andersson struct device_node *node)
222caf989c3SBjorn Andersson {
223caf989c3SBjorn Andersson struct glink_smem_pipe *rx_pipe;
224caf989c3SBjorn Andersson struct glink_smem_pipe *tx_pipe;
225ab9fdd41SBjorn Andersson struct qcom_glink_smem *smem;
226caf989c3SBjorn Andersson struct qcom_glink *glink;
227caf989c3SBjorn Andersson struct device *dev;
228caf989c3SBjorn Andersson u32 remote_pid;
229caf989c3SBjorn Andersson __le32 *descs;
230caf989c3SBjorn Andersson size_t size;
231caf989c3SBjorn Andersson int ret;
232caf989c3SBjorn Andersson
233ab9fdd41SBjorn Andersson smem = kzalloc(sizeof(*smem), GFP_KERNEL);
234ab9fdd41SBjorn Andersson if (!smem)
235caf989c3SBjorn Andersson return ERR_PTR(-ENOMEM);
236caf989c3SBjorn Andersson
237ab9fdd41SBjorn Andersson dev = &smem->dev;
238ab9fdd41SBjorn Andersson
239caf989c3SBjorn Andersson dev->parent = parent;
240caf989c3SBjorn Andersson dev->of_node = node;
241caf989c3SBjorn Andersson dev->release = qcom_glink_smem_release;
2429fe69a72SBjorn Andersson dev_set_name(dev, "%s:%pOFn", dev_name(parent->parent), node);
243caf989c3SBjorn Andersson ret = device_register(dev);
244caf989c3SBjorn Andersson if (ret) {
245caf989c3SBjorn Andersson pr_err("failed to register glink edge\n");
246a9011726SArvind Yadav put_device(dev);
247caf989c3SBjorn Andersson return ERR_PTR(ret);
248caf989c3SBjorn Andersson }
249caf989c3SBjorn Andersson
250caf989c3SBjorn Andersson ret = of_property_read_u32(dev->of_node, "qcom,remote-pid",
251caf989c3SBjorn Andersson &remote_pid);
252caf989c3SBjorn Andersson if (ret) {
253caf989c3SBjorn Andersson dev_err(dev, "failed to parse qcom,remote-pid\n");
254caf989c3SBjorn Andersson goto err_put_dev;
255caf989c3SBjorn Andersson }
256caf989c3SBjorn Andersson
257ab9fdd41SBjorn Andersson smem->remote_pid = remote_pid;
258ab9fdd41SBjorn Andersson
259caf989c3SBjorn Andersson rx_pipe = devm_kzalloc(dev, sizeof(*rx_pipe), GFP_KERNEL);
260caf989c3SBjorn Andersson tx_pipe = devm_kzalloc(dev, sizeof(*tx_pipe), GFP_KERNEL);
261caf989c3SBjorn Andersson if (!rx_pipe || !tx_pipe) {
262caf989c3SBjorn Andersson ret = -ENOMEM;
263caf989c3SBjorn Andersson goto err_put_dev;
264caf989c3SBjorn Andersson }
265caf989c3SBjorn Andersson
266caf989c3SBjorn Andersson ret = qcom_smem_alloc(remote_pid,
267caf989c3SBjorn Andersson SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, 32);
268caf989c3SBjorn Andersson if (ret && ret != -EEXIST) {
269caf989c3SBjorn Andersson dev_err(dev, "failed to allocate glink descriptors\n");
270caf989c3SBjorn Andersson goto err_put_dev;
271caf989c3SBjorn Andersson }
272caf989c3SBjorn Andersson
273caf989c3SBjorn Andersson descs = qcom_smem_get(remote_pid,
274caf989c3SBjorn Andersson SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, &size);
275caf989c3SBjorn Andersson if (IS_ERR(descs)) {
276caf989c3SBjorn Andersson dev_err(dev, "failed to acquire xprt descriptor\n");
277caf989c3SBjorn Andersson ret = PTR_ERR(descs);
278caf989c3SBjorn Andersson goto err_put_dev;
279caf989c3SBjorn Andersson }
280caf989c3SBjorn Andersson
281caf989c3SBjorn Andersson if (size != 32) {
282caf989c3SBjorn Andersson dev_err(dev, "glink descriptor of invalid size\n");
283caf989c3SBjorn Andersson ret = -EINVAL;
284caf989c3SBjorn Andersson goto err_put_dev;
285caf989c3SBjorn Andersson }
286caf989c3SBjorn Andersson
287caf989c3SBjorn Andersson tx_pipe->tail = &descs[0];
288caf989c3SBjorn Andersson tx_pipe->head = &descs[1];
289caf989c3SBjorn Andersson rx_pipe->tail = &descs[2];
290caf989c3SBjorn Andersson rx_pipe->head = &descs[3];
291caf989c3SBjorn Andersson
292caf989c3SBjorn Andersson ret = qcom_smem_alloc(remote_pid, SMEM_GLINK_NATIVE_XPRT_FIFO_0,
293caf989c3SBjorn Andersson SZ_16K);
294caf989c3SBjorn Andersson if (ret && ret != -EEXIST) {
295caf989c3SBjorn Andersson dev_err(dev, "failed to allocate TX fifo\n");
296caf989c3SBjorn Andersson goto err_put_dev;
297caf989c3SBjorn Andersson }
298caf989c3SBjorn Andersson
299caf989c3SBjorn Andersson tx_pipe->fifo = qcom_smem_get(remote_pid, SMEM_GLINK_NATIVE_XPRT_FIFO_0,
300caf989c3SBjorn Andersson &tx_pipe->native.length);
301caf989c3SBjorn Andersson if (IS_ERR(tx_pipe->fifo)) {
302caf989c3SBjorn Andersson dev_err(dev, "failed to acquire TX fifo\n");
303caf989c3SBjorn Andersson ret = PTR_ERR(tx_pipe->fifo);
304caf989c3SBjorn Andersson goto err_put_dev;
305caf989c3SBjorn Andersson }
306caf989c3SBjorn Andersson
307f424d1cbSBjorn Andersson smem->irq = of_irq_get(smem->dev.of_node, 0);
308f424d1cbSBjorn Andersson ret = devm_request_irq(&smem->dev, smem->irq, qcom_glink_smem_intr,
309f424d1cbSBjorn Andersson IRQF_NO_SUSPEND | IRQF_NO_AUTOEN,
310f424d1cbSBjorn Andersson "glink-smem", smem);
311f424d1cbSBjorn Andersson if (ret) {
312f424d1cbSBjorn Andersson dev_err(&smem->dev, "failed to request IRQ\n");
313f424d1cbSBjorn Andersson goto err_put_dev;
314f424d1cbSBjorn Andersson }
315f424d1cbSBjorn Andersson
316f424d1cbSBjorn Andersson smem->mbox_client.dev = &smem->dev;
317f424d1cbSBjorn Andersson smem->mbox_client.knows_txdone = true;
318f424d1cbSBjorn Andersson smem->mbox_chan = mbox_request_channel(&smem->mbox_client, 0);
319f424d1cbSBjorn Andersson if (IS_ERR(smem->mbox_chan)) {
320f424d1cbSBjorn Andersson ret = dev_err_probe(&smem->dev, PTR_ERR(smem->mbox_chan),
321f424d1cbSBjorn Andersson "failed to acquire IPC channel\n");
322f424d1cbSBjorn Andersson goto err_put_dev;
323f424d1cbSBjorn Andersson }
324f424d1cbSBjorn Andersson
325ab9fdd41SBjorn Andersson rx_pipe->smem = smem;
326caf989c3SBjorn Andersson rx_pipe->native.avail = glink_smem_rx_avail;
327*a8f500c6SBjorn Andersson rx_pipe->native.peek = glink_smem_rx_peek;
328caf989c3SBjorn Andersson rx_pipe->native.advance = glink_smem_rx_advance;
329caf989c3SBjorn Andersson
330ab9fdd41SBjorn Andersson tx_pipe->smem = smem;
331caf989c3SBjorn Andersson tx_pipe->native.avail = glink_smem_tx_avail;
332caf989c3SBjorn Andersson tx_pipe->native.write = glink_smem_tx_write;
333f424d1cbSBjorn Andersson tx_pipe->native.kick = glink_smem_tx_kick;
334caf989c3SBjorn Andersson
335caf989c3SBjorn Andersson *rx_pipe->tail = 0;
336caf989c3SBjorn Andersson *tx_pipe->head = 0;
337caf989c3SBjorn Andersson
338caf989c3SBjorn Andersson glink = qcom_glink_native_probe(dev,
339933b45daSSricharan R GLINK_FEATURE_INTENT_REUSE,
340933b45daSSricharan R &rx_pipe->native, &tx_pipe->native,
341933b45daSSricharan R false);
342caf989c3SBjorn Andersson if (IS_ERR(glink)) {
343caf989c3SBjorn Andersson ret = PTR_ERR(glink);
344f424d1cbSBjorn Andersson goto err_free_mbox;
345caf989c3SBjorn Andersson }
346caf989c3SBjorn Andersson
347ab9fdd41SBjorn Andersson smem->glink = glink;
348ab9fdd41SBjorn Andersson
349f424d1cbSBjorn Andersson enable_irq(smem->irq);
350f424d1cbSBjorn Andersson
351ab9fdd41SBjorn Andersson return smem;
352ab9fdd41SBjorn Andersson
353f424d1cbSBjorn Andersson err_free_mbox:
354f424d1cbSBjorn Andersson mbox_free_channel(smem->mbox_chan);
355caf989c3SBjorn Andersson
356caf989c3SBjorn Andersson err_put_dev:
357a9011726SArvind Yadav device_unregister(dev);
358caf989c3SBjorn Andersson
359caf989c3SBjorn Andersson return ERR_PTR(ret);
360caf989c3SBjorn Andersson }
361caf989c3SBjorn Andersson EXPORT_SYMBOL_GPL(qcom_glink_smem_register);
362caf989c3SBjorn Andersson
qcom_glink_smem_unregister(struct qcom_glink_smem * smem)363ab9fdd41SBjorn Andersson void qcom_glink_smem_unregister(struct qcom_glink_smem *smem)
364caf989c3SBjorn Andersson {
365ab9fdd41SBjorn Andersson struct qcom_glink *glink = smem->glink;
366ab9fdd41SBjorn Andersson
367f424d1cbSBjorn Andersson disable_irq(smem->irq);
368f424d1cbSBjorn Andersson
369caf989c3SBjorn Andersson qcom_glink_native_remove(glink);
370f424d1cbSBjorn Andersson
371f424d1cbSBjorn Andersson mbox_free_channel(smem->mbox_chan);
372f424d1cbSBjorn Andersson device_unregister(&smem->dev);
373caf989c3SBjorn Andersson }
374caf989c3SBjorn Andersson EXPORT_SYMBOL_GPL(qcom_glink_smem_unregister);
375caf989c3SBjorn Andersson
376caf989c3SBjorn Andersson MODULE_AUTHOR("Bjorn Andersson <bjorn.andersson@linaro.org>");
377caf989c3SBjorn Andersson MODULE_DESCRIPTION("Qualcomm GLINK SMEM driver");
378caf989c3SBjorn Andersson MODULE_LICENSE("GPL v2");
379