From patchwork Tue Jun 21 07:18:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 908142 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5N5BlV7001281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 Jun 2011 05:12:14 GMT Received: from dlep35.itg.ti.com ([157.170.170.118]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p5N59eq5001613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Jun 2011 00:09:50 -0500 Received: from linux.omap.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep35.itg.ti.com (8.13.7/8.13.8) with ESMTP id p5N59eWi015691; Thu, 23 Jun 2011 00:09:40 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 6B7E68062A; Thu, 23 Jun 2011 00:09:40 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 8EE2980626 for ; Tue, 21 Jun 2011 02:22:15 -0500 (CDT) Received: from medina.ext.ti.com (medina.ext.ti.com [192.91.81.31]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id p5L7MFY0028134 for ; Tue, 21 Jun 2011 02:22:15 -0500 (CDT) Received: from psmtp.com (na3sys009amx199.postini.com [74.125.149.235]) by medina.ext.ti.com (8.13.7/8.13.7) with SMTP id p5L7MEK8000452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Jun 2011 02:22:14 -0500 Received: from mail-ww0-f47.google.com ([74.125.82.47]) (using TLSv1) by na3sys009amx199.postini.com ([74.125.148.10]) with SMTP; Tue, 21 Jun 2011 07:22:14 GMT Received: by mail-ww0-f47.google.com with SMTP id 27so2747957wwf.4 for ; Tue, 21 Jun 2011 00:22:14 -0700 (PDT) Received: by 10.227.58.71 with SMTP id f7mr768408wbh.110.1308640933909; Tue, 21 Jun 2011 00:22:13 -0700 (PDT) Received: from localhost.localdomain (46-116-119-47.bb.netvision.net.il [46.116.119.47]) by mx.google.com with ESMTPS id o19sm3767542wbh.38.2011.06.21.00.22.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Jun 2011 00:22:13 -0700 (PDT) From: Ohad Ben-Cohen To: , , Subject: [RFC 4/8] omap: add remoteproc devices Date: Tue, 21 Jun 2011 10:18:30 +0300 Message-Id: <1308640714-17961-5-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308640714-17961-1-git-send-email-ohad@wizery.com> References: <1308640714-17961-1-git-send-email-ohad@wizery.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [35/1] X-Mailman-Approved-At: Thu, 23 Jun 2011 00:07:34 -0500 Cc: Ohad Ben-Cohen , davinci-linux-open-source , "Guzman Lugo, Fernando" , Arnd Bergmann , Brian Swetland , Rusty Russell , Grant Likely , akpm@linux-foundation.org X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 23 Jun 2011 05:12:15 +0000 (UTC) From: Guzman Lugo, Fernando Add omap remoteproc devices for the ipu and dsp remote processors. TODO: - rework to use CMA instead of reserving memory at boot [ohad@wizery.com: commit log, refactored and simplified, still wip] Signed-off-by: Guzman Lugo, Fernando Signed-off-by: Ohad Ben-Cohen --- arch/arm/mach-omap2/Makefile | 2 + arch/arm/mach-omap2/remoteproc.c | 159 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-omap2/remoteproc.c diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index b148077..2b04fe6 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -270,3 +270,5 @@ disp-$(CONFIG_OMAP2_DSS) := display.o obj-y += $(disp-m) $(disp-y) obj-y += common-board-devices.o + +obj-$(CONFIG_OMAP_REMOTE_PROC) += remoteproc.o diff --git a/arch/arm/mach-omap2/remoteproc.c b/arch/arm/mach-omap2/remoteproc.c new file mode 100644 index 0000000..4f846cb --- /dev/null +++ b/arch/arm/mach-omap2/remoteproc.c @@ -0,0 +1,159 @@ +/* + * Remote processor machine-specific module for OMAP4 + * + * Copyright (C) 2011 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. + */ + +#define pr_fmt(fmt) "%s: " fmt, __func__ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#define L4_PERIPHERAL_L4CFG (L4_44XX_BASE) +#define IPU_PERIPHERAL_L4CFG 0xAA000000 + +#define IPU_MEM_TEXT 0x0 +#define IPU_MEM_DATA 0x80000000 +#define IPU_MEM_IPC 0xA0000000 + +/* + * Memory mappings for the remote M3 subsystem + * + * Don't change the device addresses (first parameter), otherwise you'd have + * to update the firmware (BIOS image) accordingly. + * + * A 0 physical address (second parameter) means this physical region should + * be dynamically carved out at boot time. + * + * Sizes should be in the form of 2 ^ n * PAGE_SIZE (where n = 0, 1, 2, ...) + * + * Alignment requirement: at least page-based + */ +static struct rproc_mem_entry ipu_memory_maps[] = { + {IPU_MEM_IPC, 0, SZ_1M}, /* keep this IPC region first */ + {IPU_MEM_TEXT, 0, SZ_4M}, + {IPU_MEM_DATA, 0, SZ_32M}, + {IPU_PERIPHERAL_L4CFG, L4_PERIPHERAL_L4CFG, SZ_16M}, + { } +}; + +static struct omap_rproc_pdata omap4_rproc_data[] = { + { + .name = "dsp", + .iommu_name = "tesla", + .firmware = "tesla-dsp.bin", + .oh_name = "dsp_c0", + }, + { + .name = "ipu", + .iommu_name = "ducati", + .firmware = "ducati-m3.bin", + .oh_name = "ipu_c0", + .oh_name_opt = "ipu_c1", + .memory_maps = ipu_memory_maps, + }, +}; + +static struct omap_device_pm_latency omap_rproc_latency[] = { + { + .deactivate_func = omap_device_idle_hwmods, + .activate_func = omap_device_enable_hwmods, + .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST, + }, +}; + +static int __init omap_rproc_init(void) +{ + const char *pdev_name = "omap-rproc"; + struct omap_hwmod *oh[2]; + struct omap_device *od; + int i, ret = 0, oh_count; + phys_addr_t paddr, size; + + /* names like ipu_cx/dsp_cx might show up on other OMAPs, too */ + if (!cpu_is_omap44xx()) + return 0; + + paddr = omap_dsp_get_mempool_base(); + size = omap_dsp_get_mempool_size(); + if (!paddr || !size) { + pr_warn("carveout memory is unavailable: 0x%x, 0x%x\n", + paddr, size); + return -ENOMEM; + } + + /* dynamically allocate carveout memory as required by the ipu */ + for (i = 0; i < ARRAY_SIZE(ipu_memory_maps); i++) { + struct rproc_mem_entry *me = &ipu_memory_maps[i]; + + if (!me->pa && me->size) { + if (me->size > size) { + pr_warn("out of carveout memory\n"); + return -ENOMEM; + } + + me->pa = paddr; + paddr += me->size; + size -= me->size; + + pr_info("0x%x bytes at 0x%x %d\n", me->size, me->pa, i); + } + } + + /* build the remote proc devices */ + for (i = 0; i < ARRAY_SIZE(omap4_rproc_data); i++) { + const char *oh_name = omap4_rproc_data[i].oh_name; + const char *oh_name_opt = omap4_rproc_data[i].oh_name_opt; + oh_count = 0; + + oh[0] = omap_hwmod_lookup(oh_name); + if (!oh[0]) { + pr_err("could not look up %s\n", oh_name); + continue; + } + oh_count++; + + /* ipu has a secondary hwmod entry */ + if (oh_name_opt) { + oh[1] = omap_hwmod_lookup(oh_name_opt); + if (!oh[1]) { + pr_err("could not look up %s\n", oh_name_opt); + continue; + } + oh_count++; + } + + od = omap_device_build_ss(pdev_name, i, oh, oh_count, + &omap4_rproc_data[i], + sizeof(struct omap_rproc_pdata), + omap_rproc_latency, + ARRAY_SIZE(omap_rproc_latency), + false); + if (IS_ERR(od)) { + pr_err("Could not build omap_device for %s:%s\n", + pdev_name, oh_name); + ret = PTR_ERR(od); + } + } + + return ret; +} +/* must be ready in time for device_initcall users */ +subsys_initcall(omap_rproc_init);