Lines Matching refs:mdev
136 unsigned int mbox_read_reg(struct omap_mbox_device *mdev, size_t ofs) in mbox_read_reg() argument
138 return __raw_readl(mdev->mbox_base + ofs); in mbox_read_reg()
142 void mbox_write_reg(struct omap_mbox_device *mdev, u32 val, size_t ofs) in mbox_write_reg() argument
144 __raw_writel(val, mdev->mbox_base + ofs); in mbox_write_reg()
397 static struct omap_mbox *omap_mbox_device_find(struct omap_mbox_device *mdev, in omap_mbox_device_find() argument
401 struct omap_mbox **mboxes = mdev->mboxes; in omap_mbox_device_find()
421 struct omap_mbox_device *mdev; in omap_mbox_request_channel() local
436 list_for_each_entry(mdev, &omap_mbox_devices, elem) { in omap_mbox_request_channel()
437 mbox = omap_mbox_device_find(mdev, chan_name); in omap_mbox_request_channel()
468 static int omap_mbox_register(struct omap_mbox_device *mdev) in omap_mbox_register() argument
474 if (!mdev || !mdev->mboxes) in omap_mbox_register()
477 mboxes = mdev->mboxes; in omap_mbox_register()
481 mbox->dev = device_create(&omap_mbox_class, mdev->dev, in omap_mbox_register()
490 list_add(&mdev->elem, &omap_mbox_devices); in omap_mbox_register()
493 ret = mbox_controller_register(&mdev->controller); in omap_mbox_register()
503 static int omap_mbox_unregister(struct omap_mbox_device *mdev) in omap_mbox_unregister() argument
508 if (!mdev || !mdev->mboxes) in omap_mbox_unregister()
512 list_del(&mdev->elem); in omap_mbox_unregister()
515 mbox_controller_unregister(&mdev->controller); in omap_mbox_unregister()
517 mboxes = mdev->mboxes; in omap_mbox_unregister()
526 struct omap_mbox_device *mdev = mbox->parent; in omap_mbox_chan_startup() local
529 mutex_lock(&mdev->cfg_lock); in omap_mbox_chan_startup()
530 pm_runtime_get_sync(mdev->dev); in omap_mbox_chan_startup()
533 pm_runtime_put_sync(mdev->dev); in omap_mbox_chan_startup()
534 mutex_unlock(&mdev->cfg_lock); in omap_mbox_chan_startup()
541 struct omap_mbox_device *mdev = mbox->parent; in omap_mbox_chan_shutdown() local
543 mutex_lock(&mdev->cfg_lock); in omap_mbox_chan_shutdown()
545 pm_runtime_put_sync(mdev->dev); in omap_mbox_chan_shutdown()
546 mutex_unlock(&mdev->cfg_lock); in omap_mbox_chan_shutdown()
606 struct omap_mbox_device *mdev = dev_get_drvdata(dev); in omap_mbox_suspend() local
612 for (fifo = 0; fifo < mdev->num_fifos; fifo++) { in omap_mbox_suspend()
613 if (mbox_read_reg(mdev, MAILBOX_MSGSTATUS(fifo))) { in omap_mbox_suspend()
614 dev_err(mdev->dev, "fifo %d has unexpected unread messages\n", in omap_mbox_suspend()
620 for (usr = 0; usr < mdev->num_users; usr++) { in omap_mbox_suspend()
621 reg = MAILBOX_IRQENABLE(mdev->intr_type, usr); in omap_mbox_suspend()
622 mdev->irq_ctx[usr] = mbox_read_reg(mdev, reg); in omap_mbox_suspend()
630 struct omap_mbox_device *mdev = dev_get_drvdata(dev); in omap_mbox_resume() local
636 for (usr = 0; usr < mdev->num_users; usr++) { in omap_mbox_resume()
637 reg = MAILBOX_IRQENABLE(mdev->intr_type, usr); in omap_mbox_resume()
638 mbox_write_reg(mdev, mdev->irq_ctx[usr], reg); in omap_mbox_resume()
673 struct omap_mbox_device *mdev; in omap_mbox_of_xlate() local
676 mdev = container_of(controller, struct omap_mbox_device, controller); in omap_mbox_of_xlate()
677 if (WARN_ON(!mdev)) in omap_mbox_of_xlate()
687 mbox = omap_mbox_device_find(mdev, node->name); in omap_mbox_of_xlate()
699 struct omap_mbox_device *mdev; in omap_mbox_probe() local
767 mdev = devm_kzalloc(&pdev->dev, sizeof(*mdev), GFP_KERNEL); in omap_mbox_probe()
768 if (!mdev) in omap_mbox_probe()
772 mdev->mbox_base = devm_ioremap_resource(&pdev->dev, mem); in omap_mbox_probe()
773 if (IS_ERR(mdev->mbox_base)) in omap_mbox_probe()
774 return PTR_ERR(mdev->mbox_base); in omap_mbox_probe()
776 mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32), in omap_mbox_probe()
778 if (!mdev->irq_ctx) in omap_mbox_probe()
819 mbox->parent = mdev; in omap_mbox_probe()
829 mutex_init(&mdev->cfg_lock); in omap_mbox_probe()
830 mdev->dev = &pdev->dev; in omap_mbox_probe()
831 mdev->num_users = num_users; in omap_mbox_probe()
832 mdev->num_fifos = num_fifos; in omap_mbox_probe()
833 mdev->intr_type = intr_type; in omap_mbox_probe()
834 mdev->mboxes = list; in omap_mbox_probe()
837 mdev->controller.txdone_irq = true; in omap_mbox_probe()
838 mdev->controller.dev = mdev->dev; in omap_mbox_probe()
839 mdev->controller.ops = &omap_mbox_chan_ops; in omap_mbox_probe()
840 mdev->controller.chans = chnls; in omap_mbox_probe()
841 mdev->controller.num_chans = info_count; in omap_mbox_probe()
842 mdev->controller.of_xlate = omap_mbox_of_xlate; in omap_mbox_probe()
843 ret = omap_mbox_register(mdev); in omap_mbox_probe()
847 platform_set_drvdata(pdev, mdev); in omap_mbox_probe()
848 pm_runtime_enable(mdev->dev); in omap_mbox_probe()
850 ret = pm_runtime_get_sync(mdev->dev); in omap_mbox_probe()
852 pm_runtime_put_noidle(mdev->dev); in omap_mbox_probe()
860 l = mbox_read_reg(mdev, MAILBOX_REVISION); in omap_mbox_probe()
861 dev_info(mdev->dev, "omap mailbox rev 0x%x\n", l); in omap_mbox_probe()
863 ret = pm_runtime_put_sync(mdev->dev); in omap_mbox_probe()
871 pm_runtime_disable(mdev->dev); in omap_mbox_probe()
872 omap_mbox_unregister(mdev); in omap_mbox_probe()
878 struct omap_mbox_device *mdev = platform_get_drvdata(pdev); in omap_mbox_remove() local
880 pm_runtime_disable(mdev->dev); in omap_mbox_remove()
881 omap_mbox_unregister(mdev); in omap_mbox_remove()