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

Commit 17a5e3c0 authored by Prasad Sodagudi's avatar Prasad Sodagudi Committed by Gerrit - the friendly Code Review server
Browse files

pwm: qpnp: re-enable PWM or LUT output when configuration is changed



The PWM controller in Qualcomm PMIC chipset needs to re-enabled
if the underlying PWM configuration is changed. Currently all
the PWM client drivers are disabling pwm before changing configuration
and there is no output from PWM while changing the configuration.

Hence re-enable PWM or LUT output whenever the PWM or LUT
configuration is changed. This will allow clients to change
the configuration without first calling pwm_disable().

Change-Id: I3dd1b6644c2c04bdfb053ee7c6d18c59ae129295
Signed-off-by: default avatarPrasad Sodagudi <psodagud@codeaurora.org>
parent 1d63465e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -307,6 +307,7 @@ struct _qpnp_pwm_config {
struct qpnp_pwm_chip {
	struct	spmi_device	*spmi_dev;
	struct pwm_chip         chip;
	bool			enabled;
	struct _qpnp_pwm_config	pwm_config;
	struct	qpnp_lpg_config	lpg_config;
	spinlock_t		lpg_lock;
@@ -1102,6 +1103,9 @@ static int _pwm_config(struct qpnp_pwm_chip *chip,
	if (rc)
		goto out;

	if (!rc && chip->enabled)
		rc = qpnp_lpg_configure_pwm_state(chip, QPNP_PWM_ENABLE);

	pr_debug("duty/period=%u/%u %s: pwm_value=%d (of %d)\n",
		 (unsigned)duty_value, (unsigned)period_value,
		 (tm_lvl == LVL_USEC) ? "usec" : "nsec",
@@ -1172,6 +1176,9 @@ after_table_write:

	rc = qpnp_lpg_change_lut(chip);

	if (!rc && chip->enabled)
		rc = qpnp_lpg_configure_lut_state(chip, QPNP_LUT_ENABLE);

	return rc;
}

@@ -1191,6 +1198,9 @@ static int _pwm_enable(struct qpnp_pwm_chip *chip)
						QPNP_LUT_ENABLE);
	}

	if (!rc)
		chip->enabled = true;

	spin_unlock_irqrestore(&chip->lpg_lock, flags);

	return rc;
@@ -1214,6 +1224,7 @@ static void qpnp_pwm_free(struct pwm_chip *pwm_chip,
	if (!(chip->flags & QPNP_PWM_LUT_NOT_SUPPORTED))
		qpnp_lpg_configure_lut_state(chip, QPNP_LUT_DISABLE);

	chip->enabled = false;
	spin_unlock_irqrestore(&chip->lpg_lock, flags);
}

@@ -1297,6 +1308,9 @@ static void qpnp_pwm_disable(struct pwm_chip *pwm_chip,
		rc = qpnp_lpg_configure_lut_state(chip,
					QPNP_LUT_DISABLE);

	if (!rc)
		chip->enabled = false;

	spin_unlock_irqrestore(&chip->lpg_lock, flags);

	if (rc)