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

Commit f088ba4e authored by Nicholas Troast's avatar Nicholas Troast
Browse files

msm: qpnp-power-on: add support for configuring SMPL PON trigger



Add a sysfs node named "smpl_en" to allow configuring the SMPL PON
trigger. This sysfs node takes the values 0 or 1 for disable or enable
respectively.

This example shell command will disable the SMPL PON trigger.
echo 0 > /sys/module/qpnp_power_on/parameters/smpl_en

CRs-Fixed: 957185
Change-Id: I32ebe84ceaac21443b28abea2b4935a96d94c9cd
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent 1c2c6d7f
Loading
Loading
Loading
Loading
+72 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -616,6 +616,41 @@ int qpnp_pon_wd_config(bool enable)
}
EXPORT_SYMBOL(qpnp_pon_wd_config);

static int qpnp_pon_get_trigger_config(enum pon_trigger_source pon_src,
							bool *enabled)
{
	struct qpnp_pon *pon = sys_reset_dev;
	int rc;
	u16 addr;
	u8 val;
	u8 mask;

	if (!pon)
		return -ENODEV;

	if (pon_src < PON_SMPL || pon_src > PON_KPDPWR_N) {
		dev_err(&pon->spmi->dev, "Invalid PON source\n");
		return -EINVAL;
	}

	addr = QPNP_PON_TRIGGER_EN(pon);
	mask = BIT(pon_src);
	if (is_pon_gen2(pon) && pon_src == PON_SMPL) {
		addr = QPNP_PON_SMPL_CTL(pon);
		mask = QPNP_PON_SMPL_EN;
	}

	rc = spmi_ext_register_readl(pon->spmi->ctrl, pon->spmi->sid,
							addr, &val, 1);
	if (rc)
		dev_err(&pon->spmi->dev,
			"Unable to read from addr=%hx, rc(%d)\n",
			addr, rc);
	else
		*enabled = !!(val & mask);

	return rc;
}

/**
 * qpnp_pon_trigger_config - Configures (enable/disable) the PON trigger source
@@ -1671,6 +1706,42 @@ static int pon_regulator_init(struct qpnp_pon *pon)
	return rc;
}

static bool smpl_en;

static int qpnp_pon_smpl_en_get(char *buf, const struct kernel_param *kp)
{
	bool enabled;
	int rc;

	rc = qpnp_pon_get_trigger_config(PON_SMPL, &enabled);
	if (rc < 0)
		return rc;

	return snprintf(buf, QPNP_PON_BUFFER_SIZE, "%d", enabled);
}

static int qpnp_pon_smpl_en_set(const char *val,
					const struct kernel_param *kp)
{
	int rc;

	rc = param_set_bool(val, kp);
	if (rc < 0) {
		pr_err("Unable to set smpl_en rc=%d\n", rc);
		return rc;
	}

	rc = qpnp_pon_trigger_config(PON_SMPL, *(bool *)kp->arg);
	return rc;
}

static struct kernel_param_ops smpl_en_ops = {
	.set = qpnp_pon_smpl_en_set,
	.get = qpnp_pon_smpl_en_get,
};

module_param_cb(smpl_en, &smpl_en_ops, &smpl_en, 0644);

static bool dload_on_uvlo;

static int qpnp_pon_debugfs_uvlo_dload_get(char *buf,