0
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2025-03-01 04:31:30 +00:00
Lakka-LibreELEC/projects/Samsung/patches/linux/samsung-0016-MEMEKA-thermal-add-irq-mode-configuration-for-trip-p.patch
heitbaum c846f6a87b Samsung: linux: Remove patches included in 5.10.15
samsung-0001-FROMLIST-v1-serial-samsung-Re-factors-UART-IRQ-resou.patch
- deleted
- ref: https://www.spinics.net/lists/linux-serial/msg39463.html

samsung-0012-MEMEKA-phy-exynos5-usbdrd-Calibrating-makes-sense-on.patch
- deleted
- incorporated in 5.10.y

samsung-0013-MEMEKA-clk-samsung-exynos5420-Keep-top-G3D-clocks-en.patch
- deleted
- replaced by 67f96ff7c8
- included in kernel 5.10.y

samsung-0016-MEMEKA-thermal-add-irq-mode-configuration-for-trip-p.patch
- updated for 5.10.y, needs to be build/run tested.
2021-02-17 21:41:14 +00:00

144 lines
4.9 KiB
Diff

From c6272f5973722d3d396e7123ebb3e1fcd35ba5cc Mon Sep 17 00:00:00 2001
From: Lukasz Luba <l.luba@partner.samsung.com>
Date: Wed, 7 Nov 2018 18:09:44 +0100
Subject: [PATCH 16/25] MEMEKA: thermal: add irq-mode configuration for trip
point
This patch adds support irq mode in trip point.
When that flag is set in DT, there is no need for polling
in thermal framework. Crossing the trip point will rise an IRQ.
The naming convention for tip point 'type' can be confussing
and 'passive' (whic is passive cooling) might be interpretted wrongly.
This mechanism prevents from missue and adds explicit setting
for hardware which support interrupts for pre-configured temperature
threshold.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
Signed-off-by: memeka <mihailescu2m@gmail.com>
---
drivers/thermal/thermal_of.c | 17 +++++++++++++++++
drivers/thermal/thermal_core.c | 10 ++++++++--
include/linux/thermal.h | 5 +++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index 874a47d6923f..1549561e28b2 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -315,6 +315,20 @@ static int of_thermal_get_trip_type(struct thermal_zone_device *tz, int trip,
return 0;
}
+static int
+of_thermal_get_trip_irq_mode(struct thermal_zone_device *tz, int trip,
+ bool *mode)
+{
+ struct __thermal_zone *data = tz->devdata;
+
+ if (trip >= data->ntrips || trip < 0)
+ return -EDOM;
+
+ *mode = data->trips[trip].irq_mode;
+
+ return 0;
+}
+
static int of_thermal_get_trip_temp(struct thermal_zone_device *tz, int trip,
int *temp)
{
@@ -397,6 +411,7 @@ static struct thermal_zone_device_ops of_thermal_ops = {
.set_mode = of_thermal_set_mode,
.get_trip_type = of_thermal_get_trip_type,
+ .get_trip_irq_mode = of_thermal_get_trip_irq_mode,
.get_trip_temp = of_thermal_get_trip_temp,
.set_trip_temp = of_thermal_set_trip_temp,
.get_trip_hyst = of_thermal_get_trip_hyst,
@@ -860,6 +875,8 @@ static int thermal_of_populate_trip(struct device_node *np,
return ret;
}
+ trip->irq_mode = of_property_read_bool(np, "irq-mode");
+
/* Required for cooling map matching */
trip->np = np;
of_node_get(np);
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 9a321dc548c8..ef23a33d34b6 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -410,7 +410,8 @@ static void handle_critical_trips(struct thermal_zone_device *tz,
static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
{
enum thermal_trip_type type;
int trip_temp, hyst = 0;
+ bool irq_mode = false;
/* Ignore disabled trip points */
if (test_bit(trip, &tz->trips_disabled))
@@ -423,9 +424,14 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
handle_non_critical_trips(tz, trip);
/*
* Alright, we handled this trip successfully.
- * So, start monitoring again.
+ * So, start monitoring in polling mode if
+ * trip is not using irq HW support.
*/
- monitor_thermal_zone(tz);
+ if (tz->ops->get_trip_irq_mode)
+ tz->ops->get_trip_irq_mode(tz, trip, &irq_mode);
+
+ if (!irq_mode)
+ monitor_thermal_zone(tz);
}
static void update_temperature(struct thermal_zone_device *tz)
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index c91b1e344d56..c4ce2b875b73 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -92,6 +92,7 @@ struct thermal_zone_device_ops {
enum thermal_device_mode);
int (*get_trip_type) (struct thermal_zone_device *, int,
enum thermal_trip_type *);
+ int (*get_trip_irq_mode) (struct thermal_zone_device *, int, bool *);
int (*get_trip_temp) (struct thermal_zone_device *, int, int *);
int (*set_trip_temp) (struct thermal_zone_device *, int, int);
int (*get_trip_hyst) (struct thermal_zone_device *, int, int *);
@@ -185,6 +186,7 @@ struct thermal_zone_device {
struct thermal_attr *trip_temp_attrs;
struct thermal_attr *trip_type_attrs;
struct thermal_attr *trip_hyst_attrs;
+ struct thermal_attr *trip_irq_mode_attrs;
enum thermal_device_mode mode;
void *devdata;
int trips;
diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
index c91b1e344d56..c4ce2b875b73 100644
--- a/drivers/thermal/thermal_core.h
+++ b/drivers/thermal/thermal_core.h
@@ -353,6 +355,8 @@ struct thermal_zone_of_device_ops {
* @temperature: temperature value in miliCelsius
* @hysteresis: relative hysteresis in miliCelsius
* @type: trip point type
+ * @irq_mode: to not use polling in framework set support of HW irq (which will
+ * be triggered when temperature reaches this level).
*/
struct thermal_trip {
@@ -360,6 +364,7 @@ struct thermal_trip {
int temperature;
int hysteresis;
enum thermal_trip_type type;
+ bool irq_mode;
};
/* Function declarations */
--
2.17.1