From 3b354ef07871eebab5978c567342fa0e99338eca Mon Sep 17 00:00:00 2001 From: Manaf Meethalavalappu Pallikunhi Date: Thu, 25 Feb 2021 22:26:00 +0530 Subject: [PATCH] drivers: thermal: pe_sensor: enable pe interrupt as wake up interrupt The policy engine interrupt disables during apps power collapse. But there is a chance that still other subsystem SDPM voting can be changed and that could cause policy engine violation. It leads to non handling of interrupt and mitigation during apps power collapse. Enable pe interrupt as wake up interrupt. Re-order PE interrupt clear and handling mitigation sequence in pe interrupt handler so that there is no chance to miss interrupt post handling of previous interrupt. Change-Id: I2c7d3014617acc99be30d3ae727736d5695c15e1 Signed-off-by: Manaf Meethalavalappu Pallikunhi --- drivers/thermal/qcom/policy_engine.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/qcom/policy_engine.c b/drivers/thermal/qcom/policy_engine.c index 39c0fd1f9fb6..9a1f2c326862 100644 --- a/drivers/thermal/qcom/policy_engine.c +++ b/drivers/thermal/qcom/policy_engine.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. */ #include @@ -80,6 +80,9 @@ static irqreturn_t pe_handle_irq(int irq, void *data) struct pe_sensor_data *pe_sens = (struct pe_sensor_data *)data; int val = 0, ret = 0; + writel_relaxed(PE_INTR_CLEAR, pe_sens->regmap + PE_INT_STATUS_OFFSET); + writel_relaxed(PE_STS_CLEAR, pe_sens->regmap + PE_INT_STATUS1_OFFSET); + ret = fetch_mitigation_table_idx(pe_sens, &val); if (ret) return IRQ_HANDLED; @@ -92,8 +95,6 @@ static irqreturn_t pe_handle_irq(int irq, void *data) of_thermal_handle_trip_temp(pe_sens->dev, pe_sens->tz_dev, val); } else mutex_unlock(&pe_sens->mutex); - writel_relaxed(PE_INTR_CLEAR, pe_sens->regmap + PE_INT_STATUS_OFFSET); - writel_relaxed(PE_STS_CLEAR, pe_sens->regmap + PE_INT_STATUS1_OFFSET); return IRQ_HANDLED; } @@ -155,6 +156,8 @@ static int pe_sens_device_probe(struct platform_device *pdev) pe_sens->tz_dev); return ret; } + enable_irq_wake(pe_sens->irq_num); + dev_dbg(dev, "PE sensor register success\n"); return 0;