Lines Matching defs:bpmp

17 #include <soc/tegra/bpmp.h>
18 #include <soc/tegra/bpmp-abi.h>
21 #include "bpmp-private.h"
36 struct tegra_bpmp *bpmp = channel->bpmp;
38 return bpmp->soc->ops;
44 struct tegra_bpmp *bpmp;
47 np = of_parse_phandle(dev->of_node, "nvidia,bpmp", 0);
53 bpmp = ERR_PTR(-ENODEV);
57 bpmp = platform_get_drvdata(pdev);
58 if (!bpmp) {
59 bpmp = ERR_PTR(-EPROBE_DEFER);
66 return bpmp;
70 void tegra_bpmp_put(struct tegra_bpmp *bpmp)
72 if (bpmp)
73 put_device(bpmp->dev);
80 struct tegra_bpmp *bpmp = channel->bpmp;
84 count = bpmp->soc->channels.thread.count;
86 index = channel - channel->bpmp->threaded_channels;
117 unsigned long timeout = channel->bpmp->soc->channels.cpu_tx.timeout;
163 unsigned long timeout = channel->bpmp->soc->channels.cpu_tx.timeout;
192 static int tegra_bpmp_ring_doorbell(struct tegra_bpmp *bpmp)
194 return bpmp->soc->ops->ring_doorbell(bpmp);
217 struct tegra_bpmp *bpmp = channel->bpmp;
228 spin_lock_irqsave(&bpmp->lock, flags);
230 clear_bit(index, bpmp->threaded.allocated);
231 spin_unlock_irqrestore(&bpmp->lock, flags);
234 up(&bpmp->threaded.lock);
253 tegra_bpmp_write_threaded(struct tegra_bpmp *bpmp, unsigned int mrq,
256 unsigned long timeout = bpmp->soc->channels.thread.timeout;
257 unsigned int count = bpmp->soc->channels.thread.count;
263 err = down_timeout(&bpmp->threaded.lock, usecs_to_jiffies(timeout));
267 spin_lock_irqsave(&bpmp->lock, flags);
269 index = find_first_zero_bit(bpmp->threaded.allocated, count);
275 channel = &bpmp->threaded_channels[index];
282 set_bit(index, bpmp->threaded.allocated);
289 set_bit(index, bpmp->threaded.busy);
291 spin_unlock_irqrestore(&bpmp->lock, flags);
295 clear_bit(index, bpmp->threaded.allocated);
297 spin_unlock_irqrestore(&bpmp->lock, flags);
298 up(&bpmp->threaded.lock);
318 int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
330 if (bpmp->suspended) {
333 tegra_bpmp_resume(bpmp->dev);
338 channel = bpmp->tx_channel;
340 spin_lock(&bpmp->atomic_tx_lock);
345 spin_unlock(&bpmp->atomic_tx_lock);
349 spin_unlock(&bpmp->atomic_tx_lock);
351 err = tegra_bpmp_ring_doorbell(bpmp);
364 int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
377 if (bpmp->suspended) {
380 tegra_bpmp_resume(bpmp->dev);
385 channel = tegra_bpmp_write_threaded(bpmp, msg->mrq, msg->tx.data,
390 err = tegra_bpmp_ring_doorbell(bpmp);
394 timeout = usecs_to_jiffies(bpmp->soc->channels.thread.timeout);
405 static struct tegra_bpmp_mrq *tegra_bpmp_find_mrq(struct tegra_bpmp *bpmp,
410 list_for_each_entry(entry, &bpmp->mrqs, list)
421 struct tegra_bpmp *bpmp = channel->bpmp;
447 err = tegra_bpmp_ring_doorbell(bpmp);
454 static void tegra_bpmp_handle_mrq(struct tegra_bpmp *bpmp,
461 spin_lock(&bpmp->lock);
463 entry = tegra_bpmp_find_mrq(bpmp, mrq);
465 spin_unlock(&bpmp->lock);
472 spin_unlock(&bpmp->lock);
475 int tegra_bpmp_request_mrq(struct tegra_bpmp *bpmp, unsigned int mrq,
484 entry = devm_kzalloc(bpmp->dev, sizeof(*entry), GFP_KERNEL);
488 spin_lock_irqsave(&bpmp->lock, flags);
493 list_add(&entry->list, &bpmp->mrqs);
495 spin_unlock_irqrestore(&bpmp->lock, flags);
501 void tegra_bpmp_free_mrq(struct tegra_bpmp *bpmp, unsigned int mrq, void *data)
506 spin_lock_irqsave(&bpmp->lock, flags);
508 entry = tegra_bpmp_find_mrq(bpmp, mrq);
513 devm_kfree(bpmp->dev, entry);
516 spin_unlock_irqrestore(&bpmp->lock, flags);
520 bool tegra_bpmp_mrq_is_supported(struct tegra_bpmp *bpmp, unsigned int mrq)
537 err = tegra_bpmp_transfer(bpmp, &msg);
560 static int tegra_bpmp_ping(struct tegra_bpmp *bpmp)
583 err = tegra_bpmp_transfer_atomic(bpmp, &msg);
588 dev_dbg(bpmp->dev,
597 static int tegra_bpmp_get_firmware_tag_old(struct tegra_bpmp *bpmp, char *tag,
610 virt = dma_alloc_coherent(bpmp->dev, TAG_SZ, &phys,
624 err = tegra_bpmp_transfer_atomic(bpmp, &msg);
630 dma_free_coherent(bpmp->dev, TAG_SZ, virt, phys);
635 static int tegra_bpmp_get_firmware_tag(struct tegra_bpmp *bpmp, char *tag,
638 if (tegra_bpmp_mrq_is_supported(bpmp, MRQ_QUERY_FW_TAG)) {
652 err = tegra_bpmp_transfer(bpmp, &msg);
663 return tegra_bpmp_get_firmware_tag_old(bpmp, tag, size);
676 void tegra_bpmp_handle_rx(struct tegra_bpmp *bpmp)
682 channel = bpmp->rx_channel;
683 count = bpmp->soc->channels.thread.count;
684 busy = bpmp->threaded.busy;
689 tegra_bpmp_handle_mrq(bpmp, mrq, channel);
692 spin_lock(&bpmp->lock);
697 channel = &bpmp->threaded_channels[i];
705 spin_unlock(&bpmp->lock);
710 struct tegra_bpmp *bpmp;
715 bpmp = devm_kzalloc(&pdev->dev, sizeof(*bpmp), GFP_KERNEL);
716 if (!bpmp)
719 bpmp->soc = of_device_get_match_data(&pdev->dev);
720 bpmp->dev = &pdev->dev;
722 INIT_LIST_HEAD(&bpmp->mrqs);
723 spin_lock_init(&bpmp->lock);
725 bpmp->threaded.count = bpmp->soc->channels.thread.count;
726 sema_init(&bpmp->threaded.lock, bpmp->threaded.count);
728 size = BITS_TO_LONGS(bpmp->threaded.count) * sizeof(long);
730 bpmp->threaded.allocated = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
731 if (!bpmp->threaded.allocated)
734 bpmp->threaded.busy = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
735 if (!bpmp->threaded.busy)
738 spin_lock_init(&bpmp->atomic_tx_lock);
739 bpmp->tx_channel = devm_kzalloc(&pdev->dev, sizeof(*bpmp->tx_channel),
741 if (!bpmp->tx_channel)
744 bpmp->rx_channel = devm_kzalloc(&pdev->dev, sizeof(*bpmp->rx_channel),
746 if (!bpmp->rx_channel)
749 bpmp->threaded_channels = devm_kcalloc(&pdev->dev, bpmp->threaded.count,
750 sizeof(*bpmp->threaded_channels),
752 if (!bpmp->threaded_channels)
755 platform_set_drvdata(pdev, bpmp);
757 err = bpmp->soc->ops->init(bpmp);
761 err = tegra_bpmp_request_mrq(bpmp, MRQ_PING,
762 tegra_bpmp_mrq_handle_ping, bpmp);
766 err = tegra_bpmp_ping(bpmp);
772 err = tegra_bpmp_get_firmware_tag(bpmp, tag, sizeof(tag));
785 err = tegra_bpmp_init_clocks(bpmp);
791 err = tegra_bpmp_init_resets(bpmp);
797 err = tegra_bpmp_init_powergates(bpmp);
802 err = tegra_bpmp_init_debugfs(bpmp);
809 tegra_bpmp_free_mrq(bpmp, MRQ_PING, bpmp);
811 if (bpmp->soc->ops->deinit)
812 bpmp->soc->ops->deinit(bpmp);
819 struct tegra_bpmp *bpmp = dev_get_drvdata(dev);
821 bpmp->suspended = true;
828 struct tegra_bpmp *bpmp = dev_get_drvdata(dev);
830 bpmp->suspended = false;
832 if (bpmp->soc->ops->resume)
833 return bpmp->soc->ops->resume(bpmp);
894 { .compatible = "nvidia,tegra186-bpmp", .data = &tegra186_soc },
897 { .compatible = "nvidia,tegra210-bpmp", .data = &tegra210_soc },
904 .name = "tegra-bpmp",