aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/soc_camera/mx1_camera.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/platform/soc_camera/mx1_camera.c')
-rw-r--r--drivers/media/platform/soc_camera/mx1_camera.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/media/platform/soc_camera/mx1_camera.c b/drivers/media/platform/soc_camera/mx1_camera.c
index a3fd8d63546c..fea3e61476ae 100644
--- a/drivers/media/platform/soc_camera/mx1_camera.c
+++ b/drivers/media/platform/soc_camera/mx1_camera.c
@@ -104,7 +104,6 @@ struct mx1_buffer {
104 */ 104 */
105struct mx1_camera_dev { 105struct mx1_camera_dev {
106 struct soc_camera_host soc_host; 106 struct soc_camera_host soc_host;
107 struct soc_camera_device *icd;
108 struct mx1_camera_pdata *pdata; 107 struct mx1_camera_pdata *pdata;
109 struct mx1_buffer *active; 108 struct mx1_buffer *active;
110 struct resource *res; 109 struct resource *res;
@@ -220,7 +219,7 @@ out:
220static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev) 219static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
221{ 220{
222 struct videobuf_buffer *vbuf = &pcdev->active->vb; 221 struct videobuf_buffer *vbuf = &pcdev->active->vb;
223 struct device *dev = pcdev->icd->parent; 222 struct device *dev = pcdev->soc_host.icd->parent;
224 int ret; 223 int ret;
225 224
226 if (unlikely(!pcdev->active)) { 225 if (unlikely(!pcdev->active)) {
@@ -331,7 +330,7 @@ static void mx1_camera_wakeup(struct mx1_camera_dev *pcdev,
331static void mx1_camera_dma_irq(int channel, void *data) 330static void mx1_camera_dma_irq(int channel, void *data)
332{ 331{
333 struct mx1_camera_dev *pcdev = data; 332 struct mx1_camera_dev *pcdev = data;
334 struct device *dev = pcdev->icd->parent; 333 struct device *dev = pcdev->soc_host.icd->parent;
335 struct mx1_buffer *buf; 334 struct mx1_buffer *buf;
336 struct videobuf_buffer *vb; 335 struct videobuf_buffer *vb;
337 unsigned long flags; 336 unsigned long flags;
@@ -389,7 +388,7 @@ static int mclk_get_divisor(struct mx1_camera_dev *pcdev)
389 */ 388 */
390 div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1; 389 div = (lcdclk + 2 * mclk - 1) / (2 * mclk) - 1;
391 390
392 dev_dbg(pcdev->icd->parent, 391 dev_dbg(pcdev->soc_host.icd->parent,
393 "System clock %lukHz, target freq %dkHz, divisor %lu\n", 392 "System clock %lukHz, target freq %dkHz, divisor %lu\n",
394 lcdclk / 1000, mclk / 1000, div); 393 lcdclk / 1000, mclk / 1000, div);
395 394
@@ -400,7 +399,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
400{ 399{
401 unsigned int csicr1 = CSICR1_EN; 400 unsigned int csicr1 = CSICR1_EN;
402 401
403 dev_dbg(pcdev->icd->parent, "Activate device\n"); 402 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "Activate device\n");
404 403
405 clk_prepare_enable(pcdev->clk); 404 clk_prepare_enable(pcdev->clk);
406 405
@@ -416,7 +415,7 @@ static void mx1_camera_activate(struct mx1_camera_dev *pcdev)
416 415
417static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev) 416static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
418{ 417{
419 dev_dbg(pcdev->icd->parent, "Deactivate device\n"); 418 dev_dbg(pcdev->soc_host.v4l2_dev.dev, "Deactivate device\n");
420 419
421 /* Disable all CSI interface */ 420 /* Disable all CSI interface */
422 __raw_writel(0x00, pcdev->base + CSICR1); 421 __raw_writel(0x00, pcdev->base + CSICR1);
@@ -424,36 +423,38 @@ static void mx1_camera_deactivate(struct mx1_camera_dev *pcdev)
424 clk_disable_unprepare(pcdev->clk); 423 clk_disable_unprepare(pcdev->clk);
425} 424}
426 425
426static int mx1_camera_add_device(struct soc_camera_device *icd)
427{
428 dev_info(icd->parent, "MX1 Camera driver attached to camera %d\n",
429 icd->devnum);
430
431 return 0;
432}
433
434static void mx1_camera_remove_device(struct soc_camera_device *icd)
435{
436 dev_info(icd->parent, "MX1 Camera driver detached from camera %d\n",
437 icd->devnum);
438}
439
427/* 440/*
428 * The following two functions absolutely depend on the fact, that 441 * The following two functions absolutely depend on the fact, that
429 * there can be only one camera on i.MX1/i.MXL camera sensor interface 442 * there can be only one camera on i.MX1/i.MXL camera sensor interface
430 */ 443 */
431static int mx1_camera_add_device(struct soc_camera_device *icd) 444static int mx1_camera_clock_start(struct soc_camera_host *ici)
432{ 445{
433 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
434 struct mx1_camera_dev *pcdev = ici->priv; 446 struct mx1_camera_dev *pcdev = ici->priv;
435 447
436 if (pcdev->icd)
437 return -EBUSY;
438
439 dev_info(icd->parent, "MX1 Camera driver attached to camera %d\n",
440 icd->devnum);
441
442 mx1_camera_activate(pcdev); 448 mx1_camera_activate(pcdev);
443 449
444 pcdev->icd = icd;
445
446 return 0; 450 return 0;
447} 451}
448 452
449static void mx1_camera_remove_device(struct soc_camera_device *icd) 453static void mx1_camera_clock_stop(struct soc_camera_host *ici)
450{ 454{
451 struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
452 struct mx1_camera_dev *pcdev = ici->priv; 455 struct mx1_camera_dev *pcdev = ici->priv;
453 unsigned int csicr1; 456 unsigned int csicr1;
454 457
455 BUG_ON(icd != pcdev->icd);
456
457 /* disable interrupts */ 458 /* disable interrupts */
458 csicr1 = __raw_readl(pcdev->base + CSICR1) & ~CSI_IRQ_MASK; 459 csicr1 = __raw_readl(pcdev->base + CSICR1) & ~CSI_IRQ_MASK;
459 __raw_writel(csicr1, pcdev->base + CSICR1); 460 __raw_writel(csicr1, pcdev->base + CSICR1);
@@ -461,12 +462,7 @@ static void mx1_camera_remove_device(struct soc_camera_device *icd)
461 /* Stop DMA engine */ 462 /* Stop DMA engine */
462 imx_dma_disable(pcdev->dma_chan); 463 imx_dma_disable(pcdev->dma_chan);
463 464
464 dev_info(icd->parent, "MX1 Camera driver detached from camera %d\n",
465 icd->devnum);
466
467 mx1_camera_deactivate(pcdev); 465 mx1_camera_deactivate(pcdev);
468
469 pcdev->icd = NULL;
470} 466}
471 467
472static int mx1_camera_set_bus_param(struct soc_camera_device *icd) 468static int mx1_camera_set_bus_param(struct soc_camera_device *icd)
@@ -679,6 +675,8 @@ static struct soc_camera_host_ops mx1_soc_camera_host_ops = {
679 .owner = THIS_MODULE, 675 .owner = THIS_MODULE,
680 .add = mx1_camera_add_device, 676 .add = mx1_camera_add_device,
681 .remove = mx1_camera_remove_device, 677 .remove = mx1_camera_remove_device,
678 .clock_start = mx1_camera_clock_start,
679 .clock_stop = mx1_camera_clock_stop,
682 .set_bus_param = mx1_camera_set_bus_param, 680 .set_bus_param = mx1_camera_set_bus_param,
683 .set_fmt = mx1_camera_set_fmt, 681 .set_fmt = mx1_camera_set_fmt,
684 .try_fmt = mx1_camera_try_fmt, 682 .try_fmt = mx1_camera_try_fmt,