static int msm8930_ov5693_vreg_off(void)
{
	int rc = 0;

	pr_info("[CAM] %s\n", __func__);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO1, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO1 failed!\n");
	}
	udelay(50);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO3, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO3 failed!\n");
	}
	udelay(50);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO2, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO2 failed!\n");
	}
	udelay(50);

	return rc;
}
static int msm8930_mt9v113_vreg_off(void)
{
	int rc = 0;
	pr_info("[CAM] %s\n", __func__);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO3, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO3 failed!\n");
	}
	udelay(50);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO1, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO1 failed!\n");
	}
	udelay(50);

	rc = ncp6924_enable_dcdc(NCP6924_ID_DCDC2, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_DCDC2 failed!\n");
	}
	udelay(50);

	/* reset pin */
	rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "mt9v113");
	pr_info("[CAM] reset pin gpio_request, %d\n", CAM_PIN_GPIO_CAM2_RSTz);
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz);
	else {
		gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 0);
		gpio_free(CAM_PIN_GPIO_CAM2_RSTz);
	}
	udelay(50);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO2, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO2 failed!\n");
	}
	udelay(50);

	return rc;
}
static int msm8930_ov5693_vreg_on(void)
{
	int rc;
	pr_info("[CAM] %s\n", __func__);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO2, true);
	if (rc < 0) {
		pr_err("Enable NCP6924_ID_LDO2 failed!\n");
		goto enable_ov5693_vcm_fail;
	}
	udelay(50);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO1, true);
	if (rc < 0) {
		pr_err("Enable NCP6924_ID_LDO1 failed!\n");
		goto enable_ov5693_analog_fail;
	}
	udelay(50);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO3, true);
	if (rc < 0) {
		pr_err("Enable NCP6924_ID_LDO3 failed!\n");
		goto enable_ov5693_io_fail;
	}
	udelay(50);

	return rc;

enable_ov5693_io_fail:
	rc = ncp6924_enable_ldo(NCP6924_ID_LDO1, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO1 failed!\n");
	}

enable_ov5693_analog_fail:
	rc = ncp6924_enable_ldo(NCP6924_ID_LDO2, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO2 failed!\n");
	}
enable_ov5693_vcm_fail:
	return rc;
}
예제 #4
0
static int mipi_dsi_panel_power(int on)
{
	static struct regulator *reg_l2;
	static struct regulator *reg_l10;

	int rc;

	PR_DISP_INFO("%s: power %s.\n", __func__, on ? "on" : "off");

	if (!dsi_power_on) {
		
		reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi_vdda");
		if (IS_ERR(reg_l2)) {
			pr_err("could not get 8038_l2, rc = %ld\n",
				PTR_ERR(reg_l2));
			return -ENODEV;
		}
		rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
		if (rc) {
			pr_err("set_voltage l2 failed, rc=%d\n", rc);
			return -EINVAL;
		}

		
		reg_l10 = regulator_get(&msm_mipi_dsi1_device.dev,
				"8038_l10");
		if (IS_ERR(reg_l10)) {
			pr_err("could not get 8038_l10, rc = %ld\n",
				PTR_ERR(reg_l10));
			return -ENODEV;
		}
		rc = regulator_set_voltage(reg_l10, 3000000, 3000000);
		if (rc) {
			pr_err("set_voltage l10 failed, rc=%d\n", rc);
			return -EINVAL;
		}

		dsi_power_on = true;
	}

	if (on) {
		rc = regulator_set_optimum_mode(reg_l2, 100000);
		if (rc < 0) {
			pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_set_optimum_mode(reg_l10, 100000);
		if (rc < 0) {
			pr_err("set_optimum_mode l10 failed, rc=%d\n", rc);
			return -EINVAL;
		}

		if (panel_type == PANEL_ID_CANIS_LG_NOVATEK) {
			
			rc = ncp6924_enable_ldo(NCP6924_ID_LDO4, true);
			if (rc < 0) {
				pr_err("Enable LCM 1.8V via NCP6924 failed!\n");
				return -EINVAL;
			}
			gpio_set_value(MSM_V_LCMIO_1V8_EN, 1);
			hr_msleep(1);

			
			rc = regulator_enable(reg_l10);
			if (rc) {
				pr_err("enable l10 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			hr_msleep(30);

			
			

			
			rc = regulator_enable(reg_l2);
			if (rc) {
				pr_err("enable l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}
		} else if (panel_type == PANEL_ID_CANIS_JDI_NOVATEK) {
			
			rc = ncp6924_enable_ldo(NCP6924_ID_LDO4, true);
			if (rc < 0) {
				pr_err("Enable LCM 1.8V via NCP6924 failed!\n");
				return -EINVAL;
			}
			gpio_set_value(MSM_V_LCMIO_1V8_EN, 1);
			hr_msleep(2);

			
			rc = regulator_enable(reg_l10);
			if (rc) {
				pr_err("enable l10 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			hr_msleep(2);

			gpio_set_value(MSM_LCD_RSTz, 1);
			hr_msleep(1);
			gpio_set_value(MSM_LCD_RSTz, 0);
			hr_msleep(1);
			gpio_set_value(MSM_LCD_RSTz, 1);
			hr_msleep(20);

			
			rc = regulator_enable(reg_l2);
			if (rc) {
				pr_err("enable l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}
		}
	} else {
		if (panel_type == PANEL_ID_CANIS_LG_NOVATEK) {
			gpio_set_value(MSM_LCD_RSTz, 0);
			hr_msleep(130);

			gpio_set_value(MSM_V_LCMIO_1V8_EN, 0);
			rc = ncp6924_enable_ldo(NCP6924_ID_LDO4, false);
			if (rc < 0) {
				pr_err("Disable LCM 1.8V via NCP6924 failed!\n");
				return -EINVAL;
			}
			usleep(100);

			rc = regulator_disable(reg_l10);
			if (rc) {
				pr_err("disable reg_l10 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			rc = regulator_set_optimum_mode(reg_l10, 100);
			if (rc < 0) {
				pr_err("set_optimum_mode l10 failed, rc=%d\n", rc);
				return -EINVAL;
			}

			rc = regulator_disable(reg_l2);
			if (rc) {
				pr_err("disable reg_l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			rc = regulator_set_optimum_mode(reg_l2, 100);
			if (rc < 0) {
				pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
				return -EINVAL;
			}
		} else if (panel_type == PANEL_ID_CANIS_JDI_NOVATEK) {
			gpio_set_value(MSM_LCD_RSTz, 0);
			hr_msleep(5);

			gpio_set_value(MSM_V_LCMIO_1V8_EN, 0);
			rc = ncp6924_enable_ldo(NCP6924_ID_LDO4, false);
			if (rc < 0) {
				pr_err("Disable LCM 1.8V via NCP6924 failed!\n");
				return -EINVAL;
			}
			usleep(2);

			rc = regulator_disable(reg_l10);
			if (rc) {
				pr_err("disable reg_l10 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			rc = regulator_set_optimum_mode(reg_l10, 100);
			if (rc < 0) {
				pr_err("set_optimum_mode l10 failed, rc=%d\n", rc);
				return -EINVAL;
			}

			rc = regulator_disable(reg_l2);
			if (rc) {
				pr_err("disable reg_l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			rc = regulator_set_optimum_mode(reg_l2, 100);
			if (rc < 0) {
				pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
				return -EINVAL;
			}
		}
	}

	return 0;
}
static int msm8930_mt9v113_vreg_on(void)
{
	int rc;
	pr_info("[CAM] %s\n", __func__);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO2, true);
	if (rc < 0) {
		pr_err("Enable NCP6924_ID_LDO2 failed!\n");
		goto enable_mt9v113_vcm_fail;
	}
	udelay(50);

	/* reset pin */
	rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "mt9v113");
	pr_info("[CAM] reset pin gpio_request, %d\n", CAM_PIN_GPIO_CAM2_RSTz);
	if (rc < 0) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz);
		goto enable_mt9v113_rst_fail;
	}
	gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 1);
	gpio_free(CAM_PIN_GPIO_CAM2_RSTz);
	mdelay(1);

	rc = ncp6924_enable_dcdc(NCP6924_ID_DCDC2, true);
	if (rc < 0) {
		pr_err("Enable NCP6924_ID_DCDC2 failed!\n");
		goto enable_mt9v113_digital_fail;
	}
	mdelay(1);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO1, true);
	if (rc < 0) {
		pr_err("Enable NCP6924_ID_LDO1 failed!\n");
		goto enable_mt9v113_analog_fail;
	}
	udelay(50);

	rc = ncp6924_enable_ldo(NCP6924_ID_LDO3, true);
	if (rc < 0) {
		pr_err("Enable NCP6924_ID_LDO3 failed!\n");
		goto enable_mt9v113_io_fail;
	}
	udelay(50);

	rc = gpio_request(CAM_PIN_GPIO_CAM_VCM_PD, "CAM_VCM_PD");
	pr_info("[CAM] vcm pd gpio_request, %d\n", CAM_PIN_GPIO_CAM_VCM_PD);
	if (rc < 0 && rc != -EBUSY) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM_VCM_PD);
		goto enable_mt9v113_vcm_pd_fail;
	} else {
		gpio_direction_output(CAM_PIN_GPIO_CAM_VCM_PD, 1);
		gpio_free(CAM_PIN_GPIO_CAM_VCM_PD);
		rc = 0;
	}

	return rc;

enable_mt9v113_vcm_pd_fail:
	rc = ncp6924_enable_ldo(NCP6924_ID_LDO3, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO3 failed!\n");
	}
enable_mt9v113_io_fail:
	rc = ncp6924_enable_ldo(NCP6924_ID_LDO1, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO1 failed!\n");
	}
enable_mt9v113_analog_fail:
	rc = ncp6924_enable_dcdc(NCP6924_ID_DCDC2, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_DCDC2 failed!\n");
	}
enable_mt9v113_digital_fail:
	rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "mt9v113");
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz);
	else {
		gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 0);
		gpio_free(CAM_PIN_GPIO_CAM2_RSTz);
	}
enable_mt9v113_rst_fail:
	rc = ncp6924_enable_ldo(NCP6924_ID_LDO2, false);
	if (rc < 0) {
		pr_err("Disable NCP6924_ID_LDO2 failed!\n");
	}
enable_mt9v113_vcm_fail:
	return rc;
}