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

Commit 125d2a45 authored by Chun Zhang's avatar Chun Zhang Committed by Matt Wagantall
Browse files

led: leds-qpnp-flash: set OTG pulse skip bit around LED usage



When device is used as OTG mode and after flash LED, USB client
is not able to work properly as flash LED causes voltage dip on VBUS
line. Setting OTG pulse enablement skip solves this problem.

Change-Id: Id5473103ff021e348c895fed5b41218cde231007
Signed-off-by: default avatarChun Zhang <chunz@codeaurora.org>
Signed-off-by: default avatarJigarkumar Kishorkumar Zala <j_zala@codeaurora.org>
parent 2fb34d69
Loading
Loading
Loading
Loading
+32 −3
Original line number Diff line number Diff line
@@ -209,9 +209,6 @@ qpnp_flash_led_get_max_avail_current(struct flash_node_data *flash_node,
	int max_curr_avail_ma;
	int rc;

	if (!led->battery_psy)
		led->battery_psy = power_supply_get_by_name("battery");

	if (led->battery_psy) {
		rc = led->battery_psy->get_property(led->battery_psy,
				POWER_SUPPLY_PROP_FLASH_CURRENT_MAX,
@@ -494,6 +491,7 @@ qpnp_flash_led_get_peripheral_type(struct qpnp_flash_led *led)
static int qpnp_flash_led_module_disable(struct qpnp_flash_led *led,
				struct flash_node_data *flash_node)
{
	union power_supply_propval psy_prop;
	int rc;
	u8 val, tmp;

@@ -536,6 +534,18 @@ static int qpnp_flash_led_module_disable(struct qpnp_flash_led *led,
			dev_err(&led->spmi_dev->dev, "Module disable failed\n");
			return -EINVAL;
		}

		if (led->battery_psy) {
			psy_prop.intval = false;
			rc = led->battery_psy->set_property(led->battery_psy,
						POWER_SUPPLY_PROP_FLASH_ACTIVE,
								&psy_prop);
			if (rc) {
				dev_err(&led->spmi_dev->dev,
					"Failed to setup OTG pulse skip enable\n");
				return -EINVAL;
			}
		}
	} else {
		rc = qpnp_led_masked_write(led->spmi_dev,
			FLASH_MODULE_ENABLE_CTRL(led->base),
@@ -560,6 +570,7 @@ static void qpnp_flash_led_work(struct work_struct *work)
				struct flash_node_data, work);
	struct qpnp_flash_led *led =
			dev_get_drvdata(&flash_node->spmi_dev->dev);
	union power_supply_propval psy_prop;
	int rc, brightness = flash_node->cdev.brightness;
	int max_curr_avail_ma;
	u8 val;
@@ -654,6 +665,24 @@ static void qpnp_flash_led_work(struct work_struct *work)
			goto exit_flash_led_work;
		}
	} else if (flash_node->type == FLASH) {
		if (!led->battery_psy)
			led->battery_psy = power_supply_get_by_name("battery");
		if (!led->battery_psy) {
			dev_err(&led->spmi_dev->dev,
				"Failed to get battery power supply\n");
			goto exit_flash_led_work;
		}

		psy_prop.intval = true;
		rc = led->battery_psy->set_property(led->battery_psy,
						POWER_SUPPLY_PROP_FLASH_ACTIVE,
								&psy_prop);
		if (rc) {
			dev_err(&led->spmi_dev->dev,
				"Failed to setup OTG pulse skip enable\n");
			goto exit_flash_led_work;
		}

		if (led->pdata->power_detect_en) {
			max_curr_avail_ma =
				qpnp_flash_led_get_max_avail_current