[ipc/ipcdev.git] / linux / patches / 3.8.0 / omapl138 / 0006-Add-a-new-remoteproc-platform-device-for-DA8XX.patch
1 From 81117b56046ed3dc5540eca2b7782fd5a6e17a34 Mon Sep 17 00:00:00 2001
2 From: Robert Tivy <rtivy@ti.com>
3 Date: Fri, 8 Mar 2013 10:55:18 -0800
4 Subject: [PATCH v8 6/7] ARM: davinci: Add a new remoteproc platform device for DA8XX
6 Contains CMA-based reservation of physical memory block. A new kernel
7 command-line parameter has been added to allow boot-time specification
8 of the physical memory block.
10 Signed-off-by: Robert Tivy <rtivy@ti.com>
11 Acked-by: Sekhar Nori <nsekhar@ti.com>
12 ---
13 Documentation/kernel-parameters.txt | 6 ++
14 arch/arm/mach-davinci/devices-da8xx.c | 88 +++++++++++++++++++++++++++-
15 arch/arm/mach-davinci/include/mach/da8xx.h | 4 ++
16 3 files changed, 97 insertions(+), 1 deletion(-)
18 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
19 index 6c72381..a46456a 100644
20 --- a/Documentation/kernel-parameters.txt
21 +++ b/Documentation/kernel-parameters.txt
22 @@ -44,6 +44,7 @@ parameter is applicable:
23 AVR32 AVR32 architecture is enabled.
24 AX25 Appropriate AX.25 support is enabled.
25 BLACKFIN Blackfin architecture is enabled.
26 + CMA Contiguous Memory Area support is enabled.
27 DRM Direct Rendering Management support is enabled.
28 DYNAMIC_DEBUG Build in debug messages and enable them at runtime
29 EDD BIOS Enhanced Disk Drive Services (EDD) is enabled
30 @@ -2634,6 +2635,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
31 Useful for devices that are detected asynchronously
32 (e.g. USB and MMC devices).
34 + rproc_mem=nn[KMG][@address]
35 + [KNL,ARM,CMA] Remoteproc physical memory block.
36 + Memory area to be used by remote processor image,
37 + managed by CMA.
38 +
39 rw [KNL] Mount root device read-write on boot
41 S [KNL] Run init in single mode
42 diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
43 index fc50243..08a6b36 100644
44 --- a/arch/arm/mach-davinci/devices-da8xx.c
45 +++ b/arch/arm/mach-davinci/devices-da8xx.c
46 @@ -12,7 +12,7 @@
47 */
48 #include <linux/init.h>
49 #include <linux/platform_device.h>
50 -#include <linux/dma-mapping.h>
51 +#include <linux/dma-contiguous.h>
52 #include <linux/serial_8250.h>
53 #include <linux/ahci_platform.h>
54 #include <linux/clk.h>
55 @@ -714,6 +714,92 @@ int __init da850_register_mmcsd1(struct davinci_mmc_config *config)
56 }
57 #endif
59 +static struct resource da8xx_rproc_resources[] = {
60 + { /* DSP boot address */
61 + .start = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG,
62 + .end = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG + 3,
63 + .flags = IORESOURCE_MEM,
64 + },
65 + { /* DSP interrupt registers */
66 + .start = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG,
67 + .end = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG + 7,
68 + .flags = IORESOURCE_MEM,
69 + },
70 + { /* dsp irq */
71 + .start = IRQ_DA8XX_CHIPINT0,
72 + .end = IRQ_DA8XX_CHIPINT0,
73 + .flags = IORESOURCE_IRQ,
74 + },
75 +};
76 +
77 +static struct platform_device da8xx_dsp = {
78 + .name = "davinci-rproc",
79 + .dev = {
80 + .coherent_dma_mask = DMA_BIT_MASK(32),
81 + },
82 + .num_resources = ARRAY_SIZE(da8xx_rproc_resources),
83 + .resource = da8xx_rproc_resources,
84 +};
85 +
86 +#if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC)
87 +
88 +static phys_addr_t rproc_base __initdata;
89 +static unsigned long rproc_size __initdata;
90 +
91 +static int __init early_rproc_mem(char *p)
92 +{
93 + char *endp;
94 +
95 + if (p == NULL)
96 + return 0;
97 +
98 + rproc_size = memparse(p, &endp);
99 + if (*endp == '@')
100 + rproc_base = memparse(endp + 1, NULL);
101 +
102 + return 0;
103 +}
104 +early_param("rproc_mem", early_rproc_mem);
105 +
106 +void __init da8xx_rproc_reserve_cma(void)
107 +{
108 + int ret;
109 +
110 + if (!rproc_base || !rproc_size) {
111 + pr_err("%s: 'rproc_mem=nn@address' badly specified\n"
112 + " 'nn' and 'address' must both be non-zero\n",
113 + __func__);
114 +
115 + return;
116 + }
117 +
118 + pr_info("%s: reserving 0x%lx @ 0x%lx...\n",
119 + __func__, rproc_size, (unsigned long)rproc_base);
120 +
121 + ret = dma_declare_contiguous(&da8xx_dsp.dev, rproc_size, rproc_base, 0);
122 + if (ret)
123 + pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret);
124 +}
125 +
126 +#else
127 +
128 +void __init da8xx_rproc_reserve_cma(void)
129 +{
130 +}
131 +
132 +#endif
133 +
134 +int __init da8xx_register_rproc(void)
135 +{
136 + int ret;
137 +
138 + ret = platform_device_register(&da8xx_dsp);
139 + if (ret)
140 + pr_err("%s: can't register DSP device: %d\n", __func__, ret);
141 +
142 + return ret;
143 +};
144 +
145 static struct resource da8xx_rtc_resources[] = {
146 {
147 .start = DA8XX_RTC_BASE,
148 diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h
149 index de439b7..5e85c27 100644
150 --- a/arch/arm/mach-davinci/include/mach/da8xx.h
151 +++ b/arch/arm/mach-davinci/include/mach/da8xx.h
152 @@ -54,6 +54,8 @@ extern unsigned int da850_max_speed;
153 #define DA8XX_SYSCFG0_BASE (IO_PHYS + 0x14000)
154 #define DA8XX_SYSCFG0_VIRT(x) (da8xx_syscfg0_base + (x))
155 #define DA8XX_JTAG_ID_REG 0x18
156 +#define DA8XX_HOST1CFG_REG 0x44
157 +#define DA8XX_CHIPSIG_REG 0x174
158 #define DA8XX_CFGCHIP0_REG 0x17c
159 #define DA8XX_CFGCHIP2_REG 0x184
160 #define DA8XX_CFGCHIP3_REG 0x188
161 @@ -104,6 +106,8 @@ int __init da850_register_vpif_display
162 int __init da850_register_vpif_capture
163 (struct vpif_capture_config *capture_config);
164 void da8xx_restart(char mode, const char *cmd);
165 +void da8xx_rproc_reserve_cma(void);
166 +int da8xx_register_rproc(void);
168 extern struct platform_device da8xx_serial_device;
169 extern struct emac_platform_data da8xx_emac_pdata;
170 --
171 1.7.9.4