From patchwork Wed Jun 25 01:47:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Anna X-Patchwork-Id: 4415851 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C04B9F1D6 for ; Wed, 25 Jun 2014 01:50:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F5992037B for ; Wed, 25 Jun 2014 01:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6644C20377 for ; Wed, 25 Jun 2014 01:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754550AbaFYBtW (ORCPT ); Tue, 24 Jun 2014 21:49:22 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:45583 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754184AbaFYBtT (ORCPT ); Tue, 24 Jun 2014 21:49:19 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5P1muxB017849; Tue, 24 Jun 2014 20:48:56 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5P1muXC014745; Tue, 24 Jun 2014 20:48:56 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Tue, 24 Jun 2014 20:48:55 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5P1mtOA022083; Tue, 24 Jun 2014 20:48:55 -0500 Received: from localhost (irmo.am.dhcp.ti.com [128.247.71.175]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id s5P1mtt24519; Tue, 24 Jun 2014 20:48:55 -0500 (CDT) From: Suman Anna To: Tony Lindgren CC: Jassi Brar , Dave Gerlach , , , , , Suman Anna , Jassi Brar Subject: [PATCH 6/6] mailbox/omap: add a custom of_xlate function Date: Tue, 24 Jun 2014 20:47:58 -0500 Message-ID: <1403660878-56350-7-git-send-email-s-anna@ti.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1403660878-56350-1-git-send-email-s-anna@ti.com> References: <1403660878-56350-1-git-send-email-s-anna@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The mailbox framework currently does not support using the channel phandles directly in the mbox property of client nodes, and also expects a minimum value of 1 for the #mbox-cells in the mailbox controller device node. Implement a custom of_xlate function for the OMAP mailbox driver that allows phandles for the pargs specifier instead of indexing to avoid any channel registration order dependencies. Cc: Jassi Brar Signed-off-by: Suman Anna --- drivers/mailbox/omap-mailbox.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index d71e84f..4847466 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -676,6 +676,28 @@ static const struct of_device_id omap_mailbox_of_match[] = { }; MODULE_DEVICE_TABLE(of, omap_mailbox_of_match); +static struct mbox_chan *omap_mbox_of_xlate(struct mbox_controller *controller, + const struct of_phandle_args *sp) +{ + phandle phandle = sp->args[0]; + struct device_node *node; + struct omap_mbox_device *mdev; + struct omap_mbox *mbox; + + node = of_find_node_by_phandle(phandle); + if (!node) { + pr_err("could not find node phandle 0x%x\n", phandle); + return NULL; + } + + mdev = container_of(controller, struct omap_mbox_device, controller); + if (WARN_ON(!mdev)) + return NULL; + + mbox = omap_mbox_device_find(mdev, node->name); + return mbox ? mbox->chan : NULL; +} + static int omap_mbox_probe(struct platform_device *pdev) { struct resource *mem; @@ -835,6 +857,7 @@ static int omap_mbox_probe(struct platform_device *pdev) mdev->controller.ops = &omap_mbox_chan_ops; mdev->controller.chans = chnls; mdev->controller.num_chans = info_count; + mdev->controller.of_xlate = omap_mbox_of_xlate; ret = omap_mbox_register(mdev); if (ret) return ret;