From patchwork Tue Oct 26 21:53:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: omar ramirez X-Patchwork-Id: 284132 X-Patchwork-Delegate: hiroshi.doyu@nokia.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9QM3MoJ013157 for ; Tue, 26 Oct 2010 22:03:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760544Ab0JZWDT (ORCPT ); Tue, 26 Oct 2010 18:03:19 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:35624 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760542Ab0JZWDR (ORCPT ); Tue, 26 Oct 2010 18:03:17 -0400 Received: from dlep33.itg.ti.com ([157.170.170.112]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o9QM3A5p029108 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Oct 2010 17:03:10 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o9QM35Jg020807; Tue, 26 Oct 2010 17:03:05 -0500 (CDT) Received: from localhost (bacab.am.dhcp.ti.com [128.247.77.143]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o9QM34f20308; Tue, 26 Oct 2010 17:03:04 -0500 (CDT) From: Omar Ramirez Luna To: Tony Lindgren , Hiroshi DOYU Cc: Felipe Contreras , Dmitry Kasatkin , Kevin Hilman , Omar Ramirez Luna , Suman Anna , Paul Walmsley , Benoit Cousson , "Govindraj.R" , C A Subramaniam , linux-omap@vger.kernel.org Subject: [PATCH 3/5] omap: mailbox: add omap_device latency information Date: Tue, 26 Oct 2010 16:53:02 -0500 Message-Id: <1288129984-22957-4-git-send-email-omar.ramirez@ti.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1288129984-22957-1-git-send-email-omar.ramirez@ti.com> References: <1288129984-22957-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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 26 Oct 2010 22:03:22 +0000 (UTC) diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index d977572..337fd7a 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "mux.h" #include "control.h" @@ -141,10 +142,20 @@ static inline void omap_init_camera(void) #endif #if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) +static struct omap_device_pm_latency mbox_latencies[] = { + [0] = { + .activate_func = omap_device_enable_clocks, + .activate_lat = 50000, /* FIXME random value */ + .deactivate_func = omap_device_enable_clocks, + .deactivate_lat = 50000, /* FIXME random value */ + }, +}; + static inline void omap_init_mbox(void) { struct omap_hwmod *oh; struct omap_device *od; + struct omap_mbox_platform_data pdata; oh = omap_hwmod_lookup("mailbox"); if (!oh) { @@ -152,10 +163,14 @@ static inline void omap_init_mbox(void) return; } + pdata.device_enable = omap_device_enable; + pdata.device_disable = omap_device_idle; + od = omap_device_build("omap-mailbox", -1, oh, - NULL, 0, - NULL, 0, + &pdata, sizeof(pdata), + mbox_latencies, ARRAY_SIZE(mbox_latencies), 0); + if (!od) { pr_err("%s: could not build device\n", __func__); return; diff --git a/arch/arm/mach-omap2/mailbox.c b/arch/arm/mach-omap2/mailbox.c index 1ddb82d..61f2149 100644 --- a/arch/arm/mach-omap2/mailbox.c +++ b/arch/arm/mach-omap2/mailbox.c @@ -53,6 +53,7 @@ #define OMAP4_MBOX_NR_REGS (OMAP4_MBOX_REG_SIZE / sizeof(u32)) static void __iomem *mbox_base; +static struct platform_device *mbox_pdev; struct omap_mbox2_fifo { unsigned long msg; @@ -71,8 +72,6 @@ struct omap_mbox2_priv { unsigned long irqdisable; }; -static struct clk *mbox_ick_handle; - static void omap2_mbox_enable_irq(struct omap_mbox *mbox, omap_mbox_type_t irq); @@ -91,14 +90,10 @@ static int omap2_mbox_startup(struct omap_mbox *mbox) { u32 l; unsigned long timeout; + struct omap_mbox_platform_data *pdata = mbox_pdev->dev.platform_data; - mbox_ick_handle = clk_get(NULL, "mailboxes_ick"); - if (IS_ERR(mbox_ick_handle)) { - printk(KERN_ERR "Could not get mailboxes_ick: %ld\n", - PTR_ERR(mbox_ick_handle)); - return PTR_ERR(mbox_ick_handle); - } - clk_enable(mbox_ick_handle); + if (pdata->device_enable) + pdata->device_enable(mbox_pdev); if (cpu_is_omap44xx()) { mbox_write_reg(OMAP4_SOFTRESET, MAILBOX_SYSCONFIG); @@ -144,9 +139,9 @@ static int omap2_mbox_startup(struct omap_mbox *mbox) static void omap2_mbox_shutdown(struct omap_mbox *mbox) { - clk_disable(mbox_ick_handle); - clk_put(mbox_ick_handle); - mbox_ick_handle = NULL; + struct omap_mbox_platform_data *pdata = mbox_pdev->dev.platform_data; + if (pdata->device_disable) + pdata->device_disable(mbox_pdev); } /* Mailbox FIFO handle functions */ @@ -428,6 +423,8 @@ static int __devinit omap2_mbox_probe(struct platform_device *pdev) if (!mbox_base) return -ENOMEM; + mbox_pdev = pdev; + ret = omap_mbox_register(&pdev->dev, list); if (ret) { iounmap(mbox_base); diff --git a/arch/arm/plat-omap/include/plat/mailbox.h b/arch/arm/plat-omap/include/plat/mailbox.h index 9976565..59443b1 100644 --- a/arch/arm/plat-omap/include/plat/mailbox.h +++ b/arch/arm/plat-omap/include/plat/mailbox.h @@ -11,6 +11,7 @@ typedef u32 mbox_msg_t; struct omap_mbox; +struct platform_device; typedef int __bitwise omap_mbox_irq_t; #define IRQ_TX ((__force omap_mbox_irq_t) 1) @@ -59,6 +60,11 @@ struct omap_mbox { void *priv; }; +struct omap_mbox_platform_data { + int (*device_enable)(struct platform_device *pdev); + int (*device_disable)(struct platform_device *pdev); +}; + int omap_mbox_msg_send(struct omap_mbox *, mbox_msg_t msg); void omap_mbox_init_seq(struct omap_mbox *);