Lines Matching +full:qcom +full:- +full:ipcc
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
14 #include <dt-bindings/mailbox/qcom-ipcc.h>
16 /* IPCC Register offsets */
30 * struct qcom_ipcc_chan_info - Per-mailbox-channel info
31 * @client_id: The client-id to which the interrupt has to be triggered
32 * @signal_id: The signal-id to which the interrupt has to be triggered
40 * struct qcom_ipcc - Holder for the mailbox driver
42 * @base: Base address of the IPCC frame associated to APSS
45 * @mchan: The per-mailbox channel info array
74 struct qcom_ipcc *ipcc = data; in qcom_ipcc_irq_fn() local
79 hwirq = readl(ipcc->base + IPCC_REG_RECV_ID); in qcom_ipcc_irq_fn()
83 virq = irq_find_mapping(ipcc->irq_domain, hwirq); in qcom_ipcc_irq_fn()
84 writel(hwirq, ipcc->base + IPCC_REG_RECV_SIGNAL_CLEAR); in qcom_ipcc_irq_fn()
93 struct qcom_ipcc *ipcc = irq_data_get_irq_chip_data(irqd); in qcom_ipcc_mask_irq() local
96 writel(hwirq, ipcc->base + IPCC_REG_RECV_SIGNAL_DISABLE); in qcom_ipcc_mask_irq()
101 struct qcom_ipcc *ipcc = irq_data_get_irq_chip_data(irqd); in qcom_ipcc_unmask_irq() local
104 writel(hwirq, ipcc->base + IPCC_REG_RECV_SIGNAL_ENABLE); in qcom_ipcc_unmask_irq()
108 .name = "ipcc",
117 struct qcom_ipcc *ipcc = d->host_data; in qcom_ipcc_domain_map() local
120 irq_set_chip_data(irq, ipcc); in qcom_ipcc_domain_map()
133 return -EINVAL; in qcom_ipcc_domain_xlate()
148 struct qcom_ipcc *ipcc = to_qcom_ipcc(chan->mbox); in qcom_ipcc_mbox_send_data() local
149 struct qcom_ipcc_chan_info *mchan = chan->con_priv; in qcom_ipcc_mbox_send_data()
152 hwirq = qcom_ipcc_get_hwirq(mchan->client_id, mchan->signal_id); in qcom_ipcc_mbox_send_data()
153 writel(hwirq, ipcc->base + IPCC_REG_SEND_ID); in qcom_ipcc_mbox_send_data()
160 chan->con_priv = NULL; in qcom_ipcc_mbox_shutdown()
166 struct qcom_ipcc *ipcc = to_qcom_ipcc(mbox); in qcom_ipcc_mbox_xlate() local
172 dev = ipcc->dev; in qcom_ipcc_mbox_xlate()
174 if (ph->args_count != 2) in qcom_ipcc_mbox_xlate()
175 return ERR_PTR(-EINVAL); in qcom_ipcc_mbox_xlate()
177 for (chan_id = 0; chan_id < mbox->num_chans; chan_id++) { in qcom_ipcc_mbox_xlate()
178 chan = &ipcc->chans[chan_id]; in qcom_ipcc_mbox_xlate()
179 mchan = chan->con_priv; in qcom_ipcc_mbox_xlate()
183 else if (mchan->client_id == ph->args[0] && in qcom_ipcc_mbox_xlate()
184 mchan->signal_id == ph->args[1]) in qcom_ipcc_mbox_xlate()
185 return ERR_PTR(-EBUSY); in qcom_ipcc_mbox_xlate()
188 if (chan_id >= mbox->num_chans) in qcom_ipcc_mbox_xlate()
189 return ERR_PTR(-EBUSY); in qcom_ipcc_mbox_xlate()
193 return ERR_PTR(-ENOMEM); in qcom_ipcc_mbox_xlate()
195 mchan->client_id = ph->args[0]; in qcom_ipcc_mbox_xlate()
196 mchan->signal_id = ph->args[1]; in qcom_ipcc_mbox_xlate()
197 chan->con_priv = mchan; in qcom_ipcc_mbox_xlate()
207 static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc, in qcom_ipcc_setup_mbox() argument
213 struct device *dev = ipcc->dev; in qcom_ipcc_setup_mbox()
220 ipcc->num_chans = 0; in qcom_ipcc_setup_mbox()
225 "mboxes", "#mbox-cells"); in qcom_ipcc_setup_mbox()
228 "#mbox-cells", j, &curr_ph); in qcom_ipcc_setup_mbox()
231 ipcc->num_chans++; in qcom_ipcc_setup_mbox()
236 if (!ipcc->num_chans) in qcom_ipcc_setup_mbox()
239 ipcc->chans = devm_kcalloc(dev, ipcc->num_chans, in qcom_ipcc_setup_mbox()
241 if (!ipcc->chans) in qcom_ipcc_setup_mbox()
242 return -ENOMEM; in qcom_ipcc_setup_mbox()
244 mbox = &ipcc->mbox; in qcom_ipcc_setup_mbox()
245 mbox->dev = dev; in qcom_ipcc_setup_mbox()
246 mbox->num_chans = ipcc->num_chans; in qcom_ipcc_setup_mbox()
247 mbox->chans = ipcc->chans; in qcom_ipcc_setup_mbox()
248 mbox->ops = &ipcc_mbox_chan_ops; in qcom_ipcc_setup_mbox()
249 mbox->of_xlate = qcom_ipcc_mbox_xlate; in qcom_ipcc_setup_mbox()
250 mbox->txdone_irq = false; in qcom_ipcc_setup_mbox()
251 mbox->txdone_poll = false; in qcom_ipcc_setup_mbox()
258 struct qcom_ipcc *ipcc = dev_get_drvdata(dev); in qcom_ipcc_pm_resume() local
262 hwirq = readl(ipcc->base + IPCC_REG_RECV_ID); in qcom_ipcc_pm_resume()
266 virq = irq_find_mapping(ipcc->irq_domain, hwirq); in qcom_ipcc_pm_resume()
268 dev_dbg(dev, "virq: %d triggered client-id: %ld; signal-id: %ld\n", virq, in qcom_ipcc_pm_resume()
276 struct qcom_ipcc *ipcc; in qcom_ipcc_probe() local
281 ipcc = devm_kzalloc(&pdev->dev, sizeof(*ipcc), GFP_KERNEL); in qcom_ipcc_probe()
282 if (!ipcc) in qcom_ipcc_probe()
283 return -ENOMEM; in qcom_ipcc_probe()
285 ipcc->dev = &pdev->dev; in qcom_ipcc_probe()
287 ipcc->base = devm_platform_ioremap_resource(pdev, 0); in qcom_ipcc_probe()
288 if (IS_ERR(ipcc->base)) in qcom_ipcc_probe()
289 return PTR_ERR(ipcc->base); in qcom_ipcc_probe()
291 ipcc->irq = platform_get_irq(pdev, 0); in qcom_ipcc_probe()
292 if (ipcc->irq < 0) in qcom_ipcc_probe()
293 return ipcc->irq; in qcom_ipcc_probe()
295 name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "ipcc_%d", id++); in qcom_ipcc_probe()
297 return -ENOMEM; in qcom_ipcc_probe()
299 ipcc->irq_domain = irq_domain_add_tree(pdev->dev.of_node, in qcom_ipcc_probe()
300 &qcom_ipcc_irq_ops, ipcc); in qcom_ipcc_probe()
301 if (!ipcc->irq_domain) in qcom_ipcc_probe()
302 return -ENOMEM; in qcom_ipcc_probe()
304 ret = qcom_ipcc_setup_mbox(ipcc, pdev->dev.of_node); in qcom_ipcc_probe()
308 ret = devm_request_irq(&pdev->dev, ipcc->irq, qcom_ipcc_irq_fn, in qcom_ipcc_probe()
310 IRQF_NO_THREAD, name, ipcc); in qcom_ipcc_probe()
312 dev_err(&pdev->dev, "Failed to register the irq: %d\n", ret); in qcom_ipcc_probe()
316 platform_set_drvdata(pdev, ipcc); in qcom_ipcc_probe()
321 if (ipcc->num_chans) in qcom_ipcc_probe()
322 mbox_controller_unregister(&ipcc->mbox); in qcom_ipcc_probe()
324 irq_domain_remove(ipcc->irq_domain); in qcom_ipcc_probe()
331 struct qcom_ipcc *ipcc = platform_get_drvdata(pdev); in qcom_ipcc_remove() local
333 disable_irq_wake(ipcc->irq); in qcom_ipcc_remove()
334 irq_domain_remove(ipcc->irq_domain); in qcom_ipcc_remove()
340 { .compatible = "qcom,ipcc"},
353 .name = "qcom-ipcc",
368 MODULE_DESCRIPTION("Qualcomm Technologies, Inc. IPCC driver");