From patchwork Thu Jul 1 22:23:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 109763 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o61MOHlm030248 for ; Thu, 1 Jul 2010 22:24:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932447Ab0GAWXl (ORCPT ); Thu, 1 Jul 2010 18:23:41 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:49802 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932451Ab0GAWXi (ORCPT ); Thu, 1 Jul 2010 18:23:38 -0400 Received: by bwz1 with SMTP id 1so1212780bwz.19 for ; Thu, 01 Jul 2010 15:23:36 -0700 (PDT) Received: by 10.204.79.199 with SMTP id q7mr118972bkk.76.1278023016691; Thu, 01 Jul 2010 15:23:36 -0700 (PDT) Received: from localhost.localdomain (93-173-171-226.bb.netvision.net.il [93.173.171.226]) by mx.google.com with ESMTPS id s34sm141464bkk.13.2010.07.01.15.23.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 01 Jul 2010 15:23:35 -0700 (PDT) From: Ohad Ben-Cohen To: Cc: Kanigeri Hari , Ohad Ben-Cohen Subject: [RFC 3/6] omap: introduce OMAP4 remoteproc module Date: Fri, 2 Jul 2010 01:23:11 +0300 Message-Id: <1278022994-28476-4-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1278022994-28476-1-git-send-email-ohad@wizery.com> References: <1278022994-28476-1-git-send-email-ohad@wizery.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]); Thu, 01 Jul 2010 22:24:19 +0000 (UTC) diff --git a/arch/arm/mach-omap2/remoteproc44xx.c b/arch/arm/mach-omap2/remoteproc44xx.c new file mode 100644 index 0000000..e240595 --- /dev/null +++ b/arch/arm/mach-omap2/remoteproc44xx.c @@ -0,0 +1,196 @@ +/* + * Remote Processor machine-specific module for OMAP4 + * + * Copyright (C) 2010 Texas Instruments Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ +/* this is needed for multi-omap support */ +#ifdef CONFIG_ARCH_OMAP4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cm.h" +#include "prm.h" + +#define RM_M3_RST1ST 0x1 +#define RM_M3_RST2ST 0x2 +#define RM_M3_RST3ST 0x4 +#define RM_M3_REL_RST1_MASK 0x2 +#define RM_M3_REL_RST2_MASK 0x0 +#define RM_M3_AST_RST1_MASK 0x3 +#define RM_M3_AST_RST2_MASK 0x2 + +#define M3_CLK_MOD_MODE_HW_AUTO 0x1 +#define M3_CLKTRCTRL_SW_WKUP 0x2 +#define M3_CLKTRCTRL_SW_SLEEP 0x1 +#define M3_CLKACTIVITY_MPU_M3_CLK 0x100 + +static inline int omap4_rproc_get_state(struct omap_rproc *rproc) +{ + return rproc->state; +} + +static inline int proc44x_sysm3_start(struct device *dev, u32 start_addr) +{ + u32 reg; + int counter = 10; + + /* Module is managed automatically by HW */ + cm_write_mod_reg(M3_CLK_MOD_MODE_HW_AUTO, OMAP4430_CM2_CORE_MOD, + OMAP4_CM_DUCATI_DUCATI_CLKCTRL_OFFSET); + + /* Enable the M3 clock */ + cm_write_mod_reg(M3_CLKTRCTRL_SW_WKUP, OMAP4430_CM2_CORE_MOD, + OMAP4_CM_DUCATI_CLKSTCTRL_OFFSET); + do { + reg = cm_read_mod_reg(OMAP4430_CM2_CORE_MOD, + OMAP4_CM_DUCATI_CLKSTCTRL_OFFSET); + if (reg & M3_CLKACTIVITY_MPU_M3_CLK) { + dev_info(dev, "M3 clock enabled:" + "OMAP4430_CM_DUCATI_CLKSTCTRL = 0x%x\n", reg); + break; + } + msleep(1); + } while (--counter); + if (counter == 0) { + dev_info(dev, "FAILED TO ENABLE DUCATI M3 CLOCK !%x\n", reg); + return -EFAULT; + } + + /* De-assert RST1, and clear the Reset status */ + dev_info(dev, "De-assert RST1\n"); + prm_write_mod_reg(RM_M3_REL_RST1_MASK, OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTCTRL_OFFSET); + while (!(prm_read_mod_reg(OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTST_OFFSET) & RM_M3_RST1ST)) + ; + dev_info(dev, "RST1 released!"); + + prm_write_mod_reg(RM_M3_RST1ST, OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTST_OFFSET); + + return 0; +} + +static inline int proc44x_appm3_start(struct device *dev, u32 start_addr) +{ + /* De-assert RST2, and clear the Reset status */ + dev_info(dev, "De-assert RST2\n"); + prm_write_mod_reg(RM_M3_REL_RST2_MASK, OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTCTRL_OFFSET); + + while (!(prm_read_mod_reg(OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTST_OFFSET) & RM_M3_RST2ST)) + ; + dev_info(dev, "RST2 released!"); + + prm_write_mod_reg(RM_M3_RST2ST, OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTST_OFFSET); + + return 0; +} + +static inline int proc44x_sysm3_stop(struct device *dev) +{ + dev_info(dev, "assert RST1\n"); + prm_write_mod_reg(RM_M3_AST_RST1_MASK, OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTCTRL_OFFSET); + /* Disable the M3 clock */ + cm_write_mod_reg(M3_CLKTRCTRL_SW_SLEEP, OMAP4430_CM2_CORE_MOD, + OMAP4_CM_DUCATI_CLKSTCTRL_OFFSET); + + return 0; +} + +static inline int proc44x_appm3_stop(struct device *dev) +{ + dev_info(dev, "assert RST2\n"); + prm_write_mod_reg(RM_M3_AST_RST2_MASK, OMAP4430_PRM_CORE_MOD, + OMAP4_RM_DUCATI_RSTCTRL_OFFSET); + + return 0; +} + +static struct omap_rproc_ops omap4_ducati0_ops = { + .start = proc44x_sysm3_start, + .stop = proc44x_sysm3_stop, + .get_state = omap4_rproc_get_state, +}; + +static struct omap_rproc_ops omap4_ducati1_ops = { + .start = proc44x_appm3_start, + .stop = proc44x_appm3_stop, + .get_state = omap4_rproc_get_state, +}; + +static struct omap_rproc_ops omap4_tesla_ops = { + .start = NULL, + .stop = NULL, + .get_state = NULL, +}; + +static struct omap_rproc_platform_data omap4_rproc_data[] = { + { + .name = "tesla", + .ops = &omap4_tesla_ops, + .oh_name = "tesla_hwmod", + }, + { + .name = "ducati-proc0", + .ops = &omap4_ducati0_ops, + .oh_name = "ducati_hwmod0", + }, + { + .name = "ducati-proc1", + .ops = &omap4_ducati1_ops, + .oh_name = "ducati_hwmod1", + }, +}; + +struct omap_rproc_platform_data *omap4_get_rproc_data(void) +{ + return omap4_rproc_data; +} + +int omap4_get_rproc_data_size(void) +{ + return ARRAY_SIZE(omap4_rproc_data); +} +#else +struct omap_rproc_platform_data *omap4_get_rproc_data(void) +{ + return NULL; +} + +int omap4_get_rproc_data_size(void) +{ + return 0; +} +#endif + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("OMAP4 Remote Processor module"); +MODULE_AUTHOR("Hari Kanigeri "); +MODULE_AUTHOR("Ohad Ben-Cohen ");