Lines Matching refs:channel
74 tegra_bpmp_channel_get_thread_index(struct tegra_bpmp_channel *channel) in tegra_bpmp_channel_get_thread_index() argument
76 struct tegra_bpmp *bpmp = channel->bpmp; in tegra_bpmp_channel_get_thread_index()
82 index = channel - channel->bpmp->threaded_channels; in tegra_bpmp_channel_get_thread_index()
97 static bool tegra_bpmp_master_acked(struct tegra_bpmp_channel *channel) in tegra_bpmp_master_acked() argument
101 frame = tegra_ivc_read_get_next_frame(channel->ivc); in tegra_bpmp_master_acked()
103 channel->ib = NULL; in tegra_bpmp_master_acked()
107 channel->ib = frame; in tegra_bpmp_master_acked()
112 static int tegra_bpmp_wait_ack(struct tegra_bpmp_channel *channel) in tegra_bpmp_wait_ack() argument
114 unsigned long timeout = channel->bpmp->soc->channels.cpu_tx.timeout; in tegra_bpmp_wait_ack()
120 if (tegra_bpmp_master_acked(channel)) in tegra_bpmp_wait_ack()
127 static bool tegra_bpmp_master_free(struct tegra_bpmp_channel *channel) in tegra_bpmp_master_free() argument
131 frame = tegra_ivc_write_get_next_frame(channel->ivc); in tegra_bpmp_master_free()
133 channel->ob = NULL; in tegra_bpmp_master_free()
137 channel->ob = frame; in tegra_bpmp_master_free()
142 static int tegra_bpmp_wait_master_free(struct tegra_bpmp_channel *channel) in tegra_bpmp_wait_master_free() argument
144 unsigned long timeout = channel->bpmp->soc->channels.cpu_tx.timeout; in tegra_bpmp_wait_master_free()
150 if (tegra_bpmp_master_free(channel)) in tegra_bpmp_wait_master_free()
159 static ssize_t __tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel, in __tegra_bpmp_channel_read() argument
165 memcpy(data, channel->ib->data, size); in __tegra_bpmp_channel_read()
167 err = tegra_ivc_read_advance(channel->ivc); in __tegra_bpmp_channel_read()
171 *ret = channel->ib->code; in __tegra_bpmp_channel_read()
176 static ssize_t tegra_bpmp_channel_read(struct tegra_bpmp_channel *channel, in tegra_bpmp_channel_read() argument
179 struct tegra_bpmp *bpmp = channel->bpmp; in tegra_bpmp_channel_read()
184 index = tegra_bpmp_channel_get_thread_index(channel); in tegra_bpmp_channel_read()
191 err = __tegra_bpmp_channel_read(channel, data, size, ret); in tegra_bpmp_channel_read()
201 static ssize_t __tegra_bpmp_channel_write(struct tegra_bpmp_channel *channel, in __tegra_bpmp_channel_write() argument
205 channel->ob->code = mrq; in __tegra_bpmp_channel_write()
206 channel->ob->flags = flags; in __tegra_bpmp_channel_write()
209 memcpy(channel->ob->data, data, size); in __tegra_bpmp_channel_write()
211 return tegra_ivc_write_advance(channel->ivc); in __tegra_bpmp_channel_write()
220 struct tegra_bpmp_channel *channel; in tegra_bpmp_write_threaded() local
237 channel = &bpmp->threaded_channels[index]; in tegra_bpmp_write_threaded()
239 if (!tegra_bpmp_master_free(channel)) { in tegra_bpmp_write_threaded()
246 err = __tegra_bpmp_channel_write(channel, mrq, MSG_ACK | MSG_RING, in tegra_bpmp_write_threaded()
254 return channel; in tegra_bpmp_write_threaded()
265 static ssize_t tegra_bpmp_channel_write(struct tegra_bpmp_channel *channel, in tegra_bpmp_channel_write() argument
271 err = tegra_bpmp_wait_master_free(channel); in tegra_bpmp_channel_write()
275 return __tegra_bpmp_channel_write(channel, mrq, flags, data, size); in tegra_bpmp_channel_write()
281 struct tegra_bpmp_channel *channel; in tegra_bpmp_transfer_atomic() local
290 channel = bpmp->tx_channel; in tegra_bpmp_transfer_atomic()
294 err = tegra_bpmp_channel_write(channel, msg->mrq, MSG_ACK, in tegra_bpmp_transfer_atomic()
303 err = mbox_send_message(bpmp->mbox.channel, NULL); in tegra_bpmp_transfer_atomic()
307 mbox_client_txdone(bpmp->mbox.channel, 0); in tegra_bpmp_transfer_atomic()
309 err = tegra_bpmp_wait_ack(channel); in tegra_bpmp_transfer_atomic()
313 return __tegra_bpmp_channel_read(channel, msg->rx.data, msg->rx.size, in tegra_bpmp_transfer_atomic()
321 struct tegra_bpmp_channel *channel; in tegra_bpmp_transfer() local
331 channel = tegra_bpmp_write_threaded(bpmp, msg->mrq, msg->tx.data, in tegra_bpmp_transfer()
333 if (IS_ERR(channel)) in tegra_bpmp_transfer()
334 return PTR_ERR(channel); in tegra_bpmp_transfer()
336 err = mbox_send_message(bpmp->mbox.channel, NULL); in tegra_bpmp_transfer()
340 mbox_client_txdone(bpmp->mbox.channel, 0); in tegra_bpmp_transfer()
344 err = wait_for_completion_timeout(&channel->completion, timeout); in tegra_bpmp_transfer()
348 return tegra_bpmp_channel_read(channel, msg->rx.data, msg->rx.size, in tegra_bpmp_transfer()
365 void tegra_bpmp_mrq_return(struct tegra_bpmp_channel *channel, int code, in tegra_bpmp_mrq_return() argument
368 unsigned long flags = channel->ib->flags; in tegra_bpmp_mrq_return()
369 struct tegra_bpmp *bpmp = channel->bpmp; in tegra_bpmp_mrq_return()
376 err = tegra_ivc_read_advance(channel->ivc); in tegra_bpmp_mrq_return()
383 frame = tegra_ivc_write_get_next_frame(channel->ivc); in tegra_bpmp_mrq_return()
392 err = tegra_ivc_write_advance(channel->ivc); in tegra_bpmp_mrq_return()
397 err = mbox_send_message(bpmp->mbox.channel, NULL); in tegra_bpmp_mrq_return()
401 mbox_client_txdone(bpmp->mbox.channel, 0); in tegra_bpmp_mrq_return()
408 struct tegra_bpmp_channel *channel) in tegra_bpmp_handle_mrq() argument
418 tegra_bpmp_mrq_return(channel, -EINVAL, &zero, sizeof(zero)); in tegra_bpmp_handle_mrq()
422 entry->handler(mrq, channel, entry->data); in tegra_bpmp_handle_mrq()
473 struct tegra_bpmp_channel *channel, in tegra_bpmp_mrq_handle_ping() argument
479 request = (struct mrq_ping_request *)channel->ib->data; in tegra_bpmp_mrq_handle_ping()
484 tegra_bpmp_mrq_return(channel, 0, &response, sizeof(response)); in tegra_bpmp_mrq_handle_ping()
558 static void tegra_bpmp_channel_signal(struct tegra_bpmp_channel *channel) in tegra_bpmp_channel_signal() argument
560 unsigned long flags = channel->ob->flags; in tegra_bpmp_channel_signal()
565 complete(&channel->completion); in tegra_bpmp_channel_signal()
571 struct tegra_bpmp_channel *channel; in tegra_bpmp_handle_rx() local
575 channel = bpmp->rx_channel; in tegra_bpmp_handle_rx()
579 if (tegra_bpmp_master_acked(channel)) in tegra_bpmp_handle_rx()
580 tegra_bpmp_handle_mrq(bpmp, channel->ib->code, channel); in tegra_bpmp_handle_rx()
585 struct tegra_bpmp_channel *channel; in tegra_bpmp_handle_rx() local
587 channel = &bpmp->threaded_channels[i]; in tegra_bpmp_handle_rx()
589 if (tegra_bpmp_master_acked(channel)) { in tegra_bpmp_handle_rx()
590 tegra_bpmp_channel_signal(channel); in tegra_bpmp_handle_rx()
603 if (WARN_ON(bpmp->mbox.channel == NULL)) in tegra_bpmp_ivc_notify()
606 err = mbox_send_message(bpmp->mbox.channel, NULL); in tegra_bpmp_ivc_notify()
610 mbox_client_txdone(bpmp->mbox.channel, 0); in tegra_bpmp_ivc_notify()
613 static int tegra_bpmp_channel_init(struct tegra_bpmp_channel *channel, in tegra_bpmp_channel_init() argument
621 channel->ivc = devm_kzalloc(bpmp->dev, sizeof(*channel->ivc), in tegra_bpmp_channel_init()
623 if (!channel->ivc) in tegra_bpmp_channel_init()
630 err = tegra_ivc_init(channel->ivc, NULL, in tegra_bpmp_channel_init()
641 init_completion(&channel->completion); in tegra_bpmp_channel_init()
642 channel->bpmp = bpmp; in tegra_bpmp_channel_init()
647 static void tegra_bpmp_channel_reset(struct tegra_bpmp_channel *channel) in tegra_bpmp_channel_reset() argument
650 tegra_ivc_reset(channel->ivc); in tegra_bpmp_channel_reset()
653 while (tegra_ivc_notified(channel->ivc)) in tegra_bpmp_channel_reset()
657 static void tegra_bpmp_channel_cleanup(struct tegra_bpmp_channel *channel) in tegra_bpmp_channel_cleanup() argument
659 tegra_ivc_cleanup(channel->ivc); in tegra_bpmp_channel_cleanup()
770 bpmp->mbox.channel = mbox_request_channel(&bpmp->mbox.client, 0); in tegra_bpmp_probe()
771 if (IS_ERR(bpmp->mbox.channel)) { in tegra_bpmp_probe()
772 err = PTR_ERR(bpmp->mbox.channel); in tegra_bpmp_probe()
829 mbox_free_channel(bpmp->mbox.channel); in tegra_bpmp_probe()