2 * V4L2 Driver for SuperH Mobile CEU interface
4 * Copyright (C) 2008 Magnus Damm
6 * Based on V4L2 Driver for PXA camera host - "pxa_camera.c",
8 * Copyright (C) 2006, Sascha Hauer, Pengutronix
9 * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
17 #include <linux/init.h>
18 #include <linux/module.h>
20 #include <linux/delay.h>
21 #include <linux/dma-mapping.h>
22 #include <linux/errno.h>
24 #include <linux/interrupt.h>
25 #include <linux/kernel.h>
27 #include <linux/moduleparam.h>
28 #include <linux/time.h>
29 #include <linux/version.h>
30 #include <linux/device.h>
31 #include <linux/platform_device.h>
32 #include <linux/mutex.h>
33 #include <linux/videodev2.h>
34 #include <linux/clk.h>
36 #include <media/v4l2-common.h>
37 #include <media/v4l2-dev.h>
38 #include <media/soc_camera.h>
39 #include <media/sh_mobile_ceu.h>
40 #include <media/videobuf-dma-contig.h>
42 /* register offsets for sh7722 / sh7723 */
44 #define CAPSR 0x00 /* Capture start register */
45 #define CAPCR 0x04 /* Capture control register */
46 #define CAMCR 0x08 /* Capture interface control register */
47 #define CMCYR 0x0c /* Capture interface cycle register */
48 #define CAMOR 0x10 /* Capture interface offset register */
49 #define CAPWR 0x14 /* Capture interface width register */
50 #define CAIFR 0x18 /* Capture interface input format register */
51 #define CSTCR 0x20 /* Camera strobe control register (<= sh7722) */
52 #define CSECR 0x24 /* Camera strobe emission count register (<= sh7722) */
53 #define CRCNTR 0x28 /* CEU register control register */
54 #define CRCMPR 0x2c /* CEU register forcible control register */
55 #define CFLCR 0x30 /* Capture filter control register */
56 #define CFSZR 0x34 /* Capture filter size clip register */
57 #define CDWDR 0x38 /* Capture destination width register */
58 #define CDAYR 0x3c /* Capture data address Y register */
59 #define CDACR 0x40 /* Capture data address C register */
60 #define CDBYR 0x44 /* Capture data bottom-field address Y register */
61 #define CDBCR 0x48 /* Capture data bottom-field address C register */
62 #define CBDSR 0x4c /* Capture bundle destination size register */
63 #define CFWCR 0x5c /* Firewall operation control register */
64 #define CLFCR 0x60 /* Capture low-pass filter control register */
65 #define CDOCR 0x64 /* Capture data output control register */
66 #define CDDCR 0x68 /* Capture data complexity level register */
67 #define CDDAR 0x6c /* Capture data complexity level address register */
68 #define CEIER 0x70 /* Capture event interrupt enable register */
69 #define CETCR 0x74 /* Capture event flag clear register */
70 #define CSTSR 0x7c /* Capture status register */
71 #define CSRTR 0x80 /* Capture software reset register */
72 #define CDSSR 0x84 /* Capture data size register */
73 #define CDAYR2 0x90 /* Capture data address Y register 2 */
74 #define CDACR2 0x94 /* Capture data address C register 2 */
75 #define CDBYR2 0x98 /* Capture data bottom-field address Y register 2 */
76 #define CDBCR2 0x9c /* Capture data bottom-field address C register 2 */
78 static DEFINE_MUTEX(camera_lock
);
80 /* per video frame buffer */
81 struct sh_mobile_ceu_buffer
{
82 struct videobuf_buffer vb
; /* v4l buffer must be first */
83 const struct soc_camera_data_format
*fmt
;
86 struct sh_mobile_ceu_dev
{
88 struct soc_camera_host ici
;
89 struct soc_camera_device
*icd
;
94 unsigned long video_limit
;
96 /* lock used to protect videobuf */
98 struct list_head capture
;
99 struct videobuf_buffer
*active
;
101 struct sh_mobile_ceu_info
*pdata
;
104 static void ceu_write(struct sh_mobile_ceu_dev
*priv
,
105 unsigned long reg_offs
, unsigned long data
)
107 iowrite32(data
, priv
->base
+ reg_offs
);
110 static unsigned long ceu_read(struct sh_mobile_ceu_dev
*priv
,
111 unsigned long reg_offs
)
113 return ioread32(priv
->base
+ reg_offs
);
117 * Videobuf operations
119 static int sh_mobile_ceu_videobuf_setup(struct videobuf_queue
*vq
,
123 struct soc_camera_device
*icd
= vq
->priv_data
;
124 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
125 struct sh_mobile_ceu_dev
*pcdev
= ici
->priv
;
126 int bytes_per_pixel
= (icd
->current_fmt
->depth
+ 7) >> 3;
128 *size
= PAGE_ALIGN(icd
->width
* icd
->height
* bytes_per_pixel
);
133 if (pcdev
->video_limit
) {
134 while (*size
* *count
> pcdev
->video_limit
)
138 dev_dbg(&icd
->dev
, "count=%d, size=%d\n", *count
, *size
);
143 static void free_buffer(struct videobuf_queue
*vq
,
144 struct sh_mobile_ceu_buffer
*buf
)
146 struct soc_camera_device
*icd
= vq
->priv_data
;
148 dev_dbg(&icd
->dev
, "%s (vb=0x%p) 0x%08lx %zd\n", __func__
,
149 &buf
->vb
, buf
->vb
.baddr
, buf
->vb
.bsize
);
154 videobuf_dma_contig_free(vq
, &buf
->vb
);
155 dev_dbg(&icd
->dev
, "%s freed\n", __func__
);
156 buf
->vb
.state
= VIDEOBUF_NEEDS_INIT
;
159 static void sh_mobile_ceu_capture(struct sh_mobile_ceu_dev
*pcdev
)
161 ceu_write(pcdev
, CEIER
, ceu_read(pcdev
, CEIER
) & ~1);
162 ceu_write(pcdev
, CETCR
, ~ceu_read(pcdev
, CETCR
) & 0x0317f313);
163 ceu_write(pcdev
, CEIER
, ceu_read(pcdev
, CEIER
) | 1);
165 ceu_write(pcdev
, CAPCR
, ceu_read(pcdev
, CAPCR
) & ~0x10000);
167 ceu_write(pcdev
, CETCR
, 0x0317f313 ^ 0x10);
170 pcdev
->active
->state
= VIDEOBUF_ACTIVE
;
171 ceu_write(pcdev
, CDAYR
, videobuf_to_dma_contig(pcdev
->active
));
172 ceu_write(pcdev
, CAPSR
, 0x1); /* start capture */
176 static int sh_mobile_ceu_videobuf_prepare(struct videobuf_queue
*vq
,
177 struct videobuf_buffer
*vb
,
178 enum v4l2_field field
)
180 struct soc_camera_device
*icd
= vq
->priv_data
;
181 struct sh_mobile_ceu_buffer
*buf
;
184 buf
= container_of(vb
, struct sh_mobile_ceu_buffer
, vb
);
186 dev_dbg(&icd
->dev
, "%s (vb=0x%p) 0x%08lx %zd\n", __func__
,
187 vb
, vb
->baddr
, vb
->bsize
);
189 /* Added list head initialization on alloc */
190 WARN_ON(!list_empty(&vb
->queue
));
193 /* This can be useful if you want to see if we actually fill
194 * the buffer with something */
195 memset((void *)vb
->baddr
, 0xaa, vb
->bsize
);
198 BUG_ON(NULL
== icd
->current_fmt
);
200 if (buf
->fmt
!= icd
->current_fmt
||
201 vb
->width
!= icd
->width
||
202 vb
->height
!= icd
->height
||
203 vb
->field
!= field
) {
204 buf
->fmt
= icd
->current_fmt
;
205 vb
->width
= icd
->width
;
206 vb
->height
= icd
->height
;
208 vb
->state
= VIDEOBUF_NEEDS_INIT
;
211 vb
->size
= vb
->width
* vb
->height
* ((buf
->fmt
->depth
+ 7) >> 3);
212 if (0 != vb
->baddr
&& vb
->bsize
< vb
->size
) {
217 if (vb
->state
== VIDEOBUF_NEEDS_INIT
) {
218 ret
= videobuf_iolock(vq
, vb
, NULL
);
221 vb
->state
= VIDEOBUF_PREPARED
;
226 free_buffer(vq
, buf
);
231 static void sh_mobile_ceu_videobuf_queue(struct videobuf_queue
*vq
,
232 struct videobuf_buffer
*vb
)
234 struct soc_camera_device
*icd
= vq
->priv_data
;
235 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
236 struct sh_mobile_ceu_dev
*pcdev
= ici
->priv
;
239 dev_dbg(&icd
->dev
, "%s (vb=0x%p) 0x%08lx %zd\n", __func__
,
240 vb
, vb
->baddr
, vb
->bsize
);
242 vb
->state
= VIDEOBUF_QUEUED
;
243 spin_lock_irqsave(&pcdev
->lock
, flags
);
244 list_add_tail(&vb
->queue
, &pcdev
->capture
);
246 if (!pcdev
->active
) {
248 sh_mobile_ceu_capture(pcdev
);
251 spin_unlock_irqrestore(&pcdev
->lock
, flags
);
254 static void sh_mobile_ceu_videobuf_release(struct videobuf_queue
*vq
,
255 struct videobuf_buffer
*vb
)
257 free_buffer(vq
, container_of(vb
, struct sh_mobile_ceu_buffer
, vb
));
260 static struct videobuf_queue_ops sh_mobile_ceu_videobuf_ops
= {
261 .buf_setup
= sh_mobile_ceu_videobuf_setup
,
262 .buf_prepare
= sh_mobile_ceu_videobuf_prepare
,
263 .buf_queue
= sh_mobile_ceu_videobuf_queue
,
264 .buf_release
= sh_mobile_ceu_videobuf_release
,
267 static irqreturn_t
sh_mobile_ceu_irq(int irq
, void *data
)
269 struct sh_mobile_ceu_dev
*pcdev
= data
;
270 struct videobuf_buffer
*vb
;
273 spin_lock_irqsave(&pcdev
->lock
, flags
);
276 list_del_init(&vb
->queue
);
278 if (!list_empty(&pcdev
->capture
))
279 pcdev
->active
= list_entry(pcdev
->capture
.next
,
280 struct videobuf_buffer
, queue
);
282 pcdev
->active
= NULL
;
284 sh_mobile_ceu_capture(pcdev
);
286 vb
->state
= VIDEOBUF_DONE
;
287 do_gettimeofday(&vb
->ts
);
290 spin_unlock_irqrestore(&pcdev
->lock
, flags
);
295 static int sh_mobile_ceu_add_device(struct soc_camera_device
*icd
)
297 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
298 struct sh_mobile_ceu_dev
*pcdev
= ici
->priv
;
301 mutex_lock(&camera_lock
);
307 "SuperH Mobile CEU driver attached to camera %d\n",
310 ret
= icd
->ops
->init(icd
);
314 clk_enable(pcdev
->clk
);
316 ceu_write(pcdev
, CAPSR
, 1 << 16); /* reset */
317 while (ceu_read(pcdev
, CSTSR
) & 1)
322 mutex_unlock(&camera_lock
);
327 static void sh_mobile_ceu_remove_device(struct soc_camera_device
*icd
)
329 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
330 struct sh_mobile_ceu_dev
*pcdev
= ici
->priv
;
333 BUG_ON(icd
!= pcdev
->icd
);
335 /* disable capture, disable interrupts */
336 ceu_write(pcdev
, CEIER
, 0);
337 ceu_write(pcdev
, CAPSR
, 1 << 16); /* reset */
339 /* make sure active buffer is canceled */
340 spin_lock_irqsave(&pcdev
->lock
, flags
);
342 list_del(&pcdev
->active
->queue
);
343 pcdev
->active
->state
= VIDEOBUF_ERROR
;
344 wake_up_all(&pcdev
->active
->done
);
345 pcdev
->active
= NULL
;
347 spin_unlock_irqrestore(&pcdev
->lock
, flags
);
349 clk_disable(pcdev
->clk
);
351 icd
->ops
->release(icd
);
354 "SuperH Mobile CEU driver detached from camera %d\n",
360 static int sh_mobile_ceu_set_bus_param(struct soc_camera_device
*icd
,
363 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
364 struct sh_mobile_ceu_dev
*pcdev
= ici
->priv
;
365 int ret
, buswidth
, width
, cfszr_width
, cdwdr_width
;
366 unsigned long camera_flags
, common_flags
, value
;
368 camera_flags
= icd
->ops
->query_bus_param(icd
);
369 common_flags
= soc_camera_bus_param_compatible(camera_flags
,
370 pcdev
->pdata
->flags
);
374 ret
= icd
->ops
->set_bus_param(icd
, common_flags
);
378 switch (common_flags
& SOCAM_DATAWIDTH_MASK
) {
379 case SOCAM_DATAWIDTH_8
:
382 case SOCAM_DATAWIDTH_16
:
389 ceu_write(pcdev
, CRCNTR
, 0);
390 ceu_write(pcdev
, CRCMPR
, 0);
393 value
|= (common_flags
& SOCAM_VSYNC_ACTIVE_LOW
) ? (1 << 1) : 0;
394 value
|= (common_flags
& SOCAM_HSYNC_ACTIVE_LOW
) ? (1 << 0) : 0;
395 value
|= (buswidth
== 16) ? (1 << 12) : 0;
396 ceu_write(pcdev
, CAMCR
, value
);
398 ceu_write(pcdev
, CAPCR
, 0x00300000);
399 ceu_write(pcdev
, CAIFR
, 0);
403 width
= icd
->width
* (icd
->current_fmt
->depth
/ 8);
404 width
= (buswidth
== 16) ? width
/ 2 : width
;
405 cfszr_width
= (buswidth
== 8) ? width
/ 2 : width
;
406 cdwdr_width
= (buswidth
== 16) ? width
* 2 : width
;
408 ceu_write(pcdev
, CAMOR
, 0);
409 ceu_write(pcdev
, CAPWR
, (icd
->height
<< 16) | width
);
410 ceu_write(pcdev
, CFLCR
, 0); /* data fetch mode - no scaling */
411 ceu_write(pcdev
, CFSZR
, (icd
->height
<< 16) | cfszr_width
);
412 ceu_write(pcdev
, CLFCR
, 0); /* data fetch mode - no lowpass filter */
414 /* A few words about byte order (observed in Big Endian mode)
416 * In data fetch mode bytes are received in chunks of 8 bytes.
417 * D0, D1, D2, D3, D4, D5, D6, D7 (D0 received first)
419 * The data is however by default written to memory in reverse order:
420 * D7, D6, D5, D4, D3, D2, D1, D0 (D7 written to lowest byte)
422 * The lowest three bits of CDOCR allows us to do swapping,
423 * using 7 we swap the data bytes to match the incoming order:
424 * D0, D1, D2, D3, D4, D5, D6, D7
426 ceu_write(pcdev
, CDOCR
, 0x00000017);
428 ceu_write(pcdev
, CDWDR
, cdwdr_width
);
429 ceu_write(pcdev
, CFWCR
, 0); /* keep "datafetch firewall" disabled */
431 /* not in bundle mode: skip CBDSR, CDAYR2, CDACR2, CDBYR2, CDBCR2 */
432 /* in data fetch mode: no need for CDACR, CDBYR, CDBCR */
437 static int sh_mobile_ceu_try_bus_param(struct soc_camera_device
*icd
)
439 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
440 struct sh_mobile_ceu_dev
*pcdev
= ici
->priv
;
441 unsigned long camera_flags
, common_flags
;
443 camera_flags
= icd
->ops
->query_bus_param(icd
);
444 common_flags
= soc_camera_bus_param_compatible(camera_flags
,
445 pcdev
->pdata
->flags
);
452 static int sh_mobile_ceu_get_formats(struct soc_camera_device
*icd
, int idx
,
453 struct soc_camera_format_xlate
*xlate
)
455 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
459 ret
= sh_mobile_ceu_try_bus_param(icd
);
463 switch (icd
->formats
[idx
].fourcc
) {
465 /* Generic pass-through */
468 xlate
->host_fmt
= icd
->formats
+ idx
;
469 xlate
->cam_fmt
= icd
->formats
+ idx
;
470 xlate
->buswidth
= icd
->formats
[idx
].depth
;
473 "Providing format %s in pass-through mode\n",
474 icd
->formats
[idx
].name
);
481 static int sh_mobile_ceu_set_fmt(struct soc_camera_device
*icd
,
482 __u32 pixfmt
, struct v4l2_rect
*rect
)
484 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
485 const struct soc_camera_format_xlate
*xlate
;
488 xlate
= soc_camera_xlate_by_fourcc(icd
, pixfmt
);
490 dev_warn(&ici
->dev
, "Format %x not found\n", pixfmt
);
495 case 0: /* Only geometry change */
496 ret
= icd
->ops
->set_fmt(icd
, pixfmt
, rect
);
499 ret
= icd
->ops
->set_fmt(icd
, xlate
->cam_fmt
->fourcc
, rect
);
502 if (pixfmt
&& !ret
) {
503 icd
->buswidth
= xlate
->buswidth
;
504 icd
->current_fmt
= xlate
->host_fmt
;
510 static int sh_mobile_ceu_try_fmt(struct soc_camera_device
*icd
,
511 struct v4l2_format
*f
)
513 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
514 const struct soc_camera_format_xlate
*xlate
;
515 __u32 pixfmt
= f
->fmt
.pix
.pixelformat
;
517 xlate
= soc_camera_xlate_by_fourcc(icd
, pixfmt
);
519 dev_warn(&ici
->dev
, "Format %x not found\n", pixfmt
);
523 /* FIXME: calculate using depth and bus width */
525 if (f
->fmt
.pix
.height
< 4)
526 f
->fmt
.pix
.height
= 4;
527 if (f
->fmt
.pix
.height
> 1920)
528 f
->fmt
.pix
.height
= 1920;
529 if (f
->fmt
.pix
.width
< 2)
530 f
->fmt
.pix
.width
= 2;
531 if (f
->fmt
.pix
.width
> 2560)
532 f
->fmt
.pix
.width
= 2560;
533 f
->fmt
.pix
.width
&= ~0x01;
534 f
->fmt
.pix
.height
&= ~0x03;
536 f
->fmt
.pix
.bytesperline
= f
->fmt
.pix
.width
*
537 DIV_ROUND_UP(xlate
->host_fmt
->depth
, 8);
538 f
->fmt
.pix
.sizeimage
= f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
540 /* limit to sensor capabilities */
541 return icd
->ops
->try_fmt(icd
, f
);
544 static int sh_mobile_ceu_reqbufs(struct soc_camera_file
*icf
,
545 struct v4l2_requestbuffers
*p
)
549 /* This is for locking debugging only. I removed spinlocks and now I
550 * check whether .prepare is ever called on a linked buffer, or whether
551 * a dma IRQ can occur for an in-work or unlinked buffer. Until now
552 * it hadn't triggered */
553 for (i
= 0; i
< p
->count
; i
++) {
554 struct sh_mobile_ceu_buffer
*buf
;
556 buf
= container_of(icf
->vb_vidq
.bufs
[i
],
557 struct sh_mobile_ceu_buffer
, vb
);
558 INIT_LIST_HEAD(&buf
->vb
.queue
);
564 static unsigned int sh_mobile_ceu_poll(struct file
*file
, poll_table
*pt
)
566 struct soc_camera_file
*icf
= file
->private_data
;
567 struct sh_mobile_ceu_buffer
*buf
;
569 buf
= list_entry(icf
->vb_vidq
.stream
.next
,
570 struct sh_mobile_ceu_buffer
, vb
.stream
);
572 poll_wait(file
, &buf
->vb
.done
, pt
);
574 if (buf
->vb
.state
== VIDEOBUF_DONE
||
575 buf
->vb
.state
== VIDEOBUF_ERROR
)
576 return POLLIN
|POLLRDNORM
;
581 static int sh_mobile_ceu_querycap(struct soc_camera_host
*ici
,
582 struct v4l2_capability
*cap
)
584 strlcpy(cap
->card
, "SuperH_Mobile_CEU", sizeof(cap
->card
));
585 cap
->version
= KERNEL_VERSION(0, 0, 5);
586 cap
->capabilities
= V4L2_CAP_VIDEO_CAPTURE
| V4L2_CAP_STREAMING
;
590 static void sh_mobile_ceu_init_videobuf(struct videobuf_queue
*q
,
591 struct soc_camera_device
*icd
)
593 struct soc_camera_host
*ici
= to_soc_camera_host(icd
->dev
.parent
);
594 struct sh_mobile_ceu_dev
*pcdev
= ici
->priv
;
596 videobuf_queue_dma_contig_init(q
,
597 &sh_mobile_ceu_videobuf_ops
,
598 &ici
->dev
, &pcdev
->lock
,
599 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
601 sizeof(struct sh_mobile_ceu_buffer
),
605 static struct soc_camera_host_ops sh_mobile_ceu_host_ops
= {
606 .owner
= THIS_MODULE
,
607 .add
= sh_mobile_ceu_add_device
,
608 .remove
= sh_mobile_ceu_remove_device
,
609 .get_formats
= sh_mobile_ceu_get_formats
,
610 .set_fmt
= sh_mobile_ceu_set_fmt
,
611 .try_fmt
= sh_mobile_ceu_try_fmt
,
612 .reqbufs
= sh_mobile_ceu_reqbufs
,
613 .poll
= sh_mobile_ceu_poll
,
614 .querycap
= sh_mobile_ceu_querycap
,
615 .set_bus_param
= sh_mobile_ceu_set_bus_param
,
616 .init_videobuf
= sh_mobile_ceu_init_videobuf
,
619 static int sh_mobile_ceu_probe(struct platform_device
*pdev
)
621 struct sh_mobile_ceu_dev
*pcdev
;
622 struct resource
*res
;
628 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
629 irq
= platform_get_irq(pdev
, 0);
631 dev_err(&pdev
->dev
, "Not enough CEU platform resources.\n");
636 pcdev
= kzalloc(sizeof(*pcdev
), GFP_KERNEL
);
638 dev_err(&pdev
->dev
, "Could not allocate pcdev\n");
643 platform_set_drvdata(pdev
, pcdev
);
644 INIT_LIST_HEAD(&pcdev
->capture
);
645 spin_lock_init(&pcdev
->lock
);
647 pcdev
->pdata
= pdev
->dev
.platform_data
;
650 dev_err(&pdev
->dev
, "CEU platform data not set.\n");
654 base
= ioremap_nocache(res
->start
, res
->end
- res
->start
+ 1);
657 dev_err(&pdev
->dev
, "Unable to ioremap CEU registers.\n");
663 pcdev
->video_limit
= 0; /* only enabled if second resource exists */
664 pcdev
->dev
= &pdev
->dev
;
666 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 1);
668 err
= dma_declare_coherent_memory(&pdev
->dev
, res
->start
,
670 (res
->end
- res
->start
) + 1,
672 DMA_MEMORY_EXCLUSIVE
);
674 dev_err(&pdev
->dev
, "Unable to declare CEU memory.\n");
679 pcdev
->video_limit
= (res
->end
- res
->start
) + 1;
683 err
= request_irq(pcdev
->irq
, sh_mobile_ceu_irq
, IRQF_DISABLED
,
684 dev_name(&pdev
->dev
), pcdev
);
686 dev_err(&pdev
->dev
, "Unable to register CEU interrupt.\n");
687 goto exit_release_mem
;
690 snprintf(clk_name
, sizeof(clk_name
), "ceu%d", pdev
->id
);
691 pcdev
->clk
= clk_get(&pdev
->dev
, clk_name
);
692 if (IS_ERR(pcdev
->clk
)) {
693 dev_err(&pdev
->dev
, "cannot get clock \"%s\"\n", clk_name
);
694 err
= PTR_ERR(pcdev
->clk
);
698 pcdev
->ici
.priv
= pcdev
;
699 pcdev
->ici
.dev
.parent
= &pdev
->dev
;
700 pcdev
->ici
.nr
= pdev
->id
;
701 pcdev
->ici
.drv_name
= dev_name(&pdev
->dev
);
702 pcdev
->ici
.ops
= &sh_mobile_ceu_host_ops
;
704 err
= soc_camera_host_register(&pcdev
->ici
);
713 free_irq(pcdev
->irq
, pcdev
);
715 if (platform_get_resource(pdev
, IORESOURCE_MEM
, 1))
716 dma_release_declared_memory(&pdev
->dev
);
725 static int sh_mobile_ceu_remove(struct platform_device
*pdev
)
727 struct sh_mobile_ceu_dev
*pcdev
= platform_get_drvdata(pdev
);
729 soc_camera_host_unregister(&pcdev
->ici
);
731 free_irq(pcdev
->irq
, pcdev
);
732 if (platform_get_resource(pdev
, IORESOURCE_MEM
, 1))
733 dma_release_declared_memory(&pdev
->dev
);
734 iounmap(pcdev
->base
);
739 static struct platform_driver sh_mobile_ceu_driver
= {
741 .name
= "sh_mobile_ceu",
743 .probe
= sh_mobile_ceu_probe
,
744 .remove
= sh_mobile_ceu_remove
,
747 static int __init
sh_mobile_ceu_init(void)
749 return platform_driver_register(&sh_mobile_ceu_driver
);
752 static void __exit
sh_mobile_ceu_exit(void)
754 platform_driver_unregister(&sh_mobile_ceu_driver
);
757 module_init(sh_mobile_ceu_init
);
758 module_exit(sh_mobile_ceu_exit
);
760 MODULE_DESCRIPTION("SuperH Mobile CEU driver");
761 MODULE_AUTHOR("Magnus Damm");
762 MODULE_LICENSE("GPL");