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

Commit b81eec09 authored by Bill Huang's avatar Bill Huang Committed by Lee Jones
Browse files

mfd: palmas: Add power off control



Hook up "pm_power_off" to palmas power off routine if there is DT
property "ti,system-power-controller" defined, so platform which is
powered by this regulator can be powered off properly.

Acked-by: default avatarNishanth Menon <nm@ti.com>
Signed-off-by: default avatarMallikarjun Kasoju <mkasoju@nvidia.com>
Signed-off-by: default avatarBill Huang <bilhuang@nvidia.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 3134bcae
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ Optional nodes:
	       ti,smps-range - OTP has the wrong range set for the hardware so override
	       0 - low range, 1 - high range.

- ti,system-power-controller: Telling whether or not this pmic is controlling
			      the system power.

Example:

#include <dt-bindings/interrupt-controller/irq.h>
@@ -49,6 +52,8 @@ pmic {

	ti,ldo6-vibrator;

	ti,system-power-controller;

	regulators {
		smps12_reg : smps12 {
			regulator-name = "smps12";
+31 −2
Original line number Diff line number Diff line
@@ -229,6 +229,32 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,
					PALMAS_POWER_CTRL_ENABLE2_MASK;
	if (i2c->irq)
		palmas_set_pdata_irq_flag(i2c, pdata);

	pdata->pm_off = of_property_read_bool(node,
			"ti,system-power-controller");
}

static struct palmas *palmas_dev;
static void palmas_power_off(void)
{
	unsigned int addr;
	int ret, slave;

	if (!palmas_dev)
		return;

	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE);
	addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL);

	ret = regmap_update_bits(
			palmas_dev->regmap[slave],
			addr,
			PALMAS_DEV_CTRL_DEV_ON,
			0);

	if (ret)
		pr_err("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n",
				__func__, ret);
}

static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST;
@@ -423,11 +449,14 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
	 */
	if (node) {
		ret = of_platform_populate(node, NULL, NULL, &i2c->dev);
		if (ret < 0)
		if (ret < 0) {
			goto err_irq;
		else
		} else if (pdata->pm_off && !pm_power_off) {
			palmas_dev = palmas;
			pm_power_off = palmas_power_off;
			return ret;
		}
	}

	return ret;

+1 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ struct palmas_platform_data {
	 */
	int mux_from_pdata;
	u8 pad1, pad2;
	bool pm_off;

	struct palmas_pmic_platform_data *pmic_pdata;
	struct palmas_gpadc_platform_data *gpadc_pdata;