aboutsummaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0128-rcar_imr-v4l2-driver-Fix-module-support.patch
blob: f4ee6e28a95f9ff5186de7b786e3d67fa8089aeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
From 772299b20e32fc3ff86de4a83845e8246d97bcbb Mon Sep 17 00:00:00 2001
From: Andrey Dolnikov <andrey.dolnikov@cogentembedded.com>
Date: Mon, 9 Apr 2018 12:50:23 +0300
Subject: [PATCH 2/2] rcar_imr v4l2 driver: Fix module support.

---
 arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi |  8 +++++++
 arch/arm64/boot/dts/renesas/r8a7795.dtsi     |  8 +++++++
 arch/arm64/boot/dts/renesas/r8a7796.dtsi     |  6 ++++++
 arch/arm64/boot/dts/renesas/r8a7797.dtsi     |  8 +++++++
 arch/arm64/boot/dts/renesas/r8a7798.dtsi     | 10 +++++++++
 drivers/media/platform/rcar_imr.c            | 32 +++++++++++++++++++++++++---
 6 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi b/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi
index 745493c..f2769c2 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi
@@ -2899,12 +2899,17 @@
 			power-domains = <&sysc R8A7795_PD_A3IR>;
 		};
 
+		imr_v4l2_alloc: imr_alloc {
+			dma-coherent;
+		};
+
 		imrlx4_ch0: imr0@fe860000 {
 			compatible = "renesas,imr-lx4", "renesas,imr-r8a7795";
 			reg = <0 0xfe860000 0 0x10000>;
 			interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 823>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch1: imr1@fe870000 {
@@ -2913,6 +2918,7 @@
 			interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 822>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch2: imr2@fe880000 {
@@ -2921,6 +2927,7 @@
 			interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 821>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch3: imr3@fe890000 {
@@ -2929,6 +2936,7 @@
 			interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 820>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 	};
 };
diff --git a/arch/arm64/boot/dts/renesas/r8a7795.dtsi b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
index 96e182a..366ee5f 100644
--- a/arch/arm64/boot/dts/renesas/r8a7795.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7795.dtsi
@@ -2895,12 +2895,17 @@
 			power-domains = <&sysc R8A7795_PD_A3IR>;
 		};
 
+		imr_v4l2_alloc: imr_alloc {
+			dma-coherent;
+		};
+
 		imrlx4_ch0: imr0@fe860000 {
 			compatible = "renesas,imr-lx4", "renesas,imr-r8a7795";
 			reg = <0 0xfe860000 0 0x10000>;
 			interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 823>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch1: imr1@fe870000 {
@@ -2909,6 +2914,7 @@
 			interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 822>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch2: imr2@fe880000 {
@@ -2917,6 +2923,7 @@
 			interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 821>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch3: imr3@fe890000 {
@@ -2925,6 +2932,7 @@
 			interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 820>;
 			power-domains = <&sysc R8A7795_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 	};
 };
diff --git a/arch/arm64/boot/dts/renesas/r8a7796.dtsi b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
index b747f0c..442f027 100644
--- a/arch/arm64/boot/dts/renesas/r8a7796.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7796.dtsi
@@ -1174,12 +1174,17 @@
 			status = "disabled";
 		};
 
+		imr_v4l2_alloc: imr_alloc {
+			dma-coherent;
+		};
+
 		imrlx4_ch0: imr0@fe860000 {
 			compatible = "renesas,imr-lx4", "renesas,imr-r8a7796";
 			reg = <0 0xfe860000 0 0x10000>;
 			interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 823>;
 			power-domains = <&sysc R8A7796_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch1: imr1@fe870000 {
@@ -1188,6 +1193,7 @@
 			interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 822>;
 			power-domains = <&sysc R8A7796_PD_A3VC>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		can0: can@e6c30000 {
diff --git a/arch/arm64/boot/dts/renesas/r8a7797.dtsi b/arch/arm64/boot/dts/renesas/r8a7797.dtsi
index c878467..16e73b4 100644
--- a/arch/arm64/boot/dts/renesas/r8a7797.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7797.dtsi
@@ -1239,12 +1239,17 @@
 			power-domains = <&sysc R8A7797_PD_A3IR>;
 		};
 
+		imr_v4l2_alloc: imr_alloc {
+			dma-coherent;
+		};
+
 		imrlx4_ch0: imr0@fe860000 {
 			compatible = "renesas,imr-lx4", "renesas,imr-r8a7797";
 			reg = <0 0xfe860000 0 0x10000>;
 			interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 823>;
 			power-domains = <&sysc R8A7797_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch1: imr1@fe870000 {
@@ -1253,6 +1258,7 @@
 			interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 822>;
 			power-domains = <&sysc R8A7797_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch2: imr2@fe880000 {
@@ -1261,6 +1267,7 @@
 			interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 821>;
 			power-domains = <&sysc R8A7797_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch3: imr3@fe890000 {
@@ -1269,6 +1276,7 @@
 			interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 820>;
 			power-domains = <&sysc R8A7797_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 	};
 };
diff --git a/arch/arm64/boot/dts/renesas/r8a7798.dtsi b/arch/arm64/boot/dts/renesas/r8a7798.dtsi
index 7bfd0483..0742ec0 100644
--- a/arch/arm64/boot/dts/renesas/r8a7798.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a7798.dtsi
@@ -1588,12 +1588,17 @@
 			power-domains = <&sysc R8A7798_PD_A3IR>;
 		};
 
+		imr_v4l2_alloc: imr_alloc {
+			dma-coherent;
+		};
+
 		imrlx4_ch0: imr0@fe860000 {
 			compatible = "renesas,imr-lx4", "renesas,imr-r8a7798";
 			reg = <0 0xfe860000 0 0x10000>;
 			interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 823>;
 			power-domains = <&sysc R8A7798_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch1: imr1@fe870000 {
@@ -1602,6 +1607,7 @@
 			interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 822>;
 			power-domains = <&sysc R8A7798_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch2: imr2@fe880000 {
@@ -1610,6 +1616,7 @@
 			interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 821>;
 			power-domains = <&sysc R8A7798_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch3: imr3@fe890000 {
@@ -1618,6 +1625,7 @@
 			interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 820>;
 			power-domains = <&sysc R8A7798_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 		};
 
 		imrlx4_ch4: imr4@fe8a0000 {
@@ -1626,6 +1634,7 @@
 			interrupts = <GIC_SPI 254 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 707>;
 			power-domains = <&sysc R8A7798_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 			rse;
 		};
 
@@ -1635,6 +1644,7 @@
 			interrupts = <GIC_SPI 255 IRQ_TYPE_LEVEL_HIGH>;
 			clocks = <&cpg CPG_MOD 706>;
 			power-domains = <&sysc R8A7798_PD_ALWAYS_ON>;
+			alloc-dev = <&imr_v4l2_alloc>;
 			rse;
 		};
 
diff --git a/drivers/media/platform/rcar_imr.c b/drivers/media/platform/rcar_imr.c
index 7b16765..3558211 100644
--- a/drivers/media/platform/rcar_imr.c
+++ b/drivers/media/platform/rcar_imr.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/rcar-imr.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-fh.h>
@@ -1917,6 +1918,8 @@ static int imr_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct device_node *np = pdev->dev.of_node;
 	int ret;
+	phandle *prop;
+	struct device_node *node;
 
 	imr = devm_kzalloc(&pdev->dev, sizeof(*imr), GFP_KERNEL);
 	if (!imr)
@@ -1989,10 +1992,15 @@ static int imr_probe(struct platform_device *pdev)
 		ret = PTR_ERR(adev);
 		goto m2m_init_rollback;
 	}
+
 	adev->dma_mask = &adev->coherent_dma_mask;
 	adev->coherent_dma_mask = DMA_BIT_MASK(32);
-	arch_setup_dma_ops(adev, 0, DMA_BIT_MASK(32) + 1, NULL, true);
 	imr->alloc_dev = adev;
+	prop = of_get_property(np, "alloc-dev", NULL);
+	if (prop) {
+		node = of_find_node_by_phandle(be32_to_cpup(prop));
+		of_dma_configure(adev, node);
+	}
 
 	strlcpy(imr->video_dev.name, dev_name(&pdev->dev), sizeof(imr->video_dev.name));
 	imr->video_dev.fops         = &imr_fops;
@@ -2032,7 +2040,6 @@ static int imr_remove(struct platform_device *pdev)
 
 	//pm_runtime_disable(imr->v4l2_dev.dev);
 	video_unregister_device(&imr->video_dev);
-	//device_destroy(imr->alloc_dev, MKDEV(0, 0));
 	v4l2_m2m_release(imr->m2m_dev);
 	v4l2_device_unregister(&imr->v4l2_dev);
 
@@ -2100,7 +2107,26 @@ static struct platform_driver imr_platform_driver = {
 	},
 };
 
-module_platform_driver(imr_platform_driver);
+static int __init imr_module_init(void)
+{
+	return platform_driver_register(&imr_platform_driver);
+}
+
+static int imr_device_destroy(struct device *dev, void *data)
+{
+	device_destroy(imr_alloc_class, dev->devt);
+	return 0;
+}
+
+static void __exit imr_module_exit(void)
+{
+	class_for_each_device(imr_alloc_class, NULL, NULL, imr_device_destroy);
+	class_destroy(imr_alloc_class);
+	platform_driver_unregister(&imr_platform_driver);
+}
+
+module_init(imr_module_init);
+module_exit(imr_module_exit);
 
 MODULE_ALIAS("imr");
 MODULE_AUTHOR("Cogent Embedded Inc. <sources@cogentembedded.com>");
-- 
2.7.4