aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/marvell-ccic/mcam-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/marvell-ccic/mcam-core.c')
-rw-r--r--drivers/media/video/marvell-ccic/mcam-core.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/media/video/marvell-ccic/mcam-core.c b/drivers/media/video/marvell-ccic/mcam-core.c
index 014b70b5a9b..3e6a5e8b0cd 100644
--- a/drivers/media/video/marvell-ccic/mcam-core.c
+++ b/drivers/media/video/marvell-ccic/mcam-core.c
@@ -167,7 +167,7 @@ static void mcam_set_config_needed(struct mcam_camera *cam, int needed)
167 167
168 168
169/* 169/*
170 * Debugging and related. FIXME these are broken 170 * Debugging and related.
171 */ 171 */
172#define cam_err(cam, fmt, arg...) \ 172#define cam_err(cam, fmt, arg...) \
173 dev_err((cam)->dev, fmt, ##arg); 173 dev_err((cam)->dev, fmt, ##arg);
@@ -202,7 +202,8 @@ static void mcam_ctlr_dma(struct mcam_camera *cam)
202 mcam_reg_clear_bit(cam, REG_CTRL1, C1_TWOBUFS); 202 mcam_reg_clear_bit(cam, REG_CTRL1, C1_TWOBUFS);
203 } else 203 } else
204 mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS); 204 mcam_reg_set_bit(cam, REG_CTRL1, C1_TWOBUFS);
205 mcam_reg_write(cam, REG_UBAR, 0); /* 32 bits only for now */ 205 if (cam->chip_id == V4L2_IDENT_CAFE)
206 mcam_reg_write(cam, REG_UBAR, 0); /* 32 bits only */
206} 207}
207 208
208static void mcam_ctlr_image(struct mcam_camera *cam) 209static void mcam_ctlr_image(struct mcam_camera *cam)
@@ -358,8 +359,8 @@ static void mcam_ctlr_power_up(struct mcam_camera *cam)
358 unsigned long flags; 359 unsigned long flags;
359 360
360 spin_lock_irqsave(&cam->dev_lock, flags); 361 spin_lock_irqsave(&cam->dev_lock, flags);
361 mcam_reg_clear_bit(cam, REG_CTRL1, C1_PWRDWN);
362 cam->plat_power_up(cam); 362 cam->plat_power_up(cam);
363 mcam_reg_clear_bit(cam, REG_CTRL1, C1_PWRDWN);
363 spin_unlock_irqrestore(&cam->dev_lock, flags); 364 spin_unlock_irqrestore(&cam->dev_lock, flags);
364 msleep(5); /* Just to be sure */ 365 msleep(5); /* Just to be sure */
365} 366}
@@ -369,8 +370,13 @@ static void mcam_ctlr_power_down(struct mcam_camera *cam)
369 unsigned long flags; 370 unsigned long flags;
370 371
371 spin_lock_irqsave(&cam->dev_lock, flags); 372 spin_lock_irqsave(&cam->dev_lock, flags);
372 cam->plat_power_down(cam); 373 /*
374 * School of hard knocks department: be sure we do any register
375 * twiddling on the controller *before* calling the platform
376 * power down routine.
377 */
373 mcam_reg_set_bit(cam, REG_CTRL1, C1_PWRDWN); 378 mcam_reg_set_bit(cam, REG_CTRL1, C1_PWRDWN);
379 cam->plat_power_down(cam);
374 spin_unlock_irqrestore(&cam->dev_lock, flags); 380 spin_unlock_irqrestore(&cam->dev_lock, flags);
375} 381}
376 382
@@ -1622,14 +1628,20 @@ out_unregister:
1622 1628
1623void mccic_shutdown(struct mcam_camera *cam) 1629void mccic_shutdown(struct mcam_camera *cam)
1624{ 1630{
1625 if (cam->users > 0) 1631 /*
1632 * If we have no users (and we really, really should have no
1633 * users) the device will already be powered down. Trying to
1634 * take it down again will wedge the machine, which is frowned
1635 * upon.
1636 */
1637 if (cam->users > 0) {
1626 cam_warn(cam, "Removing a device with users!\n"); 1638 cam_warn(cam, "Removing a device with users!\n");
1639 mcam_ctlr_power_down(cam);
1640 }
1641 mcam_free_dma_bufs(cam);
1627 if (cam->n_sbufs > 0) 1642 if (cam->n_sbufs > 0)
1628 /* What if they are still mapped? Shouldn't be, but... */ 1643 /* What if they are still mapped? Shouldn't be, but... */
1629 mcam_free_sio_buffers(cam); 1644 mcam_free_sio_buffers(cam);
1630 mcam_ctlr_stop_dma(cam);
1631 mcam_ctlr_power_down(cam);
1632 mcam_free_dma_bufs(cam);
1633 video_unregister_device(&cam->vdev); 1645 video_unregister_device(&cam->vdev);
1634 v4l2_device_unregister(&cam->v4l2_dev); 1646 v4l2_device_unregister(&cam->v4l2_dev);
1635} 1647}