Lines Matching +full:rpm +full:- +full:msg +full:- +full:ram
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016-2017, Linaro Ltd
27 #define RPM_TOC_MAX_ENTRIES ((RPM_TOC_SIZE - sizeof(struct rpm_toc)) / \
75 head = readl(pipe->head); in glink_rpm_rx_avail()
76 tail = readl(pipe->tail); in glink_rpm_rx_avail()
79 return pipe->native.length - tail + head; in glink_rpm_rx_avail()
81 return head - tail; in glink_rpm_rx_avail()
91 tail = readl(pipe->tail); in glink_rpm_rx_peek()
93 if (tail >= pipe->native.length) in glink_rpm_rx_peek()
94 tail -= pipe->native.length; in glink_rpm_rx_peek()
96 len = min_t(size_t, count, pipe->native.length - tail); in glink_rpm_rx_peek()
98 __ioread32_copy(data, pipe->fifo + tail, in glink_rpm_rx_peek()
103 __ioread32_copy(data + len, pipe->fifo, in glink_rpm_rx_peek()
104 (count - len) / sizeof(u32)); in glink_rpm_rx_peek()
114 tail = readl(pipe->tail); in glink_rpm_rx_advance()
117 if (tail >= pipe->native.length) in glink_rpm_rx_advance()
118 tail -= pipe->native.length; in glink_rpm_rx_advance()
120 writel(tail, pipe->tail); in glink_rpm_rx_advance()
129 head = readl(pipe->head); in glink_rpm_tx_avail()
130 tail = readl(pipe->tail); in glink_rpm_tx_avail()
133 return pipe->native.length - head + tail; in glink_rpm_tx_avail()
135 return tail - head; in glink_rpm_tx_avail()
144 len = min_t(size_t, count, pipe->native.length - head); in glink_rpm_tx_write_one()
146 __iowrite32_copy(pipe->fifo + head, data, in glink_rpm_tx_write_one()
151 __iowrite32_copy(pipe->fifo, data + len, in glink_rpm_tx_write_one()
152 (count - len) / sizeof(u32)); in glink_rpm_tx_write_one()
156 if (head >= pipe->native.length) in glink_rpm_tx_write_one()
157 head -= pipe->native.length; in glink_rpm_tx_write_one()
183 memcpy(padding, data + aligned_dlen, dlen - aligned_dlen); in glink_rpm_tx_write()
185 head = readl(pipe->head); in glink_rpm_tx_write()
189 pad = ALIGN(tlen, 8) - ALIGN_DOWN(tlen, 4); in glink_rpm_tx_write()
192 writel(head, pipe->head); in glink_rpm_tx_write()
198 struct glink_rpm *rpm = container_of(pipe, struct glink_rpm, tx_pipe); in glink_rpm_tx_kick() local
200 mbox_send_message(rpm->mbox_chan, NULL); in glink_rpm_tx_kick()
201 mbox_client_txdone(rpm->mbox_chan, 0); in glink_rpm_tx_kick()
206 struct glink_rpm *rpm = data; in qcom_glink_rpm_intr() local
208 qcom_glink_native_rx(rpm->glink); in qcom_glink_rpm_intr()
229 return -ENOMEM; in glink_rpm_parse_toc()
231 __ioread32_copy(buf, msg_ram + msg_ram_size - RPM_TOC_SIZE, in glink_rpm_parse_toc()
236 if (le32_to_cpu(toc->magic) != RPM_TOC_MAGIC) { in glink_rpm_parse_toc()
237 dev_err(dev, "RPM TOC has invalid magic\n"); in glink_rpm_parse_toc()
241 num_entries = le32_to_cpu(toc->count); in glink_rpm_parse_toc()
248 id = le32_to_cpu(toc->entries[i].id); in glink_rpm_parse_toc()
249 offset = le32_to_cpu(toc->entries[i].offset); in glink_rpm_parse_toc()
250 size = le32_to_cpu(toc->entries[i].size); in glink_rpm_parse_toc()
259 rx->native.length = size; in glink_rpm_parse_toc()
261 rx->tail = msg_ram + offset; in glink_rpm_parse_toc()
262 rx->head = msg_ram + offset + sizeof(u32); in glink_rpm_parse_toc()
263 rx->fifo = msg_ram + offset + 2 * sizeof(u32); in glink_rpm_parse_toc()
266 tx->native.length = size; in glink_rpm_parse_toc()
268 tx->tail = msg_ram + offset; in glink_rpm_parse_toc()
269 tx->head = msg_ram + offset + sizeof(u32); in glink_rpm_parse_toc()
270 tx->fifo = msg_ram + offset + 2 * sizeof(u32); in glink_rpm_parse_toc()
275 if (!rx->fifo || !tx->fifo) { in glink_rpm_parse_toc()
285 return -EINVAL; in glink_rpm_parse_toc()
291 struct glink_rpm *rpm; in glink_rpm_probe() local
295 struct device *dev = &pdev->dev; in glink_rpm_probe()
299 rpm = devm_kzalloc(&pdev->dev, sizeof(*rpm), GFP_KERNEL); in glink_rpm_probe()
300 if (!rpm) in glink_rpm_probe()
301 return -ENOMEM; in glink_rpm_probe()
303 np = of_parse_phandle(dev->of_node, "qcom,rpm-msg-ram", 0); in glink_rpm_probe()
312 return -ENOMEM; in glink_rpm_probe()
315 &rpm->rx_pipe, &rpm->tx_pipe); in glink_rpm_probe()
319 rpm->irq = of_irq_get(dev->of_node, 0); in glink_rpm_probe()
320 ret = devm_request_irq(dev, rpm->irq, qcom_glink_rpm_intr, in glink_rpm_probe()
322 "glink-rpm", rpm); in glink_rpm_probe()
328 rpm->mbox_client.dev = dev; in glink_rpm_probe()
329 rpm->mbox_client.knows_txdone = true; in glink_rpm_probe()
330 rpm->mbox_chan = mbox_request_channel(&rpm->mbox_client, 0); in glink_rpm_probe()
331 if (IS_ERR(rpm->mbox_chan)) in glink_rpm_probe()
332 return dev_err_probe(dev, PTR_ERR(rpm->mbox_chan), "failed to acquire IPC channel\n"); in glink_rpm_probe()
335 rpm->rx_pipe.native.avail = glink_rpm_rx_avail; in glink_rpm_probe()
336 rpm->rx_pipe.native.peek = glink_rpm_rx_peek; in glink_rpm_probe()
337 rpm->rx_pipe.native.advance = glink_rpm_rx_advance; in glink_rpm_probe()
338 rpm->tx_pipe.native.avail = glink_rpm_tx_avail; in glink_rpm_probe()
339 rpm->tx_pipe.native.write = glink_rpm_tx_write; in glink_rpm_probe()
340 rpm->tx_pipe.native.kick = glink_rpm_tx_kick; in glink_rpm_probe()
342 writel(0, rpm->tx_pipe.head); in glink_rpm_probe()
343 writel(0, rpm->rx_pipe.tail); in glink_rpm_probe()
347 &rpm->rx_pipe.native, in glink_rpm_probe()
348 &rpm->tx_pipe.native, in glink_rpm_probe()
351 mbox_free_channel(rpm->mbox_chan); in glink_rpm_probe()
355 rpm->glink = glink; in glink_rpm_probe()
357 platform_set_drvdata(pdev, rpm); in glink_rpm_probe()
359 enable_irq(rpm->irq); in glink_rpm_probe()
366 struct glink_rpm *rpm = platform_get_drvdata(pdev); in glink_rpm_remove() local
367 struct qcom_glink *glink = rpm->glink; in glink_rpm_remove()
369 disable_irq(rpm->irq); in glink_rpm_remove()
373 mbox_free_channel(rpm->mbox_chan); in glink_rpm_remove()
377 { .compatible = "qcom,glink-rpm" },
404 MODULE_DESCRIPTION("Qualcomm GLINK RPM driver");