Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26cf5e74 authored by Shiju Mathew's avatar Shiju Mathew
Browse files

adv7481: Add voltage regulator configurations for adv7481



Configure voltage regulator for adv7481 CCI interface.

CRs-Fixed: 1021381
Change-Id: I6a9f023a84450d56ba313af2bcee2216a1008213
Signed-off-by: default avatarShiju Mathew <shijum@codeaurora.org>
parent 96ff2006
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -8,16 +8,41 @@ The devicetree representation of the VIDEO_ADV7481 block should be:
Required properties

- compatible: "qcom,adv7481"
- qcom,slave-addr: The i2c slave address of adv7481 driver.
- reg: The i2c slave address of adv7481 device.
- qcom,cci-master: The i2c master id to be used for adv7481 driver.
- gpios: The GPIOs required to be configured for the driver. It should
	be in the order I2C data line, i2c clock line, reset line,
	interrupt 1, interrupt 2 and interrupt 3.
- cam_vdig-supply: Should contain regulator to be used for the digital
	vdd.
- cam_vio-supply: Should contain regulator to be used for the IO vdd.
- cam_vana-supply: Should contain regulator from which analog voltage
	is supplied.
- qcom,cam-vreg-name: Should specify array of regulator names required
	for the device.
- qcom,cam-vreg-min-voltage: Should specify array of minimum voltage
	level in uV for the regulators specified in the property
	"qcom,cam-vreg-name".
- qcom,cam-vreg-max-voltage: Should specify array of maximum voltage
	level in uV for the regulators specified in the property
	"qcom,cam-vreg-name".
- qcom,cam-vreg-op-mode: Should specify array of current level in uA
	for the regulators specified in the property "qcom,cam-vreg-name".

Example:

	qcom,adv7481@0 {
	qcom,adv7481@70 {
		compatible = "qcom,adv7481";
		reg = <0x70 0xff>;
		cam_vdig-supply = <&vph_pwr_vreg>;
		/* Cameras powered by PMIC: */
		cam_vio-supply = <&pm8994_lvs1>;
		cam_vana-supply = <&pm8994_l17>;
		/* Self-powered cameras: */
		qcom,cam-vreg-name = "cam_vdig", "cam_vio", "cam_vana";
		qcom,cam-vreg-min-voltage = <1300000 0 2500000>;
		qcom,cam-vreg-max-voltage = <1300000 0 2500000>;
		qcom,cam-vreg-op-mode = <105000 0 80000>;
		qcom,cci-master = <0>;
		qcom,slave-addr = <0x70>;
		gpios = <&tlmm 17 0>,          /* I2C SDA */
+38 −7
Original line number Diff line number Diff line
@@ -79,6 +79,11 @@ enum adv7481_gpio_t {
struct adv7481_state {
	struct device *dev;

	/* VREG */
	struct camera_vreg_t *cci_vreg;
	struct regulator *cci_reg_ptr[MAX_REGULATOR];
	int32_t regulator_count;

	/* I2C */
	struct msm_camera_i2c_client i2c_client;
	u32 cci_master;
@@ -2043,11 +2048,13 @@ err_cci_init:
	return ret;
}

static int adv7481_parse_dt(struct adv7481_state *state)
static int adv7481_parse_dt(struct platform_device *pdev,
			struct adv7481_state *state)
{
	struct device_node *np = state->dev->of_node;
	uint32_t i = 0;
	int gpio_count = 0;
	struct resource *adv_addr_res = NULL;
	int ret = 0;

	/* config CCI */
@@ -2059,13 +2066,12 @@ static int adv7481_parse_dt(struct adv7481_state *state)
		goto exit;
	}
	pr_debug("%s: cci_master: 0x%x\n", __func__, state->cci_master);
	ret = of_property_read_u32(np, "qcom,slave-addr",
			&state->i2c_slave_addr);
	if (ret < 0) {
		pr_err("%s: failed to read slave-addr. ret %d\n",
			__func__, ret);
	adv_addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!adv_addr_res) {
		pr_err("%s: failed to read adv7481 resource.\n", __func__);
		goto exit;
	}
	state->i2c_slave_addr = adv_addr_res->start;
	pr_debug("%s: i2c_slave_addr: 0x%x\n", __func__, state->i2c_slave_addr);
	state->i2c_io_addr = (uint8_t)state->i2c_slave_addr;

@@ -2123,7 +2129,7 @@ static int adv7481_probe(struct platform_device *pdev)
	state->dev = &pdev->dev;

	mutex_init(&state->mutex);
	ret = adv7481_parse_dt(state);
	ret = adv7481_parse_dt(pdev, state);
	if (ret < 0) {
		pr_err("Error parsing dt tree\n");
		goto err_mem_free;
@@ -2135,6 +2141,31 @@ static int adv7481_probe(struct platform_device *pdev)
		goto err_mem_free;
	}

	/* config VREG */
	ret = msm_camera_get_dt_vreg_data(pdev->dev.of_node,
			&(state->cci_vreg), &(state->regulator_count));
	if (ret < 0) {
		pr_err("%s:cci get_dt_vreg failed\n", __func__);
		goto err_mem_free;
	}

	ret = msm_camera_config_vreg(&pdev->dev, state->cci_vreg,
			state->regulator_count, NULL, 0,
			&state->cci_reg_ptr[0], 1);
	if (ret < 0) {
		pr_err("%s:cci config_vreg failed\n", __func__);
		goto err_mem_free;
	}

	ret = msm_camera_enable_vreg(&pdev->dev, state->cci_vreg,
			state->regulator_count, NULL, 0,
			&state->cci_reg_ptr[0], 1);
	if (ret < 0) {
		pr_err("%s:cci enable_vreg failed\n", __func__);
		goto err_mem_free;
	}
	pr_debug("%s - VREG Initialized...\n", __func__);

	/* Configure and Register V4L2 Sub-device */
	sd = &state->sd;
	v4l2_subdev_init(sd, &adv7481_ops);