From patchwork Sat Jun 25 01:17:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: omar ramirez X-Patchwork-Id: 918012 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5P1LAk0007154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 25 Jun 2011 01:21:33 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QaHYC-0003h7-VG; Sat, 25 Jun 2011 01:20:46 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QaHXv-0004dy-Ac; Sat, 25 Jun 2011 01:20:27 +0000 Received: from na3sys009aog123.obsmtp.com ([74.125.149.149]) by canuck.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1QaHVw-00048Q-AE for linux-arm-kernel@lists.infradead.org; Sat, 25 Jun 2011 01:18:26 +0000 Received: from mail-gy0-f174.google.com ([209.85.160.174]) (using TLSv1) by na3sys009aob123.postini.com ([74.125.148.12]) with SMTP ID DSNKTgU3XAt7/QCzE8nVmTtsYMh+X0YHOvLV@postini.com; Fri, 24 Jun 2011 18:18:24 PDT Received: by mail-gy0-f174.google.com with SMTP id 3so1672719gyh.5 for ; Fri, 24 Jun 2011 18:18:20 -0700 (PDT) Received: by 10.146.33.3 with SMTP id g3mr4262043yag.23.1308964699704; Fri, 24 Jun 2011 18:18:19 -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.18 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 24 Jun 2011 18:18:18 -0700 (PDT) From: Omar Ramirez Luna To: Hiroshi Doyu Subject: [RFC PATCH 7/7] OMAP2+: mailbox: remove mailbox static declarations Date: Fri, 24 Jun 2011 20:17:43 -0500 Message-Id: <1308964663-5669-8-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> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110624_211824_769775_FB4867DA X-CRM114-Status: GOOD ( 18.31 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Cc: Omar Ramirez Luna , Russell King , Benoit Cousson , Fernando Guzman Lugo , Tony Lindgren , Felipe Contreras , lo , lak X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 25 Jun 2011 01:21:34 +0000 (UTC) Remove mailbox static declarations which limit the driver to either work with 1 or 2 predefined mailboxes, even if there are more mailboxes in hardware. New approach configures available mailboxes per request. Signed-off-by: Omar Ramirez Luna --- arch/arm/mach-omap2/mailbox.c | 210 +++++++++++------------------------------ 1 files changed, 54 insertions(+), 156 deletions(-) diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c index 946a70a..b85e33b 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/arch/arm/mach-omap2/mailbox.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,10 @@ #define MBOX_NR_REGS (MBOX_REG_SIZE / sizeof(u32)) #define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32)) +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; struct omap_mbox2_fifo { @@ -58,9 +63,6 @@ struct omap_mbox2_priv { unsigned long irqdisable; }; -static void omap2_mbox_enable_irq(struct omap_mbox *mbox, - omap_mbox_type_t irq); - static inline unsigned int mbox_read_reg(size_t ofs) { return __raw_readl(mbox_base + ofs); @@ -76,21 +78,19 @@ static int omap2_mbox_startup(struct omap_mbox *mbox) { u32 l; - pm_runtime_enable(mbox->dev->parent); - pm_runtime_get_sync(mbox->dev->parent); + pm_runtime_enable(mbox->dev); + pm_runtime_get_sync(mbox->dev); l = mbox_read_reg(MAILBOX_REVISION); pr_debug("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f)); - omap2_mbox_enable_irq(mbox, IRQ_RX); - return 0; } static void omap2_mbox_shutdown(struct omap_mbox *mbox) { - pm_runtime_put_sync(mbox->dev->parent); - pm_runtime_disable(mbox->dev->parent); + pm_runtime_put_sync(mbox->dev); + pm_runtime_disable(mbox->dev); } /* Mailbox FIFO handle functions */ @@ -203,6 +203,33 @@ static void omap2_mbox_restore_ctx(struct omap_mbox *mbox) } } +static void *omap2_mbox_request(u16 id, u16 owner) +{ + struct omap_mbox2_priv *p; + + p = kzalloc(sizeof(struct omap_mbox2_priv), GFP_KERNEL); + if (!p) + return ERR_PTR(-ENOMEM); + + p->tx_fifo.msg = MAILBOX_MESSAGE(id); + p->tx_fifo.fifo_stat = MAILBOX_FIFOSTATUS(id); + p->notfull_bit = MAILBOX_IRQ_NOTFULL(id); + p->rx_fifo.msg = MAILBOX_MESSAGE(id); + p->rx_fifo.msg_stat = MAILBOX_MSGSTATUS(id); + p->newmsg_bit = MAILBOX_IRQ_NEWMSG(id); + p->irqenable = MAILBOX_IRQENABLE(owner); + p->irqstatus = MAILBOX_IRQSTATUS(owner); + p->irqdisable = MAILBOX_IRQENABLE(owner); + + return p; +} + +static void omap2_mbox_release(void *priv) +{ + kfree(priv); + priv = NULL; +} + static struct omap_mbox_ops omap2_mbox_ops = { .type = OMAP_MBOX_TYPE2, .startup = omap2_mbox_startup, @@ -217,168 +244,39 @@ static struct omap_mbox_ops omap2_mbox_ops = { .is_irq = omap2_mbox_is_irq, .save_ctx = omap2_mbox_save_ctx, .restore_ctx = omap2_mbox_restore_ctx, + .request = omap2_mbox_request, + .release = omap2_mbox_release, }; -/* - * MAILBOX 0: ARM -> DSP, - * MAILBOX 1: ARM <- DSP. - * MAILBOX 2: ARM -> IVA, - * MAILBOX 3: ARM <- IVA. - */ - -/* FIXME: the following structs should be filled automatically by the user id */ - -#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP2) -/* DSP */ -static struct omap_mbox2_priv omap2_mbox_dsp_priv = { - .tx_fifo = { - .msg = MAILBOX_MESSAGE(0), - .fifo_stat = MAILBOX_FIFOSTATUS(0), - }, - .rx_fifo = { - .msg = MAILBOX_MESSAGE(1), - .msg_stat = MAILBOX_MSGSTATUS(1), - }, - .irqenable = MAILBOX_IRQENABLE(0), - .irqstatus = MAILBOX_IRQSTATUS(0), - .notfull_bit = MAILBOX_IRQ_NOTFULL(0), - .newmsg_bit = MAILBOX_IRQ_NEWMSG(1), - .irqdisable = MAILBOX_IRQENABLE(0), -}; - -struct omap_mbox mbox_dsp_info = { - .name = "dsp", - .ops = &omap2_mbox_ops, - .priv = &omap2_mbox_dsp_priv, -}; -#endif - -#if defined(CONFIG_ARCH_OMAP3) -struct omap_mbox *omap3_mboxes[] = { &mbox_dsp_info, NULL }; -#endif - -#if defined(CONFIG_SOC_OMAP2420) -/* IVA */ -static struct omap_mbox2_priv omap2_mbox_iva_priv = { - .tx_fifo = { - .msg = MAILBOX_MESSAGE(2), - .fifo_stat = MAILBOX_FIFOSTATUS(2), - }, - .rx_fifo = { - .msg = MAILBOX_MESSAGE(3), - .msg_stat = MAILBOX_MSGSTATUS(3), - }, - .irqenable = MAILBOX_IRQENABLE(3), - .irqstatus = MAILBOX_IRQSTATUS(3), - .notfull_bit = MAILBOX_IRQ_NOTFULL(2), - .newmsg_bit = MAILBOX_IRQ_NEWMSG(3), - .irqdisable = MAILBOX_IRQENABLE(3), -}; - -static struct omap_mbox mbox_iva_info = { - .name = "iva", - .ops = &omap2_mbox_ops, - .priv = &omap2_mbox_iva_priv, -}; - -struct omap_mbox *omap2_mboxes[] = { &mbox_dsp_info, &mbox_iva_info, NULL }; -#endif - -#if defined(CONFIG_ARCH_OMAP4) -/* OMAP4 */ -static struct omap_mbox2_priv omap2_mbox_1_priv = { - .tx_fifo = { - .msg = MAILBOX_MESSAGE(0), - .fifo_stat = MAILBOX_FIFOSTATUS(0), - }, - .rx_fifo = { - .msg = MAILBOX_MESSAGE(1), - .msg_stat = MAILBOX_MSGSTATUS(1), - }, - .irqenable = OMAP4_MAILBOX_IRQENABLE(0), - .irqstatus = OMAP4_MAILBOX_IRQSTATUS(0), - .notfull_bit = MAILBOX_IRQ_NOTFULL(0), - .newmsg_bit = MAILBOX_IRQ_NEWMSG(1), - .irqdisable = OMAP4_MAILBOX_IRQENABLE_CLR(0), -}; - -struct omap_mbox mbox_1_info = { - .name = "mailbox-1", - .ops = &omap2_mbox_ops, - .priv = &omap2_mbox_1_priv, -}; - -static struct omap_mbox2_priv omap2_mbox_2_priv = { - .tx_fifo = { - .msg = MAILBOX_MESSAGE(3), - .fifo_stat = MAILBOX_FIFOSTATUS(3), - }, - .rx_fifo = { - .msg = MAILBOX_MESSAGE(2), - .msg_stat = MAILBOX_MSGSTATUS(2), - }, - .irqenable = OMAP4_MAILBOX_IRQENABLE(0), - .irqstatus = OMAP4_MAILBOX_IRQSTATUS(0), - .notfull_bit = MAILBOX_IRQ_NOTFULL(3), - .newmsg_bit = MAILBOX_IRQ_NEWMSG(2), - .irqdisable = OMAP4_MAILBOX_IRQENABLE_CLR(0), -}; - -struct omap_mbox mbox_2_info = { - .name = "mailbox-2", - .ops = &omap2_mbox_ops, - .priv = &omap2_mbox_2_priv, -}; - -struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL }; -#endif - static int __devinit omap2_mbox_probe(struct platform_device *pdev) { struct resource *mem; + struct mbox_info *arch_mbi; + struct omap_mailbox_platform_data *pdata = pdev->dev.platform_data; int ret; - struct omap_mbox **list; - if (false) - ; -#if defined(CONFIG_ARCH_OMAP3) - else if (cpu_is_omap34xx()) { - list = omap3_mboxes; - - list[0]->irq = platform_get_irq(pdev, 0); - } -#endif -#if defined(CONFIG_ARCH_OMAP2) - else if (cpu_is_omap2430()) { - list = omap2_mboxes; - - list[0]->irq = platform_get_irq(pdev, 0); - } else if (cpu_is_omap2420()) { - list = omap2_mboxes; - - list[0]->irq = platform_get_irq_byname(pdev, "dsp"); - list[1]->irq = platform_get_irq_byname(pdev, "iva"); - } -#endif -#if defined(CONFIG_ARCH_OMAP4) - else if (cpu_is_omap44xx()) { - list = omap4_mboxes; - - list[0]->irq = list[1]->irq = platform_get_irq(pdev, 0); - } -#endif - else { - pr_err("%s: platform not supported\n", __func__); + if (!pdata) return -ENODEV; - } 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 = &omap2_mbox_ops; + arch_mbi->kfifo_size = mbox_kfifo_size; + arch_mbi->nr_mbox = pdata->nr_mbox; + + ret = omap_mbox_register(arch_mbi); if (ret) { + kfree(arch_mbi); iounmap(mbox_base); return ret; }