aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/soc_camera/ov5642.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-07-18 09:54:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-15 16:04:42 -0400
commit4bbc6d52e61a8a9c19fcc859c4acab89cb8cd4e5 (patch)
tree64ce43072ed8fa87bd8f5bc4d8fe5794a0373aef /drivers/media/i2c/soc_camera/ov5642.c
parent4ec10bacd6bf08de39ebdba9e75060452cc313e0 (diff)
[media] soc-camera: Push probe-time power management to drivers
Several client drivers access the hardware at probe time, for instance to read the probe chip ID. Such chips need to be powered up when being probed. soc-camera handles this by powering chips up in the soc-camera probe implementation. However, this will break with non soc-camera hosts that don't perform the same operations. Fix the problem by pushing the power up/down from the soc-camera core down to individual drivers on a needs basis. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c/soc_camera/ov5642.c')
-rw-r--r--drivers/media/i2c/soc_camera/ov5642.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/media/i2c/soc_camera/ov5642.c b/drivers/media/i2c/soc_camera/ov5642.c
index 61824c6911d5..d886c0b9ce44 100644
--- a/drivers/media/i2c/soc_camera/ov5642.c
+++ b/drivers/media/i2c/soc_camera/ov5642.c
@@ -980,29 +980,40 @@ static struct v4l2_subdev_ops ov5642_subdev_ops = {
980 980
981static int ov5642_video_probe(struct i2c_client *client) 981static int ov5642_video_probe(struct i2c_client *client)
982{ 982{
983 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
983 int ret; 984 int ret;
984 u8 id_high, id_low; 985 u8 id_high, id_low;
985 u16 id; 986 u16 id;
986 987
988 ret = ov5642_s_power(subdev, 1);
989 if (ret < 0)
990 return ret;
991
987 /* Read sensor Model ID */ 992 /* Read sensor Model ID */
988 ret = reg_read(client, REG_CHIP_ID_HIGH, &id_high); 993 ret = reg_read(client, REG_CHIP_ID_HIGH, &id_high);
989 if (ret < 0) 994 if (ret < 0)
990 return ret; 995 goto done;
991 996
992 id = id_high << 8; 997 id = id_high << 8;
993 998
994 ret = reg_read(client, REG_CHIP_ID_LOW, &id_low); 999 ret = reg_read(client, REG_CHIP_ID_LOW, &id_low);
995 if (ret < 0) 1000 if (ret < 0)
996 return ret; 1001 goto done;
997 1002
998 id |= id_low; 1003 id |= id_low;
999 1004
1000 dev_info(&client->dev, "Chip ID 0x%04x detected\n", id); 1005 dev_info(&client->dev, "Chip ID 0x%04x detected\n", id);
1001 1006
1002 if (id != 0x5642) 1007 if (id != 0x5642) {
1003 return -ENODEV; 1008 ret = -ENODEV;
1009 goto done;
1010 }
1004 1011
1005 return 0; 1012 ret = 0;
1013
1014done:
1015 ov5642_s_power(subdev, 0);
1016 return ret;
1006} 1017}
1007 1018
1008static int ov5642_probe(struct i2c_client *client, 1019static int ov5642_probe(struct i2c_client *client,