summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSheng Nan <b38800@freescale.com>2013-03-01 10:24:12 +0800
committerSheng Nan <b38800@freescale.com>2013-03-01 13:49:37 +0800
commit281c304672ea59a083242938c1b8a7a95e895f26 (patch)
treeaa80c7445777ea3a16f4f22a7f41d411202bbfb8
parent447322b3e5225934cb75b539f3787e1ff05bd71e (diff)
ENGR00252071-1: mxc_v4l2_capture: auto detection parallel ov5642 and ov5640
Both ov5642 and ov5640 need to be supported for parallel port of validation board and no code change is needed when change from one sensor to another. - Add additional common i2c id for ov5640 and ov5642 for auto dectection - Since two sensors will be checked because of auto detection, so use warning instead of error if sensor id don't match. - Add found information to tell user which camera is found. Signed-off-by: Sheng Nan <b38800@freescale.com>
-rw-r--r--drivers/media/video/mxc/capture/ov5640.c30
-rw-r--r--drivers/media/video/mxc/capture/ov5642.c8
2 files changed, 35 insertions, 3 deletions
diff --git a/drivers/media/video/mxc/capture/ov5640.c b/drivers/media/video/mxc/capture/ov5640.c
index 9d1e40e7927c..6b78e21e66ef 100644
--- a/drivers/media/video/mxc/capture/ov5640.c
+++ b/drivers/media/video/mxc/capture/ov5640.c
@@ -43,6 +43,9 @@
#define OV5640_XCLK_MIN 6000000
#define OV5640_XCLK_MAX 24000000
+#define OV5640_CHIP_ID_HIGH_BYTE 0x300A
+#define OV5640_CHIP_ID_LOW_BYTE 0x300B
+
enum ov5640_mode {
ov5640_mode_MIN = 0,
ov5640_mode_VGA_640_480 = 0,
@@ -565,6 +568,7 @@ static s32 ov5640_write_reg(u16 reg, u8 val);
static const struct i2c_device_id ov5640_id[] = {
{"ov5640", 0},
+ {"ov564x", 0},
{},
};
@@ -1736,6 +1740,7 @@ static int ov5640_probe(struct i2c_client *client,
{
int retval;
struct fsl_mxc_camera_platform_data *plat_data = client->dev.platform_data;
+ u8 chip_id_high, chip_id_low;
/* Set initial values for the sensor struct. */
memset(&ov5640_data, 0, sizeof(ov5640_data));
@@ -1813,13 +1818,38 @@ static int ov5640_probe(struct i2c_client *client,
if (plat_data->io_init)
plat_data->io_init();
+ if (plat_data->pwdn)
+ plat_data->pwdn(0);
+
+ retval = ov5640_read_reg(OV5640_CHIP_ID_HIGH_BYTE, &chip_id_high);
+ if (retval < 0 || chip_id_high != 0x56) {
+ pr_warning("camera ov5640 is not found\n");
+ retval = -ENODEV;
+ goto err4;
+ }
+ retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low);
+ if (retval < 0 || chip_id_low != 0x40) {
+ pr_warning("camera ov5640 is not found\n");
+ retval = -ENODEV;
+ goto err4;
+ }
+
+ if (plat_data->pwdn)
+ plat_data->pwdn(1);
+
camera_plat = plat_data;
ov5640_int_device.priv = &ov5640_data;
retval = v4l2_int_device_register(&ov5640_int_device);
+ pr_info("camera ov5640 is found\n");
return retval;
+err4:
+ if (analog_regulator) {
+ regulator_disable(analog_regulator);
+ regulator_put(analog_regulator);
+ }
err3:
if (core_regulator) {
regulator_disable(core_regulator);
diff --git a/drivers/media/video/mxc/capture/ov5642.c b/drivers/media/video/mxc/capture/ov5642.c
index 5653a6b1c35a..6cf5af9567a0 100644
--- a/drivers/media/video/mxc/capture/ov5642.c
+++ b/drivers/media/video/mxc/capture/ov5642.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2012-2013 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
@@ -2999,6 +2999,7 @@ static s32 ov5642_write_reg(u16 reg, u8 val);
static const struct i2c_device_id ov5642_id[] = {
{"ov5642", 0},
+ {"ov564x", 0},
{},
};
@@ -4060,13 +4061,13 @@ static int ov5642_probe(struct i2c_client *client,
retval = ov5642_read_reg(OV5642_CHIP_ID_HIGH_BYTE, &chip_id_high);
if (retval < 0 || chip_id_high != 0x56) {
- pr_err("%s:cannot find camera\n", __func__);
+ pr_warning("camera ov5642 is not found\n");
retval = -ENODEV;
goto err4;
}
retval = ov5642_read_reg(OV5642_CHIP_ID_LOW_BYTE, &chip_id_low);
if (retval < 0 || chip_id_low != 0x42) {
- pr_err("%s:cannot find camera\n", __func__);
+ pr_warning("camera ov5642 is not found\n");
retval = -ENODEV;
goto err4;
}
@@ -4079,6 +4080,7 @@ static int ov5642_probe(struct i2c_client *client,
ov5642_int_device.priv = &ov5642_data;
retval = v4l2_int_device_register(&ov5642_int_device);
+ pr_info("camera ov5642 is found\n");
return retval;
err4: