From patchwork Sat May 22 17:25:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 101661 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4MHPcfo019179 for ; Sat, 22 May 2010 17:25:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755873Ab0EVRZk (ORCPT ); Sat, 22 May 2010 13:25:40 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:50783 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755809Ab0EVRZj (ORCPT ); Sat, 22 May 2010 13:25:39 -0400 Received: by bwz7 with SMTP id 7so385453bwz.19 for ; Sat, 22 May 2010 10:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=cLZkss7wB1d8zYc2ezUGj3het8EXrVU+wfUzjkGAcaU=; b=dKQqXa0V0gDyqm6/cTwhTJLKB2SHtSG1TBOBcK5GwbBfPaFwRcB/hw+G5a+S4gAAFw NK0zE8LIeQhZqts5EZzgUsKHP9c45SfRgsqRs7V96mbHBfr30Q7acMCHstKGQmoqjo00 c8tFrsWMUkVx1KccHnN6NMR7SltaNJD76WERM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=HN/O8V61q5bJYhV6/fWwwZdpKwqu5GdSXYkOpB4yqjqTVUquP7d6PEO2Bml/LD0BX3 LPFKB/ak4DrbSC9QdCIxVgt4BwxKBcfME0SQdRR5KZOt+z9mYzLGDI/+Idu2TyjtNeSE KOXqqYuogixDCVICLS27+nT/z0z1O36pEWi9Y= Received: by 10.204.74.77 with SMTP id t13mr804588bkj.7.1274549136680; Sat, 22 May 2010 10:25:36 -0700 (PDT) Received: from localhost (a91-153-253-80.elisa-laajakaista.fi [91.153.253.80]) by mx.google.com with ESMTPS id s17sm10217987bkd.16.2010.05.22.10.25.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 22 May 2010 10:25:36 -0700 (PDT) From: Felipe Contreras To: linux-omap Cc: Hiroshi Doyu , Kevin Hilman , Paul Walmsley , Ohad Ben-Cohen , Felipe Contreras Subject: [RFC/PATCH 1/2] omap: mailbox: initial hwmod support Date: Sat, 22 May 2010 20:25:21 +0300 Message-Id: <1274549122-26521-2-git-send-email-felipe.contreras@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1274549122-26521-1-git-send-email-felipe.contreras@gmail.com> References: <1274549122-26521-1-git-send-email-felipe.contreras@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 22 May 2010 17:25:40 +0000 (UTC) diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index d9ac853..89f6cbc 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -20,12 +20,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include "mux.h" @@ -137,95 +139,28 @@ static inline void omap_init_camera(void) #endif #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) +static inline void omap_init_mbox(void) +{ + struct omap_hwmod *hwmod; + struct omap_device *odev; + struct omap_mbox_platform_data pdata; -#define MBOX_REG_SIZE 0x120 - -#ifdef CONFIG_ARCH_OMAP2 -static struct resource omap2_mbox_resources[] = { - { - .start = OMAP24XX_MAILBOX_BASE, - .end = OMAP24XX_MAILBOX_BASE + MBOX_REG_SIZE - 1, - .flags = IORESOURCE_MEM, - }, - { - .start = INT_24XX_MAIL_U0_MPU, - .flags = IORESOURCE_IRQ, - .name = "dsp", - }, - { - .start = INT_24XX_MAIL_U3_MPU, - .flags = IORESOURCE_IRQ, - .name = "iva", - }, -}; -static int omap2_mbox_resources_sz = ARRAY_SIZE(omap2_mbox_resources); -#else -#define omap2_mbox_resources NULL -#define omap2_mbox_resources_sz 0 -#endif - -#ifdef CONFIG_ARCH_OMAP3 -static struct resource omap3_mbox_resources[] = { - { - .start = OMAP34XX_MAILBOX_BASE, - .end = OMAP34XX_MAILBOX_BASE + MBOX_REG_SIZE - 1, - .flags = IORESOURCE_MEM, - }, - { - .start = INT_24XX_MAIL_U0_MPU, - .flags = IORESOURCE_IRQ, - .name = "dsp", - }, -}; -static int omap3_mbox_resources_sz = ARRAY_SIZE(omap3_mbox_resources); -#else -#define omap3_mbox_resources NULL -#define omap3_mbox_resources_sz 0 -#endif - -#ifdef CONFIG_ARCH_OMAP4 - -#define OMAP4_MBOX_REG_SIZE 0x130 -static struct resource omap4_mbox_resources[] = { - { - .start = OMAP44XX_MAILBOX_BASE, - .end = OMAP44XX_MAILBOX_BASE + - OMAP4_MBOX_REG_SIZE - 1, - .flags = IORESOURCE_MEM, - }, - { - .start = OMAP44XX_IRQ_MAIL_U0, - .flags = IORESOURCE_IRQ, - .name = "mbox", - }, -}; -static int omap4_mbox_resources_sz = ARRAY_SIZE(omap4_mbox_resources); -#else -#define omap4_mbox_resources NULL -#define omap4_mbox_resources_sz 0 -#endif + hwmod = omap_hwmod_lookup("mailbox"); + if (!hwmod) { + pr_err("%s: unable to find hwmod\n", __func__); + return; + } -static struct platform_device mbox_device = { - .name = "omap-mailbox", - .id = -1, -}; + pdata.base_addr = hwmod->_rt_va; -static inline void omap_init_mbox(void) -{ - if (cpu_is_omap24xx()) { - mbox_device.resource = omap2_mbox_resources; - mbox_device.num_resources = omap2_mbox_resources_sz; - } else if (cpu_is_omap34xx()) { - mbox_device.resource = omap3_mbox_resources; - mbox_device.num_resources = omap3_mbox_resources_sz; - } else if (cpu_is_omap44xx()) { - mbox_device.resource = omap4_mbox_resources; - mbox_device.num_resources = omap4_mbox_resources_sz; - } else { - pr_err("%s: platform not supported\n", __func__); + odev = omap_device_build("omap-mailbox", -1, hwmod, + &pdata, sizeof(pdata), + NULL, 0, + 0); + if (!odev) { + pr_err("%s: could not build device\n", __func__); return; } - platform_device_register(&mbox_device); } #else static inline void omap_init_mbox(void) { } diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c index d46e439..baaaa5a 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/arch/arm/mach-omap2/mailbox.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #define MAILBOX_REVISION 0x000 @@ -388,11 +389,9 @@ struct omap_mbox *omap4_mboxes[] = { &mbox_1_info, &mbox_2_info, NULL }; static int __devinit omap2_mbox_probe(struct platform_device *pdev) { - struct resource *res; int ret; struct omap_mbox **list; - - res = pdev->resource; + struct omap_mbox_platform_data *pdata = pdev->dev.platform_data; if (false); #if defined(CONFIG_ARCH_OMAP3430) @@ -423,15 +422,11 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) return -ENODEV; } - mbox_base = ioremap(res[0].start, resource_size(&res[0])); - if (!mbox_base) - return -ENOMEM; + mbox_base = pdata->base_addr; ret = omap_mbox_register(&pdev->dev, list); - if (ret) { - iounmap(mbox_base); + if (ret) return ret; - } return 0; return ret; @@ -440,7 +435,6 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) static int __devexit omap2_mbox_remove(struct platform_device *pdev) { omap_mbox_unregister(); - iounmap(mbox_base); return 0; } diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c index ed60840..62b8fa8 100644 --- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c @@ -164,12 +164,57 @@ static struct omap_hwmod omap3xxx_mpu_hwmod = { .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430), }; +/* mailbox */ + +static struct omap_hwmod_class omap3xxx_mailbox_hwmod_class = { + .name = "mailbox", +}; + +static struct omap_hwmod omap3xxx_mailbox_hwmod; +static struct omap_hwmod_irq_info omap3xxx_mailbox_irqs[] = { + { .name = "dsp", .irq = 26 }, +}; + +static struct omap_hwmod_addr_space omap3xxx_mailbox_addrs[] = { + { + .pa_start = 0x48094000, + .pa_end = 0x48094120, + .flags = ADDR_TYPE_RT + }, +}; + +/* L4_CORE -> mailbox */ +static struct omap_hwmod_ocp_if omap3xxx_l4_core__mailbox = { + .master = &omap3xxx_l4_core_hwmod, + .slave = &omap3xxx_mailbox_hwmod, + .addr = omap3xxx_mailbox_addrs, + .addr_cnt = ARRAY_SIZE(omap3xxx_mailbox_addrs), + .user = OCP_USER_MPU | OCP_USER_SDMA, +}; + +/* mailbox slave ports */ +static struct omap_hwmod_ocp_if *omap3xxx_mailbox_slaves[] = { + &omap3xxx_l4_core__mailbox, +}; + +static struct omap_hwmod omap3xxx_mailbox_hwmod = { + .name = "mailbox", + .class = &omap3xxx_mailbox_hwmod_class, + .main_clk = "mailboxes_ick", + .mpu_irqs = omap3xxx_mailbox_irqs, + .mpu_irqs_cnt = ARRAY_SIZE(omap3xxx_mailbox_irqs), + .slaves = omap3xxx_mailbox_slaves, + .slaves_cnt = ARRAY_SIZE(omap3xxx_mailbox_slaves), + .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430), +}; + static __initdata struct omap_hwmod *omap3xxx_hwmods[] = { &omap3xxx_l3_hwmod, &omap3xxx_l4_core_hwmod, &omap3xxx_l4_per_hwmod, &omap3xxx_l4_wkup_hwmod, &omap3xxx_mpu_hwmod, + &omap3xxx_mailbox_hwmod, NULL, }; diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h index 9976565..78060bd 100644 --- a/arch/arm/plat-omap/include/plat/mailbox.h +++ b/arch/arm/plat-omap/include/plat/mailbox.h @@ -59,6 +59,10 @@ struct omap_mbox { void *priv; }; +struct omap_mbox_platform_data { + void __iomem *base_addr; +}; + int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg); void omap_mbox_init_seq(struct omap_mbox *);