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

Commit a8596093 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ARM: dts: msm: Enable KPDPWR software debounce for PM8994"

parents 1bc1b27c 55f030ef
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ Optional properties:
					but this applies for the system hard reset case.
- qcom,shutdown-poweroff-type		Same description as qcom,warm-reset-poweroff-type
					but this applies for the system shutdown case.
- qcom,kpdpwr-sw-debounce	Boolean property to enable the debounce logic
				on the KPDPWR_N rising edge.


All the below properties are in the sub-node section (properties of the child
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2015, 2017 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
@@ -49,6 +49,7 @@
			qcom,pon-dbc-delay = <15625>;
			qcom,system-reset;
			qcom,store-hard-reset-reason;
			qcom,kpdpwr-sw-debounce;

			qcom,pon_1 {
				qcom,pon-type = <0>;
+58 −4
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ struct qpnp_pon {
	int			num_pon_reg;
	int			num_pon_config;
	int			reg_count;
	u32			dbc;
	u32			dbc_time_us;
	u32			uvlo;
	int			warm_reset_poff_type;
	int			hard_reset_poff_type;
@@ -224,6 +224,8 @@ struct qpnp_pon {
	u8			warm_reset_reason2;
	bool			is_spon;
	bool			store_hard_reset_reason;
	bool			kpdpwr_dbc_enable;
	ktime_t			kpdpwr_last_release_time;
};

static struct qpnp_pon *sys_reset_dev;
@@ -396,7 +398,7 @@ static int qpnp_pon_set_dbc(struct qpnp_pon *pon, u32 delay)
	int rc = 0;
	u32 val;

	if (delay == pon->dbc)
	if (delay == pon->dbc_time_us)
		goto out;

	if (pon->pon_input)
@@ -424,7 +426,7 @@ static int qpnp_pon_set_dbc(struct qpnp_pon *pon, u32 delay)
		goto unlock;
	}

	pon->dbc = delay;
	pon->dbc_time_us = delay;

unlock:
	if (pon->pon_input)
@@ -433,12 +435,35 @@ out:
	return rc;
}

static int qpnp_pon_get_dbc(struct qpnp_pon *pon, u32 *delay)
{
	int rc;
	u8 val;

	rc = spmi_ext_register_readl(pon->spmi->ctrl, pon->spmi->sid,
					QPNP_PON_DBC_CTL(pon), &val, 1);
	if (rc) {
		pr_err("Unable to read pon_dbc_ctl rc=%d\n", rc);
		return rc;
	}
	val &= QPNP_PON_DBC_DELAY_MASK(pon);

	if (is_pon_gen2(pon))
		*delay = USEC_PER_SEC /
			(1 << (QPNP_PON_GEN2_DELAY_BIT_SHIFT - val));
	else
		*delay = USEC_PER_SEC /
			(1 << (QPNP_PON_DELAY_BIT_SHIFT - val));

	return rc;
}

static ssize_t qpnp_pon_dbc_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct qpnp_pon *pon = dev_get_drvdata(dev);

	return snprintf(buf, QPNP_PON_BUFFER_SIZE, "%d\n", pon->dbc);
	return snprintf(buf, QPNP_PON_BUFFER_SIZE, "%d\n", pon->dbc_time_us);
}

static ssize_t qpnp_pon_dbc_store(struct device *dev,
@@ -771,6 +796,7 @@ qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
	struct qpnp_pon_config *cfg = NULL;
	u8 pon_rt_sts = 0, pon_rt_bit = 0;
	u32 key_status;
	u64 elapsed_us;

	cfg = qpnp_get_cfg(pon, pon_type);
	if (!cfg)
@@ -783,6 +809,15 @@ qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
	if (device_may_wakeup(&pon->spmi->dev))
		pm_wakeup_event(&pon->spmi->dev, WAKEUP_TIMEOUT_MSEC);

	if (pon->kpdpwr_dbc_enable && cfg->pon_type == PON_KPDPWR) {
		elapsed_us = ktime_us_delta(ktime_get(),
				pon->kpdpwr_last_release_time);
		if (elapsed_us < pon->dbc_time_us) {
			pr_debug("Ignoring kpdpwr event - within debounce time\n");
			return 0;
		}
	}

	/* check the RT status to get the current status of the line */
	rc = spmi_ext_register_readl(pon->spmi->ctrl, pon->spmi->sid,
				QPNP_PON_RT_STS(pon), &pon_rt_sts, 1);
@@ -812,6 +847,11 @@ qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
					cfg->key_code, pon_rt_sts);
	key_status = pon_rt_sts & pon_rt_bit;

	if (pon->kpdpwr_dbc_enable && cfg->pon_type == PON_KPDPWR) {
		if (!key_status)
			pon->kpdpwr_last_release_time = ktime_get();
	}

	/* simulate press event in case release event occured
	 * without a press event
	 */
@@ -2211,7 +2251,21 @@ static int qpnp_pon_probe(struct spmi_device *spmi)
		}
	} else {
		rc = qpnp_pon_set_dbc(pon, delay);
		if (rc) {
			dev_err(&spmi->dev,
				"Unable to set PON debounce delay rc=%d\n", rc);
			return rc;
		}
	}
	rc = qpnp_pon_get_dbc(pon, &pon->dbc_time_us);
	if (rc) {
		dev_err(&spmi->dev,
			"Unable to get PON debounce delay rc=%d\n", rc);
		return rc;
	}

	pon->kpdpwr_dbc_enable = of_property_read_bool(pon->spmi->dev.of_node,
					"qcom,kpdpwr-sw-debounce");

	rc = of_property_read_u32(pon->spmi->dev.of_node,
				"qcom,warm-reset-poweroff-type",