Lines Matching defs:mdev

132 unsigned int mbox_read_reg(struct omap_mbox_device *mdev, size_t ofs)
134 return __raw_readl(mdev->mbox_base + ofs);
138 void mbox_write_reg(struct omap_mbox_device *mdev, u32 val, size_t ofs)
140 __raw_writel(val, mdev->mbox_base + ofs);
395 static struct omap_mbox *omap_mbox_device_find(struct omap_mbox_device *mdev,
399 struct omap_mbox **mboxes = mdev->mboxes;
419 struct omap_mbox_device *mdev;
434 list_for_each_entry(mdev, &omap_mbox_devices, elem) {
435 mbox = omap_mbox_device_find(mdev, chan_name);
466 static int omap_mbox_register(struct omap_mbox_device *mdev)
472 if (!mdev || !mdev->mboxes)
475 mboxes = mdev->mboxes;
479 mbox->dev = device_create(&omap_mbox_class, mdev->dev,
488 list_add(&mdev->elem, &omap_mbox_devices);
491 ret = devm_mbox_controller_register(mdev->dev, &mdev->controller);
501 static int omap_mbox_unregister(struct omap_mbox_device *mdev)
506 if (!mdev || !mdev->mboxes)
510 list_del(&mdev->elem);
513 mboxes = mdev->mboxes;
522 struct omap_mbox_device *mdev = mbox->parent;
525 mutex_lock(&mdev->cfg_lock);
526 pm_runtime_get_sync(mdev->dev);
529 pm_runtime_put_sync(mdev->dev);
530 mutex_unlock(&mdev->cfg_lock);
537 struct omap_mbox_device *mdev = mbox->parent;
539 mutex_lock(&mdev->cfg_lock);
541 pm_runtime_put_sync(mdev->dev);
542 mutex_unlock(&mdev->cfg_lock);
603 struct omap_mbox_device *mdev = dev_get_drvdata(dev);
609 for (fifo = 0; fifo < mdev->num_fifos; fifo++) {
610 if (mbox_read_reg(mdev, MAILBOX_MSGSTATUS(fifo))) {
611 dev_err(mdev->dev, "fifo %d has unexpected unread messages\n",
617 for (usr = 0; usr < mdev->num_users; usr++) {
618 reg = MAILBOX_IRQENABLE(mdev->intr_type, usr);
619 mdev->irq_ctx[usr] = mbox_read_reg(mdev, reg);
627 struct omap_mbox_device *mdev = dev_get_drvdata(dev);
633 for (usr = 0; usr < mdev->num_users; usr++) {
634 reg = MAILBOX_IRQENABLE(mdev->intr_type, usr);
635 mbox_write_reg(mdev, mdev->irq_ctx[usr], reg);
677 struct omap_mbox_device *mdev;
680 mdev = container_of(controller, struct omap_mbox_device, controller);
681 if (WARN_ON(!mdev))
691 mbox = omap_mbox_device_find(mdev, node->name);
703 struct omap_mbox_device *mdev;
771 mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_KERNEL);
772 if (!mdev)
776 mdev->mbox_base = devm_ioremap_resource(&pdev->dev, mem);
777 if (IS_ERR(mdev->mbox_base))
778 return PTR_ERR(mdev->mbox_base);
780 mdev->irq_ctx = devm_kcalloc(&pdev->dev, num_users, sizeof(u32),
782 if (!mdev->irq_ctx)
823 mbox->parent = mdev;
833 mutex_init(&mdev->cfg_lock);
834 mdev->dev = &pdev->dev;
835 mdev->num_users = num_users;
836 mdev->num_fifos = num_fifos;
837 mdev->intr_type = intr_type;
838 mdev->mboxes = list;
844 mdev->controller.txdone_irq = true;
845 mdev->controller.dev = mdev->dev;
846 mdev->controller.ops = &omap_mbox_chan_ops;
847 mdev->controller.chans = chnls;
848 mdev->controller.num_chans = info_count;
849 mdev->controller.of_xlate = omap_mbox_of_xlate;
850 ret = omap_mbox_register(mdev);
854 platform_set_drvdata(pdev, mdev);
855 pm_runtime_enable(mdev->dev);
857 ret = pm_runtime_get_sync(mdev->dev);
859 pm_runtime_put_noidle(mdev->dev);
867 l = mbox_read_reg(mdev, MAILBOX_REVISION);
868 dev_info(mdev->dev, "omap mailbox rev 0x%x\n", l);
870 ret = pm_runtime_put_sync(mdev->dev);
878 pm_runtime_disable(mdev->dev);
879 omap_mbox_unregister(mdev);
885 struct omap_mbox_device *mdev = platform_get_drvdata(pdev);
887 pm_runtime_disable(mdev->dev);
888 omap_mbox_unregister(mdev);