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

1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (c) 2017-2019 Samuel Holland <samuel@sholland.org>
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()
206 return -ENOMEM; in sun6i_msgbox_probe()
210 return -ENOMEM; in sun6i_msgbox_probe()
215 mbox->clk = devm_clk_get(dev, NULL); in sun6i_msgbox_probe()
216 if (IS_ERR(mbox->clk)) { in sun6i_msgbox_probe()
217 ret = PTR_ERR(mbox->clk); in sun6i_msgbox_probe()
222 ret = clk_prepare_enable(mbox->clk); in sun6i_msgbox_probe()
251 ret = -ENODEV; in sun6i_msgbox_probe()
255 mbox->regs = devm_ioremap_resource(&pdev->dev, res); in sun6i_msgbox_probe()
256 if (IS_ERR(mbox->regs)) { in sun6i_msgbox_probe()
257 ret = PTR_ERR(mbox->regs); in sun6i_msgbox_probe()
262 /* Disable all IRQs for this end of the msgbox. */ in sun6i_msgbox_probe()
263 writel(0, mbox->regs + LOCAL_IRQ_EN_REG); in sun6i_msgbox_probe()
265 ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0), in sun6i_msgbox_probe()
272 mbox->controller.dev = dev; in sun6i_msgbox_probe()
273 mbox->controller.ops = &sun6i_msgbox_chan_ops; in sun6i_msgbox_probe()
274 mbox->controller.chans = chans; in sun6i_msgbox_probe()
275 mbox->controller.num_chans = NUM_CHANS; in sun6i_msgbox_probe()
276 mbox->controller.txdone_irq = false; in sun6i_msgbox_probe()
277 mbox->controller.txdone_poll = true; in sun6i_msgbox_probe()
278 mbox->controller.txpoll_period = 5; in sun6i_msgbox_probe()
280 spin_lock_init(&mbox->lock); in sun6i_msgbox_probe()
283 ret = mbox_controller_register(&mbox->controller); in sun6i_msgbox_probe()
292 clk_disable_unprepare(mbox->clk); in sun6i_msgbox_probe()
301 mbox_controller_unregister(&mbox->controller); in sun6i_msgbox_remove()
303 clk_disable_unprepare(mbox->clk); in sun6i_msgbox_remove()
309 { .compatible = "allwinner,sun6i-a31-msgbox", },
316 .name = "sun6i-msgbox",
325 MODULE_DESCRIPTION("Allwinner sun6i/sun8i/sun9i/sun50i Message Box");