From patchwork Sat Jun 25 01:17:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: omar ramirez X-Patchwork-Id: 918022 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5P1NQTP009973 for ; Sat, 25 Jun 2011 01:23:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753287Ab1FYBXX (ORCPT ); Fri, 24 Jun 2011 21:23:23 -0400 Received: from na3sys009aog126.obsmtp.com ([74.125.149.155]:49835 "EHLO na3sys009aog126.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888Ab1FYBXX (ORCPT ); Fri, 24 Jun 2011 21:23:23 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 25 Jun 2011 01:23:26 +0000 (UTC) X-Greylist: delayed 303 seconds by postgrey-1.27 at vger.kernel.org; Fri, 24 Jun 2011 21:23:22 EDT Received: from mail-yw0-f46.google.com ([209.85.213.46]) (using TLSv1) by na3sys009aob126.postini.com ([74.125.148.12]) with SMTP ID DSNKTgU4iq2KdDphGr/BdhvqH17kDwGJ2upt@postini.com; Fri, 24 Jun 2011 18:23:22 PDT Received: by mail-yw0-f46.google.com with SMTP id 9so1290485ywe.19 for ; Fri, 24 Jun 2011 18:23:22 -0700 (PDT) Received: by 10.101.166.33 with SMTP id t33mr1307724ano.149.1308964698130; Fri, 24 Jun 2011 18:18:18 -0700 (PDT) Received: from localhost.localdomain (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id r10sm3051365anh.28.2011.06.24.18.18.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 18:18:17 -0700 (PDT) From: Omar Ramirez Luna To: Hiroshi Doyu Cc: Tony Lindgren , Russell King , Benoit Cousson , Omar Ramirez Luna , Felipe Contreras , Fernando Guzman Lugo , lo , lak Subject: [RFC PATCH 6/7] OMAP1: mailbox: adapt to dynamic mailbox requests Date: Fri, 24 Jun 2011 20:17:42 -0500 Message-Id: <1308964663-5669-7-git-send-email-omar.ramirez@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1308964663-5669-1-git-send-email-omar.ramirez@ti.com> References: <1308964663-5669-1-git-send-email-omar.ramirez@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Remove mailbox static declarations, while at it, simplify the macros to be reused in a cleaner way. New approach configures available mailboxes per request. Signed-off-by: Omar Ramirez Luna --- arch/arm/mach-omap1/mailbox.c | 92 ++++++++++++++++++++++++----------------- 1 files changed, 54 insertions(+), 38 deletions(-) diff --git a/arch/arm/mach-omap1/mailbox.c b/arch/arm/mach-omap1/mailbox.c index 2845652..f3a40de 100644 --- a/arch/arm/mach-omap1/mailbox.c +++ b/arch/arm/mach-omap1/mailbox.c @@ -9,20 +9,23 @@ * for more details. */ +#include #include #include #include +#include #include -#define MAILBOX_ARM2DSP1 0x00 -#define MAILBOX_ARM2DSP1b 0x04 -#define MAILBOX_DSP2ARM1 0x08 -#define MAILBOX_DSP2ARM1b 0x0c -#define MAILBOX_DSP2ARM2 0x10 -#define MAILBOX_DSP2ARM2b 0x14 -#define MAILBOX_ARM2DSP1_Flag 0x18 -#define MAILBOX_DSP2ARM1_Flag 0x1c -#define MAILBOX_DSP2ARM2_Flag 0x20 +#define MAILBOX_ARM2DSPm(m) (0x24 * (m - 1)) +#define MAILBOX_DSP2ARMm(m) (0x08 + 0x8 * (m - 1)) +#define MAILBOX_ARM2DSPmb(m) (0x04 + 0x24 * (m - 1)) +#define MAILBOX_DSP2ARMmb(m) (0x0c + 0x8 * (m - 1)) +#define MAILBOX_ARM2DSPm_Flag(m) (0x18 + 0x14 * (m - 1)) +#define MAILBOX_DSP2ARMm_Flag(m) (0x1c + 0x4 * (m - 1)) + +static unsigned int mbox_kfifo_size = CONFIG_OMAP_MBOX_KFIFO_SIZE; +module_param(mbox_kfifo_size, uint, S_IRUGO); +MODULE_PARM_DESC(mbox_kfifo_size, "Size of omap's mailbox kfifo (bytes)"); static void __iomem *mbox_base; @@ -106,6 +109,32 @@ omap1_mbox_is_irq(struct omap_mbox *mbox, omap_mbox_type_t irq) return 1; } +struct device *mbox_dev; + +static void *omap1_mbox_request(u16 id, u16 owner) +{ + struct omap_mbox1_priv *p; + + p = kzalloc(sizeof(struct omap_mbox1_priv), GFP_KERNEL); + if (!p) + return ERR_PTR(-ENOMEM); + + p->tx_fifo.cmd = MAILBOX_ARM2DSPmb(id); + p->tx_fifo.data = MAILBOX_ARM2DSPm(id); + p->tx_fifo.flag = MAILBOX_ARM2DSPm_Flag(id); + p->rx_fifo.cmd = MAILBOX_DSP2ARMmb(id); + p->rx_fifo.data = MAILBOX_DSP2ARMm(id); + p->rx_fifo.flag = MAILBOX_DSP2ARMm_Flag(id); + + return mbox; +} + +static void omap1_mbox_release(void *priv) +{ + kfree(priv); + priv = NULL; +} + static struct omap_mbox_ops omap1_mbox_ops = { .type = OMAP_MBOX_TYPE1, .fifo_read = omap1_mbox_fifo_read, @@ -115,48 +144,35 @@ static struct omap_mbox_ops omap1_mbox_ops = { .enable_irq = omap1_mbox_enable_irq, .disable_irq = omap1_mbox_disable_irq, .is_irq = omap1_mbox_is_irq, + .request = omap1_mbox_request, + .release = omap1_mbox_release, }; -/* FIXME: the following struct should be created automatically by the user id */ - -/* DSP */ -static struct omap_mbox1_priv omap1_mbox_dsp_priv = { - .tx_fifo = { - .cmd = MAILBOX_ARM2DSP1b, - .data = MAILBOX_ARM2DSP1, - .flag = MAILBOX_ARM2DSP1_Flag, - }, - .rx_fifo = { - .cmd = MAILBOX_DSP2ARM1b, - .data = MAILBOX_DSP2ARM1, - .flag = MAILBOX_DSP2ARM1_Flag, - }, -}; - -static struct omap_mbox mbox_dsp_info = { - .name = "dsp", - .ops = &omap1_mbox_ops, - .priv = &omap1_mbox_dsp_priv, -}; - -static struct omap_mbox *omap1_mboxes[] = { &mbox_dsp_info, NULL }; - static int __devinit omap1_mbox_probe(struct platform_device *pdev) { struct resource *mem; + struct mbox_info *arch_mbi; int ret; - struct omap_mbox **list; - - list = omap1_mboxes; - list[0]->irq = platform_get_irq_byname(pdev, "dsp"); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); mbox_base = ioremap(mem->start, resource_size(mem)); if (!mbox_base) return -ENOMEM; - ret = omap_mbox_register(&pdev->dev, list); + arch_mbi = kzalloc(sizeof(struct mbox_info), GFP_KERNEL); + if (!arch_mbi) { + iounmap(mbox_base); + return -ENOMEM; + } + + arch_mbi->dev = &pdev->dev; + arch_mbi->ops = &omap1_mbox_ops; + arch_mbi->kfifo_size = mbox_kfifo_size; + arch_mbi->nr_mbox = 2; + + ret = omap_mbox_register(arch_mbi); if (ret) { + kfree(arch_mbi); iounmap(mbox_base); return ret; }