int imx135_match_id(struct hisi_sensor_ctrl_t *s_ctrl) { int ret = 0; u16 id_h = 0; u16 id_l = 0; u16 sensor_id = 0; cam_info( "%s, sensor_chipid:0x%x\n", __func__, s_ctrl->sensor->sensor_info->sensor_chipid); ret = hisi_sensor_power_up(s_ctrl); if(ret) { cam_err("sensor[%s] power up failed.", s_ctrl->sensor->sensor_info->name); ret = -1; goto out; } /* check sensor id */ isp_read_sensor_byte(&s_ctrl->sensor->sensor_info->i2c_config, 0x0016, &id_h); isp_read_sensor_byte(&s_ctrl->sensor->sensor_info->i2c_config, 0x0017, &id_l); sensor_id = id_h << 8 | id_l; cam_notice( "sensor id: 0x%x", sensor_id); if (sensor_id != s_ctrl->sensor->sensor_info->sensor_chipid) { ret = -1; } out: hisi_sensor_power_down(s_ctrl); return ret; }
int imx214otp_read_reg(struct hisi_sensor_ctrl_t *s_ctrl, u16 reg, u8 *val) { i2c_t *i2c_info = &s_ctrl->sensor->sensor_info->otp_i2c_config; int rc = 0; rc = isp_read_sensor_byte(i2c_info, reg, (u16*)val); otp_sum += (u8)(*val); return rc; }
int hisi_sensor_i2c_read(struct hisi_sensor_ctrl_t *s_ctrl, void *data) { struct sensor_cfg_data *cdata = (struct sensor_cfg_data *)data; long rc = 0; unsigned int reg, *val; cam_debug("%s: address=0x%x\n", __func__, cdata->cfg.reg.subaddr); /* parse the I2C parameters */ reg = cdata->cfg.reg.subaddr; val = &cdata->cfg.reg.value; rc = isp_read_sensor_byte(&s_ctrl->sensor->sensor_info->i2c_config, reg, (u16 *)val); return rc; }
int imx214_match_id(struct hisi_sensor_ctrl_t *s_ctrl) { int ret = 0; u16 id_h = 0; u16 id_l = 0; u16 sensor_id = 0; int camif_id = -1; struct hisi_sensor_info *sensor_info = s_ctrl->sensor->sensor_info; cam_info( "%s, sensor_chipid:0x%x\n", __func__, sensor_info->sensor_chipid); ret = hisi_sensor_power_up(s_ctrl); if(ret) { cam_err("sensor[%s] power up failed.", sensor_info->name); ret = -1; goto out; } /* check sensor id */ isp_read_sensor_byte(&sensor_info->i2c_config, 0x0016, &id_h); isp_read_sensor_byte(&sensor_info->i2c_config, 0x0017, &id_l); sensor_id = id_h << 8 | id_l; cam_notice( "sensor id: 0x%x", sensor_id); if (sensor_id != sensor_info->sensor_chipid) { ret = -1; goto out; } if (!is_fpga_board()) { if(0 == sensor_info->gpios[FSIN].gpio) { cam_err("%s gpio type[FSIN] is not actived.", __func__); ret = -1; goto out; } ret = gpio_request(sensor_info->gpios[FSIN].gpio, "camif_id"); if(ret < 0) { cam_err("failed to request gpio[%d]", sensor_info->gpios[FSIN].gpio); goto out; } ret = gpio_direction_input(sensor_info->gpios[FSIN].gpio); if(ret < 0) { cam_err("failed to control gpio[%d]", sensor_info->gpios[FSIN].gpio); goto out_gpio; } ret = gpio_get_value(sensor_info->gpios[FSIN].gpio); if(ret < 0) { cam_err("failed to get gpio[%d]", sensor_info->gpios[FSIN].gpio); goto out_gpio; } else { camif_id = ret; cam_notice("%s camif id = %d.", __func__, camif_id); } if (camif_id != sensor_info->camif_id) { cam_notice("%s camera[%s] module is not match.", __func__, sensor_info->name); ret = -1; } else { cam_notice("%s camera[%s] match successfully.", __func__, sensor_info->name); ret = 0; } if (0 == ret) { #ifdef IMX214_OTP_FEATURE imx214_read_otp(s_ctrl); #endif } } out_gpio: gpio_free(sensor_info->gpios[FSIN].gpio); out: hisi_sensor_power_down(s_ctrl); return ret; }