diff options
author | Liu Ying <Ying.liu@freescale.com> | 2012-07-24 18:00:08 +0800 |
---|---|---|
committer | Liu Ying <Ying.liu@freescale.com> | 2012-07-25 16:02:42 +0800 |
commit | 7b7c5eea49b244296075b7b8fcaa649437f5e2f4 (patch) | |
tree | 3e35b7c641c87175bedc02395c3129b1b4530335 /drivers/media | |
parent | 6474118ccd32ba14700c35bd0fc147cd4d2a0240 (diff) |
ENGR00182061-2 OV5640 mipi camera:Check dev id before register
This patch checks camera device id via i2c bus before register
v4l2 internal device.
Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/mxc/capture/ov5640_mipi.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/drivers/media/video/mxc/capture/ov5640_mipi.c b/drivers/media/video/mxc/capture/ov5640_mipi.c index cdb58f272908..b46820b58b12 100644 --- a/drivers/media/video/mxc/capture/ov5640_mipi.c +++ b/drivers/media/video/mxc/capture/ov5640_mipi.c @@ -44,6 +44,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, @@ -1771,6 +1774,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)); @@ -1797,7 +1801,8 @@ static int ov5640_probe(struct i2c_client *client, regulator_set_voltage(io_regulator, OV5640_VOLTAGE_DIGITAL_IO, OV5640_VOLTAGE_DIGITAL_IO); - if (regulator_enable(io_regulator) != 0) { + retval = regulator_enable(io_regulator); + if (retval) { pr_err("%s:io set voltage error\n", __func__); goto err1; } else { @@ -1815,7 +1820,8 @@ static int ov5640_probe(struct i2c_client *client, regulator_set_voltage(core_regulator, OV5640_VOLTAGE_DIGITAL_CORE, OV5640_VOLTAGE_DIGITAL_CORE); - if (regulator_enable(core_regulator) != 0) { + retval = regulator_enable(core_regulator); + if (retval) { pr_err("%s:core set voltage error\n", __func__); goto err2; } else { @@ -1833,7 +1839,8 @@ static int ov5640_probe(struct i2c_client *client, regulator_set_voltage(analog_regulator, OV5640_VOLTAGE_ANALOG, OV5640_VOLTAGE_ANALOG); - if (regulator_enable(analog_regulator) != 0) { + retval = regulator_enable(analog_regulator); + if (retval) { pr_err("%s:analog set voltage error\n", __func__); goto err3; @@ -1848,6 +1855,22 @@ 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_err("%s:cannot find camera\n", __func__); + retval = -ENODEV; + goto err4; + } + retval = ov5640_read_reg(OV5640_CHIP_ID_LOW_BYTE, &chip_id_low); + if (retval < 0 || chip_id_low != 0x40) { + pr_err("%s:cannot find camera\n", __func__); + retval = -ENODEV; + goto err4; + } + camera_plat = plat_data; ov5640_int_device.priv = &ov5640_data; @@ -1855,6 +1878,11 @@ static int ov5640_probe(struct i2c_client *client, return retval; +err4: + if (analog_regulator) { + regulator_disable(analog_regulator); + regulator_put(analog_regulator); + } err3: if (core_regulator) { regulator_disable(core_regulator); @@ -1866,7 +1894,7 @@ err2: regulator_put(io_regulator); } err1: - return -1; + return retval; } /*! |