aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorMurali Karicheri <mkaricheri@gmail.com>2010-02-21 13:51:14 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 13:11:06 -0500
commit85b848caf77a0cc6a9df0a0f40d876211b394682 (patch)
tree1b100413a3952bb5814521544415b22b7944871f /drivers/media/video
parent63e3ab142fa3f46c290891655681c6a6304bd2b3 (diff)
V4L/DVB: V4L - vpfe capture - vpss driver enhancements for DM365
Enhancements to support DM365 ISP5 and VPSS module configuration. Also cleaned up the driver by removing redundant variables. Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Murali Karicheri <mkaricheri@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/davinci/vpss.c289
1 files changed, 235 insertions, 54 deletions
diff --git a/drivers/media/video/davinci/vpss.c b/drivers/media/video/davinci/vpss.c
index 7ee72ecd3d81..7918680917d0 100644
--- a/drivers/media/video/davinci/vpss.c
+++ b/drivers/media/video/davinci/vpss.c
@@ -15,7 +15,7 @@
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 * 17 *
18 * common vpss driver for all video drivers. 18 * common vpss system module platform driver for all video drivers.
19 */ 19 */
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/sched.h> 21#include <linux/sched.h>
@@ -35,12 +35,52 @@ MODULE_AUTHOR("Texas Instruments");
35/* DM644x defines */ 35/* DM644x defines */
36#define DM644X_SBL_PCR_VPSS (4) 36#define DM644X_SBL_PCR_VPSS (4)
37 37
38#define DM355_VPSSBL_INTSEL 0x10
39#define DM355_VPSSBL_EVTSEL 0x14
38/* vpss BL register offsets */ 40/* vpss BL register offsets */
39#define DM355_VPSSBL_CCDCMUX 0x1c 41#define DM355_VPSSBL_CCDCMUX 0x1c
40/* vpss CLK register offsets */ 42/* vpss CLK register offsets */
41#define DM355_VPSSCLK_CLKCTRL 0x04 43#define DM355_VPSSCLK_CLKCTRL 0x04
42/* masks and shifts */ 44/* masks and shifts */
43#define VPSS_HSSISEL_SHIFT 4 45#define VPSS_HSSISEL_SHIFT 4
46/*
47 * VDINT0 - vpss_int0, VDINT1 - vpss_int1, H3A - vpss_int4,
48 * IPIPE_INT1_SDR - vpss_int5
49 */
50#define DM355_VPSSBL_INTSEL_DEFAULT 0xff83ff10
51/* VENCINT - vpss_int8 */
52#define DM355_VPSSBL_EVTSEL_DEFAULT 0x4
53
54#define DM365_ISP5_PCCR 0x04
55#define DM365_ISP5_INTSEL1 0x10
56#define DM365_ISP5_INTSEL2 0x14
57#define DM365_ISP5_INTSEL3 0x18
58#define DM365_ISP5_CCDCMUX 0x20
59#define DM365_ISP5_PG_FRAME_SIZE 0x28
60#define DM365_VPBE_CLK_CTRL 0x00
61/*
62 * vpss interrupts. VDINT0 - vpss_int0, VDINT1 - vpss_int1,
63 * AF - vpss_int3
64 */
65#define DM365_ISP5_INTSEL1_DEFAULT 0x0b1f0100
66/* AEW - vpss_int6, RSZ_INT_DMA - vpss_int5 */
67#define DM365_ISP5_INTSEL2_DEFAULT 0x1f0a0f1f
68/* VENC - vpss_int8 */
69#define DM365_ISP5_INTSEL3_DEFAULT 0x00000015
70
71/* masks and shifts for DM365*/
72#define DM365_CCDC_PG_VD_POL_SHIFT 0
73#define DM365_CCDC_PG_HD_POL_SHIFT 1
74
75#define CCD_SRC_SEL_MASK (BIT_MASK(5) | BIT_MASK(4))
76#define CCD_SRC_SEL_SHIFT 4
77
78/* Different SoC platforms supported by this driver */
79enum vpss_platform_type {
80 DM644X,
81 DM355,
82 DM365,
83};
44 84
45/* 85/*
46 * vpss operations. Depends on platform. Not all functions are available 86 * vpss operations. Depends on platform. Not all functions are available
@@ -59,13 +99,9 @@ struct vpss_hw_ops {
59 99
60/* vpss configuration */ 100/* vpss configuration */
61struct vpss_oper_config { 101struct vpss_oper_config {
62 __iomem void *vpss_bl_regs_base; 102 __iomem void *vpss_regs_base0;
63 __iomem void *vpss_regs_base; 103 __iomem void *vpss_regs_base1;
64 struct resource *r1; 104 enum vpss_platform_type platform;
65 resource_size_t len1;
66 struct resource *r2;
67 resource_size_t len2;
68 char vpss_name[32];
69 spinlock_t vpss_lock; 105 spinlock_t vpss_lock;
70 struct vpss_hw_ops hw_ops; 106 struct vpss_hw_ops hw_ops;
71}; 107};
@@ -75,22 +111,46 @@ static struct vpss_oper_config oper_cfg;
75/* register access routines */ 111/* register access routines */
76static inline u32 bl_regr(u32 offset) 112static inline u32 bl_regr(u32 offset)
77{ 113{
78 return __raw_readl(oper_cfg.vpss_bl_regs_base + offset); 114 return __raw_readl(oper_cfg.vpss_regs_base0 + offset);
79} 115}
80 116
81static inline void bl_regw(u32 val, u32 offset) 117static inline void bl_regw(u32 val, u32 offset)
82{ 118{
83 __raw_writel(val, oper_cfg.vpss_bl_regs_base + offset); 119 __raw_writel(val, oper_cfg.vpss_regs_base0 + offset);
84} 120}
85 121
86static inline u32 vpss_regr(u32 offset) 122static inline u32 vpss_regr(u32 offset)
87{ 123{
88 return __raw_readl(oper_cfg.vpss_regs_base + offset); 124 return __raw_readl(oper_cfg.vpss_regs_base1 + offset);
89} 125}
90 126
91static inline void vpss_regw(u32 val, u32 offset) 127static inline void vpss_regw(u32 val, u32 offset)
92{ 128{
93 __raw_writel(val, oper_cfg.vpss_regs_base + offset); 129 __raw_writel(val, oper_cfg.vpss_regs_base1 + offset);
130}
131
132/* For DM365 only */
133static inline u32 isp5_read(u32 offset)
134{
135 return __raw_readl(oper_cfg.vpss_regs_base0 + offset);
136}
137
138/* For DM365 only */
139static inline void isp5_write(u32 val, u32 offset)
140{
141 __raw_writel(val, oper_cfg.vpss_regs_base0 + offset);
142}
143
144static void dm365_select_ccdc_source(enum vpss_ccdc_source_sel src_sel)
145{
146 u32 temp = isp5_read(DM365_ISP5_CCDCMUX) & ~CCD_SRC_SEL_MASK;
147
148 /* if we are using pattern generator, enable it */
149 if (src_sel == VPSS_PGLPBK || src_sel == VPSS_CCDCPG)
150 temp |= 0x08;
151
152 temp |= (src_sel << CCD_SRC_SEL_SHIFT);
153 isp5_write(temp, DM365_ISP5_CCDCMUX);
94} 154}
95 155
96static void dm355_select_ccdc_source(enum vpss_ccdc_source_sel src_sel) 156static void dm355_select_ccdc_source(enum vpss_ccdc_source_sel src_sel)
@@ -101,9 +161,9 @@ static void dm355_select_ccdc_source(enum vpss_ccdc_source_sel src_sel)
101int vpss_select_ccdc_source(enum vpss_ccdc_source_sel src_sel) 161int vpss_select_ccdc_source(enum vpss_ccdc_source_sel src_sel)
102{ 162{
103 if (!oper_cfg.hw_ops.select_ccdc_source) 163 if (!oper_cfg.hw_ops.select_ccdc_source)
104 return -1; 164 return -EINVAL;
105 165
106 dm355_select_ccdc_source(src_sel); 166 oper_cfg.hw_ops.select_ccdc_source(src_sel);
107 return 0; 167 return 0;
108} 168}
109EXPORT_SYMBOL(vpss_select_ccdc_source); 169EXPORT_SYMBOL(vpss_select_ccdc_source);
@@ -114,7 +174,7 @@ static int dm644x_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel)
114 174
115 if (wbl_sel < VPSS_PCR_AEW_WBL_0 || 175 if (wbl_sel < VPSS_PCR_AEW_WBL_0 ||
116 wbl_sel > VPSS_PCR_CCDC_WBL_O) 176 wbl_sel > VPSS_PCR_CCDC_WBL_O)
117 return -1; 177 return -EINVAL;
118 178
119 /* writing a 0 clear the overflow */ 179 /* writing a 0 clear the overflow */
120 mask = ~(mask << wbl_sel); 180 mask = ~(mask << wbl_sel);
@@ -126,7 +186,7 @@ static int dm644x_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel)
126int vpss_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel) 186int vpss_clear_wbl_overflow(enum vpss_wbl_sel wbl_sel)
127{ 187{
128 if (!oper_cfg.hw_ops.clear_wbl_overflow) 188 if (!oper_cfg.hw_ops.clear_wbl_overflow)
129 return -1; 189 return -EINVAL;
130 190
131 return oper_cfg.hw_ops.clear_wbl_overflow(wbl_sel); 191 return oper_cfg.hw_ops.clear_wbl_overflow(wbl_sel);
132} 192}
@@ -166,7 +226,7 @@ static int dm355_enable_clock(enum vpss_clock_sel clock_sel, int en)
166 default: 226 default:
167 printk(KERN_ERR "dm355_enable_clock:" 227 printk(KERN_ERR "dm355_enable_clock:"
168 " Invalid selector: %d\n", clock_sel); 228 " Invalid selector: %d\n", clock_sel);
169 return -1; 229 return -EINVAL;
170 } 230 }
171 231
172 spin_lock_irqsave(&oper_cfg.vpss_lock, flags); 232 spin_lock_irqsave(&oper_cfg.vpss_lock, flags);
@@ -181,100 +241,221 @@ static int dm355_enable_clock(enum vpss_clock_sel clock_sel, int en)
181 return 0; 241 return 0;
182} 242}
183 243
244static int dm365_enable_clock(enum vpss_clock_sel clock_sel, int en)
245{
246 unsigned long flags;
247 u32 utemp, mask = 0x1, shift = 0, offset = DM365_ISP5_PCCR;
248 u32 (*read)(u32 offset) = isp5_read;
249 void(*write)(u32 val, u32 offset) = isp5_write;
250
251 switch (clock_sel) {
252 case VPSS_BL_CLOCK:
253 break;
254 case VPSS_CCDC_CLOCK:
255 shift = 1;
256 break;
257 case VPSS_H3A_CLOCK:
258 shift = 2;
259 break;
260 case VPSS_RSZ_CLOCK:
261 shift = 3;
262 break;
263 case VPSS_IPIPE_CLOCK:
264 shift = 4;
265 break;
266 case VPSS_IPIPEIF_CLOCK:
267 shift = 5;
268 break;
269 case VPSS_PCLK_INTERNAL:
270 shift = 6;
271 break;
272 case VPSS_PSYNC_CLOCK_SEL:
273 shift = 7;
274 break;
275 case VPSS_VPBE_CLOCK:
276 read = vpss_regr;
277 write = vpss_regw;
278 offset = DM365_VPBE_CLK_CTRL;
279 break;
280 case VPSS_VENC_CLOCK_SEL:
281 shift = 2;
282 read = vpss_regr;
283 write = vpss_regw;
284 offset = DM365_VPBE_CLK_CTRL;
285 break;
286 case VPSS_LDC_CLOCK:
287 shift = 3;
288 read = vpss_regr;
289 write = vpss_regw;
290 offset = DM365_VPBE_CLK_CTRL;
291 break;
292 case VPSS_FDIF_CLOCK:
293 shift = 4;
294 read = vpss_regr;
295 write = vpss_regw;
296 offset = DM365_VPBE_CLK_CTRL;
297 break;
298 case VPSS_OSD_CLOCK_SEL:
299 shift = 6;
300 read = vpss_regr;
301 write = vpss_regw;
302 offset = DM365_VPBE_CLK_CTRL;
303 break;
304 case VPSS_LDC_CLOCK_SEL:
305 shift = 7;
306 read = vpss_regr;
307 write = vpss_regw;
308 offset = DM365_VPBE_CLK_CTRL;
309 break;
310 default:
311 printk(KERN_ERR "dm365_enable_clock: Invalid selector: %d\n",
312 clock_sel);
313 return -1;
314 }
315
316 spin_lock_irqsave(&oper_cfg.vpss_lock, flags);
317 utemp = read(offset);
318 if (!en) {
319 mask = ~mask;
320 utemp &= (mask << shift);
321 } else
322 utemp |= (mask << shift);
323
324 write(utemp, offset);
325 spin_unlock_irqrestore(&oper_cfg.vpss_lock, flags);
326
327 return 0;
328}
329
184int vpss_enable_clock(enum vpss_clock_sel clock_sel, int en) 330int vpss_enable_clock(enum vpss_clock_sel clock_sel, int en)
185{ 331{
186 if (!oper_cfg.hw_ops.enable_clock) 332 if (!oper_cfg.hw_ops.enable_clock)
187 return -1; 333 return -EINVAL;
188 334
189 return oper_cfg.hw_ops.enable_clock(clock_sel, en); 335 return oper_cfg.hw_ops.enable_clock(clock_sel, en);
190} 336}
191EXPORT_SYMBOL(vpss_enable_clock); 337EXPORT_SYMBOL(vpss_enable_clock);
192 338
339void dm365_vpss_set_sync_pol(struct vpss_sync_pol sync)
340{
341 int val = 0;
342 val = isp5_read(DM365_ISP5_CCDCMUX);
343
344 val |= (sync.ccdpg_hdpol << DM365_CCDC_PG_HD_POL_SHIFT);
345 val |= (sync.ccdpg_vdpol << DM365_CCDC_PG_VD_POL_SHIFT);
346
347 isp5_write(val, DM365_ISP5_CCDCMUX);
348}
349EXPORT_SYMBOL(dm365_vpss_set_sync_pol);
350
351void dm365_vpss_set_pg_frame_size(struct vpss_pg_frame_size frame_size)
352{
353 int current_reg = ((frame_size.hlpfr >> 1) - 1) << 16;
354
355 current_reg |= (frame_size.pplen - 1);
356 isp5_write(current_reg, DM365_ISP5_PG_FRAME_SIZE);
357}
358EXPORT_SYMBOL(dm365_vpss_set_pg_frame_size);
359
193static int __init vpss_probe(struct platform_device *pdev) 360static int __init vpss_probe(struct platform_device *pdev)
194{ 361{
195 int status, dm355 = 0; 362 struct resource *r1, *r2;
363 char *platform_name;
364 int status;
196 365
197 if (!pdev->dev.platform_data) { 366 if (!pdev->dev.platform_data) {
198 dev_err(&pdev->dev, "no platform data\n"); 367 dev_err(&pdev->dev, "no platform data\n");
199 return -ENOENT; 368 return -ENOENT;
200 } 369 }
201 strcpy(oper_cfg.vpss_name, pdev->dev.platform_data);
202 370
203 if (!strcmp(oper_cfg.vpss_name, "dm355_vpss")) 371 platform_name = pdev->dev.platform_data;
204 dm355 = 1; 372 if (!strcmp(platform_name, "dm355_vpss"))
205 else if (strcmp(oper_cfg.vpss_name, "dm644x_vpss")) { 373 oper_cfg.platform = DM355;
374 else if (!strcmp(platform_name, "dm365_vpss"))
375 oper_cfg.platform = DM365;
376 else if (!strcmp(platform_name, "dm644x_vpss"))
377 oper_cfg.platform = DM644X;
378 else {
206 dev_err(&pdev->dev, "vpss driver not supported on" 379 dev_err(&pdev->dev, "vpss driver not supported on"
207 " this platform\n"); 380 " this platform\n");
208 return -ENODEV; 381 return -ENODEV;
209 } 382 }
210 383
211 dev_info(&pdev->dev, "%s vpss probed\n", oper_cfg.vpss_name); 384 dev_info(&pdev->dev, "%s vpss probed\n", platform_name);
212 oper_cfg.r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 385 r1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
213 if (!oper_cfg.r1) 386 if (!r1)
214 return -ENOENT; 387 return -ENOENT;
215 388
216 oper_cfg.len1 = oper_cfg.r1->end - oper_cfg.r1->start + 1; 389 r1 = request_mem_region(r1->start, resource_size(r1), r1->name);
217 390 if (!r1)
218 oper_cfg.r1 = request_mem_region(oper_cfg.r1->start, oper_cfg.len1,
219 oper_cfg.r1->name);
220 if (!oper_cfg.r1)
221 return -EBUSY; 391 return -EBUSY;
222 392
223 oper_cfg.vpss_bl_regs_base = ioremap(oper_cfg.r1->start, oper_cfg.len1); 393 oper_cfg.vpss_regs_base0 = ioremap(r1->start, resource_size(r1));
224 if (!oper_cfg.vpss_bl_regs_base) { 394 if (!oper_cfg.vpss_regs_base0) {
225 status = -EBUSY; 395 status = -EBUSY;
226 goto fail1; 396 goto fail1;
227 } 397 }
228 398
229 if (dm355) { 399 if (oper_cfg.platform == DM355 || oper_cfg.platform == DM365) {
230 oper_cfg.r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1); 400 r2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
231 if (!oper_cfg.r2) { 401 if (!r2) {
232 status = -ENOENT; 402 status = -ENOENT;
233 goto fail2; 403 goto fail2;
234 } 404 }
235 oper_cfg.len2 = oper_cfg.r2->end - oper_cfg.r2->start + 1; 405 r2 = request_mem_region(r2->start, resource_size(r2), r2->name);
236 oper_cfg.r2 = request_mem_region(oper_cfg.r2->start, 406 if (!r2) {
237 oper_cfg.len2,
238 oper_cfg.r2->name);
239 if (!oper_cfg.r2) {
240 status = -EBUSY; 407 status = -EBUSY;
241 goto fail2; 408 goto fail2;
242 } 409 }
243 410
244 oper_cfg.vpss_regs_base = ioremap(oper_cfg.r2->start, 411 oper_cfg.vpss_regs_base1 = ioremap(r2->start,
245 oper_cfg.len2); 412 resource_size(r2));
246 if (!oper_cfg.vpss_regs_base) { 413 if (!oper_cfg.vpss_regs_base1) {
247 status = -EBUSY; 414 status = -EBUSY;
248 goto fail3; 415 goto fail3;
249 } 416 }
250 } 417 }
251 418
252 if (dm355) { 419 if (oper_cfg.platform == DM355) {
253 oper_cfg.hw_ops.enable_clock = dm355_enable_clock; 420 oper_cfg.hw_ops.enable_clock = dm355_enable_clock;
254 oper_cfg.hw_ops.select_ccdc_source = dm355_select_ccdc_source; 421 oper_cfg.hw_ops.select_ccdc_source = dm355_select_ccdc_source;
422 /* Setup vpss interrupts */
423 bl_regw(DM355_VPSSBL_INTSEL_DEFAULT, DM355_VPSSBL_INTSEL);
424 bl_regw(DM355_VPSSBL_EVTSEL_DEFAULT, DM355_VPSSBL_EVTSEL);
425 } else if (oper_cfg.platform == DM365) {
426 oper_cfg.hw_ops.enable_clock = dm365_enable_clock;
427 oper_cfg.hw_ops.select_ccdc_source = dm365_select_ccdc_source;
428 /* Setup vpss interrupts */
429 isp5_write(DM365_ISP5_INTSEL1_DEFAULT, DM365_ISP5_INTSEL1);
430 isp5_write(DM365_ISP5_INTSEL2_DEFAULT, DM365_ISP5_INTSEL2);
431 isp5_write(DM365_ISP5_INTSEL3_DEFAULT, DM365_ISP5_INTSEL3);
255 } else 432 } else
256 oper_cfg.hw_ops.clear_wbl_overflow = dm644x_clear_wbl_overflow; 433 oper_cfg.hw_ops.clear_wbl_overflow = dm644x_clear_wbl_overflow;
257 434
258 spin_lock_init(&oper_cfg.vpss_lock); 435 spin_lock_init(&oper_cfg.vpss_lock);
259 dev_info(&pdev->dev, "%s vpss probe success\n", oper_cfg.vpss_name); 436 dev_info(&pdev->dev, "%s vpss probe success\n", platform_name);
260 return 0; 437 return 0;
261 438
262fail3: 439fail3:
263 release_mem_region(oper_cfg.r2->start, oper_cfg.len2); 440 release_mem_region(r2->start, resource_size(r2));
264fail2: 441fail2:
265 iounmap(oper_cfg.vpss_bl_regs_base); 442 iounmap(oper_cfg.vpss_regs_base0);
266fail1: 443fail1:
267 release_mem_region(oper_cfg.r1->start, oper_cfg.len1); 444 release_mem_region(r1->start, resource_size(r1));
268 return status; 445 return status;
269} 446}
270 447
271static int __devexit vpss_remove(struct platform_device *pdev) 448static int __devexit vpss_remove(struct platform_device *pdev)
272{ 449{
273 iounmap(oper_cfg.vpss_bl_regs_base); 450 struct resource *res;
274 release_mem_region(oper_cfg.r1->start, oper_cfg.len1); 451
275 if (!strcmp(oper_cfg.vpss_name, "dm355_vpss")) { 452 iounmap(oper_cfg.vpss_regs_base0);
276 iounmap(oper_cfg.vpss_regs_base); 453 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
277 release_mem_region(oper_cfg.r2->start, oper_cfg.len2); 454 release_mem_region(res->start, resource_size(res));
455 if (oper_cfg.platform == DM355 || oper_cfg.platform == DM365) {
456 iounmap(oper_cfg.vpss_regs_base1);
457 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
458 release_mem_region(res->start, resource_size(res));
278 } 459 }
279 return 0; 460 return 0;
280} 461}