Lines Matching refs:mbox

44 #define mbox_dbg(mbox, ...)	dev_dbg((mbox)->controller.dev, __VA_ARGS__)  argument
58 return chan - chan->mbox->chans; in channel_number()
68 struct sun6i_msgbox *mbox = dev_id; in sun6i_msgbox_irq() local
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()
88 mbox_dbg(mbox, "Channel %d received 0x%08x\n", n, msg); in sun6i_msgbox_irq()
93 writel(RX_IRQ(n), mbox->regs + LOCAL_IRQ_STAT_REG); in sun6i_msgbox_irq()
101 struct sun6i_msgbox *mbox = to_sun6i_msgbox(chan); in sun6i_msgbox_send_data() local
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()
110 mbox_dbg(mbox, "Channel %d sent 0x%08x\n", n, msg); in sun6i_msgbox_send_data()
117 struct sun6i_msgbox *mbox = to_sun6i_msgbox(chan); in sun6i_msgbox_startup() local
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()
134 mbox_dbg(mbox, "Channel %d startup complete\n", n); in sun6i_msgbox_startup()
141 struct sun6i_msgbox *mbox = to_sun6i_msgbox(chan); in sun6i_msgbox_shutdown() local
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()
159 mbox_dbg(mbox, "Channel %d shutdown complete\n", n); in sun6i_msgbox_shutdown()
164 struct sun6i_msgbox *mbox = to_sun6i_msgbox(chan); in sun6i_msgbox_last_tx_done() local
176 return !(readl(mbox->regs + REMOTE_IRQ_STAT_REG) & RX_IRQ(n)); in sun6i_msgbox_last_tx_done()
181 struct sun6i_msgbox *mbox = to_sun6i_msgbox(chan); in sun6i_msgbox_peek_data() local
184 return readl(mbox->regs + MSG_STAT_REG(n)) & MSG_STAT_MASK; in sun6i_msgbox_peek_data()
200 struct sun6i_msgbox *mbox; in sun6i_msgbox_probe() local
203 mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL); in sun6i_msgbox_probe()
204 if (!mbox) in sun6i_msgbox_probe()
212 chans[i].con_priv = mbox; 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()
256 writel(0, mbox->regs + LOCAL_IRQ_EN_REG); in sun6i_msgbox_probe()
259 sun6i_msgbox_irq, 0, dev_name(dev), mbox); 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()
274 platform_set_drvdata(pdev, mbox); 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()
292 struct sun6i_msgbox *mbox = platform_get_drvdata(pdev); in sun6i_msgbox_remove() local
294 mbox_controller_unregister(&mbox->controller); in sun6i_msgbox_remove()
296 clk_disable_unprepare(mbox->clk); in sun6i_msgbox_remove()