Lines Matching refs:bpmp
18 #include <soc/tegra/bpmp.h>
19 #include <soc/tegra/bpmp-abi.h>
22 #include "bpmp-private.h"
37 struct tegra_bpmp *bpmp = channel->bpmp;
39 return bpmp->soc->ops;
45 struct tegra_bpmp *bpmp;
48 np = of_parse_phandle(dev->of_node, "nvidia,bpmp", 0);
54 bpmp = ERR_PTR(-ENODEV);
58 bpmp = platform_get_drvdata(pdev);
59 if (!bpmp) {
60 bpmp = ERR_PTR(-EPROBE_DEFER);
67 return bpmp;
71 void tegra_bpmp_put(struct tegra_bpmp *bpmp)
73 if (bpmp)
74 put_device(bpmp->dev);
81 struct tegra_bpmp *bpmp = channel->bpmp;
85 count = bpmp->soc->channels.thread.count;
87 index = channel - channel->bpmp->threaded_channels;
118 unsigned long timeout = channel->bpmp->soc->channels.cpu_tx.timeout;
164 unsigned long timeout = channel->bpmp->soc->channels.cpu_tx.timeout;
193 static int tegra_bpmp_ring_doorbell(struct tegra_bpmp *bpmp)
195 return bpmp->soc->ops->ring_doorbell(bpmp);
218 struct tegra_bpmp *bpmp = channel->bpmp;
229 spin_lock_irqsave(&bpmp->lock, flags);
231 clear_bit(index, bpmp->threaded.allocated);
232 spin_unlock_irqrestore(&bpmp->lock, flags);
235 up(&bpmp->threaded.lock);
254 tegra_bpmp_write_threaded(struct tegra_bpmp *bpmp, unsigned int mrq,
257 unsigned long timeout = bpmp->soc->channels.thread.timeout;
258 unsigned int count = bpmp->soc->channels.thread.count;
264 err = down_timeout(&bpmp->threaded.lock, usecs_to_jiffies(timeout));
268 spin_lock_irqsave(&bpmp->lock, flags);
270 index = find_first_zero_bit(bpmp->threaded.allocated, count);
276 channel = &bpmp->threaded_channels[index];
283 set_bit(index, bpmp->threaded.allocated);
290 set_bit(index, bpmp->threaded.busy);
292 spin_unlock_irqrestore(&bpmp->lock, flags);
296 clear_bit(index, bpmp->threaded.allocated);
298 spin_unlock_irqrestore(&bpmp->lock, flags);
299 up(&bpmp->threaded.lock);
317 int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
329 channel = bpmp->tx_channel;
331 spin_lock(&bpmp->atomic_tx_lock);
336 spin_unlock(&bpmp->atomic_tx_lock);
340 spin_unlock(&bpmp->atomic_tx_lock);
342 err = tegra_bpmp_ring_doorbell(bpmp);
355 int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
368 channel = tegra_bpmp_write_threaded(bpmp, msg->mrq, msg->tx.data,
373 err = tegra_bpmp_ring_doorbell(bpmp);
377 timeout = usecs_to_jiffies(bpmp->soc->channels.thread.timeout);
388 static struct tegra_bpmp_mrq *tegra_bpmp_find_mrq(struct tegra_bpmp *bpmp,
393 list_for_each_entry(entry, &bpmp->mrqs, list)
404 struct tegra_bpmp *bpmp = channel->bpmp;
430 err = tegra_bpmp_ring_doorbell(bpmp);
437 static void tegra_bpmp_handle_mrq(struct tegra_bpmp *bpmp,
444 spin_lock(&bpmp->lock);
446 entry = tegra_bpmp_find_mrq(bpmp, mrq);
448 spin_unlock(&bpmp->lock);
455 spin_unlock(&bpmp->lock);
458 int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
467 entry = devm_kzalloc(bpmp->dev, sizeof(*entry), GFP_KERNEL);
471 spin_lock_irqsave(&bpmp->lock, flags);
476 list_add(&entry->list, &bpmp->mrqs);
478 spin_unlock_irqrestore(&bpmp->lock, flags);
484 void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq, void *data)
489 spin_lock_irqsave(&bpmp->lock, flags);
491 entry = tegra_bpmp_find_mrq(bpmp, mrq);
496 devm_kfree(bpmp->dev, entry);
499 spin_unlock_irqrestore(&bpmp->lock, flags);
503 bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq)
520 err = tegra_bpmp_transfer(bpmp, &msg);
543 static int tegra_bpmp_ping(struct tegra_bpmp *bpmp)
566 err = tegra_bpmp_transfer_atomic(bpmp, &msg);
571 dev_dbg(bpmp->dev,
580 static int tegra_bpmp_get_firmware_tag_old(struct tegra_bpmp *bpmp, char *tag,
593 virt = dma_alloc_coherent(bpmp->dev, TAG_SZ, &phys,
607 err = tegra_bpmp_transfer_atomic(bpmp, &msg);
613 dma_free_coherent(bpmp->dev, TAG_SZ, virt, phys);
618 static int tegra_bpmp_get_firmware_tag(struct tegra_bpmp *bpmp, char *tag,
621 if (tegra_bpmp_mrq_is_supported(bpmp, MRQ_QUERY_FW_TAG)) {
635 err = tegra_bpmp_transfer(bpmp, &msg);
646 return tegra_bpmp_get_firmware_tag_old(bpmp, tag, size);
659 void tegra_bpmp_handle_rx(struct tegra_bpmp *bpmp)
665 channel = bpmp->rx_channel;
666 count = bpmp->soc->channels.thread.count;
667 busy = bpmp->threaded.busy;
670 tegra_bpmp_handle_mrq(bpmp, channel->ib->code, channel);
672 spin_lock(&bpmp->lock);
677 channel = &bpmp->threaded_channels[i];
685 spin_unlock(&bpmp->lock);
690 struct tegra_bpmp *bpmp;
695 bpmp = devm_kzalloc(&pdev->dev, sizeof(*bpmp), GFP_KERNEL);
696 if (!bpmp)
699 bpmp->soc = of_device_get_match_data(&pdev->dev);
700 bpmp->dev = &pdev->dev;
702 INIT_LIST_HEAD(&bpmp->mrqs);
703 spin_lock_init(&bpmp->lock);
705 bpmp->threaded.count = bpmp->soc->channels.thread.count;
706 sema_init(&bpmp->threaded.lock, bpmp->threaded.count);
708 size = BITS_TO_LONGS(bpmp->threaded.count) * sizeof(long);
710 bpmp->threaded.allocated = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
711 if (!bpmp->threaded.allocated)
714 bpmp->threaded.busy = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
715 if (!bpmp->threaded.busy)
718 spin_lock_init(&bpmp->atomic_tx_lock);
719 bpmp->tx_channel = devm_kzalloc(&pdev->dev, sizeof(*bpmp->tx_channel),
721 if (!bpmp->tx_channel)
724 bpmp->rx_channel = devm_kzalloc(&pdev->dev, sizeof(*bpmp->rx_channel),
726 if (!bpmp->rx_channel)
729 bpmp->threaded_channels = devm_kcalloc(&pdev->dev, bpmp->threaded.count,
730 sizeof(*bpmp->threaded_channels),
732 if (!bpmp->threaded_channels)
735 err = bpmp->soc->ops->init(bpmp);
739 err = tegra_bpmp_request_mrq(bpmp, MRQ_PING,
740 tegra_bpmp_mrq_handle_ping, bpmp);
744 err = tegra_bpmp_ping(bpmp);
750 err = tegra_bpmp_get_firmware_tag(bpmp, tag, sizeof(tag));
758 platform_set_drvdata(pdev, bpmp);
765 err = tegra_bpmp_init_clocks(bpmp);
771 err = tegra_bpmp_init_resets(bpmp);
777 err = tegra_bpmp_init_powergates(bpmp);
782 err = tegra_bpmp_init_debugfs(bpmp);
789 tegra_bpmp_free_mrq(bpmp, MRQ_PING, bpmp);
791 if (bpmp->soc->ops->deinit)
792 bpmp->soc->ops->deinit(bpmp);
799 struct tegra_bpmp *bpmp = dev_get_drvdata(dev);
801 if (bpmp->soc->ops->resume)
802 return bpmp->soc->ops->resume(bpmp);
862 { .compatible = "nvidia,tegra186-bpmp", .data = &tegra186_soc },
865 { .compatible = "nvidia,tegra210-bpmp", .data = &tegra210_soc },
872 .name = "tegra-bpmp",