Exemplo n.º 1
0
static int32_t imx135_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	struct msm_camera_sensor_board_info *info = s_ctrl->sensordata;
	struct device *dev = s_ctrl->dev;

	pr_debug("%s: Enter\n", __func__);

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

	if (imx135_devboard_config == true)
		return imx135_sensor_power_down_devboard(s_ctrl);

	/* Disable MCLK */
	msm_cam_clk_enable(dev, &s_ctrl->clk_info[0],
			(struct clk **)&imx135_cam_mclk[0],
			s_ctrl->clk_info_size, CLK_OFF);
	usleep_range(500, 600);

	/* Set reset low */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[4].gpio,
			GPIO_OUT_LOW);
	usleep_range(1000, 2000);

	/* Disable VAF */
	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VAF],
			&imx135_cam_vaf, VREG_OFF);

	/* Disable AVDD */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[1].gpio,
			GPIO_OUT_LOW);
	usleep_range(1000, 2000);

	/* Disable VDD_EN */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[3].gpio,
			GPIO_OUT_LOW);
	usleep_range(500, 600);

	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VDIG],
			&imx135_cam_vdd, VREG_OFF);
	usleep_range(1000, 2000);

	/* Disable I/O Supply(Vddio) */
	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VIO],
			&imx135_cam_vddio, VREG_OFF);
	usleep_range(1000, 2000);

	msm_camera_request_gpio_table(
		info->gpio_conf->cam_gpio_req_tbl,
		info->gpio_conf->cam_gpio_req_tbl_size, GPIO_REQUEST_NO_USE);
	return rc;
}
Exemplo n.º 2
0
static int32_t imx135_sensor_power_down_devboard(
		struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	struct msm_camera_sensor_board_info *info = s_ctrl->sensordata;
	struct device *dev = s_ctrl->dev;

	pr_debug("%s: Enter\n", __func__);

	/* Disable MCLK */
	msm_cam_clk_enable(dev, &s_ctrl->clk_info[0],
			(struct clk **)&imx135_cam_mclk[0],
			s_ctrl->clk_info_size, CLK_OFF);
	usleep_range(500, 600);

	/* Put into Reset State */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[2].gpio,
			GPIO_OUT_LOW);
	usleep_range(5000, 6000);

	/* Disable VAF */
	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VAF],
			&imx135_cam_vaf, VREG_OFF);

	/* Disable Avdd */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[1].gpio,
			GPIO_OUT_LOW);
	usleep_range(1000, 2000);

	/* Disable VDIG */
	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VDIG],
			&imx135_cam_vdd, VREG_OFF);
	usleep_range(1000, 2000);

	/* Disable VDDIO */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[3].gpio,
			GPIO_OUT_LOW);

	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VIO],
			&imx135_cam_vddio, VREG_OFF);
	usleep_range(1000, 2000);

	/* Disable GPIO's */
	msm_camera_request_gpio_table(
		info->gpio_conf->cam_gpio_req_tbl,
		info->gpio_conf->cam_gpio_req_tbl_size, GPIO_REQUEST_NO_USE);

	return rc;
}
static int32_t stmvl6180_vreg_control(struct cci_data *data, int config)
{
	int rc = 0, i, cnt;
	struct msm_tof_vreg *vreg_cfg;

	vl6180_dbgmsg("Enter\n");

	vreg_cfg = &data->vreg_cfg;
	cnt = vreg_cfg->num_vreg;
	vl6180_dbgmsg("num_vreg: %d\n", cnt);
	if (!cnt) {
		vl6180_errmsg("failed %d\n", __LINE__);
		return 0;
	}

	if (cnt >= MSM_TOF_MAX_VREGS) {
		vl6180_errmsg("failed %d cnt %d\n", __LINE__, cnt);
		return -EINVAL;
	}

	for (i = 0; i < cnt; i++) {
		rc = msm_camera_config_single_vreg(&(data->pdev->dev), &vreg_cfg->cam_vreg[i], (struct regulator **)&vreg_cfg->data[i], config);
	}

	vl6180_dbgmsg("EXIT rc =%d\n", rc);
	return rc;
}
Exemplo n.º 4
0
static int32_t msm_ois_vreg_control(struct msm_ois_ctrl_t *a_ctrl,
							int config)
{
	int rc = 0, i, cnt;
	struct msm_ois_vreg *vreg_cfg;

	CDBG_I("Enter\n");
	vreg_cfg = &a_ctrl->vreg_cfg;
	cnt = vreg_cfg->num_vreg;
	if (!cnt){
		pr_err("failed\n");
		return 0;
	}
	CDBG("[num_vreg::%d]", cnt);

	if (cnt >= MSM_OIS_MAX_VREGS) {
		pr_err("%s failed %d cnt %d\n", __func__, __LINE__, cnt);
		return -EINVAL;
	}

	for (i = 0; i < cnt; i++) {
		rc = msm_camera_config_single_vreg(&(a_ctrl->pdev->dev),
			&vreg_cfg->cam_vreg[i],
			(struct regulator **)&vreg_cfg->data[i],
			config);
	}
	return rc;
}
Exemplo n.º 5
0
int ov680_power_down(struct msm_sensor_ctrl_t *s_ctrl, struct msm_sensor_power_setting* power_setting_table, int size)
{
	int index;
	struct msm_sensor_power_setting* power_setting;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;
	ov680_info("%s line %d", __func__, __LINE__);

	/* call CCI RELEASE */
	ov680_dbg("call CCI REL");
	s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
		s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);

	for (index = size-1; index >= 0; index--) {
		ov680_dbg("%s index %d\n", __func__, index);
		power_setting = &power_setting_table[index];
		ov680_dbg("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			ov680_dbg("%s Disable MCLK %d", __func__, __LINE__);
			msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				0);
			break;
		case SENSOR_VREG:
			ov680_dbg("%s Disable VREG %d", __func__, __LINE__);
			msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		case SENSOR_GPIO:
		case SENSOR_I2C_MUX:
		default:
			ov680_info("Not handled");
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	/* de-request GPIO table */
	msm_camera_request_gpio_table(standby_gpios, sizeof(standby_gpios)/sizeof(standby_gpios[0]), 0);

return 0;
}
Exemplo n.º 6
0
static int32_t msm_tcs_vreg_control(struct msm_tcs_ctrl_t *o_ctrl,
							int config)
{
	int rc = 0, i, cnt;
	struct msm_tcs_vreg *vreg_cfg;

	vreg_cfg = &o_ctrl->vreg_cfg;
	cnt = vreg_cfg->num_vreg;
	if (!cnt)
		return 0;

	if (cnt >= MSM_TCS_MAX_VREGS) {
		pr_err("%s failed %d cnt %d\n", __func__, __LINE__, cnt);
		return -EINVAL;
	}

	for (i = 0; i < cnt; i++) {
		rc = msm_camera_config_single_vreg(&(o_ctrl->pdev->dev),
			&vreg_cfg->cam_vreg[i],
			(struct regulator **)&vreg_cfg->data[i],
			config);
	}
	return rc;
}
Exemplo n.º 7
0
int32_t gc0339_power_up(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0, index = 0;
	struct msm_sensor_power_setting_array *power_setting_array = NULL;
	struct msm_sensor_power_setting *power_setting = NULL;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;
	struct msm_camera_power_ctrl_t *power_info = &data->power_info;
	struct msm_camera_gpio_conf *gpio_conf = power_info->gpio_conf;

	CDBG("%s:%d\n", __func__, __LINE__);
	power_setting_array = &s_ctrl->power_setting_array;

	if (gpio_conf->cam_gpiomux_conf_tbl != NULL) {
		pr_err("%s:%d mux install\n", __func__, __LINE__);
		msm_gpiomux_install(
			(struct msm_gpiomux_config *)
			gpio_conf->cam_gpiomux_conf_tbl,
			gpio_conf->cam_gpiomux_conf_tbl_size);
	}

	rc = msm_camera_request_gpio_table(
		gpio_conf->cam_gpio_req_tbl,
		gpio_conf->cam_gpio_req_tbl_size, 1);
	if (rc < 0) {
		pr_err("%s: request gpio failed\n", __func__);
		return rc;
	}
	for (index = 0; index < power_setting_array->size; index++) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			if (power_setting->seq_val >=
					power_info->clk_info_size) {
				pr_err("%s clk index %d >= max %d\n", __func__,
					power_setting->seq_val,
					power_info->clk_info_size);
				goto power_up_failed;
			}
			if (power_setting->config_val)
				power_info->clk_info[power_setting->seq_val].
					clk_rate = power_setting->config_val;

			rc = msm_cam_clk_enable(power_info->dev,
				&power_info->clk_info[0],
				(struct clk **)&power_setting->data[0],
				power_info->clk_info_size,
				1);
			if (rc < 0) {
				pr_err("%s: clk enable failed\n",
					__func__);
				goto power_up_failed;
			}
			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			pr_debug("%s:%d gpio set val %d\n", __func__, __LINE__,
				gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val]);
			if (gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val])
				gpio_set_value_cansleep(
					gpio_conf->gpio_num_info->gpio_num
					[power_setting->seq_val],
					power_setting->config_val);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			msm_camera_config_single_vreg(power_info->dev,
				&power_info->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				1);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_INIT);
		if (rc < 0) {
			pr_err("%s cci_init failed\n", __func__);
			goto power_up_failed;
		}
	}

	s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write(
		s_ctrl->sensor_i2c_client,
		0xfc,
		0x10, MSM_CAMERA_I2C_BYTE_DATA);

	if (s_ctrl->func_tbl->sensor_match_id)
		rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl);
	else
		rc = msm_sensor_match_id(s_ctrl);
	if (rc < 0) {
		pr_err("%s:%d match id failed rc %d\n", __func__, __LINE__, rc);
		goto power_up_failed;
	}

	CDBG("%s exit\n", __func__);
	return 0;
power_up_failed:
	pr_err("%s:%d failed\n", __func__, __LINE__);
	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

	for (index--; index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(power_info->dev,
				&power_info->clk_info[0],
				(struct clk **)&power_setting->data[0],
				power_info->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val])
				gpio_set_value_cansleep(
					gpio_conf->gpio_num_info->gpio_num
					[power_setting->seq_val],
					GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			msm_camera_config_single_vreg(power_info->dev,
				&power_info->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		gpio_conf->cam_gpio_req_tbl,
		gpio_conf->cam_gpio_req_tbl_size, 0);
	return rc;
}
Exemplo n.º 8
0
int32_t ov10820_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
{
    int32_t rc = 0;
    struct msm_camera_sensor_board_info *info = s_ctrl->sensordata;
    struct device *dev = s_ctrl->dev;

    pr_debug("%s\n", __func__);
    if (info->gpio_conf->cam_gpiomux_conf_tbl != NULL) {
        msm_gpiomux_install(
            (struct msm_gpiomux_config *)
            info->gpio_conf->cam_gpiomux_conf_tbl,
            info->gpio_conf->cam_gpiomux_conf_tbl_size);
    }

    rc = msm_camera_request_gpio_table(
             info->gpio_conf->cam_gpio_req_tbl,
             info->gpio_conf->cam_gpio_req_tbl_size, GPIO_REQUEST_USE);
    if (rc < 0) {
        pr_err("%s: request gpio failed\n", __func__);
        return rc;
    }

    /*Set PWDN to low for power up*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[1].gpio,
                          GPIO_OUT_LOW);

    /*Reset OV660*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[5].gpio,
                          GPIO_OUT_LOW);

    /*Reset 10MP*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[4].gpio,
                          GPIO_OUT_LOW);

    /*Turn on mclk */
    rc = msm_cam_clk_enable(dev, &s_ctrl->clk_info[0],
                            (struct clk **)&cam_mclk[0],
                            s_ctrl->clk_info_size, CLK_ON);
    if (rc < 0) {
        pr_err("%s: clk enable failed\n", __func__);
        goto abort0;
    }

    /*Turn on vdd pk for ov660*/
    rc = msm_camera_config_single_vreg(dev,
                                       &info->cam_vreg[OV10820_CAM_VDIG],
                                       &cam_ov660_dvdd_pk, VREG_ON);
    if (rc < 0) {
        pr_err("%s: Unable to turn on cam_pk_dvdd (%d)\n",
               __func__, rc);
        goto abort1;
    }
    usleep_range(1000, 2000);

    /*Turn on VIO for both 10MP and OV660*/
    rc = msm_camera_config_single_vreg(dev,
                                       &info->cam_vreg[OV10820_CAM_VIO],
                                       &cam_vddio, VREG_ON);

    if (rc < 0) {
        pr_err("%s: Unable to turn on VDDIO (%d)\n", __func__, rc);
        goto abort2;
    }
    usleep_range(500, 600);

    /*Turn on AF Supply*/
    rc = msm_camera_config_single_vreg(dev,
                                       &info->cam_vreg[OV10820_CAM_VAF],
                                       &cam_afvdd, VREG_ON);

    if (rc < 0) {
        pr_err("%s: Unable to turn on AF Supply (%d)\n", __func__, rc);
        goto abort3;
    }
    usleep_range(500, 600);

    /*Enable 1.2V PD*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[6].gpio,
                          GPIO_OUT_HIGH);
    usleep_range(500, 600);

    /*Enable 10mp analog*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[0].gpio,
                          GPIO_OUT_HIGH);
    usleep_range(500, 600);

    /*Enable 10mp 1.2v*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[3].gpio,
                          GPIO_OUT_HIGH);
    usleep_range(500, 600);

    /*Wait for core supplies to power up*/
    usleep_range(1000, 2000);

    /*Set PWRDWN to high for normal mode for 10MP and OV660*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[1].gpio,
                          GPIO_OUT_HIGH);
    usleep_range(500, 600);

    /*Set reset high for 10MP*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[4].gpio,
                          GPIO_OUT_HIGH);

    /*Set reset high for OV660*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[5].gpio,
                          GPIO_OUT_HIGH);
    usleep_range(500, 600);

    if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
        rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
                 s_ctrl->sensor_i2c_client, MSM_CCI_INIT);
        if (rc < 0) {
            pr_err("%s cci_init failed\n", __func__);
            goto abort4;
        }
    }

    rc = ov10820_match_id(s_ctrl);
    if (rc < 0) {
        pr_err("%s:%d match id failed rc %d\n", __func__, __LINE__, rc);
        goto abort5;
    }

    goto power_up_done;

abort5:
    if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
        s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
            s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
    }
abort4:
    msm_camera_config_single_vreg(s_ctrl->dev,
                                  &info->cam_vreg[OV10820_CAM_VIO],
                                  &cam_vddio, VREG_OFF);
abort3:
    msm_camera_config_single_vreg(s_ctrl->dev,
                                  &info->cam_vreg[OV10820_CAM_VAF],
                                  &cam_afvdd, VREG_OFF);
abort2:
    msm_camera_config_single_vreg(dev,
                                  &info->cam_vreg[OV10820_CAM_VDIG],
                                  &cam_ov660_dvdd_pk, VREG_OFF);
abort1:
    msm_cam_clk_enable(dev, &s_ctrl->clk_info[0],
                       (struct clk **)&cam_mclk[0],
                       s_ctrl->clk_info_size, CLK_OFF);
abort0:
    msm_camera_request_gpio_table(
        info->gpio_conf->cam_gpio_req_tbl,
        info->gpio_conf->cam_gpio_req_tbl_size,
        GPIO_REQUEST_NO_USE);
power_up_done:
    return rc;
}
Exemplo n.º 9
0
static int32_t ov10820_sensor_power_down(
    struct msm_sensor_ctrl_t *s_ctrl)
{
    int32_t rc = 0;
    struct msm_camera_sensor_board_info *info = s_ctrl->sensordata;
    struct msm_sensor_power_setting_array *power_setting_array = NULL;
    struct msm_sensor_power_setting *power_setting = NULL;

    pr_debug("%s\n", __func__);

    power_setting_array = &s_ctrl->power_setting_array;
    power_setting = &power_setting_array->power_setting[0];

    if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
        s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
            s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
    }

    /*Disable MCLK*/
    rc = msm_cam_clk_enable(s_ctrl->dev, &s_ctrl->clk_info[0],
                            (struct clk **)&cam_mclk[0],
                            s_ctrl->clk_info_size, CLK_OFF);
    if (rc < 0)
        pr_err("ov10820: msm_cam_clk_enable failed (%d)\n", rc);
    usleep_range(500, 600);

    /*Reset 10MP*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[4].gpio,
                          GPIO_OUT_LOW);
    usleep_range(100, 200);

    /*Reset OV660*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[5].gpio,
                          GPIO_OUT_LOW);
    usleep_range(100, 200);

    /*Set 10MP DVDD Low*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[3].gpio,
                          GPIO_OUT_LOW);
    usleep_range(100, 200);

    /*Set OV660 DVDD low*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[6].gpio,
                          GPIO_OUT_LOW);
    usleep_range(100, 200);

    /*Disable AVDD for 10MP*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[0].gpio,
                          GPIO_OUT_LOW);
    usleep_range(100, 200);

    /*Set standby state to be on*/
    gpio_direction_output(info->gpio_conf->cam_gpio_req_tbl[1].gpio,
                          GPIO_OUT_LOW);
    usleep_range(100, 200);

    /*Turn off VDDIO*/
    rc = msm_camera_config_single_vreg(s_ctrl->dev,
                                       &s_ctrl->sensordata->cam_vreg[OV10820_CAM_VIO],
                                       &cam_vddio, VREG_OFF);
    usleep_range(500, 600);

    /*Turn off VDD PK*/
    msm_camera_config_single_vreg(s_ctrl->dev,
                                  &info->cam_vreg[OV10820_CAM_VDIG],
                                  &cam_ov660_dvdd_pk, VREG_OFF);

    /*Turn off AF regulator supply*/
    rc = msm_camera_config_single_vreg(s_ctrl->dev,
                                       &s_ctrl->sensordata->cam_vreg[OV10820_CAM_VAF],
                                       &cam_afvdd, VREG_OFF);
    usleep_range(100, 200);

    msm_camera_request_gpio_table(
        info->gpio_conf->cam_gpio_req_tbl,
        info->gpio_conf->cam_gpio_req_tbl_size, GPIO_REQUEST_NO_USE);

    return rc;
}
Exemplo n.º 10
0
int msm_camera_power_down(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int index = 0;
	struct msm_sensor_power_setting *power_setting = NULL;
	struct msm_sensor_power_setting *t_save_for_power_off = NULL;
	int32_t l_save_for_power_off = 0;
#if defined(CONFIG_MACH_MONTBLANC) || defined(CONFIG_MACH_VIKALCU)
		int ret;	//kk0704.park
#endif

	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}

	if (ctrl->check_power_on)
	    ctrl->check_power_on = false;
	else {
	    pr_err("This function needs power_up before it was called!!");
	    return 0;
	}

	if (device_type == MSM_CAMERA_PLATFORM_DEVICE)
		sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_RELEASE);

	if (ctrl->power_off_setting) {
	    CDBG("power off setting");
	    t_save_for_power_off = ctrl->power_setting;
	    l_save_for_power_off = ctrl->power_setting_size;
	    ctrl->power_setting = ctrl->power_off_setting;
	    ctrl->power_setting_size = ctrl->power_off_setting_size;
	}

	for (index = (ctrl->power_setting_size - 1); index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val], GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
#if defined(CONFIG_MACH_MONTBLANC) || defined(CONFIG_MACH_VIKALCU)
		case SENSOR_ADDITIONAL_LDO:
			switch(power_setting->seq_val) {
				case SENSOR_GPIO_EXT_VANA_POWER:
					if(sub_ldo3 != NULL) {
						ret = regulator_disable(sub_ldo3); /*2.8V*/
						if (ret) 
							pr_err("enable sub_ldo3 failed, rc=%d\n", ret);
					}
					break;
				case SENSOR_GPIO_EXT_VIO_POWER:
					if(sub_ldo4 != NULL) {
						ret = regulator_disable(sub_ldo4); /*1.8V*/
						if (ret) 
							pr_err("enable sub_ldo4 failed, rc=%d\n", ret);
					}
					break;
			}
			break;
#endif
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);

	if (ctrl->power_off_setting) {
	    CDBG("recovery power setting");
	    ctrl->power_setting = t_save_for_power_off;
	    ctrl->power_setting_size = l_save_for_power_off;
	}

	CDBG("%s exit\n", __func__);
	return 0;
}
Exemplo n.º 11
0
int msm_camera_power_up(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int rc = 0, index = 0, no_gpio = 0;
	struct msm_sensor_power_setting *power_setting = NULL;
	struct msm_sensor_power_setting *power_off_setting = NULL;
	int32_t off_index = 0;
#if defined(CONFIG_MACH_MONTBLANC) || defined(CONFIG_MACH_VIKALCU)
		int ret;	//kk0704.park
	
#endif


	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}

	if (ctrl->gpio_conf->cam_gpiomux_conf_tbl != NULL) {
		pr_err("%s:%d mux install\n", __func__, __LINE__);
		msm_gpiomux_install(
			(struct msm_gpiomux_config *)
			ctrl->gpio_conf->cam_gpiomux_conf_tbl,
			ctrl->gpio_conf->cam_gpiomux_conf_tbl_size);
	}

	rc = msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 1);
	if (rc < 0)
		no_gpio = rc;

	for (index = 0; index < ctrl->power_setting_size; index++) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			if (power_setting->seq_val >= ctrl->clk_info_size) {
				pr_err("%s clk index %d >= max %d\n", __func__,
					power_setting->seq_val,
					ctrl->clk_info_size);
				goto power_up_failed;
			}
			if (power_setting->config_val)
				ctrl->clk_info[power_setting->seq_val].
					clk_rate = power_setting->config_val;

			rc = msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				1);
			if (rc < 0) {
				pr_err("%s: clk enable failed\n",
					__func__);
				goto power_up_failed;
			}
			if (ctrl->power_off_setting) {
			    for (off_index = 0; off_index < ctrl->power_off_setting_size; off_index++) {
				power_off_setting = &ctrl->power_off_setting[off_index];
					if (power_off_setting->seq_type == SENSOR_CLK) {
					    CDBG("check clk %s,%d, %d!!!!", ctrl->clk_info[0].clk_name,
						 index, off_index);
					    memcpy(power_off_setting->data, power_setting->data,
						   sizeof(power_setting->data));
					}
			    }
			}

			break;
		case SENSOR_GPIO:
			if (no_gpio) {
				pr_err("%s: request gpio failed\n", __func__);
				return no_gpio;
			}
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			CDBG("%s:%d gpio set val %d\n", __func__, __LINE__,
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val]);
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val],
				power_setting->config_val);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}

			if (ctrl->cam_vreg[power_setting->seq_val].reg_name == NULL) {
				pr_err("%s can't find reg name from %d\n", __func__,
				       power_setting->seq_val);
				goto power_up_failed;
			}
			msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				1);

			if (ctrl->power_off_setting) {
			    for (off_index = 0; off_index < ctrl->power_off_setting_size; off_index++) {
					power_off_setting = &ctrl->power_off_setting[off_index];
					if (power_off_setting->seq_type == SENSOR_VREG) {
					    if (ctrl->cam_vreg[power_setting->seq_val].reg_name == NULL) {
							pr_err("can't find reg name from power setting");
							pr_err("sequence %d, index %d, off index %d", power_setting->seq_val,
							       index, off_index);
							break;
					    }
					    if (ctrl->cam_vreg[power_off_setting->seq_val].reg_name == NULL) {
							pr_err("can't find reg name from power off setting");
							pr_err("sequence %d, index %d, off index %d", power_off_setting->seq_val,
							       index, off_index);
							break;
					    }
					    if (!strcmp(ctrl->cam_vreg[power_setting->seq_val].reg_name,
							ctrl->cam_vreg[power_off_setting->seq_val].reg_name)) {
							CDBG("check regulator %s,%d, %d!!!!",
							     ctrl->cam_vreg[power_off_setting->seq_val].reg_name,
							     index, off_index);
							memcpy(power_off_setting->data, power_setting->data,
							       sizeof(power_setting->data));
							break;
					    }
					}
		    	}
			}

			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_enable_i2c_mux(ctrl->i2c_conf);
			break;
#if defined(CONFIG_MACH_MONTBLANC) || defined(CONFIG_MACH_VIKALCU)
		case SENSOR_ADDITIONAL_LDO:
			switch(power_setting->seq_val) {
				case SENSOR_GPIO_EXT_VANA_POWER:

					sub_ldo3 = regulator_get(NULL, "lp8720_ldo3");
					if (IS_ERR(sub_ldo3)) {
						pr_err("lp8720 : could not get sub_ldo3, rc = %ld\n", PTR_ERR(sub_ldo3));
						sub_ldo3 = NULL;
					}
					if(sub_ldo3 != NULL)
					{
						ret = regulator_set_voltage(sub_ldo3, 2800000, 2800000);
						if (ret) 
							pr_err("set_voltage sub_ldo3 failed, rc=%d\n", ret);
						else {
							ret = regulator_enable(sub_ldo3); /*2.8V*/
							if (ret) 
								pr_err("enable sub_ldo3 failed, rc=%d\n", ret);
						}
					}

					break;
					
				case SENSOR_GPIO_EXT_VIO_POWER:
					
					sub_ldo4 = regulator_get(NULL, "lp8720_ldo4");
					if (IS_ERR(sub_ldo4)) {
						pr_err("lp8720 : could not get sub_ldo4, rc = %ld\n", PTR_ERR(sub_ldo4));
						sub_ldo4 = NULL;
					}
					if(sub_ldo4 != NULL)
					{
						ret = regulator_set_voltage(sub_ldo4, 1800000, 1800000);
						if (ret) 
							pr_err("set_voltage sub_ldo4 failed, rc=%d\n", ret);
						else {
							ret = regulator_enable(sub_ldo4); /*1.8V*/
							if (ret) 
								pr_err("enable sub_ldo4 failed, rc=%d\n", ret);
						}
					}
					break;
					
				}

			break;
#endif
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}

	if (device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		rc = sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_INIT);
		if (rc < 0) {
			pr_err("%s cci_init failed\n", __func__);
			goto power_up_failed;
		}
	}

	ctrl->check_power_on = true;

	CDBG("%s exit\n", __func__);
	return 0;
power_up_failed:
	pr_err("%s:%d failed\n", __func__, __LINE__);
	if (device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_RELEASE);
	}

	for (index--; index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val], GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
#if defined(CONFIG_MACH_MONTBLANC) || defined(CONFIG_MACH_VIKALCU)
		case SENSOR_ADDITIONAL_LDO:
			switch(power_setting->seq_val) {
				case SENSOR_GPIO_EXT_VANA_POWER:
					if(sub_ldo3 != NULL) {
						ret = regulator_disable(sub_ldo3); /*2.8V*/
						if (ret) 
							pr_err("enable sub_ldo3 failed, rc=%d\n", ret);
					}
					break;
				case SENSOR_GPIO_EXT_VIO_POWER:
					if(sub_ldo4 != NULL) {
						ret = regulator_disable(sub_ldo4); /*1.8V*/
						if (ret) 
							pr_err("enable sub_ldo4 failed, rc=%d\n", ret);
					}
					break;
			}
			break;
#endif
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);
	return rc;
}
Exemplo n.º 12
0
int msm_camera_power_down(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int index = 0;
	struct msm_sensor_power_setting *pd = NULL;
	struct msm_sensor_power_setting *ps;


	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}

	if (device_type == MSM_CAMERA_PLATFORM_DEVICE)
		sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_RELEASE);

	for (index = 0; index < ctrl->power_down_setting_size; index++) {
		CDBG("%s index %d\n", __func__, index);
		pd = &ctrl->power_down_setting[index];
		ps = NULL;
		CDBG("%s type %d\n", __func__, pd->seq_type);
		switch (pd->seq_type) {
		case SENSOR_CLK:

			ps = msm_camera_get_power_settings(ctrl,
						pd->seq_type,
						pd->seq_val);
			if (ps)
				msm_cam_clk_enable(ctrl->dev,
					&ctrl->clk_info[0],
					(struct clk **)&ps->data[0],
					ctrl->clk_info_size,
					0);
			else
				pr_err("%s error in power up/down seq data\n",
								__func__);
				break;
		case SENSOR_GPIO:
			if (pd->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					pd->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
                    

			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[pd->seq_val], GPIOF_OUT_INIT_LOW);
                    // zte-modify, fuyipeng modify for power down ---
			break;
		case SENSOR_VREG:
			if (pd->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					pd->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}

			ps = msm_camera_get_power_settings(ctrl,
						pd->seq_type,
						pd->seq_val);

			if (ps)
				msm_camera_config_single_vreg(ctrl->dev,
					&ctrl->cam_vreg[pd->seq_val],
					(struct regulator **)&ps->data[0],
					0);
			else
				pr_err("%s error in power up/down seq data\n",
								__func__);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				pd->seq_type);
			break;
		}
		if (pd->delay > 20) {
			msleep(pd->delay);
		} else if (pd->delay) {
			usleep_range(pd->delay * 1000,
				(pd->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);
	CDBG("%s exit\n", __func__);
	return 0;
}
int msm_camera_power_up(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int rc = 0, index = 0, no_gpio = 0, ret = 0;
	struct msm_sensor_power_setting *power_setting = NULL;

	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}
	if (ctrl->gpio_conf->cam_gpiomux_conf_tbl != NULL) {
		pr_err("%s:%d mux install\n", __func__, __LINE__);
	}
	ret = msm_camera_pinctrl_init(ctrl);
	if (ret < 0) {
		pr_err("%s:%d Initialization of pinctrl failed\n",
				__func__, __LINE__);
		ctrl->cam_pinctrl_status = 0;
	} else {
		ctrl->cam_pinctrl_status = 1;
	}
	rc = msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 1);
	if (rc < 0)
		no_gpio = rc;
	if (ctrl->cam_pinctrl_status) {
		ret = pinctrl_select_state(ctrl->pinctrl_info.pinctrl,
			ctrl->pinctrl_info.gpio_state_active);
		if (ret)
			pr_err("%s:%d cannot set pin to active state",
				__func__, __LINE__);
	}
	for (index = 0; index < ctrl->power_setting_size; index++) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			if (power_setting->seq_val >= ctrl->clk_info_size) {
				pr_err("%s clk index %d >= max %d\n", __func__,
					power_setting->seq_val,
					ctrl->clk_info_size);
				goto power_up_failed;
			}
			if (power_setting->config_val)
				ctrl->clk_info[power_setting->seq_val].
					clk_rate = power_setting->config_val;

			rc = msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				1);
			if (rc < 0) {
				pr_err("%s: clk enable failed\n",
					__func__);
				goto power_up_failed;
			}
			break;
		case SENSOR_GPIO:
			if (no_gpio) {
				pr_err("%s: request gpio failed\n", __func__);

				//LGE_CHANGE_S, goto 'power up fail routine' before return error, [email protected]
			#if defined (CONFIG_MACH_MSM8916_C70W_KR)
				rc = no_gpio;
				goto power_up_failed;
			#else
				return no_gpio;
			#endif
				//LGE_CHANGE_E, goto 'power up fail routine' before return error, [email protected]
			}
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			if (!ctrl->gpio_conf->gpio_num_info->valid
				[power_setting->seq_val])
				continue;
			CDBG("%s:%d gpio set val %d\n", __func__, __LINE__,
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val]);
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val],
				(int) power_setting->config_val);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			if (power_setting->seq_val < ctrl->num_vreg)
				msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				1);
			else
				pr_err("ERR:%s: %d usr_idx:%d dts_idx:%d\n",
					__func__, __LINE__,
					power_setting->seq_val, ctrl->num_vreg);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_enable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}

	if (device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		rc = sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_INIT);
		if (rc < 0) {
			pr_err("%s cci_init failed\n", __func__);
			goto power_up_failed;
		}
	}

	CDBG("%s exit\n", __func__);
	return 0;
power_up_failed:
	pr_err("%s:%d failed\n", __func__, __LINE__);
	for (index--; index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {

		case SENSOR_CLK:
			msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (!ctrl->gpio_conf->gpio_num_info)
				continue;
			if (!ctrl->gpio_conf->gpio_num_info->valid
				[power_setting->seq_val])
				continue;
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val], GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val < ctrl->num_vreg)
				msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			else
				pr_err("%s:%d:seq_val: %d > num_vreg: %d\n",
					__func__, __LINE__,
					power_setting->seq_val, ctrl->num_vreg);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	if (ctrl->cam_pinctrl_status) {
		ret = pinctrl_select_state(ctrl->pinctrl_info.pinctrl,
				ctrl->pinctrl_info.gpio_state_suspend);
		if (ret)
			pr_err("%s:%d cannot set pin to suspend state\n",
				__func__, __LINE__);
		devm_pinctrl_put(ctrl->pinctrl_info.pinctrl);
	}
	ctrl->cam_pinctrl_status = 0;
	msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);
	return rc;
}
Exemplo n.º 14
0
int msm_camera_power_down(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int index = 0;
	struct msm_sensor_power_setting *pd = NULL;
	struct msm_sensor_power_setting *ps;


	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}

	if (device_type == MSM_CAMERA_PLATFORM_DEVICE)
		sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_RELEASE);

	for (index = 0; index < ctrl->power_down_setting_size; index++) {
		CDBG("%s index %d\n", __func__, index);
		pd = &ctrl->power_down_setting[index];
		ps = NULL;
		CDBG("%s type %d\n", __func__, pd->seq_type);
		switch (pd->seq_type) {
		case SENSOR_CLK:

			ps = msm_camera_get_power_settings(ctrl,
						pd->seq_type,
						pd->seq_val);
			if (ps)
				msm_cam_clk_enable(ctrl->dev,
					&ctrl->clk_info[0],
					(struct clk **)&ps->data[0],
					ctrl->clk_info_size,
					0);
			else
				pr_err("%s error in power up/down seq data\n",
								__func__);
				break;
		case SENSOR_GPIO:
			if (pd->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					pd->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			if (!ctrl->gpio_conf->gpio_num_info->valid
				[pd->seq_val])
				continue;
/* +add ljk for gpio 22/23 share */
			if(22 == ctrl->gpio_conf->gpio_num_info->gpio_num[pd->seq_val])
			{
			    gpio22_req_times--;
                CDBG("%s:2-- %d gpio22_req_times=%d\n", __func__, __LINE__,gpio22_req_times);

			    if(gpio22_req_times == 0)
			    {
        			gpio_set_value_cansleep(
        				ctrl->gpio_conf->gpio_num_info->gpio_num
        				[pd->seq_val],
        				ctrl->gpio_conf->gpio_num_info->gpio_num
        				[pd->config_val]);
                    CDBG("%s:2-- %d gpio set val %d\n", __func__, __LINE__,
    				ctrl->gpio_conf->gpio_num_info->gpio_num
    				[pd->seq_val]);

				}
            }

			else if(23 == ctrl->gpio_conf->gpio_num_info->gpio_num[pd->seq_val])
            {
			    gpio23_req_times--;
                CDBG("%s:3-- %d gpio23_req_times=%d\n", __func__, __LINE__,gpio23_req_times);

			    if(gpio23_req_times == 0)
			    {
        			gpio_set_value_cansleep(
        				ctrl->gpio_conf->gpio_num_info->gpio_num
        				[pd->seq_val],
        				ctrl->gpio_conf->gpio_num_info->gpio_num
        				[pd->config_val]);
                    CDBG("%s:3-- %d gpio set val %d\n", __func__, __LINE__,
    				ctrl->gpio_conf->gpio_num_info->gpio_num
    				[pd->seq_val]);
				}

			}
            else
            {
                gpio_set_value_cansleep(
        		ctrl->gpio_conf->gpio_num_info->gpio_num
        		[pd->seq_val],
        		ctrl->gpio_conf->gpio_num_info->gpio_num
        		[pd->config_val]);

                CDBG("%s:4-- %d gpio set val %d\n", __func__, __LINE__,
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[pd->seq_val]);
            }
/* + end */
			break;
		case SENSOR_VREG:
			if (pd->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					pd->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}

			ps = msm_camera_get_power_settings(ctrl,
						pd->seq_type,
						pd->seq_val);

			if (ps)
				msm_camera_config_single_vreg(ctrl->dev,
					&ctrl->cam_vreg[pd->seq_val],
					(struct regulator **)&ps->data[0],
					0);
			else
				pr_err("%s error in power up/down seq data\n",
								__func__);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				pd->seq_type);
			break;
		}
		if (pd->delay > 20) {
			msleep(pd->delay);
		} else if (pd->delay) {
			usleep_range(pd->delay * 1000,
				(pd->delay * 1000) + 1000);
		}
	}

/* +add ljk for gpio 22/23 share */

			    if((gpio22_req_times == 0) || (gpio23_req_times == 0))///22 last gpio_common for 8825; 23  last gpio_common for 9760;
			    {

                	msm_camera_request_gpio_table(
                		ctrl->gpio_conf->cam_gpio_req_tbl,
                		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);

                    CDBG("%s:2-- %d gpio_free_array \n", __func__, __LINE__);

				}
/* +end */
	CDBG("%s exit\n", __func__);
	return 0;
}
Exemplo n.º 15
0
int ov680_power_up(struct msm_sensor_ctrl_t *s_ctrl, struct msm_sensor_power_setting* power_setting_table, int size)
{
	int index, rc = 0;
	struct msm_sensor_power_setting* power_setting;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;
	ov680_info("%s line %d", __func__, __LINE__);

	/* request GPIO table */
	rc = msm_camera_request_gpio_table(standby_gpios, sizeof(standby_gpios)/sizeof(standby_gpios[0]), 1);
	if(rc){
		ov680_err("%s msm_camera_request_gpio_table failed rc=%d %d", __func__, rc, __LINE__);
		return rc;
	}

	for (index = 0; index < size; index++) {
		ov680_dbg("%s index %d\n", __func__, index);
		power_setting = &power_setting_table[index];
		ov680_dbg("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			if (power_setting->seq_val >= s_ctrl->clk_info_size) {
				pr_err("%s clk index %d >= max %d\n", __func__,
					power_setting->seq_val,
					s_ctrl->clk_info_size);
				goto ov680_power_up_failed;
			}
			if (power_setting->config_val)
				s_ctrl->clk_info[power_setting->seq_val].
					clk_rate = power_setting->config_val;

			ov680_dbg("%s Enable MCLK %d", __func__, __LINE__);
			rc = msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				1);
			if (rc < 0) {
				pr_err("%s: clk enable failed\n",
					__func__);
				goto ov680_power_up_failed;
			}
			break;
		case SENSOR_VREG:
			ov680_dbg("%s Enable VREG %d", __func__, __LINE__);
			rc = msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				1);
			if (rc < 0) {
				pr_err("%s: vreg enable failed\n",
					__func__);
				goto ov680_power_up_failed;
			}

			break;
		case SENSOR_GPIO:
		case SENSOR_I2C_MUX:
		default:
			ov680_info("Not handled");
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	/* call CCI INIT */
	ov680_dbg("call CCI INIT");
	rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
		s_ctrl->sensor_i2c_client, MSM_CCI_INIT);
	if (rc < 0) {
		pr_err("%s cci_init failed\n", __func__);
		goto ov680_power_up_failed;
	}
	return 0;

ov680_power_up_failed:
	ov680_err("%s:%d failed\n", __func__, __LINE__);
	s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
                        s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);

	for (index--; index >= 0; index--) {
                ov680_err("%s index %d\n", __func__, index);
		power_setting = &power_setting_table[index];
                ov680_err("%s type %d\n", __func__, power_setting->seq_type);
                switch (power_setting->seq_type) {
                case SENSOR_CLK:
                        msm_cam_clk_enable(s_ctrl->dev,
                                &s_ctrl->clk_info[0],
                                (struct clk **)&power_setting->data[0],
                                s_ctrl->clk_info_size,
                                0);
                        break;
		case SENSOR_VREG:
                        msm_camera_config_single_vreg(s_ctrl->dev,
                                &data->cam_vreg[power_setting->seq_val],
                                (struct regulator **)&power_setting->data[0],
                                0);
			break;
		case SENSOR_GPIO:
		case SENSOR_I2C_MUX:
		default:
			ov680_info("Not handled");
			break;

		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(standby_gpios, sizeof(standby_gpios)/sizeof(standby_gpios[0]), 0);

return rc;
}
int32_t s5k4e1_liteon_affli_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t index = 0;
	struct msm_sensor_power_setting_array *power_setting_array = NULL;
	struct msm_sensor_power_setting *power_setting = NULL;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;
	s_ctrl->stop_setting_valid = 0;

	CDBG("%s:%d\n", __func__, __LINE__);
	/*use separate power down array, and the positive sequence*/
	power_setting_array = &s_ctrl->power_down_setting_array;

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

	for (index = 0; index < power_setting_array->size; index++) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!data->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			/*set as the value shown, not all to LOW*/
			gpio_set_value_cansleep(
				data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val], power_setting->seq_val);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);

			gpio_set_value_cansleep(GPIO_CAM_VCM_PWDN,0); //disable vcm
							
			break;
		case SENSOR_I2C_MUX:
			if (data->i2c_conf && data->i2c_conf->use_i2c_mux)
				s5k4e1_liteon_affli_sensor_disable_i2c_mux(data->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		data->gpio_conf->cam_gpio_req_tbl,
		data->gpio_conf->cam_gpio_req_tbl_size, 0);
	CDBG("%s exit\n", __func__);

	return 0;
}
int32_t s5k4e1_liteon_affli_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0, index = 0;
	struct msm_sensor_power_setting_array *power_setting_array = NULL;
	struct msm_sensor_power_setting *power_setting = NULL;

	struct msm_sensor_power_setting_array *power_down_setting_array = NULL;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;

	CDBG("%s:%d\n", __func__, __LINE__);
	power_setting_array = &s_ctrl->power_setting_array;
	power_down_setting_array = &s_ctrl->power_down_setting_array;

	if (data->gpio_conf->cam_gpiomux_conf_tbl != NULL) {
		pr_err("%s:%d mux install\n", __func__, __LINE__);
		msm_gpiomux_install(
			(struct msm_gpiomux_config *)
			data->gpio_conf->cam_gpiomux_conf_tbl,
			data->gpio_conf->cam_gpiomux_conf_tbl_size);
	}

	rc = msm_camera_request_gpio_table(
		data->gpio_conf->cam_gpio_req_tbl,
		data->gpio_conf->cam_gpio_req_tbl_size, 1);
	if (rc < 0) {
		pr_err("%s: request gpio failed\n", __func__);
		return rc;
	}
	for (index = 0; index < power_setting_array->size; index++) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			if (power_setting->seq_val >= s_ctrl->clk_info_size) {
				pr_err("%s clk index %d >= max %d\n", __func__,
					power_setting->seq_val,
					s_ctrl->clk_info_size);
				goto power_up_failed;
			}
			if (power_setting->config_val)
				s_ctrl->clk_info[power_setting->seq_val].
					clk_rate = power_setting->config_val;

			rc = msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				1);
			if (rc < 0) {
				pr_err("%s: clk enable failed\n",
					__func__);
				goto power_up_failed;
			}

#ifdef CONFIG_HUAWEI_KERNEL_CAMERA
			/*store data[0] for the use of power down*/
			if(s_ctrl->power_down_setting_array.power_setting){
				int32_t i = 0;
				int32_t j = 0;
				struct msm_sensor_power_setting *power_down_setting = NULL;
				for(i=0; i<power_down_setting_array->size; i++){
					power_down_setting = &power_down_setting_array->power_setting[i];
					if(power_setting->seq_val == power_down_setting->seq_val){
						for(j=0; j<s_ctrl->clk_info_size; j++)
						{
							power_down_setting->data[j] = power_setting->data[j];
							CDBG("%s clkptr %p \n", __func__, power_setting->data[j]);
						}
					}
				}
			}
#endif

			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!data->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			pr_debug("%s:%d gpio set val %d\n", __func__, __LINE__,
				data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val]);
			gpio_set_value_cansleep(
				data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val],
				power_setting->config_val);		
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				1);

			gpio_set_value_cansleep(GPIO_CAM_VCM_PWDN,1); //disable vcm

#ifdef CONFIG_HUAWEI_KERNEL_CAMERA
			/*store data[0] for the use of power down*/
			if(s_ctrl->power_down_setting_array.power_setting){
				int32_t i = 0;
				struct msm_sensor_power_setting *power_down_setting = NULL;
				for(i=0;i<power_down_setting_array->size; i++){
					power_down_setting = &power_down_setting_array->power_setting[i];
					if(power_setting->seq_val == power_down_setting->seq_val){
						power_down_setting->data[0] = power_setting->data[0];
					}
				}
			}
#endif

			break;
		case SENSOR_I2C_MUX:
			if (data->i2c_conf && data->i2c_conf->use_i2c_mux)
				s5k4e1_liteon_affli_sensor_enable_i2c_mux(data->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_INIT);
		if (rc < 0) {
			pr_err("%s cci_init failed\n", __func__);
			goto power_up_failed;
		}
	}

	if (s_ctrl->func_tbl->sensor_match_id)
		rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl);
	else
		rc = msm_sensor_match_id(s_ctrl);
	if (rc < 0) {
		pr_err("%s:%d match id failed rc %d\n", __func__, __LINE__, rc);
		goto power_up_failed;
	}

	CDBG("%s exit\n", __func__);
	return 0;
power_up_failed:
	pr_err("%s:%d failed\n", __func__, __LINE__);
	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

	/*power up failed, use the power down array to power down*/
	if(s_ctrl->power_down_setting_array.power_setting){
		power_setting_array = &s_ctrl->power_down_setting_array;
		index = power_setting_array->size;
	}
	for (index = 0; index < power_setting_array->size; index++){
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			gpio_set_value_cansleep(
				data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val], GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		case SENSOR_I2C_MUX:
			if (data->i2c_conf && data->i2c_conf->use_i2c_mux)
				s5k4e1_liteon_affli_sensor_disable_i2c_mux(data->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		data->gpio_conf->cam_gpio_req_tbl,
		data->gpio_conf->cam_gpio_req_tbl_size, 0);
	return rc;
}
int msm_camera_power_down(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int index = 0, ret = 0;
	struct msm_sensor_power_setting *pd = NULL;
	struct msm_sensor_power_setting *ps;

	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}
	if (device_type == MSM_CAMERA_PLATFORM_DEVICE)
		sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_RELEASE);

	for (index = 0; index < ctrl->power_down_setting_size; index++) {
		CDBG("%s index %d\n", __func__, index);
		pd = &ctrl->power_down_setting[index];
		ps = NULL;
		CDBG("%s type %d\n", __func__, pd->seq_type);
		switch (pd->seq_type) {
		case SENSOR_CLK:

			ps = msm_camera_get_power_settings(ctrl,
						pd->seq_type,
						pd->seq_val);
			if (ps)
				msm_cam_clk_enable(ctrl->dev,
					&ctrl->clk_info[0],
					(struct clk **)&ps->data[0],
					ctrl->clk_info_size,
					0);
			else
				pr_err("%s error in power up/down seq data\n",
								__func__);
				break;
		case SENSOR_GPIO:
			if (pd->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					pd->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			if (!ctrl->gpio_conf->gpio_num_info->valid
				[pd->seq_val])
				continue;
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[pd->seq_val],
				0); //pd->config_val); //LGE_CHANGE, 2014-06-05, temp fix for power down, jongkwon.chae
			break;
		case SENSOR_VREG:
			if (pd->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					pd->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}

			ps = msm_camera_get_power_settings(ctrl,
						pd->seq_type,
						pd->seq_val);
			if (ps) {
				if (pd->seq_val < ctrl->num_vreg)
					msm_camera_config_single_vreg(ctrl->dev,
					&ctrl->cam_vreg[pd->seq_val],
					(struct regulator **)&ps->data[0],
					0);
				else
					pr_err("%s:%d:seq_val:%d > num_vreg: %d\n"
						, __func__, __LINE__,
						pd->seq_val, ctrl->num_vreg);
			} else
				pr_err("%s error in power up/down seq data\n",
								__func__);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				pd->seq_type);
			break;
		}
		if (pd->delay > 20) {
			msleep(pd->delay);
		} else if (pd->delay) {
			usleep_range(pd->delay * 1000,
				(pd->delay * 1000) + 1000);
		}
	}
	if (ctrl->cam_pinctrl_status) {
		ret = pinctrl_select_state(ctrl->pinctrl_info.pinctrl,
				ctrl->pinctrl_info.gpio_state_suspend);
		if (ret)
			pr_err("%s:%d cannot set pin to suspend state",
				__func__, __LINE__);
		devm_pinctrl_put(ctrl->pinctrl_info.pinctrl);
	}
	ctrl->cam_pinctrl_status = 0;
	msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);
	CDBG("%s exit\n", __func__);
	return 0;
}
Exemplo n.º 19
0
int32_t gc0339_power_down(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t index = 0;
	struct msm_sensor_power_setting_array *power_setting_array = NULL;
	struct msm_sensor_power_setting *power_setting = NULL;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;
	struct msm_camera_power_ctrl_t *power_info = &data->power_info;
	struct msm_camera_gpio_conf *gpio_conf = power_info->gpio_conf;

	CDBG("%s:%d\n", __func__, __LINE__);
	power_setting_array = &s_ctrl->power_setting_array;

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

	s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write(
		s_ctrl->sensor_i2c_client,
		0xfc,
		0x01, MSM_CAMERA_I2C_BYTE_DATA);

	for (index = (power_setting_array->size - 1); index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(power_info->dev,
				&power_info->clk_info[0],
				(struct clk **)&power_setting->data[0],
				power_info->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			if (gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val])
				gpio_set_value_cansleep(
					gpio_conf->gpio_num_info->gpio_num
					[power_setting->seq_val],
					GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			msm_camera_config_single_vreg(power_info->dev,
				&power_info->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		gpio_conf->cam_gpio_req_tbl,
		gpio_conf->cam_gpio_req_tbl_size, 0);
	CDBG("%s exit\n", __func__);
	return 0;
}
Exemplo n.º 20
0
int msm_camera_power_up(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int rc = 0, index = 0, no_gpio = 0;
	struct msm_sensor_power_setting *power_setting = NULL;

	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}
	if (ctrl->gpio_conf->cam_gpiomux_conf_tbl != NULL) {
		pr_err("%s:%d mux install\n", __func__, __LINE__);
		msm_gpiomux_install(
			(struct msm_gpiomux_config *)
			ctrl->gpio_conf->cam_gpiomux_conf_tbl,
			ctrl->gpio_conf->cam_gpiomux_conf_tbl_size);
	}

	rc = msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 1);
	if (rc < 0)
		no_gpio = rc;

	for (index = 0; index < ctrl->power_setting_size; index++) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			if (power_setting->seq_val >= ctrl->clk_info_size) {
				pr_err("%s clk index %d >= max %d\n", __func__,
					power_setting->seq_val,
					ctrl->clk_info_size);
				goto power_up_failed;
			}
			if (power_setting->config_val)
				ctrl->clk_info[power_setting->seq_val].
					clk_rate = power_setting->config_val;

			rc = msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				1);
			if (rc < 0) {
				pr_err("%s: clk enable failed\n",
					__func__);
				goto power_up_failed;
			}
			break;
		case SENSOR_GPIO:
			if (no_gpio) {
				pr_err("%s: request gpio failed\n", __func__);
				return no_gpio;
			}
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			if (!ctrl->gpio_conf->gpio_num_info->valid
				[power_setting->seq_val])
				continue;
			CDBG("%s:%d gpio set val %d\n", __func__, __LINE__,
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val]);

                    
                    if (ctrl->gpio_conf->gpio_num_info->gpio_num[power_setting->seq_val] == 69
                        || ctrl->gpio_conf->gpio_num_info->gpio_num[power_setting->seq_val] == 15
                        || ctrl->gpio_conf->gpio_num_info->gpio_num[power_setting->seq_val] == 14
                        || ctrl->gpio_conf->gpio_num_info->gpio_num[power_setting->seq_val] == 64)
                    {
                        CDBG("fuyipeng --- set gpio 69");
                        gpio_tlmm_config(GPIO_CFG(ctrl->gpio_conf->gpio_num_info->gpio_num[power_setting->seq_val], 
                                        0,
                        				GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
                        				GPIO_CFG_2MA), GPIO_CFG_ENABLE);            
                        gpio_direction_output(ctrl->gpio_conf->gpio_num_info->gpio_num[power_setting->seq_val], 1);
                    }
                    
 
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val],
				power_setting->config_val);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				1);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_enable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}

	if (device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		rc = sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_INIT);
		if (rc < 0) {
			pr_err("%s cci_init failed\n", __func__);
			goto power_up_failed;
		}
	}

	CDBG("%s exit\n", __func__);
	return 0;
power_up_failed:
	pr_err("%s:%d failed\n", __func__, __LINE__);
	for (index--; index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {

		case SENSOR_CLK:
			msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (!ctrl->gpio_conf->gpio_num_info->valid
				[power_setting->seq_val])
				continue;
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val], GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);
	return rc;
}
Exemplo n.º 21
0
static int32_t imx135_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	struct msm_camera_sensor_board_info *info = s_ctrl->sensordata;
	struct device *dev = s_ctrl->dev;

	pr_debug("%s: Enter\n", __func__);

	if (info->gpio_conf->cam_gpiomux_conf_tbl != NULL) {
		msm_gpiomux_install(
				(struct msm_gpiomux_config *)
				info->gpio_conf->cam_gpiomux_conf_tbl,
				info->gpio_conf->cam_gpiomux_conf_tbl_size);
	}

	rc = msm_camera_request_gpio_table(
			info->gpio_conf->cam_gpio_req_tbl,
			info->gpio_conf->cam_gpio_req_tbl_size,
			GPIO_REQUEST_USE);
	if (rc < 0) {
		pr_err("%s: request gpio failed\n", __func__);
		return rc;
	}

	if (imx135_devboard_config == true)
		return imx135_sensor_power_up_devboard(s_ctrl);

	/* Initialize gpios */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[2].gpio,
			GPIO_OUT_LOW);
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[3].gpio,
			GPIO_OUT_LOW);
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[4].gpio,
			GPIO_OUT_LOW);

	/* Enable VDDIO Supply */
	rc = msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VIO],
			&imx135_cam_vddio, VREG_ON);
	if (rc < 0) {
		pr_err("%s: Unable to turn on VDDIO (%d)\n", __func__, rc);
		goto abort0;
	}
	usleep_range(1000, 2000);

	/* Enable Core supply (VDD) and enable load switch */
	rc = msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VDIG],
			&imx135_cam_vdd, VREG_ON);
	if (rc < 0) {
		pr_err("%s: Unable to turn on VDD (%d)\n", __func__, rc);
		goto abort1;
	}
	usleep_range(1000, 2000);

	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[3].gpio,
			GPIO_OUT_HIGH);
	usleep_range(1000, 2000);

	/* Enable AVDD supply */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[1].gpio,
			GPIO_OUT_HIGH);
	usleep_range(1000, 2000);

	/* Enable AF Supply (VAF) */
	rc = msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VAF],
			&imx135_cam_vaf, VREG_ON);
	if (rc < 0) {
		pr_err("%s: Unable to turn on VAF (%d)\n", __func__, rc);
		goto abort2;
	}
	usleep_range(1000, 2000);

	/* Enable MCLK */
	s_ctrl->clk_info[0].clk_rate = 24000000;
	rc = msm_cam_clk_enable(dev, &s_ctrl->clk_info[0],
				(struct clk **)&imx135_cam_mclk[0],
				s_ctrl->clk_info_size, CLK_ON);
	if (rc < 0) {
		pr_err("%s: clk enable failed\n", __func__);
		goto abort3;
	}
	usleep_range(2000, 3000);

	/* Initiate a Reset */
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[4].gpio,
			GPIO_OUT_HIGH);
	usleep_range(30000, 31000);

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_INIT);
		if (rc < 0) {
			pr_err("%s cci_init failed\n", __func__);
			goto abort4;
		}
	}

	rc = imx135_sensor_match_id(s_ctrl);
	if (rc < 0) {
		pr_err("%s: match id failed!\n", __func__);
		goto abort5;
	}

	goto power_up_done;
abort5:
	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

abort4:
	msm_cam_clk_enable(dev, &s_ctrl->clk_info[0],
			(struct clk **)&imx135_cam_mclk[0],
			s_ctrl->clk_info_size, CLK_OFF);
	usleep_range(1000, 1500);

	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[2].gpio,
			GPIO_OUT_LOW);
	usleep_range(1000, 1500);

abort3:
	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VAF],
			&imx135_cam_vaf, VREG_OFF);

abort2:
	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[1].gpio,
			GPIO_OUT_LOW);

	gpio_set_value_cansleep(info->gpio_conf->cam_gpio_req_tbl[3].gpio,
			GPIO_OUT_LOW);

	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VDIG],
			&imx135_cam_vdd, VREG_OFF);

abort1:
	msm_camera_config_single_vreg(dev,
			&info->cam_vreg[IMX135_CAM_VIO],
			&imx135_cam_vddio, VREG_OFF);

abort0:
	msm_camera_request_gpio_table(
			info->gpio_conf->cam_gpio_req_tbl,
			info->gpio_conf->cam_gpio_req_tbl_size,
			GPIO_REQUEST_NO_USE);

power_up_done:
	return rc;
}
int msm_camera_power_down(struct msm_camera_power_ctrl_t *ctrl,
	enum msm_camera_device_type_t device_type,
	struct msm_camera_i2c_client *sensor_i2c_client)
{
	int index = 0;
	struct msm_sensor_power_setting *power_setting = NULL;

	CDBG("%s:%d\n", __func__, __LINE__);
	if (!ctrl || !sensor_i2c_client) {
		pr_err("failed ctrl %p sensor_i2c_client %p\n", ctrl,
			sensor_i2c_client);
		return -EINVAL;
	}

	if (device_type == MSM_CAMERA_PLATFORM_DEVICE)
		sensor_i2c_client->i2c_func_tbl->i2c_util(
			sensor_i2c_client, MSM_CCI_RELEASE);

	for (index = (ctrl->power_setting_size - 1); index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &ctrl->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(ctrl->dev,
				&ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!ctrl->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			gpio_set_value_cansleep(
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val],
				ctrl->gpio_conf->gpio_num_info->gpio_num
				[power_setting->config_val]);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
#ifndef FEATURE_KYOCERA_MCAM
			msm_camera_config_single_vreg(ctrl->dev,
				&ctrl->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
#endif
			break;
		case SENSOR_I2C_MUX:
			if (ctrl->i2c_conf && ctrl->i2c_conf->use_i2c_mux)
				msm_camera_disable_i2c_mux(ctrl->i2c_conf);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		ctrl->gpio_conf->cam_gpio_req_tbl,
		ctrl->gpio_conf->cam_gpio_req_tbl_size, 0);
	CDBG("%s exit\n", __func__);
	return 0;
}