ARM: cpu topology: Add debugfs interface for cpu_power
[cmplus.git] / arch / arm / mach-omap2 / remoteproc.c
blobb8ae36f35a1787ad010894a88927325e5145235e
1 /*
2 * Remote processor machine-specific module for OMAP4
4 * Copyright (C) 2011 Texas Instruments, Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #define pr_fmt(fmt) "%s: " fmt, __func__
18 #include <linux/kernel.h>
19 #include <linux/err.h>
20 #include <linux/slab.h>
21 #include <linux/remoteproc.h>
22 #include <linux/memblock.h>
23 #include <plat/omap_device.h>
24 #include <plat/omap_hwmod.h>
25 #include <plat/remoteproc.h>
26 #include <plat/dsp.h>
27 #include <plat/io.h>
28 #include "cm2_44xx.h"
29 #include "cm-regbits-44xx.h"
31 #define OMAP4430_CM_M3_M3_CLKCTRL (OMAP4430_CM2_BASE + OMAP4430_CM2_CORE_INST \
32 + OMAP4_CM_DUCATI_DUCATI_CLKCTRL_OFFSET)
34 static struct omap_rproc_timers_info ipu_timers[] = {
35 { .id = 3 },
36 { .id = 4 },
37 #ifdef CONFIG_REMOTEPROC_WATCHDOG
38 { .id = 9 },
39 { .id = 11 },
40 #endif
43 static struct omap_rproc_pdata omap4_rproc_data[] = {
45 .name = "dsp",
46 .iommu_name = "tesla",
47 .firmware = "tesla-dsp.bin",
48 .oh_name = "dsp_c0",
49 .clkdm_name = "dsp_clkdm",
52 .name = "ipu",
53 .iommu_name = "ducati",
54 .firmware = "ducati-m3.bin",
55 .oh_name = "ipu_c0",
56 .oh_name_opt = "ipu_c1",
57 .clkdm_name = "ducati_clkdm",
58 .timers = ipu_timers,
59 .timers_cnt = ARRAY_SIZE(ipu_timers),
60 .idle_addr = OMAP4430_CM_M3_M3_CLKCTRL,
61 .idle_mask = OMAP4430_STBYST_MASK,
62 .suspend_addr = 0xb3bf02d8,
63 .suspend_mask = ~0,
64 .sus_timeout = 5000,
65 .sus_mbox_name = "mailbox-1",
69 static struct omap_device_pm_latency omap_rproc_latency[] = {
71 OMAP_RPROC_DEFAULT_PM_LATENCY,
75 static struct rproc_mem_pool *omap_rproc_get_pool(const char *name)
77 struct rproc_mem_pool *pool = NULL;
79 /* check for ipu currently. dsp will be handled later */
80 if (!strcmp("ipu", name)) {
81 phys_addr_t paddr1 = omap_ipu_get_mempool_base(
82 OMAP_RPROC_MEMPOOL_STATIC);
83 phys_addr_t paddr2 = omap_ipu_get_mempool_base(
84 OMAP_RPROC_MEMPOOL_DYNAMIC);
85 u32 len1 = omap_ipu_get_mempool_size(OMAP_RPROC_MEMPOOL_STATIC);
86 u32 len2 = omap_ipu_get_mempool_size(OMAP_RPROC_MEMPOOL_DYNAMIC);
88 if (!paddr1 && !paddr2) {
89 pr_err("no carveout memory available at all for "
90 "remotproc\n");
91 return pool;
93 if (!paddr1 || !len1)
94 pr_warn("static memory is unavailable: 0x%x, 0x%x\n",
95 paddr1, len1);
96 if (!paddr2 || !len2)
97 pr_warn("carveout memory is unavailable: 0x%x, 0x%x\n",
98 paddr2, len2);
100 pool = kzalloc(sizeof(*pool), GFP_KERNEL);
101 if (pool) {
102 pool->st_base = paddr1;
103 pool->st_size = len1;
104 pool->mem_base = paddr2;
105 pool->mem_size = len2;
106 pool->cur_base = paddr2;
107 pool->cur_size = len2;
111 return pool;
114 static int __init omap_rproc_init(void)
116 const char *pdev_name = "omap-rproc";
117 struct omap_hwmod *oh[2];
118 struct omap_device *od;
119 int i, ret = 0, oh_count;
121 /* names like ipu_cx/dsp_cx might show up on other OMAPs, too */
122 if (!cpu_is_omap44xx())
123 return 0;
125 for (i = 0; i < ARRAY_SIZE(omap4_rproc_data); i++) {
126 const char *oh_name = omap4_rproc_data[i].oh_name;
127 const char *oh_name_opt = omap4_rproc_data[i].oh_name_opt;
128 oh_count = 0;
130 oh[0] = omap_hwmod_lookup(oh_name);
131 if (!oh[0]) {
132 pr_err("could not look up %s\n", oh_name);
133 continue;
135 oh_count++;
137 if (oh_name_opt) {
138 oh[1] = omap_hwmod_lookup(oh_name_opt);
139 if (!oh[1]) {
140 pr_err("could not look up %s\n", oh_name_opt);
141 continue;
143 oh_count++;
146 omap4_rproc_data[i].memory_pool =
147 omap_rproc_get_pool(omap4_rproc_data[i].name);
148 od = omap_device_build_ss(pdev_name, i, oh, oh_count,
149 &omap4_rproc_data[i],
150 sizeof(struct omap_rproc_pdata),
151 omap_rproc_latency,
152 ARRAY_SIZE(omap_rproc_latency),
153 false);
154 if (IS_ERR(od)) {
155 pr_err("Could not build omap_device for %s:%s\n",
156 pdev_name, oh_name);
157 ret = PTR_ERR(od);
161 return ret;
163 /* must be ready in time for device_initcall users */
164 subsys_initcall(omap_rproc_init);