]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - drivers/media/video/mx3_camera.c
de7ebfbf03974e1a6c953aee26287be3637ae273
[mirror_ubuntu-bionic-kernel.git] / drivers / media / video / mx3_camera.c
1 /*
2 * V4L2 Driver for i.MX3x camera host
3 *
4 * Copyright (C) 2008
5 * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 #include <linux/init.h>
13 #include <linux/module.h>
14 #include <linux/version.h>
15 #include <linux/videodev2.h>
16 #include <linux/platform_device.h>
17 #include <linux/clk.h>
18 #include <linux/vmalloc.h>
19 #include <linux/interrupt.h>
20
21 #include <media/v4l2-common.h>
22 #include <media/v4l2-dev.h>
23 #include <media/videobuf-dma-contig.h>
24 #include <media/soc_camera.h>
25
26 #include <mach/ipu.h>
27 #include <mach/mx3_camera.h>
28
29 #define MX3_CAM_DRV_NAME "mx3-camera"
30
31 /* CMOS Sensor Interface Registers */
32 #define CSI_REG_START 0x60
33
34 #define CSI_SENS_CONF (0x60 - CSI_REG_START)
35 #define CSI_SENS_FRM_SIZE (0x64 - CSI_REG_START)
36 #define CSI_ACT_FRM_SIZE (0x68 - CSI_REG_START)
37 #define CSI_OUT_FRM_CTRL (0x6C - CSI_REG_START)
38 #define CSI_TST_CTRL (0x70 - CSI_REG_START)
39 #define CSI_CCIR_CODE_1 (0x74 - CSI_REG_START)
40 #define CSI_CCIR_CODE_2 (0x78 - CSI_REG_START)
41 #define CSI_CCIR_CODE_3 (0x7C - CSI_REG_START)
42 #define CSI_FLASH_STROBE_1 (0x80 - CSI_REG_START)
43 #define CSI_FLASH_STROBE_2 (0x84 - CSI_REG_START)
44
45 #define CSI_SENS_CONF_VSYNC_POL_SHIFT 0
46 #define CSI_SENS_CONF_HSYNC_POL_SHIFT 1
47 #define CSI_SENS_CONF_DATA_POL_SHIFT 2
48 #define CSI_SENS_CONF_PIX_CLK_POL_SHIFT 3
49 #define CSI_SENS_CONF_SENS_PRTCL_SHIFT 4
50 #define CSI_SENS_CONF_SENS_CLKSRC_SHIFT 7
51 #define CSI_SENS_CONF_DATA_FMT_SHIFT 8
52 #define CSI_SENS_CONF_DATA_WIDTH_SHIFT 10
53 #define CSI_SENS_CONF_EXT_VSYNC_SHIFT 15
54 #define CSI_SENS_CONF_DIVRATIO_SHIFT 16
55
56 #define CSI_SENS_CONF_DATA_FMT_RGB_YUV444 (0UL << CSI_SENS_CONF_DATA_FMT_SHIFT)
57 #define CSI_SENS_CONF_DATA_FMT_YUV422 (2UL << CSI_SENS_CONF_DATA_FMT_SHIFT)
58 #define CSI_SENS_CONF_DATA_FMT_BAYER (3UL << CSI_SENS_CONF_DATA_FMT_SHIFT)
59
60 #define MAX_VIDEO_MEM 16
61
62 struct mx3_camera_buffer {
63 /* common v4l buffer stuff -- must be first */
64 struct videobuf_buffer vb;
65 const struct soc_camera_data_format *fmt;
66
67 /* One descriptot per scatterlist (per frame) */
68 struct dma_async_tx_descriptor *txd;
69
70 /* We have to "build" a scatterlist ourselves - one element per frame */
71 struct scatterlist sg;
72 };
73
74 /**
75 * struct mx3_camera_dev - i.MX3x camera (CSI) object
76 * @dev: camera device, to which the coherent buffer is attached
77 * @icd: currently attached camera sensor
78 * @clk: pointer to clock
79 * @base: remapped register base address
80 * @pdata: platform data
81 * @platform_flags: platform flags
82 * @mclk: master clock frequency in Hz
83 * @capture: list of capture videobuffers
84 * @lock: protects video buffer lists
85 * @active: active video buffer
86 * @idmac_channel: array of pointers to IPU DMAC DMA channels
87 * @soc_host: embedded soc_host object
88 */
89 struct mx3_camera_dev {
90 /*
91 * i.MX3x is only supposed to handle one camera on its Camera Sensor
92 * Interface. If anyone ever builds hardware to enable more than one
93 * camera _simultaneously_, they will have to modify this driver too
94 */
95 struct soc_camera_device *icd;
96 struct clk *clk;
97
98 void __iomem *base;
99
100 struct mx3_camera_pdata *pdata;
101
102 unsigned long platform_flags;
103 unsigned long mclk;
104
105 struct list_head capture;
106 spinlock_t lock; /* Protects video buffer lists */
107 struct mx3_camera_buffer *active;
108
109 /* IDMAC / dmaengine interface */
110 struct idmac_channel *idmac_channel[1]; /* We need one channel */
111
112 struct soc_camera_host soc_host;
113 };
114
115 struct dma_chan_request {
116 struct mx3_camera_dev *mx3_cam;
117 enum ipu_channel id;
118 };
119
120 static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt);
121
122 static u32 csi_reg_read(struct mx3_camera_dev *mx3, off_t reg)
123 {
124 return __raw_readl(mx3->base + reg);
125 }
126
127 static void csi_reg_write(struct mx3_camera_dev *mx3, u32 value, off_t reg)
128 {
129 __raw_writel(value, mx3->base + reg);
130 }
131
132 /* Called from the IPU IDMAC ISR */
133 static void mx3_cam_dma_done(void *arg)
134 {
135 struct idmac_tx_desc *desc = to_tx_desc(arg);
136 struct dma_chan *chan = desc->txd.chan;
137 struct idmac_channel *ichannel = to_idmac_chan(chan);
138 struct mx3_camera_dev *mx3_cam = ichannel->client;
139 struct videobuf_buffer *vb;
140
141 dev_dbg(chan->device->dev, "callback cookie %d, active DMA 0x%08x\n",
142 desc->txd.cookie, mx3_cam->active ? sg_dma_address(&mx3_cam->active->sg) : 0);
143
144 spin_lock(&mx3_cam->lock);
145 if (mx3_cam->active) {
146 vb = &mx3_cam->active->vb;
147
148 list_del_init(&vb->queue);
149 vb->state = VIDEOBUF_DONE;
150 do_gettimeofday(&vb->ts);
151 vb->field_count++;
152 wake_up(&vb->done);
153 }
154
155 if (list_empty(&mx3_cam->capture)) {
156 mx3_cam->active = NULL;
157 spin_unlock(&mx3_cam->lock);
158
159 /*
160 * stop capture - without further buffers IPU_CHA_BUF0_RDY will
161 * not get updated
162 */
163 return;
164 }
165
166 mx3_cam->active = list_entry(mx3_cam->capture.next,
167 struct mx3_camera_buffer, vb.queue);
168 mx3_cam->active->vb.state = VIDEOBUF_ACTIVE;
169 spin_unlock(&mx3_cam->lock);
170 }
171
172 static void free_buffer(struct videobuf_queue *vq, struct mx3_camera_buffer *buf)
173 {
174 struct soc_camera_device *icd = vq->priv_data;
175 struct videobuf_buffer *vb = &buf->vb;
176 struct dma_async_tx_descriptor *txd = buf->txd;
177 struct idmac_channel *ichan;
178
179 BUG_ON(in_interrupt());
180
181 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
182 vb, vb->baddr, vb->bsize);
183
184 /*
185 * This waits until this buffer is out of danger, i.e., until it is no
186 * longer in STATE_QUEUED or STATE_ACTIVE
187 */
188 videobuf_waiton(vb, 0, 0);
189 if (txd) {
190 ichan = to_idmac_chan(txd->chan);
191 async_tx_ack(txd);
192 }
193 videobuf_dma_contig_free(vq, vb);
194 buf->txd = NULL;
195
196 vb->state = VIDEOBUF_NEEDS_INIT;
197 }
198
199 /*
200 * Videobuf operations
201 */
202
203 /*
204 * Calculate the __buffer__ (not data) size and number of buffers.
205 * Called with .vb_lock held
206 */
207 static int mx3_videobuf_setup(struct videobuf_queue *vq, unsigned int *count,
208 unsigned int *size)
209 {
210 struct soc_camera_device *icd = vq->priv_data;
211 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
212 struct mx3_camera_dev *mx3_cam = ici->priv;
213 /*
214 * bits-per-pixel (depth) as specified in camera's pixel format does
215 * not necessarily match what the camera interface writes to RAM, but
216 * it should be good enough for now.
217 */
218 unsigned int bpp = DIV_ROUND_UP(icd->current_fmt->depth, 8);
219
220 if (!mx3_cam->idmac_channel[0])
221 return -EINVAL;
222
223 *size = icd->rect_current.width * icd->rect_current.height * bpp;
224
225 if (!*count)
226 *count = 32;
227
228 if (*size * *count > MAX_VIDEO_MEM * 1024 * 1024)
229 *count = MAX_VIDEO_MEM * 1024 * 1024 / *size;
230
231 return 0;
232 }
233
234 /* Called with .vb_lock held */
235 static int mx3_videobuf_prepare(struct videobuf_queue *vq,
236 struct videobuf_buffer *vb, enum v4l2_field field)
237 {
238 struct soc_camera_device *icd = vq->priv_data;
239 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
240 struct mx3_camera_dev *mx3_cam = ici->priv;
241 struct mx3_camera_buffer *buf =
242 container_of(vb, struct mx3_camera_buffer, vb);
243 /* current_fmt _must_ always be set */
244 size_t new_size = icd->rect_current.width * icd->rect_current.height *
245 ((icd->current_fmt->depth + 7) >> 3);
246 int ret;
247
248 /*
249 * I think, in buf_prepare you only have to protect global data,
250 * the actual buffer is yours
251 */
252
253 if (buf->fmt != icd->current_fmt ||
254 vb->width != icd->rect_current.width ||
255 vb->height != icd->rect_current.height ||
256 vb->field != field) {
257 buf->fmt = icd->current_fmt;
258 vb->width = icd->rect_current.width;
259 vb->height = icd->rect_current.height;
260 vb->field = field;
261 if (vb->state != VIDEOBUF_NEEDS_INIT)
262 free_buffer(vq, buf);
263 }
264
265 if (vb->baddr && vb->bsize < new_size) {
266 /* User provided buffer, but it is too small */
267 ret = -ENOMEM;
268 goto out;
269 }
270
271 if (vb->state == VIDEOBUF_NEEDS_INIT) {
272 struct idmac_channel *ichan = mx3_cam->idmac_channel[0];
273 struct scatterlist *sg = &buf->sg;
274
275 /*
276 * The total size of video-buffers that will be allocated / mapped.
277 * *size that we calculated in videobuf_setup gets assigned to
278 * vb->bsize, and now we use the same calculation to get vb->size.
279 */
280 vb->size = new_size;
281
282 /* This actually (allocates and) maps buffers */
283 ret = videobuf_iolock(vq, vb, NULL);
284 if (ret)
285 goto fail;
286
287 /*
288 * We will have to configure the IDMAC channel. It has two slots
289 * for DMA buffers, we shall enter the first two buffers there,
290 * and then submit new buffers in DMA-ready interrupts
291 */
292 sg_init_table(sg, 1);
293 sg_dma_address(sg) = videobuf_to_dma_contig(vb);
294 sg_dma_len(sg) = vb->size;
295
296 buf->txd = ichan->dma_chan.device->device_prep_slave_sg(
297 &ichan->dma_chan, sg, 1, DMA_FROM_DEVICE,
298 DMA_PREP_INTERRUPT);
299 if (!buf->txd) {
300 ret = -EIO;
301 goto fail;
302 }
303
304 buf->txd->callback_param = buf->txd;
305 buf->txd->callback = mx3_cam_dma_done;
306
307 vb->state = VIDEOBUF_PREPARED;
308 }
309
310 return 0;
311
312 fail:
313 free_buffer(vq, buf);
314 out:
315 return ret;
316 }
317
318 static enum pixel_fmt fourcc_to_ipu_pix(__u32 fourcc)
319 {
320 /* Add more formats as need arises and test possibilities appear... */
321 switch (fourcc) {
322 case V4L2_PIX_FMT_RGB565:
323 return IPU_PIX_FMT_RGB565;
324 case V4L2_PIX_FMT_RGB24:
325 return IPU_PIX_FMT_RGB24;
326 case V4L2_PIX_FMT_RGB332:
327 return IPU_PIX_FMT_RGB332;
328 case V4L2_PIX_FMT_YUV422P:
329 return IPU_PIX_FMT_YVU422P;
330 default:
331 return IPU_PIX_FMT_GENERIC;
332 }
333 }
334
335 /*
336 * Called with .vb_lock mutex held and
337 * under spinlock_irqsave(&mx3_cam->lock, ...)
338 */
339 static void mx3_videobuf_queue(struct videobuf_queue *vq,
340 struct videobuf_buffer *vb)
341 {
342 struct soc_camera_device *icd = vq->priv_data;
343 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
344 struct mx3_camera_dev *mx3_cam = ici->priv;
345 struct mx3_camera_buffer *buf =
346 container_of(vb, struct mx3_camera_buffer, vb);
347 struct dma_async_tx_descriptor *txd = buf->txd;
348 struct idmac_channel *ichan = to_idmac_chan(txd->chan);
349 struct idmac_video_param *video = &ichan->params.video;
350 const struct soc_camera_data_format *data_fmt = icd->current_fmt;
351 dma_cookie_t cookie;
352
353 BUG_ON(!irqs_disabled());
354
355 /* This is the configuration of one sg-element */
356 video->out_pixel_fmt = fourcc_to_ipu_pix(data_fmt->fourcc);
357 video->out_width = icd->rect_current.width;
358 video->out_height = icd->rect_current.height;
359 video->out_stride = icd->rect_current.width;
360
361 #ifdef DEBUG
362 /* helps to see what DMA actually has written */
363 memset((void *)vb->baddr, 0xaa, vb->bsize);
364 #endif
365
366 list_add_tail(&vb->queue, &mx3_cam->capture);
367
368 if (!mx3_cam->active) {
369 mx3_cam->active = buf;
370 vb->state = VIDEOBUF_ACTIVE;
371 } else {
372 vb->state = VIDEOBUF_QUEUED;
373 }
374
375 spin_unlock_irq(&mx3_cam->lock);
376
377 cookie = txd->tx_submit(txd);
378 dev_dbg(&icd->dev, "Submitted cookie %d DMA 0x%08x\n", cookie, sg_dma_address(&buf->sg));
379
380 spin_lock_irq(&mx3_cam->lock);
381
382 if (cookie >= 0)
383 return;
384
385 /* Submit error */
386 vb->state = VIDEOBUF_PREPARED;
387
388 list_del_init(&vb->queue);
389
390 if (mx3_cam->active == buf)
391 mx3_cam->active = NULL;
392 }
393
394 /* Called with .vb_lock held */
395 static void mx3_videobuf_release(struct videobuf_queue *vq,
396 struct videobuf_buffer *vb)
397 {
398 struct soc_camera_device *icd = vq->priv_data;
399 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
400 struct mx3_camera_dev *mx3_cam = ici->priv;
401 struct mx3_camera_buffer *buf =
402 container_of(vb, struct mx3_camera_buffer, vb);
403 unsigned long flags;
404
405 dev_dbg(&icd->dev, "Release%s DMA 0x%08x (state %d), queue %sempty\n",
406 mx3_cam->active == buf ? " active" : "", sg_dma_address(&buf->sg),
407 vb->state, list_empty(&vb->queue) ? "" : "not ");
408 spin_lock_irqsave(&mx3_cam->lock, flags);
409 if ((vb->state == VIDEOBUF_ACTIVE || vb->state == VIDEOBUF_QUEUED) &&
410 !list_empty(&vb->queue)) {
411 vb->state = VIDEOBUF_ERROR;
412
413 list_del_init(&vb->queue);
414 if (mx3_cam->active == buf)
415 mx3_cam->active = NULL;
416 }
417 spin_unlock_irqrestore(&mx3_cam->lock, flags);
418 free_buffer(vq, buf);
419 }
420
421 static struct videobuf_queue_ops mx3_videobuf_ops = {
422 .buf_setup = mx3_videobuf_setup,
423 .buf_prepare = mx3_videobuf_prepare,
424 .buf_queue = mx3_videobuf_queue,
425 .buf_release = mx3_videobuf_release,
426 };
427
428 static void mx3_camera_init_videobuf(struct videobuf_queue *q,
429 struct soc_camera_device *icd)
430 {
431 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
432 struct mx3_camera_dev *mx3_cam = ici->priv;
433
434 videobuf_queue_dma_contig_init(q, &mx3_videobuf_ops, icd->dev.parent,
435 &mx3_cam->lock,
436 V4L2_BUF_TYPE_VIDEO_CAPTURE,
437 V4L2_FIELD_NONE,
438 sizeof(struct mx3_camera_buffer), icd);
439 }
440
441 /* First part of ipu_csi_init_interface() */
442 static void mx3_camera_activate(struct mx3_camera_dev *mx3_cam,
443 struct soc_camera_device *icd)
444 {
445 u32 conf;
446 long rate;
447
448 /* Set default size: ipu_csi_set_window_size() */
449 csi_reg_write(mx3_cam, (640 - 1) | ((480 - 1) << 16), CSI_ACT_FRM_SIZE);
450 /* ...and position to 0:0: ipu_csi_set_window_pos() */
451 conf = csi_reg_read(mx3_cam, CSI_OUT_FRM_CTRL) & 0xffff0000;
452 csi_reg_write(mx3_cam, conf, CSI_OUT_FRM_CTRL);
453
454 /* We use only gated clock synchronisation mode so far */
455 conf = 0 << CSI_SENS_CONF_SENS_PRTCL_SHIFT;
456
457 /* Set generic data, platform-biggest bus-width */
458 conf |= CSI_SENS_CONF_DATA_FMT_BAYER;
459
460 if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15)
461 conf |= 3 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
462 else if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_10)
463 conf |= 2 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
464 else if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_8)
465 conf |= 1 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
466 else/* if (mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_4)*/
467 conf |= 0 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
468
469 if (mx3_cam->platform_flags & MX3_CAMERA_CLK_SRC)
470 conf |= 1 << CSI_SENS_CONF_SENS_CLKSRC_SHIFT;
471 if (mx3_cam->platform_flags & MX3_CAMERA_EXT_VSYNC)
472 conf |= 1 << CSI_SENS_CONF_EXT_VSYNC_SHIFT;
473 if (mx3_cam->platform_flags & MX3_CAMERA_DP)
474 conf |= 1 << CSI_SENS_CONF_DATA_POL_SHIFT;
475 if (mx3_cam->platform_flags & MX3_CAMERA_PCP)
476 conf |= 1 << CSI_SENS_CONF_PIX_CLK_POL_SHIFT;
477 if (mx3_cam->platform_flags & MX3_CAMERA_HSP)
478 conf |= 1 << CSI_SENS_CONF_HSYNC_POL_SHIFT;
479 if (mx3_cam->platform_flags & MX3_CAMERA_VSP)
480 conf |= 1 << CSI_SENS_CONF_VSYNC_POL_SHIFT;
481
482 /* ipu_csi_init_interface() */
483 csi_reg_write(mx3_cam, conf, CSI_SENS_CONF);
484
485 clk_enable(mx3_cam->clk);
486 rate = clk_round_rate(mx3_cam->clk, mx3_cam->mclk);
487 dev_dbg(&icd->dev, "Set SENS_CONF to %x, rate %ld\n", conf, rate);
488 if (rate)
489 clk_set_rate(mx3_cam->clk, rate);
490 }
491
492 /* Called with .video_lock held */
493 static int mx3_camera_add_device(struct soc_camera_device *icd)
494 {
495 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
496 struct mx3_camera_dev *mx3_cam = ici->priv;
497
498 if (mx3_cam->icd)
499 return -EBUSY;
500
501 mx3_camera_activate(mx3_cam, icd);
502
503 mx3_cam->icd = icd;
504
505 dev_info(&icd->dev, "MX3 Camera driver attached to camera %d\n",
506 icd->devnum);
507
508 return 0;
509 }
510
511 /* Called with .video_lock held */
512 static void mx3_camera_remove_device(struct soc_camera_device *icd)
513 {
514 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
515 struct mx3_camera_dev *mx3_cam = ici->priv;
516 struct idmac_channel **ichan = &mx3_cam->idmac_channel[0];
517
518 BUG_ON(icd != mx3_cam->icd);
519
520 if (*ichan) {
521 dma_release_channel(&(*ichan)->dma_chan);
522 *ichan = NULL;
523 }
524
525 clk_disable(mx3_cam->clk);
526
527 mx3_cam->icd = NULL;
528
529 dev_info(&icd->dev, "MX3 Camera driver detached from camera %d\n",
530 icd->devnum);
531 }
532
533 static bool channel_change_requested(struct soc_camera_device *icd,
534 struct v4l2_rect *rect)
535 {
536 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
537 struct mx3_camera_dev *mx3_cam = ici->priv;
538 struct idmac_channel *ichan = mx3_cam->idmac_channel[0];
539
540 /* Do buffers have to be re-allocated or channel re-configured? */
541 return ichan && rect->width * rect->height >
542 icd->rect_current.width * icd->rect_current.height;
543 }
544
545 static int test_platform_param(struct mx3_camera_dev *mx3_cam,
546 unsigned char buswidth, unsigned long *flags)
547 {
548 /*
549 * Platform specified synchronization and pixel clock polarities are
550 * only a recommendation and are only used during probing. MX3x
551 * camera interface only works in master mode, i.e., uses HSYNC and
552 * VSYNC signals from the sensor
553 */
554 *flags = SOCAM_MASTER |
555 SOCAM_HSYNC_ACTIVE_HIGH |
556 SOCAM_HSYNC_ACTIVE_LOW |
557 SOCAM_VSYNC_ACTIVE_HIGH |
558 SOCAM_VSYNC_ACTIVE_LOW |
559 SOCAM_PCLK_SAMPLE_RISING |
560 SOCAM_PCLK_SAMPLE_FALLING |
561 SOCAM_DATA_ACTIVE_HIGH |
562 SOCAM_DATA_ACTIVE_LOW;
563
564 /* If requested data width is supported by the platform, use it or any
565 * possible lower value - i.MX31 is smart enough to schift bits */
566 switch (buswidth) {
567 case 15:
568 if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15))
569 return -EINVAL;
570 *flags |= SOCAM_DATAWIDTH_15 | SOCAM_DATAWIDTH_10 |
571 SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_4;
572 break;
573 case 10:
574 if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_10))
575 return -EINVAL;
576 *flags |= SOCAM_DATAWIDTH_10 | SOCAM_DATAWIDTH_8 |
577 SOCAM_DATAWIDTH_4;
578 break;
579 case 8:
580 if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_8))
581 return -EINVAL;
582 *flags |= SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_4;
583 break;
584 case 4:
585 if (!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_4))
586 return -EINVAL;
587 *flags |= SOCAM_DATAWIDTH_4;
588 break;
589 default:
590 dev_info(mx3_cam->soc_host.v4l2_dev.dev, "Unsupported bus width %d\n",
591 buswidth);
592 return -EINVAL;
593 }
594
595 return 0;
596 }
597
598 static int mx3_camera_try_bus_param(struct soc_camera_device *icd,
599 const unsigned int depth)
600 {
601 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
602 struct mx3_camera_dev *mx3_cam = ici->priv;
603 unsigned long bus_flags, camera_flags;
604 int ret = test_platform_param(mx3_cam, depth, &bus_flags);
605
606 dev_dbg(icd->dev.parent, "requested bus width %d bit: %d\n", depth, ret);
607
608 if (ret < 0)
609 return ret;
610
611 camera_flags = icd->ops->query_bus_param(icd);
612
613 ret = soc_camera_bus_param_compatible(camera_flags, bus_flags);
614 if (ret < 0)
615 dev_warn(&icd->dev, "Flags incompatible: camera %lx, host %lx\n",
616 camera_flags, bus_flags);
617
618 return ret;
619 }
620
621 static bool chan_filter(struct dma_chan *chan, void *arg)
622 {
623 struct dma_chan_request *rq = arg;
624 struct mx3_camera_pdata *pdata;
625
626 if (!rq)
627 return false;
628
629 pdata = rq->mx3_cam->soc_host.v4l2_dev.dev->platform_data;
630
631 return rq->id == chan->chan_id &&
632 pdata->dma_dev == chan->device->dev;
633 }
634
635 static const struct soc_camera_data_format mx3_camera_formats[] = {
636 {
637 .name = "Bayer (sRGB) 8 bit",
638 .depth = 8,
639 .fourcc = V4L2_PIX_FMT_SBGGR8,
640 .colorspace = V4L2_COLORSPACE_SRGB,
641 }, {
642 .name = "Monochrome 8 bit",
643 .depth = 8,
644 .fourcc = V4L2_PIX_FMT_GREY,
645 .colorspace = V4L2_COLORSPACE_JPEG,
646 },
647 };
648
649 static bool buswidth_supported(struct soc_camera_host *ici, int depth)
650 {
651 struct mx3_camera_dev *mx3_cam = ici->priv;
652
653 switch (depth) {
654 case 4:
655 return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_4);
656 case 8:
657 return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_8);
658 case 10:
659 return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_10);
660 case 15:
661 return !!(mx3_cam->platform_flags & MX3_CAMERA_DATAWIDTH_15);
662 }
663 return false;
664 }
665
666 static int mx3_camera_get_formats(struct soc_camera_device *icd, int idx,
667 struct soc_camera_format_xlate *xlate)
668 {
669 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
670 int formats = 0, buswidth, ret;
671
672 buswidth = icd->formats[idx].depth;
673
674 if (!buswidth_supported(ici, buswidth))
675 return 0;
676
677 ret = mx3_camera_try_bus_param(icd, buswidth);
678 if (ret < 0)
679 return 0;
680
681 switch (icd->formats[idx].fourcc) {
682 case V4L2_PIX_FMT_SGRBG10:
683 formats++;
684 if (xlate) {
685 xlate->host_fmt = &mx3_camera_formats[0];
686 xlate->cam_fmt = icd->formats + idx;
687 xlate->buswidth = buswidth;
688 xlate++;
689 dev_dbg(icd->dev.parent, "Providing format %s using %s\n",
690 mx3_camera_formats[0].name,
691 icd->formats[idx].name);
692 }
693 goto passthrough;
694 case V4L2_PIX_FMT_Y16:
695 formats++;
696 if (xlate) {
697 xlate->host_fmt = &mx3_camera_formats[1];
698 xlate->cam_fmt = icd->formats + idx;
699 xlate->buswidth = buswidth;
700 xlate++;
701 dev_dbg(icd->dev.parent, "Providing format %s using %s\n",
702 mx3_camera_formats[0].name,
703 icd->formats[idx].name);
704 }
705 default:
706 passthrough:
707 /* Generic pass-through */
708 formats++;
709 if (xlate) {
710 xlate->host_fmt = icd->formats + idx;
711 xlate->cam_fmt = icd->formats + idx;
712 xlate->buswidth = buswidth;
713 xlate++;
714 dev_dbg(icd->dev.parent,
715 "Providing format %s in pass-through mode\n",
716 icd->formats[idx].name);
717 }
718 }
719
720 return formats;
721 }
722
723 static void configure_geometry(struct mx3_camera_dev *mx3_cam,
724 struct v4l2_rect *rect)
725 {
726 u32 ctrl, width_field, height_field;
727
728 /* Setup frame size - this cannot be changed on-the-fly... */
729 width_field = rect->width - 1;
730 height_field = rect->height - 1;
731 csi_reg_write(mx3_cam, width_field | (height_field << 16), CSI_SENS_FRM_SIZE);
732
733 csi_reg_write(mx3_cam, width_field << 16, CSI_FLASH_STROBE_1);
734 csi_reg_write(mx3_cam, (height_field << 16) | 0x22, CSI_FLASH_STROBE_2);
735
736 csi_reg_write(mx3_cam, width_field | (height_field << 16), CSI_ACT_FRM_SIZE);
737
738 /* ...and position */
739 ctrl = csi_reg_read(mx3_cam, CSI_OUT_FRM_CTRL) & 0xffff0000;
740 /* Sensor does the cropping */
741 csi_reg_write(mx3_cam, ctrl | 0 | (0 << 8), CSI_OUT_FRM_CTRL);
742
743 /*
744 * No need to free resources here if we fail, we'll see if we need to
745 * do this next time we are called
746 */
747 }
748
749 static int acquire_dma_channel(struct mx3_camera_dev *mx3_cam)
750 {
751 dma_cap_mask_t mask;
752 struct dma_chan *chan;
753 struct idmac_channel **ichan = &mx3_cam->idmac_channel[0];
754 /* We have to use IDMAC_IC_7 for Bayer / generic data */
755 struct dma_chan_request rq = {.mx3_cam = mx3_cam,
756 .id = IDMAC_IC_7};
757
758 if (*ichan) {
759 struct videobuf_buffer *vb, *_vb;
760 dma_release_channel(&(*ichan)->dma_chan);
761 *ichan = NULL;
762 mx3_cam->active = NULL;
763 list_for_each_entry_safe(vb, _vb, &mx3_cam->capture, queue) {
764 list_del_init(&vb->queue);
765 vb->state = VIDEOBUF_ERROR;
766 wake_up(&vb->done);
767 }
768 }
769
770 dma_cap_zero(mask);
771 dma_cap_set(DMA_SLAVE, mask);
772 dma_cap_set(DMA_PRIVATE, mask);
773 chan = dma_request_channel(mask, chan_filter, &rq);
774 if (!chan)
775 return -EBUSY;
776
777 *ichan = to_idmac_chan(chan);
778 (*ichan)->client = mx3_cam;
779
780 return 0;
781 }
782
783 static int mx3_camera_set_crop(struct soc_camera_device *icd,
784 struct v4l2_crop *a)
785 {
786 struct v4l2_rect *rect = &a->c;
787 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
788 struct mx3_camera_dev *mx3_cam = ici->priv;
789 struct device *control = to_soc_camera_control(icd);
790 struct v4l2_subdev *sd = dev_get_drvdata(control);
791
792 /*
793 * We now know pixel formats and can decide upon DMA-channel(s)
794 * So far only direct camera-to-memory is supported
795 */
796 if (channel_change_requested(icd, rect)) {
797 int ret = acquire_dma_channel(mx3_cam);
798 if (ret < 0)
799 return ret;
800 }
801
802 configure_geometry(mx3_cam, rect);
803
804 return v4l2_subdev_call(sd, video, s_crop, a);
805 }
806
807 static int mx3_camera_set_fmt(struct soc_camera_device *icd,
808 struct v4l2_format *f)
809 {
810 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
811 struct mx3_camera_dev *mx3_cam = ici->priv;
812 const struct soc_camera_format_xlate *xlate;
813 struct v4l2_pix_format *pix = &f->fmt.pix;
814 struct v4l2_rect rect = {
815 .left = icd->rect_current.left,
816 .top = icd->rect_current.top,
817 .width = pix->width,
818 .height = pix->height,
819 };
820 int ret;
821
822 xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
823 if (!xlate) {
824 dev_warn(icd->dev.parent, "Format %x not found\n", pix->pixelformat);
825 return -EINVAL;
826 }
827
828 ret = acquire_dma_channel(mx3_cam);
829 if (ret < 0)
830 return ret;
831
832 /*
833 * Might have to perform a complete interface initialisation like in
834 * ipu_csi_init_interface() in mxc_v4l2_s_param(). Also consider
835 * mxc_v4l2_s_fmt()
836 */
837
838 configure_geometry(mx3_cam, &rect);
839
840 ret = v4l2_device_call_until_err(&ici->v4l2_dev, 0, video, s_fmt, f);
841 if (!ret) {
842 icd->buswidth = xlate->buswidth;
843 icd->current_fmt = xlate->host_fmt;
844 }
845
846 return ret;
847 }
848
849 static int mx3_camera_try_fmt(struct soc_camera_device *icd,
850 struct v4l2_format *f)
851 {
852 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
853 const struct soc_camera_format_xlate *xlate;
854 struct v4l2_pix_format *pix = &f->fmt.pix;
855 __u32 pixfmt = pix->pixelformat;
856 enum v4l2_field field;
857 int ret;
858
859 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
860 if (pixfmt && !xlate) {
861 dev_warn(icd->dev.parent, "Format %x not found\n", pixfmt);
862 return -EINVAL;
863 }
864
865 /* limit to MX3 hardware capabilities */
866 if (pix->height > 4096)
867 pix->height = 4096;
868 if (pix->width > 4096)
869 pix->width = 4096;
870
871 pix->bytesperline = pix->width *
872 DIV_ROUND_UP(xlate->host_fmt->depth, 8);
873 pix->sizeimage = pix->height * pix->bytesperline;
874
875 /* camera has to see its format, but the user the original one */
876 pix->pixelformat = xlate->cam_fmt->fourcc;
877 /* limit to sensor capabilities */
878 ret = v4l2_device_call_until_err(&ici->v4l2_dev, 0, video, try_fmt, f);
879 pix->pixelformat = xlate->host_fmt->fourcc;
880
881 field = pix->field;
882
883 if (field == V4L2_FIELD_ANY) {
884 pix->field = V4L2_FIELD_NONE;
885 } else if (field != V4L2_FIELD_NONE) {
886 dev_err(&icd->dev, "Field type %d unsupported.\n", field);
887 return -EINVAL;
888 }
889
890 return ret;
891 }
892
893 static int mx3_camera_reqbufs(struct soc_camera_file *icf,
894 struct v4l2_requestbuffers *p)
895 {
896 return 0;
897 }
898
899 static unsigned int mx3_camera_poll(struct file *file, poll_table *pt)
900 {
901 struct soc_camera_file *icf = file->private_data;
902
903 return videobuf_poll_stream(file, &icf->vb_vidq, pt);
904 }
905
906 static int mx3_camera_querycap(struct soc_camera_host *ici,
907 struct v4l2_capability *cap)
908 {
909 /* cap->name is set by the firendly caller:-> */
910 strlcpy(cap->card, "i.MX3x Camera", sizeof(cap->card));
911 cap->version = KERNEL_VERSION(0, 2, 2);
912 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
913
914 return 0;
915 }
916
917 static int mx3_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
918 {
919 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
920 struct mx3_camera_dev *mx3_cam = ici->priv;
921 unsigned long bus_flags, camera_flags, common_flags;
922 u32 dw, sens_conf;
923 int ret = test_platform_param(mx3_cam, icd->buswidth, &bus_flags);
924 const struct soc_camera_format_xlate *xlate;
925
926 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
927 if (!xlate) {
928 dev_warn(icd->dev.parent, "Format %x not found\n", pixfmt);
929 return -EINVAL;
930 }
931
932 dev_dbg(icd->dev.parent, "requested bus width %d bit: %d\n",
933 icd->buswidth, ret);
934
935 if (ret < 0)
936 return ret;
937
938 camera_flags = icd->ops->query_bus_param(icd);
939
940 common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags);
941 dev_dbg(icd->dev.parent, "Flags cam: 0x%lx host: 0x%lx common: 0x%lx\n",
942 camera_flags, bus_flags, common_flags);
943 if (!common_flags) {
944 dev_dbg(icd->dev.parent, "no common flags");
945 return -EINVAL;
946 }
947
948 /* Make choices, based on platform preferences */
949 if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) &&
950 (common_flags & SOCAM_HSYNC_ACTIVE_LOW)) {
951 if (mx3_cam->platform_flags & MX3_CAMERA_HSP)
952 common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH;
953 else
954 common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW;
955 }
956
957 if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) &&
958 (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) {
959 if (mx3_cam->platform_flags & MX3_CAMERA_VSP)
960 common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH;
961 else
962 common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW;
963 }
964
965 if ((common_flags & SOCAM_DATA_ACTIVE_HIGH) &&
966 (common_flags & SOCAM_DATA_ACTIVE_LOW)) {
967 if (mx3_cam->platform_flags & MX3_CAMERA_DP)
968 common_flags &= ~SOCAM_DATA_ACTIVE_HIGH;
969 else
970 common_flags &= ~SOCAM_DATA_ACTIVE_LOW;
971 }
972
973 if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) &&
974 (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) {
975 if (mx3_cam->platform_flags & MX3_CAMERA_PCP)
976 common_flags &= ~SOCAM_PCLK_SAMPLE_RISING;
977 else
978 common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING;
979 }
980
981 /* Make the camera work in widest common mode, we'll take care of
982 * the rest */
983 if (common_flags & SOCAM_DATAWIDTH_15)
984 common_flags = (common_flags & ~SOCAM_DATAWIDTH_MASK) |
985 SOCAM_DATAWIDTH_15;
986 else if (common_flags & SOCAM_DATAWIDTH_10)
987 common_flags = (common_flags & ~SOCAM_DATAWIDTH_MASK) |
988 SOCAM_DATAWIDTH_10;
989 else if (common_flags & SOCAM_DATAWIDTH_8)
990 common_flags = (common_flags & ~SOCAM_DATAWIDTH_MASK) |
991 SOCAM_DATAWIDTH_8;
992 else
993 common_flags = (common_flags & ~SOCAM_DATAWIDTH_MASK) |
994 SOCAM_DATAWIDTH_4;
995
996 ret = icd->ops->set_bus_param(icd, common_flags);
997 if (ret < 0) {
998 dev_dbg(icd->dev.parent, "camera set_bus_param(%lx) returned %d\n",
999 common_flags, ret);
1000 return ret;
1001 }
1002
1003 /*
1004 * So far only gated clock mode is supported. Add a line
1005 * (3 << CSI_SENS_CONF_SENS_PRTCL_SHIFT) |
1006 * below and select the required mode when supporting other
1007 * synchronisation protocols.
1008 */
1009 sens_conf = csi_reg_read(mx3_cam, CSI_SENS_CONF) &
1010 ~((1 << CSI_SENS_CONF_VSYNC_POL_SHIFT) |
1011 (1 << CSI_SENS_CONF_HSYNC_POL_SHIFT) |
1012 (1 << CSI_SENS_CONF_DATA_POL_SHIFT) |
1013 (1 << CSI_SENS_CONF_PIX_CLK_POL_SHIFT) |
1014 (3 << CSI_SENS_CONF_DATA_FMT_SHIFT) |
1015 (3 << CSI_SENS_CONF_DATA_WIDTH_SHIFT));
1016
1017 /* TODO: Support RGB and YUV formats */
1018
1019 /* This has been set in mx3_camera_activate(), but we clear it above */
1020 sens_conf |= CSI_SENS_CONF_DATA_FMT_BAYER;
1021
1022 if (common_flags & SOCAM_PCLK_SAMPLE_FALLING)
1023 sens_conf |= 1 << CSI_SENS_CONF_PIX_CLK_POL_SHIFT;
1024 if (common_flags & SOCAM_HSYNC_ACTIVE_LOW)
1025 sens_conf |= 1 << CSI_SENS_CONF_HSYNC_POL_SHIFT;
1026 if (common_flags & SOCAM_VSYNC_ACTIVE_LOW)
1027 sens_conf |= 1 << CSI_SENS_CONF_VSYNC_POL_SHIFT;
1028 if (common_flags & SOCAM_DATA_ACTIVE_LOW)
1029 sens_conf |= 1 << CSI_SENS_CONF_DATA_POL_SHIFT;
1030
1031 /* Just do what we're asked to do */
1032 switch (xlate->host_fmt->depth) {
1033 case 4:
1034 dw = 0 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
1035 break;
1036 case 8:
1037 dw = 1 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
1038 break;
1039 case 10:
1040 dw = 2 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
1041 break;
1042 default:
1043 /*
1044 * Actually it can only be 15 now, default is just to silence
1045 * compiler warnings
1046 */
1047 case 15:
1048 dw = 3 << CSI_SENS_CONF_DATA_WIDTH_SHIFT;
1049 }
1050
1051 csi_reg_write(mx3_cam, sens_conf | dw, CSI_SENS_CONF);
1052
1053 dev_dbg(icd->dev.parent, "Set SENS_CONF to %x\n", sens_conf | dw);
1054
1055 return 0;
1056 }
1057
1058 static struct soc_camera_host_ops mx3_soc_camera_host_ops = {
1059 .owner = THIS_MODULE,
1060 .add = mx3_camera_add_device,
1061 .remove = mx3_camera_remove_device,
1062 .set_crop = mx3_camera_set_crop,
1063 .set_fmt = mx3_camera_set_fmt,
1064 .try_fmt = mx3_camera_try_fmt,
1065 .get_formats = mx3_camera_get_formats,
1066 .init_videobuf = mx3_camera_init_videobuf,
1067 .reqbufs = mx3_camera_reqbufs,
1068 .poll = mx3_camera_poll,
1069 .querycap = mx3_camera_querycap,
1070 .set_bus_param = mx3_camera_set_bus_param,
1071 };
1072
1073 static int __devinit mx3_camera_probe(struct platform_device *pdev)
1074 {
1075 struct mx3_camera_dev *mx3_cam;
1076 struct resource *res;
1077 void __iomem *base;
1078 int err = 0;
1079 struct soc_camera_host *soc_host;
1080
1081 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1082 if (!res) {
1083 err = -ENODEV;
1084 goto egetres;
1085 }
1086
1087 mx3_cam = vmalloc(sizeof(*mx3_cam));
1088 if (!mx3_cam) {
1089 dev_err(&pdev->dev, "Could not allocate mx3 camera object\n");
1090 err = -ENOMEM;
1091 goto ealloc;
1092 }
1093 memset(mx3_cam, 0, sizeof(*mx3_cam));
1094
1095 mx3_cam->clk = clk_get(&pdev->dev, NULL);
1096 if (IS_ERR(mx3_cam->clk)) {
1097 err = PTR_ERR(mx3_cam->clk);
1098 goto eclkget;
1099 }
1100
1101 mx3_cam->pdata = pdev->dev.platform_data;
1102 mx3_cam->platform_flags = mx3_cam->pdata->flags;
1103 if (!(mx3_cam->platform_flags & (MX3_CAMERA_DATAWIDTH_4 |
1104 MX3_CAMERA_DATAWIDTH_8 | MX3_CAMERA_DATAWIDTH_10 |
1105 MX3_CAMERA_DATAWIDTH_15))) {
1106 /* Platform hasn't set available data widths. This is bad.
1107 * Warn and use a default. */
1108 dev_warn(&pdev->dev, "WARNING! Platform hasn't set available "
1109 "data widths, using default 8 bit\n");
1110 mx3_cam->platform_flags |= MX3_CAMERA_DATAWIDTH_8;
1111 }
1112
1113 mx3_cam->mclk = mx3_cam->pdata->mclk_10khz * 10000;
1114 if (!mx3_cam->mclk) {
1115 dev_warn(&pdev->dev,
1116 "mclk_10khz == 0! Please, fix your platform data. "
1117 "Using default 20MHz\n");
1118 mx3_cam->mclk = 20000000;
1119 }
1120
1121 /* list of video-buffers */
1122 INIT_LIST_HEAD(&mx3_cam->capture);
1123 spin_lock_init(&mx3_cam->lock);
1124
1125 base = ioremap(res->start, resource_size(res));
1126 if (!base) {
1127 pr_err("Couldn't map %x@%x\n", resource_size(res), res->start);
1128 err = -ENOMEM;
1129 goto eioremap;
1130 }
1131
1132 mx3_cam->base = base;
1133
1134 soc_host = &mx3_cam->soc_host;
1135 soc_host->drv_name = MX3_CAM_DRV_NAME;
1136 soc_host->ops = &mx3_soc_camera_host_ops;
1137 soc_host->priv = mx3_cam;
1138 soc_host->v4l2_dev.dev = &pdev->dev;
1139 soc_host->nr = pdev->id;
1140
1141 err = soc_camera_host_register(soc_host);
1142 if (err)
1143 goto ecamhostreg;
1144
1145 /* IDMAC interface */
1146 dmaengine_get();
1147
1148 return 0;
1149
1150 ecamhostreg:
1151 iounmap(base);
1152 eioremap:
1153 clk_put(mx3_cam->clk);
1154 eclkget:
1155 vfree(mx3_cam);
1156 ealloc:
1157 egetres:
1158 return err;
1159 }
1160
1161 static int __devexit mx3_camera_remove(struct platform_device *pdev)
1162 {
1163 struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
1164 struct mx3_camera_dev *mx3_cam = container_of(soc_host,
1165 struct mx3_camera_dev, soc_host);
1166
1167 clk_put(mx3_cam->clk);
1168
1169 soc_camera_host_unregister(soc_host);
1170
1171 iounmap(mx3_cam->base);
1172
1173 /*
1174 * The channel has either not been allocated,
1175 * or should have been released
1176 */
1177 if (WARN_ON(mx3_cam->idmac_channel[0]))
1178 dma_release_channel(&mx3_cam->idmac_channel[0]->dma_chan);
1179
1180 vfree(mx3_cam);
1181
1182 dmaengine_put();
1183
1184 dev_info(&pdev->dev, "i.MX3x Camera driver unloaded\n");
1185
1186 return 0;
1187 }
1188
1189 static struct platform_driver mx3_camera_driver = {
1190 .driver = {
1191 .name = MX3_CAM_DRV_NAME,
1192 },
1193 .probe = mx3_camera_probe,
1194 .remove = __devexit_p(mx3_camera_remove),
1195 };
1196
1197
1198 static int __init mx3_camera_init(void)
1199 {
1200 return platform_driver_register(&mx3_camera_driver);
1201 }
1202
1203 static void __exit mx3_camera_exit(void)
1204 {
1205 platform_driver_unregister(&mx3_camera_driver);
1206 }
1207
1208 module_init(mx3_camera_init);
1209 module_exit(mx3_camera_exit);
1210
1211 MODULE_DESCRIPTION("i.MX3x SoC Camera Host driver");
1212 MODULE_AUTHOR("Guennadi Liakhovetski <lg@denx.de>");
1213 MODULE_LICENSE("GPL v2");
1214 MODULE_ALIAS("platform:" MX3_CAM_DRV_NAME);