Lines Matching +full:sc9860 +full:- +full:mailbox

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Spreadtrum mailbox driver
85 fifo_len = priv->outbox_fifo_depth; in sprd_mbox_get_fifo_len()
89 fifo_len = wr_pos - rd_pos; in sprd_mbox_get_fifo_len()
91 fifo_len = priv->outbox_fifo_depth - rd_pos + wr_pos; in sprd_mbox_get_fifo_len()
104 fifo_sts = readl(priv->outbox_base + SPRD_MBOX_FIFO_STS); in sprd_mbox_outbox_isr()
108 dev_warn_ratelimited(priv->dev, "spurious outbox interrupt\n"); in sprd_mbox_outbox_isr()
113 msg[0] = readl(priv->outbox_base + SPRD_MBOX_MSG_LOW); in sprd_mbox_outbox_isr()
114 msg[1] = readl(priv->outbox_base + SPRD_MBOX_MSG_HIGH); in sprd_mbox_outbox_isr()
115 id = readl(priv->outbox_base + SPRD_MBOX_ID); in sprd_mbox_outbox_isr()
117 chan = &priv->chan[id]; in sprd_mbox_outbox_isr()
121 writel(0x1, priv->outbox_base + SPRD_MBOX_TRIGGER); in sprd_mbox_outbox_isr()
125 writel(SPRD_MBOX_IRQ_CLR, priv->outbox_base + SPRD_MBOX_IRQ_STS); in sprd_mbox_outbox_isr()
136 fifo_sts = readl(priv->inbox_base + SPRD_MBOX_FIFO_STS); in sprd_mbox_inbox_isr()
142 dev_warn_ratelimited(priv->dev, "spurious inbox interrupt\n"); in sprd_mbox_inbox_isr()
148 send_sts &= (send_sts - 1); in sprd_mbox_inbox_isr()
150 chan = &priv->chan[id]; in sprd_mbox_inbox_isr()
164 priv->inbox_base + SPRD_MBOX_FIFO_RST); in sprd_mbox_inbox_isr()
167 writel(SPRD_MBOX_IRQ_CLR, priv->inbox_base + SPRD_MBOX_IRQ_STS); in sprd_mbox_inbox_isr()
174 struct sprd_mbox_priv *priv = to_sprd_mbox_priv(chan->mbox); in sprd_mbox_send_data()
175 unsigned long id = (unsigned long)chan->con_priv; in sprd_mbox_send_data()
179 writel(data[0], priv->inbox_base + SPRD_MBOX_MSG_LOW); in sprd_mbox_send_data()
180 writel(data[1], priv->inbox_base + SPRD_MBOX_MSG_HIGH); in sprd_mbox_send_data()
183 writel(id, priv->inbox_base + SPRD_MBOX_ID); in sprd_mbox_send_data()
186 writel(0x1, priv->inbox_base + SPRD_MBOX_TRIGGER); in sprd_mbox_send_data()
193 struct sprd_mbox_priv *priv = to_sprd_mbox_priv(chan->mbox); in sprd_mbox_flush()
194 unsigned long id = (unsigned long)chan->con_priv; in sprd_mbox_flush()
200 busy = readl(priv->inbox_base + SPRD_MBOX_FIFO_STS) & in sprd_mbox_flush()
210 return -ETIME; in sprd_mbox_flush()
215 struct sprd_mbox_priv *priv = to_sprd_mbox_priv(chan->mbox); in sprd_mbox_startup()
219 writel(0x0, priv->outbox_base + SPRD_MBOX_FIFO_RST); in sprd_mbox_startup()
222 val = readl(priv->inbox_base + SPRD_MBOX_IRQ_MSK); in sprd_mbox_startup()
224 writel(val, priv->inbox_base + SPRD_MBOX_IRQ_MSK); in sprd_mbox_startup()
227 val = readl(priv->outbox_base + SPRD_MBOX_IRQ_MSK); in sprd_mbox_startup()
229 writel(val, priv->outbox_base + SPRD_MBOX_IRQ_MSK); in sprd_mbox_startup()
236 struct sprd_mbox_priv *priv = to_sprd_mbox_priv(chan->mbox); in sprd_mbox_shutdown()
239 writel(SPRD_INBOX_FIFO_IRQ_MASK, priv->inbox_base + SPRD_MBOX_IRQ_MSK); in sprd_mbox_shutdown()
240 writel(SPRD_OUTBOX_FIFO_IRQ_MASK, priv->outbox_base + SPRD_MBOX_IRQ_MSK); in sprd_mbox_shutdown()
254 clk_disable_unprepare(priv->clk); in sprd_mbox_disable()
259 struct device *dev = &pdev->dev; in sprd_mbox_probe()
266 return -ENOMEM; in sprd_mbox_probe()
268 priv->dev = dev; in sprd_mbox_probe()
271 * The Spreadtrum mailbox uses an inbox to send messages to the target in sprd_mbox_probe()
274 * Thus the mailbox controller supplies 2 different register addresses in sprd_mbox_probe()
277 priv->inbox_base = devm_platform_ioremap_resource(pdev, 0); in sprd_mbox_probe()
278 if (IS_ERR(priv->inbox_base)) in sprd_mbox_probe()
279 return PTR_ERR(priv->inbox_base); in sprd_mbox_probe()
281 priv->outbox_base = devm_platform_ioremap_resource(pdev, 1); in sprd_mbox_probe()
282 if (IS_ERR(priv->outbox_base)) in sprd_mbox_probe()
283 return PTR_ERR(priv->outbox_base); in sprd_mbox_probe()
285 priv->clk = devm_clk_get(dev, "enable"); in sprd_mbox_probe()
286 if (IS_ERR(priv->clk)) { in sprd_mbox_probe()
287 dev_err(dev, "failed to get mailbox clock\n"); in sprd_mbox_probe()
288 return PTR_ERR(priv->clk); in sprd_mbox_probe()
291 ret = clk_prepare_enable(priv->clk); in sprd_mbox_probe()
297 dev_err(dev, "failed to add mailbox disable action\n"); in sprd_mbox_probe()
324 priv->outbox_fifo_depth = in sprd_mbox_probe()
325 readl(priv->outbox_base + SPRD_MBOX_FIFO_DEPTH) + 1; in sprd_mbox_probe()
326 priv->mbox.dev = dev; in sprd_mbox_probe()
327 priv->mbox.chans = &priv->chan[0]; in sprd_mbox_probe()
328 priv->mbox.num_chans = SPRD_MBOX_CHAN_MAX; in sprd_mbox_probe()
329 priv->mbox.ops = &sprd_mbox_ops; in sprd_mbox_probe()
330 priv->mbox.txdone_irq = true; in sprd_mbox_probe()
333 priv->chan[id].con_priv = (void *)id; in sprd_mbox_probe()
335 ret = devm_mbox_controller_register(dev, &priv->mbox); in sprd_mbox_probe()
337 dev_err(dev, "failed to register mailbox: %d\n", ret); in sprd_mbox_probe()
345 { .compatible = "sprd,sc9860-mailbox", },
352 .name = "sprd-mailbox",
360 MODULE_DESCRIPTION("Spreadtrum mailbox driver");