* [RFC 0/6] Introducing OMAP Remote Processor module
@ 2010-07-01 22:23 Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 1/6] omap: add iva2 hwmod support to omap3 Ohad Ben-Cohen
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-01 22:23 UTC (permalink / raw)
To: linux-omap; +Cc: Kanigeri Hari, Ohad Ben-Cohen
From: Ohad Ben-Cohen <ohadb@ti.com>
This is a preliminary version of OMAP's remoteproc module,
submitted for RFC purposes.
The purpose of the remoteproc module is to decouple
hw-specific code from generic IPC drivers (such as
dspbridge and syslink), in order to eventually make
those IPC drivers platform-independent.
Currently the supported operations are starting and stopping
the remote processor, but in the future additional functionality
might be added.
Both OMAP3 and OMAP4 are supported; OMAP3 supports the dsp
remote processor, and OMAP4 supports ducati (tesla support
is planned as well).
The code was tested on both OMAP3 (using dspbridge) and OMAP4
(using syslink).
The code is preliminary: we plan to add much more extensive
hwmod support, ideally squashing as much hw-specific code
as possible (including RST and PRCM manipulations).
In addition, a rebase to recent code bases is needed.
While dspbridge accesses remoteproc's interface via pdata
pointers, syslink accesses it from user space, via character
device interface, so both kernel and user space interfaces
are supported.
A few words on the char device interface:
* Each remote processor is represented by a different
character device: /dev/omap-rproc0, /dev/omap-rproc1, ...
* A rproc character device can only be opened by a single user
(e.g. the syslink daemon)
* The start/stop/get_state functionality is exposed via ioctl's
* We plan to add automatic stop() invokation in case the user
closes the device after starting a remote processor (for
resource cleanup purposes. Thus the user will be required
to hold the device open as long as it lives).
Thanks,
Hari Kanigeri (1):
omap: introduce OMAP4 remoteproc module
Ohad Ben-Cohen (5):
omap: add iva2 hwmod support to omap3
omap: introduce OMAP3 remoteproc module
omap: introduce common remoteproc module
omap: add remoteproc device(s)
omap: enable remoteproc building
arch/arm/mach-omap2/Makefile | 6 +
arch/arm/mach-omap2/devices.c | 86 +++++++
arch/arm/mach-omap2/omap_hwmod_34xx.h | 23 ++
arch/arm/mach-omap2/remoteproc3xxx.c | 226 ++++++++++++++++++
arch/arm/mach-omap2/remoteproc44xx.c | 196 ++++++++++++++++
arch/arm/plat-omap/Kconfig | 7 +
arch/arm/plat-omap/Makefile | 1 +
arch/arm/plat-omap/include/plat/omap_hwmod.h | 1 +
arch/arm/plat-omap/include/plat/remoteproc.h | 75 ++++++
arch/arm/plat-omap/remoteproc.c | 316 ++++++++++++++++++++++++++
10 files changed, 937 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-omap2/remoteproc3xxx.c
create mode 100644 arch/arm/mach-omap2/remoteproc44xx.c
create mode 100644 arch/arm/plat-omap/include/plat/remoteproc.h
create mode 100644 arch/arm/plat-omap/remoteproc.c
^ permalink raw reply [flat|nested] 15+ messages in thread
* [RFC 1/6] omap: add iva2 hwmod support to omap3
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
@ 2010-07-01 22:23 ` Ohad Ben-Cohen
2010-07-02 5:43 ` Cousson, Benoit
2010-07-01 22:23 ` [RFC 2/6] omap: introduce OMAP3 remoteproc module Ohad Ben-Cohen
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-01 22:23 UTC (permalink / raw)
To: linux-omap; +Cc: Kanigeri Hari, Ohad Ben-Cohen
From: Ohad Ben-Cohen <ohadb@ti.com>
Add preliminary iva2 hwmod support to omap3.
We do not include iva2_clk; that will be part of a separate
hwmod, which will be controlled by iommu.
Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
---
arch/arm/mach-omap2/omap_hwmod_34xx.h | 23 +++++++++++++++++++++++
arch/arm/plat-omap/include/plat/omap_hwmod.h | 1 +
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod_34xx.h b/arch/arm/mach-omap2/omap_hwmod_34xx.h
index b6076b9..d363a95 100644
--- a/arch/arm/mach-omap2/omap_hwmod_34xx.h
+++ b/arch/arm/mach-omap2/omap_hwmod_34xx.h
@@ -22,6 +22,7 @@
#include "prm-regbits-34xx.h"
static struct omap_hwmod omap34xx_mpu_hwmod;
+static struct omap_hwmod omap34xx_iva2_hwmod;
static struct omap_hwmod omap34xx_l3_hwmod;
static struct omap_hwmod omap34xx_l4_core_hwmod;
static struct omap_hwmod omap34xx_l4_per_hwmod;
@@ -47,9 +48,17 @@ static struct omap_hwmod_ocp_if omap34xx_mpu__l3 = {
.user = OCP_USER_MPU,
};
+/* IVA2 -> L3 interface */
+static struct omap_hwmod_ocp_if omap34xx_iva2__l3 = {
+ .master = &omap34xx_iva2_hwmod,
+ .slave = &omap34xx_l3_hwmod,
+ .user = OCP_USER_IVA2,
+};
+
/* Slave interfaces on the L3 interconnect */
static struct omap_hwmod_ocp_if *omap34xx_l3_slaves[] = {
&omap34xx_mpu__l3,
+ &omap34xx_iva2__l3,
};
/* Master interfaces on the L3 interconnect */
@@ -150,12 +159,26 @@ static struct omap_hwmod omap34xx_mpu_hwmod = {
.omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
};
+/* Master interfaces on the IVA2 device */
+static struct omap_hwmod_ocp_if *omap34xx_iva2_masters[] = {
+ &omap34xx_iva2__l3,
+};
+
+/* IVA2 */
+static struct omap_hwmod omap34xx_iva2_hwmod = {
+ .name = "iva2_hwmod",
+ .masters = omap34xx_iva2_masters,
+ .masters_cnt = ARRAY_SIZE(omap34xx_iva2_masters),
+ .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
+};
+
static __initdata struct omap_hwmod *omap34xx_hwmods[] = {
&omap34xx_l3_hwmod,
&omap34xx_l4_core_hwmod,
&omap34xx_l4_per_hwmod,
&omap34xx_l4_wkup_hwmod,
&omap34xx_mpu_hwmod,
+ &omap34xx_iva2_hwmod,
NULL,
};
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 3393325..5e64992 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -160,6 +160,7 @@ struct omap_hwmod_addr_space {
*/
#define OCP_USER_MPU (1 << 0)
#define OCP_USER_SDMA (1 << 1)
+#define OCP_USER_IVA2 (1 << 2)
/* omap_hwmod_ocp_if.flags bits */
#define OCPIF_HAS_IDLEST (1 << 0)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 2/6] omap: introduce OMAP3 remoteproc module
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 1/6] omap: add iva2 hwmod support to omap3 Ohad Ben-Cohen
@ 2010-07-01 22:23 ` Ohad Ben-Cohen
2010-07-27 15:23 ` Premi, Sanjeev
2010-07-01 22:23 ` [RFC 3/6] omap: introduce OMAP4 " Ohad Ben-Cohen
` (4 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-01 22:23 UTC (permalink / raw)
To: linux-omap; +Cc: Kanigeri Hari, Ohad Ben-Cohen
From: Ohad Ben-Cohen <ohadb@ti.com>
Introduce OMAP3 remoteproc module which takes care of
machine-specific code required to start and stop
the DSP remote processor.
Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
---
arch/arm/mach-omap2/remoteproc3xxx.c | 226 ++++++++++++++++++++++++++++++++++
1 files changed, 226 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-omap2/remoteproc3xxx.c
diff --git a/arch/arm/mach-omap2/remoteproc3xxx.c b/arch/arm/mach-omap2/remoteproc3xxx.c
new file mode 100644
index 0000000..f86a333
--- /dev/null
+++ b/arch/arm/mach-omap2/remoteproc3xxx.c
@@ -0,0 +1,226 @@
+/*
+ * Remote Processor machine-specific module for OMAP3
+ *
+ * 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_OMAP3
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/pm_runtime.h>
+#include <plat/remoteproc.h>
+#include <mach/irqs.h>
+#include <plat/omap_device.h>
+#include <plat/control.h>
+#include <plat/common.h>
+#include <plat/powerdomain.h>
+#include <plat/clockdomain.h>
+#include <asm/uaccess.h>
+
+#include "cm-regbits-34xx.h"
+#include "prm-regbits-34xx.h"
+
+#define OMAP3_IVA2_BOOTADDR_MASK 0xFFFFFC00
+
+#define PRCM_PM_PWSTCTRL_IVA2_POWER_STATE_MASK (u32)(3)
+#define PRCM_PM_PWSTCTRL_IVA2_POWER_STATE_OFFSET (u32)(0)
+
+#define PRCM_PM_PWSTST_IVA2_InTransition_MASK (u32)(0x100000)
+#define PRCM_PM_PWSTST_IVA2_InTransition_OFFSET (u32)(20)
+
+#define CM_CLKSTCTRL_IVA2_OFFSET (0)
+#define CM_CLKSTCTRL_IVA2_MASK (3)
+
+#define DSP_SYSC_DIRECTBOOT (0)
+#define DSP_SYSC_IDLEBOOT (1)
+#define DSP_SYSC_SELFLOOPBOOT (2)
+#define DSP_SYSC_USRBOOTSTRAP (3)
+#define DSP_SYSC_DEFAULTRESTORE (4)
+
+#ifdef CONFIG_BRIDGE_DEBUG
+static void omap3_rproc_dump_regs(struct device *dev)
+{
+ u32 temp;
+
+ temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_FCLKEN);
+ dev_info(dev, "CM_FCLKEN_IVA2 = 0x%x \n", temp);
+ temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_ICLKEN1);
+ dev_info(dev, "CM_ICLKEN1_IVA2 = 0x%x \n", temp);
+ temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_IDLEST);
+ dev_info(dev, "CM_IDLEST_IVA2 = 0x%x \n", temp);
+ temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_CLKSTCTRL);
+ dev_info(dev, "CM_CLKSTCTRL_IVA2 = 0x%x \n", temp);
+ temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST);
+ dev_info(dev, "CM_CLKSTST_IVA2 = 0x%x \n", temp);
+ temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, RM_RSTCTRL);
+ dev_info(dev, "RM_RSTCTRL_IVA2 = 0x%x \n", temp);
+ temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, RM_RSTST);
+ dev_info(dev, "RM_RSTST_IVA2 = 0x%x \n", temp);
+ temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTCTRL);
+ dev_info(dev, "PM_PWSTCTRL_IVA2 = 0x%x \n", temp);
+ temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTST);
+ dev_info(dev, "PM_PWSTST_IVA2 = 0x%x \n", temp);
+ temp = cm_read_mod_reg(CORE_MOD, CM_ICLKEN1);
+ dev_info(dev, "CM_ICLKEN1_CORE = 0x%x \n", temp);
+}
+#else
+static void omap3_rproc_dump_regs(struct device *dev) { }
+#endif
+
+static int omap3_rproc_get_state(struct device *dev)
+{
+ u32 dsp_pwr_state;
+
+ dsp_pwr_state = prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTST);
+
+ return dsp_pwr_state & OMAP_POWERSTATEST_MASK;
+}
+
+static int omap3_rproc_start(struct device *dev, u32 start_addr)
+{
+ dev_info(dev, "%s: set boot mode, addr: 0x%x\n", __func__, start_addr);
+
+ omap3_rproc_dump_regs(dev);
+
+ if (PWRDM_POWER_ON != omap3_rproc_get_state(dev)) {
+ /* IVA2 is not in ON state */
+ /* Read and set PM_PWSTCTRL_IVA2 to ON */
+ prm_rmw_mod_reg_bits(OMAP_POWERSTATEST_MASK, PWRDM_POWER_ON,
+ OMAP3430_IVA2_MOD, PM_PWSTCTRL);
+
+ /* Set the SW supervised state transition */
+ cm_write_mod_reg(OMAP34XX_CLKSTCTRL_FORCE_WAKEUP,
+ OMAP3430_IVA2_MOD, CM_CLKSTCTRL);
+
+ /* Wait until the state has moved to ON */
+ while (prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTST)
+ & OMAP_INTRANSITION)
+ ;
+
+ /* Disable Automatic transition */
+ cm_write_mod_reg(OMAP34XX_CLKSTCTRL_DISABLE_AUTO,
+ OMAP3430_IVA2_MOD, CM_CLKSTCTRL);
+ }
+
+ /* Assert RST1 i.e only the RST only for DSP megacell */
+ prm_rmw_mod_reg_bits(OMAP3430_RST1_IVA2, OMAP3430_RST1_IVA2,
+ OMAP3430_IVA2_MOD, RM_RSTCTRL);
+ /* Mask address with 1K for compatibility */
+ omap_ctrl_writel(start_addr & OMAP3_IVA2_BOOTADDR_MASK,
+ OMAP343X_CONTROL_IVA2_BOOTADDR);
+ /* Set bootmode to self loop if dsp_debug flag is true */
+ omap_ctrl_writel(DSP_SYSC_DIRECTBOOT, OMAP343X_CONTROL_IVA2_BOOTMOD);
+
+ /*Set Autoidle Mode for IVA2 PLL */
+ cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
+ OMAP3430_IVA2_MOD, OMAP3430_CM_AUTOIDLE_PLL);
+
+ /* select GPT5 and GPT6 as IVA2 wake-up modules */
+ prm_rmw_mod_reg_bits(0x3F, 0xC0, OMAP3430_PER_MOD,
+ OMAP3430_PM_IVAGRPSEL);
+
+ /* make sure GPT5 and GPT6 are not selected as MPU wake-up modules */
+ prm_rmw_mod_reg_bits(0xC0, 0, OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
+
+ /* PER domain sleep dependency with IVA2 domain is enabled */
+ cm_rmw_mod_reg_bits(4, 4, OMAP3430_PER_MOD, OMAP3430_CM_SLEEPDEP);
+
+ /* Allow automatic transitions */
+ cm_write_mod_reg(OMAP34XX_CLKSTCTRL_ENABLE_AUTO, OMAP3430_IVA2_MOD,
+ CM_CLKSTCTRL);
+
+ /* Let DSP go */
+ dev_dbg(dev, "%s Unreset DSP\n", __func__);
+
+ /* release the RST1, DSP starts executing now .. */
+ prm_rmw_mod_reg_bits(OMAP3430_RST1_IVA2, 0, OMAP3430_IVA2_MOD,
+ RM_RSTCTRL);
+
+ omap3_rproc_dump_regs(dev);
+
+ return 0;
+}
+
+static int omap3_rproc_stop(struct device *dev)
+{
+ dev_info(dev, "%s\n", __func__);
+
+ omap3_rproc_dump_regs(dev);
+
+ /* Set PM_PWSTCTRL_IVA2 to OFF */
+ prm_rmw_mod_reg_bits(OMAP_POWERSTATEST_MASK,
+ PWRDM_POWER_OFF, OMAP3430_IVA2_MOD, PM_PWSTCTRL);
+
+ /* Set the SW supervised state transition for Sleep */
+ cm_write_mod_reg(OMAP34XX_CLKSTCTRL_FORCE_SLEEP, OMAP3430_IVA2_MOD,
+ CM_CLKSTCTRL);
+
+ /* Reset RST1 + RST3 */
+ prm_rmw_mod_reg_bits(OMAP3430_RST1_IVA2 | OMAP3430_RST3_IVA2,
+ OMAP3430_RST1_IVA2 | OMAP3430_RST3_IVA2,
+ OMAP3430_IVA2_MOD, RM_RSTCTRL);
+
+ udelay(10);
+
+ return 0;
+}
+
+static struct omap_rproc_ops omap3_rproc_ops = {
+ .start = omap3_rproc_start,
+ .stop = omap3_rproc_stop,
+ .get_state = omap3_rproc_get_state,
+};
+
+static struct omap_rproc_platform_data omap3_rproc_data[] = {
+ {
+ .name = "dsp",
+ .ops = &omap3_rproc_ops,
+ .oh_name = "iva2_hwmod",
+ },
+};
+
+struct omap_rproc_platform_data *omap3_get_rproc_data(void)
+{
+ return omap3_rproc_data;
+}
+
+int omap3_get_rproc_data_size(void)
+{
+ return ARRAY_SIZE(omap3_rproc_data);
+}
+#else
+struct omap_rproc_platform_data *omap3_get_rproc_data(void)
+{
+ return NULL;
+}
+
+int omap3_get_rproc_data_size(void)
+{
+ return 0;
+}
+#endif
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("OMAP3 Remote Processor module");
+MODULE_AUTHOR("Ohad Ben-Cohen <ohad@wizery.com>");
+MODULE_AUTHOR("Hari Kanigeri <h-kanigeri2@ti.com>");
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 3/6] omap: introduce OMAP4 remoteproc module
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 1/6] omap: add iva2 hwmod support to omap3 Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 2/6] omap: introduce OMAP3 remoteproc module Ohad Ben-Cohen
@ 2010-07-01 22:23 ` Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 4/6] omap: introduce common " Ohad Ben-Cohen
` (3 subsequent siblings)
6 siblings, 0 replies; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-01 22:23 UTC (permalink / raw)
To: linux-omap; +Cc: Kanigeri Hari, Ohad Ben-Cohen
From: Hari Kanigeri <h-kanigeri2@ti.com>
Introduce OMAP4 machine-dependent module required
for starting and stopping the OMAP3 remote processors.
Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
---
arch/arm/mach-omap2/remoteproc44xx.c | 196 ++++++++++++++++++++++++++++++++++
1 files changed, 196 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-omap2/remoteproc44xx.c
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 <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/pm_runtime.h>
+#include <plat/remoteproc.h>
+#include <mach/irqs.h>
+#include <plat/omap_device.h>
+
+#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 <h-kanigeri2@ti.com>");
+MODULE_AUTHOR("Ohad Ben-Cohen <ohad@wizery.com>");
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 4/6] omap: introduce common remoteproc module
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
` (2 preceding siblings ...)
2010-07-01 22:23 ` [RFC 3/6] omap: introduce OMAP4 " Ohad Ben-Cohen
@ 2010-07-01 22:23 ` Ohad Ben-Cohen
2010-07-27 14:49 ` Premi, Sanjeev
2010-07-01 22:23 ` [RFC 5/6] omap: add remoteproc device(s) Ohad Ben-Cohen
` (2 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-01 22:23 UTC (permalink / raw)
To: linux-omap; +Cc: Kanigeri Hari, Ohad Ben-Cohen
From: Ohad Ben-Cohen <ohadb@ti.com>
The OMAP remote processor module decouples
machine-specific code from TI's IPC
drivers (e.g. dspbridge and syslink).
While dspbridge calls the remoteproc handlers
from the kernel, syslink calls them from
user space. Hence remoteproc supports both
interfaces.
Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
---
arch/arm/plat-omap/include/plat/remoteproc.h | 75 ++++++
arch/arm/plat-omap/remoteproc.c | 316 ++++++++++++++++++++++++++
2 files changed, 391 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/plat-omap/include/plat/remoteproc.h
create mode 100644 arch/arm/plat-omap/remoteproc.c
diff --git a/arch/arm/plat-omap/include/plat/remoteproc.h b/arch/arm/plat-omap/include/plat/remoteproc.h
new file mode 100644
index 0000000..1cedd08
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/remoteproc.h
@@ -0,0 +1,75 @@
+/*
+ * OMAP Remote Processor driver
+ *
+ * Copyright (C) 2010 Texas Instruments Inc.
+ *
+ * Written by Ohad Ben-Cohen <ohad@wizery.com>
+ *
+ * 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
+ *
+ */
+
+#ifndef REMOTEPROC_H
+#define REMOTEPROC_H
+
+#include <linux/ioctl.h>
+#include <linux/cdev.h>
+
+#define RPROC_IOC_MAGIC 'P'
+
+#define RPROC_IOCSTART _IOW(RPROC_IOC_MAGIC, 1, int)
+#define RPROC_IOCSTOP _IO(RPROC_IOC_MAGIC, 2)
+#define RPROC_IOCGETSTATE _IOR(RPROC_IOC_MAGIC, 3, int)
+
+#define RPROC_IOC_MAXNR (3)
+
+struct omap_rproc;
+
+struct omap_rproc_ops {
+ int (*start)(struct device *dev, u32 start_addr);
+ int (*stop)(struct device *dev);
+ int (*get_state)(struct device *dev);
+};
+
+struct omap_rproc_clk_t {
+ void *clk_handle;
+ const char *dev_id;
+ const char *con_id;
+};
+
+struct omap_rproc_platform_data {
+ struct omap_rproc_ops *ops;
+ char *name;
+ char *oh_name;
+};
+
+struct omap_rproc {
+ struct device *dev;
+ struct cdev cdev;
+ atomic_t count;
+ int minor;
+};
+
+struct omap_rproc_start_args {
+ u32 start_addr;
+};
+
+struct omap_rproc_platform_data *omap3_get_rproc_data(void);
+int omap3_get_rproc_data_size(void);
+struct omap_rproc_platform_data *omap4_get_rproc_data(void);
+int omap4_get_rproc_data_size(void);
+int omap_get_num_of_remoteproc(void);
+
+#endif /* REMOTEPROC_H */
diff --git a/arch/arm/plat-omap/remoteproc.c b/arch/arm/plat-omap/remoteproc.c
new file mode 100644
index 0000000..7a9862e
--- /dev/null
+++ b/arch/arm/plat-omap/remoteproc.c
@@ -0,0 +1,316 @@
+/*
+ * OMAP Remote Processor driver
+ *
+ * Copyright (C) 2010 Texas Instruments Inc.
+ *
+ * Authors:
+ * Ohad Ben-Cohen <ohad@wizery.com>
+ * Hari Kanigeri <h-kanigeri2@ti.com>
+ *
+ * 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
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/file.h>
+#include <linux/poll.h>
+#include <linux/mm.h>
+#include <linux/platform_device.h>
+
+#include <plat/remoteproc.h>
+
+#define OMAP_RPROC_NAME "omap-rproc"
+
+static struct class *omap_rproc_class;
+static dev_t omap_rproc_dev;
+static atomic_t num_of_rprocs;
+
+static inline int rproc_start(struct omap_rproc *rproc, const void __user *arg)
+{
+ struct omap_rproc_platform_data *pdata;
+ struct omap_rproc_start_args start_args;
+
+ if (!rproc->dev)
+ return -EINVAL;
+
+ pdata = rproc->dev->platform_data;
+ if (!pdata->ops)
+ return -EINVAL;
+
+ if (copy_from_user(&start_args, arg, sizeof(start_args)))
+ return -EFAULT;
+
+ return pdata->ops->start(rproc->dev, start_args.start_addr);
+}
+
+static inline int rproc_stop(struct omap_rproc *rproc)
+{
+ struct omap_rproc_platform_data *pdata;
+ if (!rproc->dev)
+ return -EINVAL;
+
+ pdata = rproc->dev->platform_data;
+ if (!pdata->ops)
+ return -EINVAL;
+
+ return pdata->ops->stop(rproc->dev);
+}
+
+static inline int rproc_get_state(struct omap_rproc *rproc)
+{
+ struct omap_rproc_platform_data *pdata;
+ if (!rproc->dev)
+ return -EINVAL;
+
+ pdata = rproc->dev->platform_data;
+ if (!pdata->ops)
+ return -EINVAL;
+
+ return pdata->ops->get_state(rproc->dev);
+}
+
+static int omap_rproc_open(struct inode *inode, struct file *filp)
+{
+ unsigned int count, dev_num = iminor(inode);
+ struct omap_rproc *rproc;
+ struct omap_rproc_platform_data *pdata;
+
+ rproc = container_of(inode->i_cdev, struct omap_rproc, cdev);
+ if (!rproc->dev)
+ return -EINVAL;
+
+ pdata = rproc->dev->platform_data;
+
+ count = atomic_inc_return(&rproc->count);
+ dev_info(rproc->dev, "%s: dev num %d, name %s, count %d\n", __func__,
+ dev_num,
+ pdata->name,
+ count);
+ if (count > 1) {
+ dev_err(rproc->dev, "%s failed: remoteproc already in use\n",
+ __func__);
+ atomic_dec(&rproc->count);
+ return -EBUSY;
+ }
+
+ filp->private_data = rproc;
+
+ return 0;
+}
+
+static int omap_rproc_release(struct inode *inode, struct file *filp)
+{
+ struct omap_rproc_platform_data *pdata;
+ struct omap_rproc *rproc = filp->private_data;
+ if (!rproc || !rproc->dev)
+ return -EINVAL;
+
+ pdata = rproc->dev->platform_data;
+
+ atomic_dec(&rproc->count);
+
+ return 0;
+}
+
+static int omap_rproc_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ int rc = 0;
+ struct omap_rproc *rproc = filp->private_data;
+
+ dev_info(rproc->dev, "%s\n", __func__);
+
+ if (!rproc)
+ return -EINVAL;
+
+ if (_IOC_TYPE(cmd) != RPROC_IOC_MAGIC)
+ return -ENOTTY;
+ if (_IOC_NR(cmd) > RPROC_IOC_MAXNR)
+ return -ENOTTY;
+
+ switch (cmd) {
+ case RPROC_IOCSTART:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ rc = rproc_start(rproc, (const void __user *) arg);
+ break;
+ case RPROC_IOCSTOP:
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+ rc = rproc_stop(rproc);
+ break;
+ case RPROC_IOCGETSTATE:
+ rc = rproc_get_state(rproc);
+ break;
+
+ default:
+ return -ENOTTY;
+ }
+
+ return rc;
+}
+
+static const struct file_operations omap_rproc_fops = {
+ .open = omap_rproc_open,
+ .release = omap_rproc_release,
+ .ioctl = omap_rproc_ioctl,
+ .owner = THIS_MODULE,
+};
+
+static int omap_rproc_probe(struct platform_device *pdev)
+{
+ int ret = 0, major, minor;
+ struct device *tmpdev;
+ struct device *dev = &pdev->dev;
+ struct omap_rproc_platform_data *pdata = dev->platform_data;
+ struct omap_rproc *rproc;
+
+ if (!pdata || !pdata->name || !pdata->oh_name || !pdata->ops)
+ return -EINVAL;
+
+ dev_info(dev, "%s: adding rproc %s\n", __func__, pdata->name);
+
+ rproc = kzalloc(sizeof(struct omap_rproc), GFP_KERNEL);
+ if (!rproc) {
+ dev_err(dev, "%s: kzalloc failed\n", __func__);
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ platform_set_drvdata(pdev, rproc);
+ major = MAJOR(omap_rproc_dev);
+ minor = atomic_read(&num_of_rprocs);
+ atomic_inc(&num_of_rprocs);
+
+ rproc->dev = dev;
+ rproc->minor = minor;
+ atomic_set(&rproc->count, 0);
+ cdev_init(&rproc->cdev, &omap_rproc_fops);
+ rproc->cdev.owner = THIS_MODULE;
+ ret = cdev_add(&rproc->cdev, MKDEV(major, minor), 1);
+ if (ret) {
+ dev_err(dev, "%s: cdev_add failed: %d\n", __func__, ret);
+ goto free_rproc;
+ }
+
+ tmpdev = device_create(omap_rproc_class, NULL,
+ MKDEV(major, minor),
+ NULL,
+ OMAP_RPROC_NAME "%d", minor);
+ if (IS_ERR(tmpdev)) {
+ ret = PTR_ERR(tmpdev);
+ dev_err(dev, "%s: device_create failed: %d\n", __func__, ret);
+ goto clean_cdev;
+ }
+
+ dev_info(dev, "%s initialized %s, major: %d, base-minor: %d\n",
+ OMAP_RPROC_NAME,
+ pdata->name,
+ MAJOR(omap_rproc_dev),
+ minor);
+ return 0;
+
+clean_cdev:
+ cdev_del(&rproc->cdev);
+free_rproc:
+ kfree(rproc);
+out:
+ return ret;
+}
+
+static int __devexit omap_rproc_remove(struct platform_device *pdev)
+{
+ int major = MAJOR(omap_rproc_dev);
+ struct device *dev = &pdev->dev;
+ struct omap_rproc_platform_data *pdata = dev->platform_data;
+ struct omap_rproc *rproc = platform_get_drvdata(pdev);
+
+ if (!pdata || !rproc)
+ return -EINVAL;
+
+ dev_info(dev, "%s removing %s, major: %d, base-minor: %d\n",
+ OMAP_RPROC_NAME,
+ pdata->name,
+ major,
+ rproc->minor);
+
+ device_destroy(omap_rproc_class, MKDEV(major, rproc->minor));
+ cdev_del(&rproc->cdev);
+
+ return 0;
+}
+
+static struct platform_driver omap_rproc_driver = {
+ .probe = omap_rproc_probe,
+ .remove = __devexit_p(omap_rproc_remove),
+ .driver = {
+ .name = OMAP_RPROC_NAME,
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init omap_rproc_init(void)
+{
+ int num = omap_get_num_of_remoteproc();
+ int ret;
+
+ ret = alloc_chrdev_region(&omap_rproc_dev, 0, num, OMAP_RPROC_NAME);
+ if (ret) {
+ pr_err("%s: alloc_chrdev_region failed: %d\n", __func__, ret);
+ goto out;
+ }
+
+ omap_rproc_class = class_create(THIS_MODULE, OMAP_RPROC_NAME);
+ if (IS_ERR(omap_rproc_class)) {
+ ret = PTR_ERR(omap_rproc_class);
+ pr_err("%s: class_create failed: %d\n", __func__, ret);
+ goto unreg_region;
+ }
+
+ atomic_set(&num_of_rprocs, 0);
+
+ ret = platform_driver_register(&omap_rproc_driver);
+ if (ret) {
+ pr_err("%s: platform_driver_register failed: %d\n", __func__,
+ ret);
+ goto out;
+ }
+
+ return 0;
+
+unreg_region:
+ unregister_chrdev_region(omap_rproc_dev, num);
+out:
+ return ret;
+}
+module_init(omap_rproc_init);
+
+static void __exit omap_rproc_exit(void)
+{
+ int num = omap_get_num_of_remoteproc();
+
+ class_destroy(omap_rproc_class);
+ unregister_chrdev_region(omap_rproc_dev, num);
+}
+module_exit(omap_rproc_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("OMAP Remote Processor driver");
+MODULE_AUTHOR("Ohad Ben-Cohen <ohad@wizery.com>");
+MODULE_AUTHOR("Hari Kanigeri <h-kanigeri2@ti.com>");
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 5/6] omap: add remoteproc device(s)
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
` (3 preceding siblings ...)
2010-07-01 22:23 ` [RFC 4/6] omap: introduce common " Ohad Ben-Cohen
@ 2010-07-01 22:23 ` Ohad Ben-Cohen
2010-07-27 15:44 ` Premi, Sanjeev
2010-07-01 22:23 ` [RFC 6/6] omap: enable remoteproc building Ohad Ben-Cohen
2010-07-27 12:27 ` [RFC 0/6] Introducing OMAP Remote Processor module Premi, Sanjeev
6 siblings, 1 reply; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-01 22:23 UTC (permalink / raw)
To: linux-omap; +Cc: Kanigeri Hari, Ohad Ben-Cohen
From: Ohad Ben-Cohen <ohadb@ti.com>
Add an omap_device for each remote processor on the system
Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
---
arch/arm/mach-omap2/devices.c | 86 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 18ad931..d365db6 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -15,6 +15,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/clk.h>
+#include <linux/err.h>
#include <mach/hardware.h>
#include <asm/mach-types.h>
@@ -26,9 +27,13 @@
#include <plat/mux.h>
#include <mach/gpio.h>
#include <plat/mmc.h>
+#include <plat/remoteproc.h>
#include "mux.h"
+#include <plat/omap_device.h>
+#include <plat/omap_hwmod.h>
+
#if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
static struct resource cam_resources[] = {
@@ -136,6 +141,86 @@ static inline void omap_init_camera(void)
}
#endif
+#if defined(CONFIG_OMAP_REMOTE_PROC) || defined(CONFIG_OMAP_REMOTE_PROC_MODULE)
+static struct omap_device_pm_latency omap_rproc_latency[] = {
+ {
+ .deactivate_func = omap_device_idle_hwmods,
+ .activate_func = omap_device_enable_hwmods,
+ .deactivate_lat = 1,
+ .activate_lat = 1,
+ },
+};
+
+static struct omap_rproc_platform_data *omap_get_remoteproc_data(void)
+{
+ struct omap_rproc_platform_data *rproc_data = NULL;
+
+ if (cpu_is_omap3430() || cpu_is_omap3630())
+ rproc_data = omap3_get_rproc_data();
+ else if (cpu_is_omap44xx())
+ rproc_data = omap4_get_rproc_data();
+ else
+ pr_err("%s: platform not supported\n", __func__);
+
+ return rproc_data;
+}
+
+int omap_get_num_of_remoteproc(void)
+{
+ int num = -1;
+
+ if (cpu_is_omap3430() || cpu_is_omap3630())
+ num = omap3_get_rproc_data_size();
+ else if (cpu_is_omap44xx())
+ num = omap4_get_rproc_data_size();
+ else
+ pr_err("%s: platform not supported\n", __func__);
+
+ return num;
+}
+EXPORT_SYMBOL(omap_get_num_of_remoteproc);
+
+static inline void omap_init_rproc(void)
+{
+ struct omap_hwmod *oh;
+ struct omap_device *od;
+ struct omap_device_pm_latency *ohl;
+ char *oh_name, *pdev_name;
+ int ohl_cnt = 0, i;
+ int rproc_data_size;
+ struct omap_rproc_platform_data *rproc_data;
+
+ pdev_name = "omap-rproc";
+ ohl = omap_rproc_latency;
+ ohl_cnt = ARRAY_SIZE(omap_rproc_latency);
+
+ rproc_data = omap_get_remoteproc_data();
+ rproc_data_size = omap_get_num_of_remoteproc();
+ if (rproc_data == NULL || rproc_data_size <= 0) {
+ pr_err("%s: platform not supported\n", __func__);
+ return;
+ }
+
+ for (i = 0; i < rproc_data_size; i++) {
+ oh_name = rproc_data[i].oh_name;
+ oh = omap_hwmod_lookup(oh_name);
+ if (!oh) {
+ pr_err("%s: could not look up %s\n", __func__, oh_name);
+ continue;
+ }
+
+ od = omap_device_build(pdev_name, i, oh,
+ &rproc_data[i],
+ sizeof(struct omap_rproc_platform_data),
+ ohl, ohl_cnt);
+ WARN(IS_ERR(od), "Could not build omap_device for %s %s\n",
+ pdev_name, oh_name);
+ }
+}
+#else
+static inline void omap_init_rproc(void) { }
+#endif /* CONFIG_OMAP_REMOTE_PROC */
+
#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
#define MBOX_REG_SIZE 0x120
@@ -773,6 +858,7 @@ static int __init omap2_init_devices(void)
omap_hsmmc_reset();
omap_init_camera();
omap_init_mbox();
+ omap_init_rproc();
omap_init_mcspi();
omap_hdq_init();
omap_init_sti();
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [RFC 6/6] omap: enable remoteproc building
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
` (4 preceding siblings ...)
2010-07-01 22:23 ` [RFC 5/6] omap: add remoteproc device(s) Ohad Ben-Cohen
@ 2010-07-01 22:23 ` Ohad Ben-Cohen
2010-07-27 15:49 ` Premi, Sanjeev
2010-07-27 12:27 ` [RFC 0/6] Introducing OMAP Remote Processor module Premi, Sanjeev
6 siblings, 1 reply; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-01 22:23 UTC (permalink / raw)
To: linux-omap; +Cc: Kanigeri Hari, Ohad Ben-Cohen
From: Ohad Ben-Cohen <ohadb@ti.com>
Make it possible to build omap's remoteproc module
Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
---
arch/arm/mach-omap2/Makefile | 6 ++++++
arch/arm/plat-omap/Kconfig | 7 +++++++
arch/arm/plat-omap/Makefile | 1 +
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 307f8b0..edb65b3 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -59,6 +59,12 @@ obj-$(CONFIG_OMAP3_EMU) += emu.o
obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
mailbox_mach-objs := mailbox.o
+ifneq ($(CONFIG_OMAP_REMOTE_PROC),)
+obj-$(CONFIG_ARCH_OMAP2) += remoteproc24xx.o
+obj-$(CONFIG_ARCH_OMAP3) += remoteproc3xxx.o
+obj-$(CONFIG_ARCH_OMAP4) += remoteproc44xx.o
+endif
+
iommu-y += iommu2.o
iommu-$(CONFIG_ARCH_OMAP3) += omap3-iommu.o
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index e2ea04a..e7d7372 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -96,6 +96,13 @@ config OMAP_MBOX_FWK
Say Y here if you want to use OMAP Mailbox framework support for
DSP, IVA1.0 and IVA2 in OMAP1/2/3.
+config OMAP_REMOTE_PROC
+ bool "Remote Processor framework support"
+ depends on ARCH_OMAP
+ help
+ Say Y here if you want to use OMAP Remote Processor framework
+ support for DSP, Tesla and/or Ducati (OMAP3/4).
+
config OMAP_IOMMU
tristate
diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
index 98f0191..bacb5c3 100644
--- a/arch/arm/plat-omap/Makefile
+++ b/arch/arm/plat-omap/Makefile
@@ -29,5 +29,6 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
# OMAP mailbox framework
obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
+obj-$(CONFIG_OMAP_REMOTE_PROC) += remoteproc.o
obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
\ No newline at end of file
--
1.7.0.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [RFC 1/6] omap: add iva2 hwmod support to omap3
2010-07-01 22:23 ` [RFC 1/6] omap: add iva2 hwmod support to omap3 Ohad Ben-Cohen
@ 2010-07-02 5:43 ` Cousson, Benoit
2010-07-04 21:57 ` Ohad Ben-Cohen
0 siblings, 1 reply; 15+ messages in thread
From: Cousson, Benoit @ 2010-07-02 5:43 UTC (permalink / raw)
To: Ohad Ben-Cohen
Cc: linux-omap@vger.kernel.org, Kanigeri, Hari, Ben-cohen, Ohad
On 7/2/2010 12:23 AM, Ohad Ben-Cohen wrote:
> From: Ohad Ben-Cohen<ohadb@ti.com>
>
> Add preliminary iva2 hwmod support to omap3.
> We do not include iva2_clk; that will be part of a separate
> hwmod, which will be controlled by iommu.
I think Kevin already sent a hwmod for IVA2... one week ago:
[PATCH 13/13] OMAP3: hwmod data: add data for OMAP3 IVA2
> Signed-off-by: Ohad Ben-Cohen<ohadb@ti.com>
> Signed-off-by: Hari Kanigeri<h-kanigeri2@ti.com>
> ---
> arch/arm/mach-omap2/omap_hwmod_34xx.h | 23 +++++++++++++++++++++++
> arch/arm/plat-omap/include/plat/omap_hwmod.h | 1 +
> 2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod_34xx.h b/arch/arm/mach-omap2/omap_hwmod_34xx.h
> index b6076b9..d363a95 100644
> --- a/arch/arm/mach-omap2/omap_hwmod_34xx.h
> +++ b/arch/arm/mach-omap2/omap_hwmod_34xx.h
> @@ -22,6 +22,7 @@
> #include "prm-regbits-34xx.h"
>
> static struct omap_hwmod omap34xx_mpu_hwmod;
> +static struct omap_hwmod omap34xx_iva2_hwmod;
> static struct omap_hwmod omap34xx_l3_hwmod;
> static struct omap_hwmod omap34xx_l4_core_hwmod;
> static struct omap_hwmod omap34xx_l4_per_hwmod;
> @@ -47,9 +48,17 @@ static struct omap_hwmod_ocp_if omap34xx_mpu__l3 = {
> .user = OCP_USER_MPU,
> };
>
> +/* IVA2 -> L3 interface */
> +static struct omap_hwmod_ocp_if omap34xx_iva2__l3 = {
> + .master =&omap34xx_iva2_hwmod,
> + .slave =&omap34xx_l3_hwmod,
> + .user = OCP_USER_IVA2,
> +};
> +
> /* Slave interfaces on the L3 interconnect */
> static struct omap_hwmod_ocp_if *omap34xx_l3_slaves[] = {
> &omap34xx_mpu__l3,
> + &omap34xx_iva2__l3,
> };
>
> /* Master interfaces on the L3 interconnect */
> @@ -150,12 +159,26 @@ static struct omap_hwmod omap34xx_mpu_hwmod = {
> .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
> };
>
> +/* Master interfaces on the IVA2 device */
> +static struct omap_hwmod_ocp_if *omap34xx_iva2_masters[] = {
> + &omap34xx_iva2__l3,
> +};
> +
> +/* IVA2 */
> +static struct omap_hwmod omap34xx_iva2_hwmod = {
> + .name = "iva2_hwmod",
Should be "iva" only.
> + .masters = omap34xx_iva2_masters,
> + .masters_cnt = ARRAY_SIZE(omap34xx_iva2_masters),
> + .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
> +};
> +
> static __initdata struct omap_hwmod *omap34xx_hwmods[] = {
> &omap34xx_l3_hwmod,
> &omap34xx_l4_core_hwmod,
> &omap34xx_l4_per_hwmod,
> &omap34xx_l4_wkup_hwmod,
> &omap34xx_mpu_hwmod,
> + &omap34xx_iva2_hwmod,
> NULL,
> };
>
> diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
> index 3393325..5e64992 100644
> --- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
> +++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
> @@ -160,6 +160,7 @@ struct omap_hwmod_addr_space {
> */
> #define OCP_USER_MPU (1<< 0)
> #define OCP_USER_SDMA (1<< 1)
> +#define OCP_USER_IVA2 (1<< 2)
Are you going to use that information somewhere?
In that case, you should populate the address space view from the DSP.
Benoit
>
> /* omap_hwmod_ocp_if.flags bits */
> #define OCPIF_HAS_IDLEST (1<< 0)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 1/6] omap: add iva2 hwmod support to omap3
2010-07-02 5:43 ` Cousson, Benoit
@ 2010-07-04 21:57 ` Ohad Ben-Cohen
0 siblings, 0 replies; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-04 21:57 UTC (permalink / raw)
To: Cousson, Benoit; +Cc: linux-omap@vger.kernel.org, Kanigeri, Hari
On Fri, Jul 2, 2010 at 8:43 AM, Cousson, Benoit <b-cousson@ti.com> wrote:
> On 7/2/2010 12:23 AM, Ohad Ben-Cohen wrote:
>> From: Ohad Ben-Cohen<ohadb@ti.com>
>>
>> Add preliminary iva2 hwmod support to omap3.
>> We do not include iva2_clk; that will be part of a separate
>> hwmod, which will be controlled by iommu.
>
> I think Kevin already sent a hwmod for IVA2... one week ago:
Thanks. I somehow missed the bulk of those patches.
I will of course rebase omap3 remoteproc on top of that now.
> [PATCH 13/13] OMAP3: hwmod data: add data for OMAP3 IVA2
>
>> Signed-off-by: Ohad Ben-Cohen<ohadb@ti.com>
>> Signed-off-by: Hari Kanigeri<h-kanigeri2@ti.com>
>> ---
>> arch/arm/mach-omap2/omap_hwmod_34xx.h | 23 +++++++++++++++++++++++
>> arch/arm/plat-omap/include/plat/omap_hwmod.h | 1 +
>> 2 files changed, 24 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/omap_hwmod_34xx.h b/arch/arm/mach-omap2/omap_hwmod_34xx.h
>> index b6076b9..d363a95 100644
>> --- a/arch/arm/mach-omap2/omap_hwmod_34xx.h
>> +++ b/arch/arm/mach-omap2/omap_hwmod_34xx.h
>> @@ -22,6 +22,7 @@
>> #include "prm-regbits-34xx.h"
>>
>> static struct omap_hwmod omap34xx_mpu_hwmod;
>> +static struct omap_hwmod omap34xx_iva2_hwmod;
>> static struct omap_hwmod omap34xx_l3_hwmod;
>> static struct omap_hwmod omap34xx_l4_core_hwmod;
>> static struct omap_hwmod omap34xx_l4_per_hwmod;
>> @@ -47,9 +48,17 @@ static struct omap_hwmod_ocp_if omap34xx_mpu__l3 = {
>> .user = OCP_USER_MPU,
>> };
>>
>> +/* IVA2 -> L3 interface */
>> +static struct omap_hwmod_ocp_if omap34xx_iva2__l3 = {
>> + .master =&omap34xx_iva2_hwmod,
>> + .slave =&omap34xx_l3_hwmod,
>> + .user = OCP_USER_IVA2,
>> +};
>> +
>> /* Slave interfaces on the L3 interconnect */
>> static struct omap_hwmod_ocp_if *omap34xx_l3_slaves[] = {
>> &omap34xx_mpu__l3,
>> + &omap34xx_iva2__l3,
>> };
>>
>> /* Master interfaces on the L3 interconnect */
>> @@ -150,12 +159,26 @@ static struct omap_hwmod omap34xx_mpu_hwmod = {
>> .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
>> };
>>
>> +/* Master interfaces on the IVA2 device */
>> +static struct omap_hwmod_ocp_if *omap34xx_iva2_masters[] = {
>> + &omap34xx_iva2__l3,
>> +};
>> +
>> +/* IVA2 */
>> +static struct omap_hwmod omap34xx_iva2_hwmod = {
>> + .name = "iva2_hwmod",
>
> Should be "iva" only.
>
>> + .masters = omap34xx_iva2_masters,
>> + .masters_cnt = ARRAY_SIZE(omap34xx_iva2_masters),
>> + .omap_chip = OMAP_CHIP_INIT(CHIP_IS_OMAP3430),
>> +};
>> +
>> static __initdata struct omap_hwmod *omap34xx_hwmods[] = {
>> &omap34xx_l3_hwmod,
>> &omap34xx_l4_core_hwmod,
>> &omap34xx_l4_per_hwmod,
>> &omap34xx_l4_wkup_hwmod,
>> &omap34xx_mpu_hwmod,
>> + &omap34xx_iva2_hwmod,
>> NULL,
>> };
>>
>> diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
>> index 3393325..5e64992 100644
>> --- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
>> +++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
>> @@ -160,6 +160,7 @@ struct omap_hwmod_addr_space {
>> */
>> #define OCP_USER_MPU (1<< 0)
>> #define OCP_USER_SDMA (1<< 1)
>> +#define OCP_USER_IVA2 (1<< 2)
>
> Are you going to use that information somewhere?
> In that case, you should populate the address space view from the DSP.
>
> Benoit
>
>>
>> /* omap_hwmod_ocp_if.flags bits */
>> #define OCPIF_HAS_IDLEST (1<< 0)
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [RFC 0/6] Introducing OMAP Remote Processor module
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
` (5 preceding siblings ...)
2010-07-01 22:23 ` [RFC 6/6] omap: enable remoteproc building Ohad Ben-Cohen
@ 2010-07-27 12:27 ` Premi, Sanjeev
2010-07-27 17:09 ` Ohad Ben-Cohen
6 siblings, 1 reply; 15+ messages in thread
From: Premi, Sanjeev @ 2010-07-27 12:27 UTC (permalink / raw)
To: Ohad Ben-Cohen, linux-omap@vger.kernel.org
Cc: Kanigeri, Hari, Ben-cohen, Ohad
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Ohad Ben-Cohen
> Sent: Friday, July 02, 2010 3:53 AM
> To: linux-omap@vger.kernel.org
> Cc: Kanigeri, Hari; Ben-cohen, Ohad
> Subject: [RFC 0/6] Introducing OMAP Remote Processor module
>
> From: Ohad Ben-Cohen <ohadb@ti.com>
>
> This is a preliminary version of OMAP's remoteproc module,
> submitted for RFC purposes.
>
> The purpose of the remoteproc module is to decouple
> hw-specific code from generic IPC drivers (such as
> dspbridge and syslink), in order to eventually make
> those IPC drivers platform-independent.
>
> Currently the supported operations are starting and stopping
> the remote processor, but in the future additional functionality
> might be added.
>
> Both OMAP3 and OMAP4 are supported; OMAP3 supports the dsp
> remote processor, and OMAP4 supports ducati (tesla support
> is planned as well).
>
> The code was tested on both OMAP3 (using dspbridge) and OMAP4
> (using syslink).
>
> The code is preliminary: we plan to add much more extensive
> hwmod support, ideally squashing as much hw-specific code
> as possible (including RST and PRCM manipulations).
> In addition, a rebase to recent code bases is needed.
>
> While dspbridge accesses remoteproc's interface via pdata
> pointers, syslink accesses it from user space, via character
> device interface, so both kernel and user space interfaces
> are supported.
>
> A few words on the char device interface:
>
> * Each remote processor is represented by a different
> character device: /dev/omap-rproc0, /dev/omap-rproc1, ...
[sp] Concept of remote processor is not really tied to omap.
Though the implementation is being done in context of
OMAP, I would suggest removing the prefix "omap-" from
the device name.
> * A rproc character device can only be opened by a single user
> (e.g. the syslink daemon)
> * The start/stop/get_state functionality is exposed via ioctl's
> * We plan to add automatic stop() invokation in case the user
> closes the device after starting a remote processor (for
> resource cleanup purposes. Thus the user will be required
> to hold the device open as long as it lives).
>
> Thanks,
>
> Hari Kanigeri (1):
> omap: introduce OMAP4 remoteproc module
>
> Ohad Ben-Cohen (5):
> omap: add iva2 hwmod support to omap3
> omap: introduce OMAP3 remoteproc module
> omap: introduce common remoteproc module
> omap: add remoteproc device(s)
> omap: enable remoteproc building
>
> arch/arm/mach-omap2/Makefile | 6 +
> arch/arm/mach-omap2/devices.c | 86 +++++++
> arch/arm/mach-omap2/omap_hwmod_34xx.h | 23 ++
> arch/arm/mach-omap2/remoteproc3xxx.c | 226
> ++++++++++++++++++
> arch/arm/mach-omap2/remoteproc44xx.c | 196 ++++++++++++++++
> arch/arm/plat-omap/Kconfig | 7 +
> arch/arm/plat-omap/Makefile | 1 +
> arch/arm/plat-omap/include/plat/omap_hwmod.h | 1 +
> arch/arm/plat-omap/include/plat/remoteproc.h | 75 ++++++
> arch/arm/plat-omap/remoteproc.c | 316
> ++++++++++++++++++++++++++
> 10 files changed, 937 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/mach-omap2/remoteproc3xxx.c
> create mode 100644 arch/arm/mach-omap2/remoteproc44xx.c
> create mode 100644 arch/arm/plat-omap/include/plat/remoteproc.h
> create mode 100644 arch/arm/plat-omap/remoteproc.c
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [RFC 4/6] omap: introduce common remoteproc module
2010-07-01 22:23 ` [RFC 4/6] omap: introduce common " Ohad Ben-Cohen
@ 2010-07-27 14:49 ` Premi, Sanjeev
0 siblings, 0 replies; 15+ messages in thread
From: Premi, Sanjeev @ 2010-07-27 14:49 UTC (permalink / raw)
To: Ohad Ben-Cohen, linux-omap@vger.kernel.org
Cc: Kanigeri, Hari, Ben-cohen, Ohad
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Ohad Ben-Cohen
> Sent: Friday, July 02, 2010 3:53 AM
> To: linux-omap@vger.kernel.org
> Cc: Kanigeri, Hari; Ben-cohen, Ohad
> Subject: [RFC 4/6] omap: introduce common remoteproc module
>
> From: Ohad Ben-Cohen <ohadb@ti.com>
>
> The OMAP remote processor module decouples
> machine-specific code from TI's IPC
> drivers (e.g. dspbridge and syslink).
>
> While dspbridge calls the remoteproc handlers
> from the kernel, syslink calls them from
> user space. Hence remoteproc supports both
> interfaces.
>
> Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
> Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
> ---
> arch/arm/plat-omap/include/plat/remoteproc.h | 75 ++++++
> arch/arm/plat-omap/remoteproc.c | 316
> ++++++++++++++++++++++++++
> 2 files changed, 391 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/plat-omap/include/plat/remoteproc.h
> create mode 100644 arch/arm/plat-omap/remoteproc.c
>
> diff --git a/arch/arm/plat-omap/include/plat/remoteproc.h
> b/arch/arm/plat-omap/include/plat/remoteproc.h
> new file mode 100644
> index 0000000..1cedd08
> --- /dev/null
> +++ b/arch/arm/plat-omap/include/plat/remoteproc.h
> @@ -0,0 +1,75 @@
> +/*
> + * OMAP Remote Processor driver
> + *
> + * Copyright (C) 2010 Texas Instruments Inc.
> + *
> + * Written by Ohad Ben-Cohen <ohad@wizery.com>
> + *
> + * 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
> + *
> + */
> +
> +#ifndef REMOTEPROC_H
> +#define REMOTEPROC_H
> +
> +#include <linux/ioctl.h>
> +#include <linux/cdev.h>
> +
> +#define RPROC_IOC_MAGIC 'P'
[sp] I notice that there is already a conflict with this magic number in
Documentation/ioctl/ioctl-number.txt.
Suggest reserving a different code as per the steps mentioned in the
same file.
> +
> +#define RPROC_IOCSTART _IOW(RPROC_IOC_MAGIC, 1, int)
> +#define RPROC_IOCSTOP _IO(RPROC_IOC_MAGIC, 2)
> +#define RPROC_IOCGETSTATE _IOR(RPROC_IOC_MAGIC, 3, int)
> +
> +#define RPROC_IOC_MAXNR (3)
> +
> +struct omap_rproc;
> +
> +struct omap_rproc_ops {
> + int (*start)(struct device *dev, u32 start_addr);
> + int (*stop)(struct device *dev);
> + int (*get_state)(struct device *dev);
> +};
> +
> +struct omap_rproc_clk_t {
> + void *clk_handle;
> + const char *dev_id;
> + const char *con_id;
> +};
> +
[sp] Small description of the fields in the structure will help understand the code better.
I couldn't locate usage of con_id in this patch; not sure what it signifies.
...hope it becomes clear in one of the other patches in the series.
(after one review) The structure is not used anywhere in this file.
> +struct omap_rproc_platform_data {
> + struct omap_rproc_ops *ops;
> + char *name;
> + char *oh_name;
> +};
[sp] same comment here.
> +
> +struct omap_rproc {
> + struct device *dev;
> + struct cdev cdev;
> + atomic_t count;
[sp] I believe this field is for "use-counts". If so, suggest renaming to
"usecount".
> + int minor;
> +};
> +
> +struct omap_rproc_start_args {
> + u32 start_addr;
> +};
> +
> +struct omap_rproc_platform_data *omap3_get_rproc_data(void);
> +int omap3_get_rproc_data_size(void);
> +struct omap_rproc_platform_data *omap4_get_rproc_data(void);
> +int omap4_get_rproc_data_size(void);
[sp] The forward declaration seems to be used for plugging
device specific data (haven't looked at complet code, so
it is currently a speculation).
The contents of this header have so far been device independent.
Can we look to reorganiza this code such that this header remains
generic?
> +int omap_get_num_of_remoteproc(void);
[sp] Don't see this being implemented in the "C" file below.
If this function is expected to be implemented in the omap3/4
specific file, then I suspect multi-omap will break for compilation.
Same function will be defined multiple times.
> +
> +#endif /* REMOTEPROC_H */
> diff --git a/arch/arm/plat-omap/remoteproc.c
> b/arch/arm/plat-omap/remoteproc.c
> new file mode 100644
> index 0000000..7a9862e
> --- /dev/null
> +++ b/arch/arm/plat-omap/remoteproc.c
> @@ -0,0 +1,316 @@
> +/*
> + * OMAP Remote Processor driver
> + *
> + * Copyright (C) 2010 Texas Instruments Inc.
> + *
> + * Authors:
> + * Ohad Ben-Cohen <ohad@wizery.com>
> + * Hari Kanigeri <h-kanigeri2@ti.com>
> + *
> + * 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
> + *
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/interrupt.h>
> +#include <linux/device.h>
> +#include <linux/delay.h>
> +#include <linux/file.h>
> +#include <linux/poll.h>
> +#include <linux/mm.h>
> +#include <linux/platform_device.h>
> +
> +#include <plat/remoteproc.h>
> +
> +#define OMAP_RPROC_NAME "omap-rproc"
[sp] See my comment in 0/6 about "omap-" prefix in the name.
BTW, I am reviewing this file from bottom; so comments may not be
in sequence.
> +
> +static struct class *omap_rproc_class;
> +static dev_t omap_rproc_dev;
> +static atomic_t num_of_rprocs;
> +
> +static inline int rproc_start(struct omap_rproc *rproc,
> const void __user *arg)
> +{
> + struct omap_rproc_platform_data *pdata;
> + struct omap_rproc_start_args start_args;
> +
> + if (!rproc->dev)
> + return -EINVAL;
> +
> + pdata = rproc->dev->platform_data;
> + if (!pdata->ops)
> + return -EINVAL;
> +
> + if (copy_from_user(&start_args, arg, sizeof(start_args)))
> + return -EFAULT;
> +
> + return pdata->ops->start(rproc->dev, start_args.start_addr);
> +}
> +
> +static inline int rproc_stop(struct omap_rproc *rproc)
> +{
> + struct omap_rproc_platform_data *pdata;
> + if (!rproc->dev)
> + return -EINVAL;
> +
> + pdata = rproc->dev->platform_data;
> + if (!pdata->ops)
> + return -EINVAL;
> +
> + return pdata->ops->stop(rproc->dev);
> +}
> +
> +static inline int rproc_get_state(struct omap_rproc *rproc)
> +{
> + struct omap_rproc_platform_data *pdata;
> + if (!rproc->dev)
> + return -EINVAL;
> +
> + pdata = rproc->dev->platform_data;
> + if (!pdata->ops)
> + return -EINVAL;
> +
> + return pdata->ops->get_state(rproc->dev);
> +}
> +
> +static int omap_rproc_open(struct inode *inode, struct file *filp)
[sp] May be nitpicking, but "filp" could simply be "fp" ... more common
in usage for file pointer.
> +{
> + unsigned int count, dev_num = iminor(inode);
> + struct omap_rproc *rproc;
> + struct omap_rproc_platform_data *pdata;
> +
> + rproc = container_of(inode->i_cdev, struct omap_rproc, cdev);
> + if (!rproc->dev)
> + return -EINVAL;
> +
> + pdata = rproc->dev->platform_data;
> +
> + count = atomic_inc_return(&rproc->count);
[sp] Wouldn't atomic_read() be better used here?
Avoids the need to call atomic_dec() below.
> + dev_info(rproc->dev, "%s: dev num %d, name %s, count
> %d\n", __func__,
> + dev_num,
> + pdata->name,
> + count);
> + if (count > 1) {
> + dev_err(rproc->dev, "%s failed: remoteproc
> already in use\n",
> +
> __func__);
> + atomic_dec(&rproc->count);
> + return -EBUSY;
> + }
> +
> + filp->private_data = rproc;
> +
> + return 0;
> +}
> +
> +static int omap_rproc_release(struct inode *inode, struct file *filp)
> +{
> + struct omap_rproc_platform_data *pdata;
> + struct omap_rproc *rproc = filp->private_data;
> + if (!rproc || !rproc->dev)
> + return -EINVAL;
> +
> + pdata = rproc->dev->platform_data;
> +
> + atomic_dec(&rproc->count);
> +
> + return 0;
> +}
> +
> +static int omap_rproc_ioctl(struct inode *inode, struct file *filp,
> + unsigned int cmd,
> unsigned long arg)
> +{
> + int rc = 0;
> + struct omap_rproc *rproc = filp->private_data;
> +
> + dev_info(rproc->dev, "%s\n", __func__);
> +
> + if (!rproc)
> + return -EINVAL;
> +
> + if (_IOC_TYPE(cmd) != RPROC_IOC_MAGIC)
> + return -ENOTTY;
> + if (_IOC_NR(cmd) > RPROC_IOC_MAXNR)
> + return -ENOTTY;
> +
> + switch (cmd) {
> + case RPROC_IOCSTART:
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
> + rc = rproc_start(rproc, (const void __user *) arg);
> + break;
> + case RPROC_IOCSTOP:
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
> + rc = rproc_stop(rproc);
> + break;
> + case RPROC_IOCGETSTATE:
> + rc = rproc_get_state(rproc);
> + break;
> +
> + default:
> + return -ENOTTY;
> + }
> +
> + return rc;
[sp] Most of the functions in this file use "ret" as variable for
return value. Here "rc" seems to out of place... significance
didn't click to me immediately.
> +}
> +
> +static const struct file_operations omap_rproc_fops = {
> + .open = omap_rproc_open,
> + .release = omap_rproc_release,
> + .ioctl = omap_rproc_ioctl,
> + .owner = THIS_MODULE,
> +};
> +
> +static int omap_rproc_probe(struct platform_device *pdev)
[sp] Shouldn't this be __devinit ?
> +{
> + int ret = 0, major, minor;
> + struct device *tmpdev;
> + struct device *dev = &pdev->dev;
> + struct omap_rproc_platform_data *pdata = dev->platform_data;
> + struct omap_rproc *rproc;
> +
> + if (!pdata || !pdata->name || !pdata->oh_name || !pdata->ops)
> + return -EINVAL;
> +
> + dev_info(dev, "%s: adding rproc %s\n", __func__, pdata->name);
> +
> + rproc = kzalloc(sizeof(struct omap_rproc), GFP_KERNEL);
[sp] any specific reason to not use kmalloc instead?
> + if (!rproc) {
> + dev_err(dev, "%s: kzalloc failed\n", __func__);
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + platform_set_drvdata(pdev, rproc);
> + major = MAJOR(omap_rproc_dev);
> + minor = atomic_read(&num_of_rprocs);
> + atomic_inc(&num_of_rprocs);
> +
> + rproc->dev = dev;
> + rproc->minor = minor;
> + atomic_set(&rproc->count, 0);
> + cdev_init(&rproc->cdev, &omap_rproc_fops);
[sp] Character driver under directory "arch/arm/plat-omap" ?
Shouldn't this driver be elsewhere? In fact, it will
help make it usable for non-OMAP devices as well.
> + rproc->cdev.owner = THIS_MODULE;
> + ret = cdev_add(&rproc->cdev, MKDEV(major, minor), 1);
> + if (ret) {
> + dev_err(dev, "%s: cdev_add failed: %d\n",
> __func__, ret);
> + goto free_rproc;
> + }
> +
> + tmpdev = device_create(omap_rproc_class, NULL,
> + MKDEV(major, minor),
> + NULL,
> + OMAP_RPROC_NAME "%d", minor);
> + if (IS_ERR(tmpdev)) {
> + ret = PTR_ERR(tmpdev);
> + dev_err(dev, "%s: device_create failed: %d\n",
> __func__, ret);
> + goto clean_cdev;
> + }
> +
> + dev_info(dev, "%s initialized %s, major: %d, base-minor: %d\n",
> + OMAP_RPROC_NAME,
> + pdata->name,
> + MAJOR(omap_rproc_dev),
> + minor);
> + return 0;
> +
> +clean_cdev:
> + cdev_del(&rproc->cdev);
> +free_rproc:
> + kfree(rproc);
> +out:
> + return ret;
> +}
> +
> +static int __devexit omap_rproc_remove(struct platform_device *pdev)
> +{
> + int major = MAJOR(omap_rproc_dev);
> + struct device *dev = &pdev->dev;
> + struct omap_rproc_platform_data *pdata = dev->platform_data;
> + struct omap_rproc *rproc = platform_get_drvdata(pdev);
> +
> + if (!pdata || !rproc)
> + return -EINVAL;
> +
> + dev_info(dev, "%s removing %s, major: %d, base-minor: %d\n",
> + OMAP_RPROC_NAME,
> + pdata->name,
> + major,
> + rproc->minor);
> +
> + device_destroy(omap_rproc_class, MKDEV(major, rproc->minor));
> + cdev_del(&rproc->cdev);
> +
> + return 0;
> +}
> +
> +static struct platform_driver omap_rproc_driver = {
> + .probe = omap_rproc_probe,
> + .remove = __devexit_p(omap_rproc_remove),
> + .driver = {
> + .name = OMAP_RPROC_NAME,
> + .owner = THIS_MODULE,
> + },
> +};
> +
> +static int __init omap_rproc_init(void)
> +{
> + int num = omap_get_num_of_remoteproc();
> + int ret;
> +
> + ret = alloc_chrdev_region(&omap_rproc_dev, 0, num,
> OMAP_RPROC_NAME);
> + if (ret) {
> + pr_err("%s: alloc_chrdev_region failed: %d\n",
> __func__, ret);
> + goto out;
> + }
> +
> + omap_rproc_class = class_create(THIS_MODULE, OMAP_RPROC_NAME);
> + if (IS_ERR(omap_rproc_class)) {
> + ret = PTR_ERR(omap_rproc_class);
> + pr_err("%s: class_create failed: %d\n", __func__, ret);
> + goto unreg_region;
> + }
> +
> + atomic_set(&num_of_rprocs, 0);
[sp] In the beginning of function "num" is expected to contain
number of remote processors - going by the function name.
Any specific reason for setting this variable to "0" which
again seem to signify the same.
There may be a reason; but it isn't clear here.
> +
> + ret = platform_driver_register(&omap_rproc_driver);
> + if (ret) {
> + pr_err("%s: platform_driver_register failed:
> %d\n", __func__,
> +
> ret);
> + goto out;
> + }
> +
> + return 0;
> +
> +unreg_region:
> + unregister_chrdev_region(omap_rproc_dev, num);
> +out:
> + return ret;
> +}
> +module_init(omap_rproc_init);
> +
> +static void __exit omap_rproc_exit(void)
> +{
> + int num = omap_get_num_of_remoteproc();
[sp] Why not use variable "num_of_rprocs" instead
of fetching the value again?
(after one review cycle) I see that you are using
this variable to track the num of "open" active
remote processors - not the total num. Renaming
the variable appropriately will help.
> +
> + class_destroy(omap_rproc_class);
> + unregister_chrdev_region(omap_rproc_dev, num);
> +}
> +module_exit(omap_rproc_exit);
> +
> +MODULE_LICENSE("GPL v2");
> +MODULE_DESCRIPTION("OMAP Remote Processor driver");
> +MODULE_AUTHOR("Ohad Ben-Cohen <ohad@wizery.com>");
> +MODULE_AUTHOR("Hari Kanigeri <h-kanigeri2@ti.com>");
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [RFC 2/6] omap: introduce OMAP3 remoteproc module
2010-07-01 22:23 ` [RFC 2/6] omap: introduce OMAP3 remoteproc module Ohad Ben-Cohen
@ 2010-07-27 15:23 ` Premi, Sanjeev
0 siblings, 0 replies; 15+ messages in thread
From: Premi, Sanjeev @ 2010-07-27 15:23 UTC (permalink / raw)
To: Ohad Ben-Cohen, linux-omap@vger.kernel.org
Cc: Kanigeri, Hari, Ben-cohen, Ohad
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Ohad Ben-Cohen
> Sent: Friday, July 02, 2010 3:53 AM
> To: linux-omap@vger.kernel.org
> Cc: Kanigeri, Hari; Ben-cohen, Ohad
> Subject: [RFC 2/6] omap: introduce OMAP3 remoteproc module
>
> From: Ohad Ben-Cohen <ohadb@ti.com>
>
> Introduce OMAP3 remoteproc module which takes care of
> machine-specific code required to start and stop
> the DSP remote processor.
>
> Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
> Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
> ---
> arch/arm/mach-omap2/remoteproc3xxx.c | 226
> ++++++++++++++++++++++++++++++++++
> 1 files changed, 226 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/mach-omap2/remoteproc3xxx.c
>
> diff --git a/arch/arm/mach-omap2/remoteproc3xxx.c
> b/arch/arm/mach-omap2/remoteproc3xxx.c
> new file mode 100644
> index 0000000..f86a333
> --- /dev/null
> +++ b/arch/arm/mach-omap2/remoteproc3xxx.c
> @@ -0,0 +1,226 @@
> +/*
> + * Remote Processor machine-specific module for OMAP3
> + *
> + * 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_OMAP3
[sp] If ARCH_OMAP3 is not defined this file shouldn't be compiled.
I do see that we are achieving the multi-omap support - a
concern I had in my comment on another patch in the series -
but this appears to be a hack.
> +#include <linux/kernel.h>
> +#include <linux/delay.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/platform_device.h>
> +#include <linux/io.h>
> +#include <linux/pm_runtime.h>
> +#include <plat/remoteproc.h>
> +#include <mach/irqs.h>
> +#include <plat/omap_device.h>
> +#include <plat/control.h>
> +#include <plat/common.h>
> +#include <plat/powerdomain.h>
> +#include <plat/clockdomain.h>
> +#include <asm/uaccess.h>
> +
> +#include "cm-regbits-34xx.h"
> +#include "prm-regbits-34xx.h"
> +
> +#define OMAP3_IVA2_BOOTADDR_MASK 0xFFFFFC00
> +
> +#define PRCM_PM_PWSTCTRL_IVA2_POWER_STATE_MASK (u32)(3)
> +#define PRCM_PM_PWSTCTRL_IVA2_POWER_STATE_OFFSET (u32)(0)
[sp] We should either use the definitions in prm-regbits-34xx.h/prm.h
or make sure appropriate headers are updated with these definitions.
The naming conventions here seem to be very differen from the ones
used in prm-regbits-34xx.h and prm.h
> +
> +#define PRCM_PM_PWSTST_IVA2_InTransition_MASK
> (u32)(0x100000)
> +#define PRCM_PM_PWSTST_IVA2_InTransition_OFFSET
> (u32)(20)
[sp] Is "InTransition" delibrately put in CamelCase?
> +
> +#define CM_CLKSTCTRL_IVA2_OFFSET (0)
> +#define CM_CLKSTCTRL_IVA2_MASK (3)
[sp] Same somment as before. See corresponding definition(s) in
cm-regbits-34xx.h for existing definitions, instead of
defining new ones.
> +
> +#define DSP_SYSC_DIRECTBOOT (0)
> +#define DSP_SYSC_IDLEBOOT (1)
> +#define DSP_SYSC_SELFLOOPBOOT (2)
> +#define DSP_SYSC_USRBOOTSTRAP (3)
> +#define DSP_SYSC_DEFAULTRESTORE (4)
> +
> +#ifdef CONFIG_BRIDGE_DEBUG
> +static void omap3_rproc_dump_regs(struct device *dev)
> +{
> + u32 temp;
> +
> + temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_FCLKEN);
> + dev_info(dev, "CM_FCLKEN_IVA2 = 0x%x \n", temp);
[sp] Shouldn't we be using dev_dbg() here?
Also, same information is available in debugfs in base linux.
Is this function really needed here?
> + temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_ICLKEN1);
> + dev_info(dev, "CM_ICLKEN1_IVA2 = 0x%x \n", temp);
> + temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_IDLEST);
> + dev_info(dev, "CM_IDLEST_IVA2 = 0x%x \n", temp);
> + temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, CM_CLKSTCTRL);
> + dev_info(dev, "CM_CLKSTCTRL_IVA2 = 0x%x \n", temp);
> + temp = cm_read_mod_reg(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSTST);
> + dev_info(dev, "CM_CLKSTST_IVA2 = 0x%x \n", temp);
> + temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, RM_RSTCTRL);
> + dev_info(dev, "RM_RSTCTRL_IVA2 = 0x%x \n", temp);
> + temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, RM_RSTST);
> + dev_info(dev, "RM_RSTST_IVA2 = 0x%x \n", temp);
> + temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTCTRL);
> + dev_info(dev, "PM_PWSTCTRL_IVA2 = 0x%x \n", temp);
> + temp = prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTST);
> + dev_info(dev, "PM_PWSTST_IVA2 = 0x%x \n", temp);
> + temp = cm_read_mod_reg(CORE_MOD, CM_ICLKEN1);
> + dev_info(dev, "CM_ICLKEN1_CORE = 0x%x \n", temp);
> +}
> +#else
> +static void omap3_rproc_dump_regs(struct device *dev) { }
> +#endif
> +
> +static int omap3_rproc_get_state(struct device *dev)
> +{
> + u32 dsp_pwr_state;
> +
> + dsp_pwr_state = prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTST);
> +
> + return dsp_pwr_state & OMAP_POWERSTATEST_MASK;
> +}
> +
> +static int omap3_rproc_start(struct device *dev, u32 start_addr)
> +{
> + dev_info(dev, "%s: set boot mode, addr: 0x%x\n",
> __func__, start_addr);
> +
> + omap3_rproc_dump_regs(dev);
> +
> + if (PWRDM_POWER_ON != omap3_rproc_get_state(dev)) {
> + /* IVA2 is not in ON state */
> + /* Read and set PM_PWSTCTRL_IVA2 to ON */
> + prm_rmw_mod_reg_bits(OMAP_POWERSTATEST_MASK,
> PWRDM_POWER_ON,
> + OMAP3430_IVA2_MOD, PM_PWSTCTRL);
> +
> + /* Set the SW supervised state transition */
> + cm_write_mod_reg(OMAP34XX_CLKSTCTRL_FORCE_WAKEUP,
> + OMAP3430_IVA2_MOD,
> CM_CLKSTCTRL);
> +
> + /* Wait until the state has moved to ON */
> + while (prm_read_mod_reg(OMAP3430_IVA2_MOD, PM_PWSTST)
> + & OMAP_INTRANSITION)
> + ;
> +
> + /* Disable Automatic transition */
> + cm_write_mod_reg(OMAP34XX_CLKSTCTRL_DISABLE_AUTO,
> + OMAP3430_IVA2_MOD,
> CM_CLKSTCTRL);
> + }
> +
> + /* Assert RST1 i.e only the RST only for DSP megacell */
> + prm_rmw_mod_reg_bits(OMAP3430_RST1_IVA2, OMAP3430_RST1_IVA2,
> + OMAP3430_IVA2_MOD, RM_RSTCTRL);
> + /* Mask address with 1K for compatibility */
> + omap_ctrl_writel(start_addr & OMAP3_IVA2_BOOTADDR_MASK,
> + OMAP343X_CONTROL_IVA2_BOOTADDR);
> + /* Set bootmode to self loop if dsp_debug flag is true */
> + omap_ctrl_writel(DSP_SYSC_DIRECTBOOT,
> OMAP343X_CONTROL_IVA2_BOOTMOD);
> +
> + /*Set Autoidle Mode for IVA2 PLL */
> + cm_write_mod_reg(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
> + OMAP3430_IVA2_MOD,
> OMAP3430_CM_AUTOIDLE_PLL);
> +
> + /* select GPT5 and GPT6 as IVA2 wake-up modules */
> + prm_rmw_mod_reg_bits(0x3F, 0xC0, OMAP3430_PER_MOD,
> +
> OMAP3430_PM_IVAGRPSEL);
> +
> + /* make sure GPT5 and GPT6 are not selected as MPU
> wake-up modules */
> + prm_rmw_mod_reg_bits(0xC0, 0, OMAP3430_PER_MOD,
> OMAP3430_PM_MPUGRPSEL);
> +
> + /* PER domain sleep dependency with IVA2 domain is enabled */
> + cm_rmw_mod_reg_bits(4, 4, OMAP3430_PER_MOD,
> OMAP3430_CM_SLEEPDEP);
> +
> + /* Allow automatic transitions */
> + cm_write_mod_reg(OMAP34XX_CLKSTCTRL_ENABLE_AUTO,
> OMAP3430_IVA2_MOD,
> +
> CM_CLKSTCTRL);
> +
> + /* Let DSP go */
> + dev_dbg(dev, "%s Unreset DSP\n", __func__);
> +
> + /* release the RST1, DSP starts executing now .. */
> + prm_rmw_mod_reg_bits(OMAP3430_RST1_IVA2, 0, OMAP3430_IVA2_MOD,
> +
> RM_RSTCTRL);
> +
> + omap3_rproc_dump_regs(dev);
> +
> + return 0;
> +}
> +
> +static int omap3_rproc_stop(struct device *dev)
> +{
> + dev_info(dev, "%s\n", __func__);
> +
> + omap3_rproc_dump_regs(dev);
> +
> + /* Set PM_PWSTCTRL_IVA2 to OFF */
> + prm_rmw_mod_reg_bits(OMAP_POWERSTATEST_MASK,
> + PWRDM_POWER_OFF, OMAP3430_IVA2_MOD,
> PM_PWSTCTRL);
> +
> + /* Set the SW supervised state transition for Sleep */
> + cm_write_mod_reg(OMAP34XX_CLKSTCTRL_FORCE_SLEEP,
> OMAP3430_IVA2_MOD,
> +
> CM_CLKSTCTRL);
> +
> + /* Reset RST1 + RST3 */
> + prm_rmw_mod_reg_bits(OMAP3430_RST1_IVA2 | OMAP3430_RST3_IVA2,
> + OMAP3430_RST1_IVA2 | OMAP3430_RST3_IVA2,
> + OMAP3430_IVA2_MOD, RM_RSTCTRL);
> +
> + udelay(10);
> +
> + return 0;
> +}
> +
> +static struct omap_rproc_ops omap3_rproc_ops = {
> + .start = omap3_rproc_start,
> + .stop = omap3_rproc_stop,
> + .get_state = omap3_rproc_get_state,
> +};
> +
> +static struct omap_rproc_platform_data omap3_rproc_data[] = {
> + {
> + .name = "dsp",
> + .ops = &omap3_rproc_ops,
> + .oh_name = "iva2_hwmod",
> + },
> +};
> +
> +struct omap_rproc_platform_data *omap3_get_rproc_data(void)
> +{
> + return omap3_rproc_data;
> +}
> +
> +int omap3_get_rproc_data_size(void)
> +{
> + return ARRAY_SIZE(omap3_rproc_data);
> +}
> +#else
> +struct omap_rproc_platform_data *omap3_get_rproc_data(void)
> +{
> + return NULL;
> +}
> +
> +int omap3_get_rproc_data_size(void)
> +{
> + return 0;
> +}
> +#endif
> +
> +MODULE_LICENSE("GPL v2");
> +MODULE_DESCRIPTION("OMAP3 Remote Processor module");
> +MODULE_AUTHOR("Ohad Ben-Cohen <ohad@wizery.com>");
> +MODULE_AUTHOR("Hari Kanigeri <h-kanigeri2@ti.com>");
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [RFC 5/6] omap: add remoteproc device(s)
2010-07-01 22:23 ` [RFC 5/6] omap: add remoteproc device(s) Ohad Ben-Cohen
@ 2010-07-27 15:44 ` Premi, Sanjeev
0 siblings, 0 replies; 15+ messages in thread
From: Premi, Sanjeev @ 2010-07-27 15:44 UTC (permalink / raw)
To: Ohad Ben-Cohen, linux-omap@vger.kernel.org
Cc: Kanigeri, Hari, Ben-cohen, Ohad
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Ohad Ben-Cohen
> Sent: Friday, July 02, 2010 3:53 AM
> To: linux-omap@vger.kernel.org
> Cc: Kanigeri, Hari; Ben-cohen, Ohad
> Subject: [RFC 5/6] omap: add remoteproc device(s)
>
> From: Ohad Ben-Cohen <ohadb@ti.com>
>
> Add an omap_device for each remote processor on the system
>
> Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
> Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
> ---
> arch/arm/mach-omap2/devices.c | 86
> +++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 86 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/devices.c
> b/arch/arm/mach-omap2/devices.c
> index 18ad931..d365db6 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -15,6 +15,7 @@
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <linux/clk.h>
> +#include <linux/err.h>
>
> #include <mach/hardware.h>
> #include <asm/mach-types.h>
> @@ -26,9 +27,13 @@
> #include <plat/mux.h>
> #include <mach/gpio.h>
> #include <plat/mmc.h>
> +#include <plat/remoteproc.h>
>
> #include "mux.h"
>
> +#include <plat/omap_device.h>
> +#include <plat/omap_hwmod.h>
> +
> #if defined(CONFIG_VIDEO_OMAP2) || defined(CONFIG_VIDEO_OMAP2_MODULE)
>
> static struct resource cam_resources[] = {
> @@ -136,6 +141,86 @@ static inline void omap_init_camera(void)
> }
> #endif
>
> +#if defined(CONFIG_OMAP_REMOTE_PROC) ||
> defined(CONFIG_OMAP_REMOTE_PROC_MODULE)
> +static struct omap_device_pm_latency omap_rproc_latency[] = {
> + {
> + .deactivate_func = omap_device_idle_hwmods,
> + .activate_func = omap_device_enable_hwmods,
> + .deactivate_lat = 1,
> + .activate_lat = 1,
> + },
> +};
> +
> +static struct omap_rproc_platform_data
> *omap_get_remoteproc_data(void)
> +{
> + struct omap_rproc_platform_data *rproc_data = NULL;
> +
> + if (cpu_is_omap3430() || cpu_is_omap3630())
> + rproc_data = omap3_get_rproc_data();
> + else if (cpu_is_omap44xx())
> + rproc_data = omap4_get_rproc_data();
> + else
> + pr_err("%s: platform not supported\n", __func__);
> +
> + return rproc_data;
> +}
> +
> +int omap_get_num_of_remoteproc(void)
> +{
> + int num = -1;
> +
> + if (cpu_is_omap3430() || cpu_is_omap3630())
> + num = omap3_get_rproc_data_size();
> + else if (cpu_is_omap44xx())
> + num = omap4_get_rproc_data_size();
> + else
> + pr_err("%s: platform not supported\n", __func__);
> +
> + return num;
> +}
[sp] I realise that I commented on this function in earlier patch
without reading this one. While my comment on breaking the
multi_omap support due to this function my not be true, but,
I didn't expect function declared in "include/plat/remoteproc.h"
to be implemented in "mach-omap2/devices.c".
I was, possibly, deceived by presence of "plat-omap/remoteproc.c"
and device specific implementations in the patch series.
Is there any specific reason why remoteproc is being implemented
quite different that other devices in the same file. See, for
example, omap_init_mbox(), omap3_mbox_resources and omap3_mbox_resources_sz.
Following the same scheme, this function is not required.
> +EXPORT_SYMBOL(omap_get_num_of_remoteproc);
> +
> +static inline void omap_init_rproc(void)
> +{
> + struct omap_hwmod *oh;
> + struct omap_device *od;
> + struct omap_device_pm_latency *ohl;
> + char *oh_name, *pdev_name;
> + int ohl_cnt = 0, i;
> + int rproc_data_size;
> + struct omap_rproc_platform_data *rproc_data;
> +
> + pdev_name = "omap-rproc";
> + ohl = omap_rproc_latency;
> + ohl_cnt = ARRAY_SIZE(omap_rproc_latency);
> +
> + rproc_data = omap_get_remoteproc_data();
> + rproc_data_size = omap_get_num_of_remoteproc();
> + if (rproc_data == NULL || rproc_data_size <= 0) {
> + pr_err("%s: platform not supported\n", __func__);
> + return;
> + }
> +
> + for (i = 0; i < rproc_data_size; i++) {
> + oh_name = rproc_data[i].oh_name;
> + oh = omap_hwmod_lookup(oh_name);
> + if (!oh) {
> + pr_err("%s: could not look up %s\n",
> __func__, oh_name);
> + continue;
> + }
> +
> + od = omap_device_build(pdev_name, i, oh,
> + &rproc_data[i],
> + sizeof(struct
> omap_rproc_platform_data),
> + ohl, ohl_cnt);
> + WARN(IS_ERR(od), "Could not build omap_device
> for %s %s\n",
> + pdev_name, oh_name);
> + }
> +}
> +#else
> +static inline void omap_init_rproc(void) { }
> +#endif /* CONFIG_OMAP_REMOTE_PROC */
> +
> #if defined(CONFIG_OMAP_MBOX_FWK) ||
> defined(CONFIG_OMAP_MBOX_FWK_MODULE)
>
> #define MBOX_REG_SIZE 0x120
> @@ -773,6 +858,7 @@ static int __init omap2_init_devices(void)
> omap_hsmmc_reset();
> omap_init_camera();
> omap_init_mbox();
> + omap_init_rproc();
> omap_init_mcspi();
> omap_hdq_init();
> omap_init_sti();
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [RFC 6/6] omap: enable remoteproc building
2010-07-01 22:23 ` [RFC 6/6] omap: enable remoteproc building Ohad Ben-Cohen
@ 2010-07-27 15:49 ` Premi, Sanjeev
0 siblings, 0 replies; 15+ messages in thread
From: Premi, Sanjeev @ 2010-07-27 15:49 UTC (permalink / raw)
To: Ohad Ben-Cohen, linux-omap@vger.kernel.org
Cc: Kanigeri, Hari, Ben-cohen, Ohad
> -----Original Message-----
> From: linux-omap-owner@vger.kernel.org
> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Ohad Ben-Cohen
> Sent: Friday, July 02, 2010 3:53 AM
> To: linux-omap@vger.kernel.org
> Cc: Kanigeri, Hari; Ben-cohen, Ohad
> Subject: [RFC 6/6] omap: enable remoteproc building
>
> From: Ohad Ben-Cohen <ohadb@ti.com>
>
> Make it possible to build omap's remoteproc module
>
> Signed-off-by: Ohad Ben-Cohen <ohadb@ti.com>
> Signed-off-by: Hari Kanigeri <h-kanigeri2@ti.com>
> ---
> arch/arm/mach-omap2/Makefile | 6 ++++++
> arch/arm/plat-omap/Kconfig | 7 +++++++
> arch/arm/plat-omap/Makefile | 1 +
> 3 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/Makefile
> b/arch/arm/mach-omap2/Makefile
> index 307f8b0..edb65b3 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -59,6 +59,12 @@ obj-$(CONFIG_OMAP3_EMU) += emu.o
> obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox_mach.o
> mailbox_mach-objs := mailbox.o
>
> +ifneq ($(CONFIG_OMAP_REMOTE_PROC),)
> +obj-$(CONFIG_ARCH_OMAP2) += remoteproc24xx.o
> +obj-$(CONFIG_ARCH_OMAP3) += remoteproc3xxx.o
[sp] Since the compilation of this file depends upon CONFIG_ARCH_OMAP3,
the "big" ifdef CONFIG_ARCH_OMAP3 in the file remoteproc3xxx.c
is not useful at all.
> +obj-$(CONFIG_ARCH_OMAP4) += remoteproc44xx.o
> +endif
> +
> iommu-y += iommu2.o
> iommu-$(CONFIG_ARCH_OMAP3) += omap3-iommu.o
>
> diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
> index e2ea04a..e7d7372 100644
> --- a/arch/arm/plat-omap/Kconfig
> +++ b/arch/arm/plat-omap/Kconfig
> @@ -96,6 +96,13 @@ config OMAP_MBOX_FWK
> Say Y here if you want to use OMAP Mailbox framework
> support for
> DSP, IVA1.0 and IVA2 in OMAP1/2/3.
>
> +config OMAP_REMOTE_PROC
> + bool "Remote Processor framework support"
> + depends on ARCH_OMAP
> + help
> + Say Y here if you want to use OMAP Remote Processor framework
> + support for DSP, Tesla and/or Ducati (OMAP3/4).
> +
> config OMAP_IOMMU
> tristate
>
> diff --git a/arch/arm/plat-omap/Makefile b/arch/arm/plat-omap/Makefile
> index 98f0191..bacb5c3 100644
> --- a/arch/arm/plat-omap/Makefile
> +++ b/arch/arm/plat-omap/Makefile
> @@ -29,5 +29,6 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
>
> # OMAP mailbox framework
> obj-$(CONFIG_OMAP_MBOX_FWK) += mailbox.o
> +obj-$(CONFIG_OMAP_REMOTE_PROC) += remoteproc.o
>
> obj-$(CONFIG_OMAP_PM_NOOP) += omap-pm-noop.o
> \ No newline at end of file
[sp] You need to fix this as well.
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe
> linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [RFC 0/6] Introducing OMAP Remote Processor module
2010-07-27 12:27 ` [RFC 0/6] Introducing OMAP Remote Processor module Premi, Sanjeev
@ 2010-07-27 17:09 ` Ohad Ben-Cohen
0 siblings, 0 replies; 15+ messages in thread
From: Ohad Ben-Cohen @ 2010-07-27 17:09 UTC (permalink / raw)
To: Premi, Sanjeev; +Cc: linux-omap@vger.kernel.org, Kanigeri, Hari
Hi Sanjeev,
Thanks for your comments.
As we plan to move remoteproc to hwmod, the code will be substantially changed.
We will keep your comments in mind, and also keep in mind other TI
platforms (like davinci).
Thanks,
Ohad.
On Tue, Jul 27, 2010 at 3:27 PM, Premi, Sanjeev <premi@ti.com> wrote:
>> -----Original Message-----
>> From: linux-omap-owner@vger.kernel.org
>> [mailto:linux-omap-owner@vger.kernel.org] On Behalf Of Ohad Ben-Cohen
>> Sent: Friday, July 02, 2010 3:53 AM
>> To: linux-omap@vger.kernel.org
>> Cc: Kanigeri, Hari; Ben-cohen, Ohad
>> Subject: [RFC 0/6] Introducing OMAP Remote Processor module
>>
>> From: Ohad Ben-Cohen <ohadb@ti.com>
>>
>> This is a preliminary version of OMAP's remoteproc module,
>> submitted for RFC purposes.
>>
>> The purpose of the remoteproc module is to decouple
>> hw-specific code from generic IPC drivers (such as
>> dspbridge and syslink), in order to eventually make
>> those IPC drivers platform-independent.
>>
>> Currently the supported operations are starting and stopping
>> the remote processor, but in the future additional functionality
>> might be added.
>>
>> Both OMAP3 and OMAP4 are supported; OMAP3 supports the dsp
>> remote processor, and OMAP4 supports ducati (tesla support
>> is planned as well).
>>
>> The code was tested on both OMAP3 (using dspbridge) and OMAP4
>> (using syslink).
>>
>> The code is preliminary: we plan to add much more extensive
>> hwmod support, ideally squashing as much hw-specific code
>> as possible (including RST and PRCM manipulations).
>> In addition, a rebase to recent code bases is needed.
>>
>> While dspbridge accesses remoteproc's interface via pdata
>> pointers, syslink accesses it from user space, via character
>> device interface, so both kernel and user space interfaces
>> are supported.
>>
>> A few words on the char device interface:
>>
>> * Each remote processor is represented by a different
>> character device: /dev/omap-rproc0, /dev/omap-rproc1, ...
>
> [sp] Concept of remote processor is not really tied to omap.
> Though the implementation is being done in context of
> OMAP, I would suggest removing the prefix "omap-" from
> the device name.
>
>> * A rproc character device can only be opened by a single user
>> (e.g. the syslink daemon)
>> * The start/stop/get_state functionality is exposed via ioctl's
>> * We plan to add automatic stop() invokation in case the user
>> closes the device after starting a remote processor (for
>> resource cleanup purposes. Thus the user will be required
>> to hold the device open as long as it lives).
>>
>> Thanks,
>>
>> Hari Kanigeri (1):
>> omap: introduce OMAP4 remoteproc module
>>
>> Ohad Ben-Cohen (5):
>> omap: add iva2 hwmod support to omap3
>> omap: introduce OMAP3 remoteproc module
>> omap: introduce common remoteproc module
>> omap: add remoteproc device(s)
>> omap: enable remoteproc building
>>
>> arch/arm/mach-omap2/Makefile | 6 +
>> arch/arm/mach-omap2/devices.c | 86 +++++++
>> arch/arm/mach-omap2/omap_hwmod_34xx.h | 23 ++
>> arch/arm/mach-omap2/remoteproc3xxx.c | 226
>> ++++++++++++++++++
>> arch/arm/mach-omap2/remoteproc44xx.c | 196 ++++++++++++++++
>> arch/arm/plat-omap/Kconfig | 7 +
>> arch/arm/plat-omap/Makefile | 1 +
>> arch/arm/plat-omap/include/plat/omap_hwmod.h | 1 +
>> arch/arm/plat-omap/include/plat/remoteproc.h | 75 ++++++
>> arch/arm/plat-omap/remoteproc.c | 316
>> ++++++++++++++++++++++++++
>> 10 files changed, 937 insertions(+), 0 deletions(-)
>> create mode 100644 arch/arm/mach-omap2/remoteproc3xxx.c
>> create mode 100644 arch/arm/mach-omap2/remoteproc44xx.c
>> create mode 100644 arch/arm/plat-omap/include/plat/remoteproc.h
>> create mode 100644 arch/arm/plat-omap/remoteproc.c
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe
>> linux-omap" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2010-07-27 17:09 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-01 22:23 [RFC 0/6] Introducing OMAP Remote Processor module Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 1/6] omap: add iva2 hwmod support to omap3 Ohad Ben-Cohen
2010-07-02 5:43 ` Cousson, Benoit
2010-07-04 21:57 ` Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 2/6] omap: introduce OMAP3 remoteproc module Ohad Ben-Cohen
2010-07-27 15:23 ` Premi, Sanjeev
2010-07-01 22:23 ` [RFC 3/6] omap: introduce OMAP4 " Ohad Ben-Cohen
2010-07-01 22:23 ` [RFC 4/6] omap: introduce common " Ohad Ben-Cohen
2010-07-27 14:49 ` Premi, Sanjeev
2010-07-01 22:23 ` [RFC 5/6] omap: add remoteproc device(s) Ohad Ben-Cohen
2010-07-27 15:44 ` Premi, Sanjeev
2010-07-01 22:23 ` [RFC 6/6] omap: enable remoteproc building Ohad Ben-Cohen
2010-07-27 15:49 ` Premi, Sanjeev
2010-07-27 12:27 ` [RFC 0/6] Introducing OMAP Remote Processor module Premi, Sanjeev
2010-07-27 17:09 ` Ohad Ben-Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).