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

Commit df71e611 authored by Fenglin Wu's avatar Fenglin Wu
Browse files

power: qpnp-bms: Disable IRQ wake-up when disabling the IRQ



If disabling an IRQ with wake-up enabled, IRQ event will be set as
pending status and this will block system going to suspend. Disable
wake-up when disabling the IRQ.

Change-Id: I6c8afeecad3b358e75069712a8536f9c3afee23d
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent ebd84378
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
/* Copyright (c) 2011-2015, 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
@@ -131,7 +131,9 @@ struct fcc_sample {
struct bms_irq {
	int		irq;
	unsigned long	disabled;
	unsigned long	wake_enabled;
	bool		ready;
	bool		is_wake;
};

struct bms_wakeup_source {
@@ -399,6 +401,9 @@ static void enable_bms_irq(struct bms_irq *irq)
	if (irq->ready && __test_and_clear_bit(0, &irq->disabled)) {
		enable_irq(irq->irq);
		pr_debug("enabled irq %d\n", irq->irq);
		if ((irq->is_wake) &&
				!__test_and_set_bit(0, &irq->wake_enabled))
			enable_irq_wake(irq->irq);
	}
}

@@ -407,6 +412,9 @@ static void disable_bms_irq(struct bms_irq *irq)
	if (irq->ready && !__test_and_set_bit(0, &irq->disabled)) {
		disable_irq(irq->irq);
		pr_debug("disabled irq %d\n", irq->irq);
		if ((irq->is_wake) &&
				__test_and_clear_bit(0, &irq->wake_enabled))
			disable_irq_wake(irq->irq);
	}
}

@@ -415,6 +423,9 @@ static void disable_bms_irq_nosync(struct bms_irq *irq)
	if (irq->ready && !__test_and_set_bit(0, &irq->disabled)) {
		disable_irq_nosync(irq->irq);
		pr_debug("disabled irq %d\n", irq->irq);
		if ((irq->is_wake) &&
				__test_and_clear_bit(0, &irq->wake_enabled))
			disable_irq_wake(irq->irq);
	}
}

@@ -3959,11 +3970,11 @@ static int bms_request_irqs(struct qpnp_bms_chip *chip)
	int rc;

	SPMI_REQUEST_IRQ(chip, rc, sw_cc_thr);
	chip->sw_cc_thr_irq.is_wake = true;
	disable_bms_irq(&chip->sw_cc_thr_irq);
	enable_irq_wake(chip->sw_cc_thr_irq.irq);
	SPMI_REQUEST_IRQ(chip, rc, ocv_thr);
	chip->ocv_thr_irq.is_wake = true;
	disable_bms_irq(&chip->ocv_thr_irq);
	enable_irq_wake(chip->ocv_thr_irq.irq);
	return 0;
}