Lines Matching +full:sun6i +full:- +full:a31 +full:- +full:msgbox

1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (c) 2017-2019 Samuel Holland <[email protected]>
44 #define mbox_dbg(mbox, ...) dev_dbg((mbox)->controller.dev, __VA_ARGS__)
58 return chan - chan->mbox->chans; in channel_number()
63 return chan->con_priv; in to_sun6i_msgbox()
73 status = readl(mbox->regs + LOCAL_IRQ_EN_REG) & in sun6i_msgbox_irq()
74 readl(mbox->regs + LOCAL_IRQ_STAT_REG); in sun6i_msgbox_irq()
80 struct mbox_chan *chan = &mbox->controller.chans[n]; in sun6i_msgbox_irq()
86 uint32_t msg = readl(mbox->regs + MSG_DATA_REG(n)); in sun6i_msgbox_irq()
93 writel(RX_IRQ(n), mbox->regs + LOCAL_IRQ_STAT_REG); in sun6i_msgbox_irq()
106 if (WARN_ON_ONCE(!(readl(mbox->regs + CTRL_REG(n)) & CTRL_TX(n)))) in sun6i_msgbox_send_data()
109 writel(msg, mbox->regs + MSG_DATA_REG(n)); in sun6i_msgbox_send_data()
121 if (readl(mbox->regs + CTRL_REG(n)) & CTRL_RX(n)) { in sun6i_msgbox_startup()
124 readl(mbox->regs + MSG_DATA_REG(n)); in sun6i_msgbox_startup()
125 writel(RX_IRQ(n), mbox->regs + LOCAL_IRQ_STAT_REG); in sun6i_msgbox_startup()
128 spin_lock(&mbox->lock); in sun6i_msgbox_startup()
129 writel(readl(mbox->regs + LOCAL_IRQ_EN_REG) | RX_IRQ(n), in sun6i_msgbox_startup()
130 mbox->regs + LOCAL_IRQ_EN_REG); in sun6i_msgbox_startup()
131 spin_unlock(&mbox->lock); in sun6i_msgbox_startup()
144 if (readl(mbox->regs + CTRL_REG(n)) & CTRL_RX(n)) { in sun6i_msgbox_shutdown()
146 spin_lock(&mbox->lock); in sun6i_msgbox_shutdown()
147 writel(readl(mbox->regs + LOCAL_IRQ_EN_REG) & ~RX_IRQ(n), in sun6i_msgbox_shutdown()
148 mbox->regs + LOCAL_IRQ_EN_REG); in sun6i_msgbox_shutdown()
149 spin_unlock(&mbox->lock); in sun6i_msgbox_shutdown()
154 readl(mbox->regs + MSG_DATA_REG(n)); in sun6i_msgbox_shutdown()
155 writel(RX_IRQ(n), mbox->regs + LOCAL_IRQ_STAT_REG); in sun6i_msgbox_shutdown()
156 } while (readl(mbox->regs + LOCAL_IRQ_STAT_REG) & RX_IRQ(n)); in sun6i_msgbox_shutdown()
176 return !(readl(mbox->regs + REMOTE_IRQ_STAT_REG) & RX_IRQ(n)); in sun6i_msgbox_last_tx_done()
184 return readl(mbox->regs + MSG_STAT_REG(n)) & MSG_STAT_MASK; in sun6i_msgbox_peek_data()
197 struct device *dev = &pdev->dev; in sun6i_msgbox_probe()
205 return -ENOMEM; in sun6i_msgbox_probe()
209 return -ENOMEM; in sun6i_msgbox_probe()
214 mbox->clk = devm_clk_get(dev, NULL); in sun6i_msgbox_probe()
215 if (IS_ERR(mbox->clk)) { in sun6i_msgbox_probe()
216 ret = PTR_ERR(mbox->clk); in sun6i_msgbox_probe()
221 ret = clk_prepare_enable(mbox->clk); in sun6i_msgbox_probe()
248 mbox->regs = devm_platform_ioremap_resource(pdev, 0); in sun6i_msgbox_probe()
249 if (IS_ERR(mbox->regs)) { in sun6i_msgbox_probe()
250 ret = PTR_ERR(mbox->regs); in sun6i_msgbox_probe()
255 /* Disable all IRQs for this end of the msgbox. */ in sun6i_msgbox_probe()
256 writel(0, mbox->regs + LOCAL_IRQ_EN_REG); in sun6i_msgbox_probe()
258 ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0), in sun6i_msgbox_probe()
265 mbox->controller.dev = dev; in sun6i_msgbox_probe()
266 mbox->controller.ops = &sun6i_msgbox_chan_ops; in sun6i_msgbox_probe()
267 mbox->controller.chans = chans; in sun6i_msgbox_probe()
268 mbox->controller.num_chans = NUM_CHANS; in sun6i_msgbox_probe()
269 mbox->controller.txdone_irq = false; in sun6i_msgbox_probe()
270 mbox->controller.txdone_poll = true; in sun6i_msgbox_probe()
271 mbox->controller.txpoll_period = 5; in sun6i_msgbox_probe()
273 spin_lock_init(&mbox->lock); in sun6i_msgbox_probe()
276 ret = mbox_controller_register(&mbox->controller); in sun6i_msgbox_probe()
285 clk_disable_unprepare(mbox->clk); in sun6i_msgbox_probe()
294 mbox_controller_unregister(&mbox->controller); in sun6i_msgbox_remove()
296 clk_disable_unprepare(mbox->clk); in sun6i_msgbox_remove()
300 { .compatible = "allwinner,sun6i-a31-msgbox", },
307 .name = "sun6i-msgbox",
316 MODULE_DESCRIPTION("Allwinner sun6i/sun8i/sun9i/sun50i Message Box");