Lines Matching refs:mbox

60 static inline int altera_mbox_full(struct altera_mbox *mbox)  in altera_mbox_full()  argument
64 status = readl_relaxed(mbox->mbox_base + MAILBOX_STS_REG); in altera_mbox_full()
68 static inline int altera_mbox_pending(struct altera_mbox *mbox) in altera_mbox_pending() argument
72 status = readl_relaxed(mbox->mbox_base + MAILBOX_STS_REG); in altera_mbox_pending()
76 static void altera_mbox_rx_intmask(struct altera_mbox *mbox, bool enable) in altera_mbox_rx_intmask() argument
80 mask = readl_relaxed(mbox->mbox_base + MAILBOX_INTMASK_REG); in altera_mbox_rx_intmask()
85 writel_relaxed(mask, mbox->mbox_base + MAILBOX_INTMASK_REG); in altera_mbox_rx_intmask()
88 static void altera_mbox_tx_intmask(struct altera_mbox *mbox, bool enable) in altera_mbox_tx_intmask() argument
92 mask = readl_relaxed(mbox->mbox_base + MAILBOX_INTMASK_REG); in altera_mbox_tx_intmask()
97 writel_relaxed(mask, mbox->mbox_base + MAILBOX_INTMASK_REG); in altera_mbox_tx_intmask()
100 static bool altera_mbox_is_sender(struct altera_mbox *mbox) in altera_mbox_is_sender() argument
107 writel_relaxed(MBOX_MAGIC, mbox->mbox_base + MAILBOX_PTR_REG); in altera_mbox_is_sender()
108 reg = readl_relaxed(mbox->mbox_base + MAILBOX_PTR_REG); in altera_mbox_is_sender()
111 writel_relaxed(0, mbox->mbox_base + MAILBOX_PTR_REG); in altera_mbox_is_sender()
119 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_rx_data() local
122 if (altera_mbox_pending(mbox)) { in altera_mbox_rx_data()
124 readl_relaxed(mbox->mbox_base + MAILBOX_PTR_REG); in altera_mbox_rx_data()
126 readl_relaxed(mbox->mbox_base + MAILBOX_CMD_REG); in altera_mbox_rx_data()
133 struct altera_mbox *mbox = from_timer(mbox, t, rxpoll_timer); in altera_mbox_poll_rx() local
135 altera_mbox_rx_data(mbox->chan); in altera_mbox_poll_rx()
137 mod_timer(&mbox->rxpoll_timer, in altera_mbox_poll_rx()
144 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_tx_interrupt() local
146 altera_mbox_tx_intmask(mbox, false); in altera_mbox_tx_interrupt()
163 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_startup_sender() local
165 if (mbox->intr_mode) { in altera_mbox_startup_sender()
166 ret = request_irq(mbox->irq, altera_mbox_tx_interrupt, 0, in altera_mbox_startup_sender()
169 dev_err(mbox->dev, in altera_mbox_startup_sender()
182 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_startup_receiver() local
184 if (mbox->intr_mode) { in altera_mbox_startup_receiver()
185 ret = request_irq(mbox->irq, altera_mbox_rx_interrupt, 0, in altera_mbox_startup_receiver()
188 mbox->intr_mode = false; in altera_mbox_startup_receiver()
192 altera_mbox_rx_intmask(mbox, true); in altera_mbox_startup_receiver()
198 mbox->chan = chan; in altera_mbox_startup_receiver()
199 timer_setup(&mbox->rxpoll_timer, altera_mbox_poll_rx, 0); in altera_mbox_startup_receiver()
200 mod_timer(&mbox->rxpoll_timer, in altera_mbox_startup_receiver()
208 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_send_data() local
211 if (!mbox || !data) in altera_mbox_send_data()
213 if (!mbox->is_sender) { in altera_mbox_send_data()
214 dev_warn(mbox->dev, in altera_mbox_send_data()
219 if (altera_mbox_full(mbox)) in altera_mbox_send_data()
223 if (mbox->intr_mode) in altera_mbox_send_data()
224 altera_mbox_tx_intmask(mbox, true); in altera_mbox_send_data()
227 writel_relaxed(udata[MBOX_PTR], mbox->mbox_base + MAILBOX_PTR_REG); in altera_mbox_send_data()
228 writel_relaxed(udata[MBOX_CMD], mbox->mbox_base + MAILBOX_CMD_REG); in altera_mbox_send_data()
235 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_last_tx_done() local
238 return altera_mbox_full(mbox) ? false : true; in altera_mbox_last_tx_done()
243 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_peek_data() local
245 return altera_mbox_pending(mbox) ? true : false; in altera_mbox_peek_data()
250 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_startup() local
253 if (!mbox) in altera_mbox_startup()
256 if (mbox->is_sender) in altera_mbox_startup()
266 struct altera_mbox *mbox = mbox_chan_to_altera_mbox(chan); in altera_mbox_shutdown() local
268 if (mbox->intr_mode) { in altera_mbox_shutdown()
270 writel_relaxed(~0, mbox->mbox_base + MAILBOX_INTMASK_REG); in altera_mbox_shutdown()
271 free_irq(mbox->irq, chan); in altera_mbox_shutdown()
272 } else if (!mbox->is_sender) { in altera_mbox_shutdown()
273 del_timer_sync(&mbox->rxpoll_timer); in altera_mbox_shutdown()
287 struct altera_mbox *mbox; in altera_mbox_probe() local
291 mbox = devm_kzalloc(&pdev->dev, sizeof(*mbox), in altera_mbox_probe()
293 if (!mbox) in altera_mbox_probe()
301 mbox->mbox_base = devm_platform_ioremap_resource(pdev, 0); in altera_mbox_probe()
302 if (IS_ERR(mbox->mbox_base)) in altera_mbox_probe()
303 return PTR_ERR(mbox->mbox_base); in altera_mbox_probe()
306 mbox->is_sender = altera_mbox_is_sender(mbox); in altera_mbox_probe()
308 mbox->irq = platform_get_irq(pdev, 0); in altera_mbox_probe()
309 if (mbox->irq >= 0) in altera_mbox_probe()
310 mbox->intr_mode = true; in altera_mbox_probe()
312 mbox->dev = &pdev->dev; in altera_mbox_probe()
315 chans[0].con_priv = mbox; in altera_mbox_probe()
316 mbox->controller.dev = mbox->dev; in altera_mbox_probe()
317 mbox->controller.num_chans = 1; in altera_mbox_probe()
318 mbox->controller.chans = chans; in altera_mbox_probe()
319 mbox->controller.ops = &altera_mbox_ops; in altera_mbox_probe()
321 if (mbox->is_sender) { in altera_mbox_probe()
322 if (mbox->intr_mode) { in altera_mbox_probe()
323 mbox->controller.txdone_irq = true; in altera_mbox_probe()
325 mbox->controller.txdone_poll = true; in altera_mbox_probe()
326 mbox->controller.txpoll_period = MBOX_POLLING_MS; in altera_mbox_probe()
330 ret = devm_mbox_controller_register(&pdev->dev, &mbox->controller); in altera_mbox_probe()
336 platform_set_drvdata(pdev, mbox); in altera_mbox_probe()