aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLibin Yang <lbyang@marvell.com>2013-11-05 03:29:07 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-12-09 11:50:51 -0500
commit326f5a3fc502f96bce991bedd1957adc2758dba9 (patch)
tree68f483919a32a70e0c18c111cad180bc09a68a8b /drivers/media
parent06eb891edb4009245278a0ae50ccfd6fc99004d2 (diff)
[media] media: marvell-ccic: use devm to release clk
This patch uses devm to release the clks instead of releasing manually. And it adds enable/disable mipi_clk when getting its rate. Signed-off-by: Libin Yang <lbyang@marvell.com> Acked-by: Jonathan Corbet <corbet@lwn.net> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/marvell-ccic/mmp-driver.c39
1 files changed, 8 insertions, 31 deletions
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 70cb57f3adc2..054507f16734 100644
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -142,12 +142,6 @@ static int mmpcam_power_up(struct mcam_camera *mcam)
142 struct mmp_camera *cam = mcam_to_cam(mcam); 142 struct mmp_camera *cam = mcam_to_cam(mcam);
143 struct mmp_camera_platform_data *pdata; 143 struct mmp_camera_platform_data *pdata;
144 144
145 if (mcam->bus_type == V4L2_MBUS_CSI2) {
146 cam->mipi_clk = devm_clk_get(mcam->dev, "mipi");
147 if ((IS_ERR(cam->mipi_clk) && mcam->dphy[2] == 0))
148 return PTR_ERR(cam->mipi_clk);
149 }
150
151/* 145/*
152 * Turn on power and clocks to the controller. 146 * Turn on power and clocks to the controller.
153 */ 147 */
@@ -186,12 +180,6 @@ static void mmpcam_power_down(struct mcam_camera *mcam)
186 gpio_set_value(pdata->sensor_power_gpio, 0); 180 gpio_set_value(pdata->sensor_power_gpio, 0);
187 gpio_set_value(pdata->sensor_reset_gpio, 0); 181 gpio_set_value(pdata->sensor_reset_gpio, 0);
188 182
189 if (mcam->bus_type == V4L2_MBUS_CSI2 && !IS_ERR(cam->mipi_clk)) {
190 if (cam->mipi_clk)
191 devm_clk_put(mcam->dev, cam->mipi_clk);
192 cam->mipi_clk = NULL;
193 }
194
195 mcam_clk_disable(mcam); 183 mcam_clk_disable(mcam);
196} 184}
197 185
@@ -292,8 +280,9 @@ void mmpcam_calc_dphy(struct mcam_camera *mcam)
292 return; 280 return;
293 281
294 /* get the escape clk, this is hard coded */ 282 /* get the escape clk, this is hard coded */
283 clk_prepare_enable(cam->mipi_clk);
295 tx_clk_esc = (clk_get_rate(cam->mipi_clk) / 1000000) / 12; 284 tx_clk_esc = (clk_get_rate(cam->mipi_clk) / 1000000) / 12;
296 285 clk_disable_unprepare(cam->mipi_clk);
297 /* 286 /*
298 * dphy[2] - CSI2_DPHY6: 287 * dphy[2] - CSI2_DPHY6:
299 * bit 0 ~ bit 7: CK Term Enable 288 * bit 0 ~ bit 7: CK Term Enable
@@ -325,19 +314,6 @@ static irqreturn_t mmpcam_irq(int irq, void *data)
325 return IRQ_RETVAL(handled); 314 return IRQ_RETVAL(handled);
326} 315}
327 316
328static void mcam_deinit_clk(struct mcam_camera *mcam)
329{
330 unsigned int i;
331
332 for (i = 0; i < NR_MCAM_CLK; i++) {
333 if (!IS_ERR(mcam->clk[i])) {
334 if (mcam->clk[i])
335 devm_clk_put(mcam->dev, mcam->clk[i]);
336 }
337 mcam->clk[i] = NULL;
338 }
339}
340
341static void mcam_init_clk(struct mcam_camera *mcam) 317static void mcam_init_clk(struct mcam_camera *mcam)
342{ 318{
343 unsigned int i; 319 unsigned int i;
@@ -371,7 +347,6 @@ static int mmpcam_probe(struct platform_device *pdev)
371 if (cam == NULL) 347 if (cam == NULL)
372 return -ENOMEM; 348 return -ENOMEM;
373 cam->pdev = pdev; 349 cam->pdev = pdev;
374 cam->mipi_clk = NULL;
375 INIT_LIST_HEAD(&cam->devlist); 350 INIT_LIST_HEAD(&cam->devlist);
376 351
377 mcam = &cam->mcam; 352 mcam = &cam->mcam;
@@ -387,6 +362,11 @@ static int mmpcam_probe(struct platform_device *pdev)
387 mcam->mclk_div = pdata->mclk_div; 362 mcam->mclk_div = pdata->mclk_div;
388 mcam->bus_type = pdata->bus_type; 363 mcam->bus_type = pdata->bus_type;
389 mcam->dphy = pdata->dphy; 364 mcam->dphy = pdata->dphy;
365 if (mcam->bus_type == V4L2_MBUS_CSI2) {
366 cam->mipi_clk = devm_clk_get(mcam->dev, "mipi");
367 if ((IS_ERR(cam->mipi_clk) && mcam->dphy[2] == 0))
368 return PTR_ERR(cam->mipi_clk);
369 }
390 mcam->mipi_enabled = false; 370 mcam->mipi_enabled = false;
391 mcam->lane = pdata->lane; 371 mcam->lane = pdata->lane;
392 mcam->chip_id = MCAM_ARMADA610; 372 mcam->chip_id = MCAM_ARMADA610;
@@ -444,7 +424,7 @@ static int mmpcam_probe(struct platform_device *pdev)
444 */ 424 */
445 ret = mmpcam_power_up(mcam); 425 ret = mmpcam_power_up(mcam);
446 if (ret) 426 if (ret)
447 goto out_deinit_clk; 427 return ret;
448 ret = mccic_register(mcam); 428 ret = mccic_register(mcam);
449 if (ret) 429 if (ret)
450 goto out_power_down; 430 goto out_power_down;
@@ -469,8 +449,6 @@ out_unregister:
469 mccic_shutdown(mcam); 449 mccic_shutdown(mcam);
470out_power_down: 450out_power_down:
471 mmpcam_power_down(mcam); 451 mmpcam_power_down(mcam);
472out_deinit_clk:
473 mcam_deinit_clk(mcam);
474 return ret; 452 return ret;
475} 453}
476 454
@@ -482,7 +460,6 @@ static int mmpcam_remove(struct mmp_camera *cam)
482 mmpcam_remove_device(cam); 460 mmpcam_remove_device(cam);
483 mccic_shutdown(mcam); 461 mccic_shutdown(mcam);
484 mmpcam_power_down(mcam); 462 mmpcam_power_down(mcam);
485 mcam_deinit_clk(mcam);
486 return 0; 463 return 0;
487} 464}
488 465