Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3367361imu; Wed, 7 Nov 2018 09:14:00 -0800 (PST) X-Google-Smtp-Source: AJdET5f+513pVzQoiF23wUbNizOnXA4WBFddgTrEUofVxr2SsUh4QBRjIN8Mk0FNN2QyucU/2BQv X-Received: by 2002:a62:d148:: with SMTP id t8-v6mr1020252pfl.212.1541610839718; Wed, 07 Nov 2018 09:13:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541610839; cv=none; d=google.com; s=arc-20160816; b=rguM2vPCAp+N3h1GJHudn624hC3KdmbIlv8U0oLxac1jSj1jJMiqerkVKFq3xj/HeK WfF1jkP6sYYEez2VdsN2MKocZmdj8+rKZGEPBpVTZaqdDjmdiTtVE/S15Jz0Bxyy7xRy xe/LZ3CpKWVJmjArcWStgVfJ5mqJPjPPpAz8+OnFTUw+83HQ6Kawh9dFjjgxuhBIks8j OzsdK906l7LsJskMVUMyptYkKHZnuVsQfhgSDgu8q9ZeDyzywM+UNbVPMo8ZhImynOUM UEaIbYoOQJ0Q1xx5o6tCxCSH9OtHTHMWJVc4dXU+yFqAZwzLj9jO4grDTbwtn+KEsDLJ 27wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=u3OQdIwMyDulwJrM1Yhs34QsfCPeLNuMuxOJylx/rhs=; b=Oi13KeTDegnszdhMhGW8z3EG0gkfjMLZ4UzH5Y0WdyjwhXooxptr9VoF/yidBhem5D k3hxvwTOtyrDqZZhUC3hOWLIS+xXtiGTMl/rzEIHav635rQIim+5x67FAVYXuybXzsuI tdxw/tkHvROsfcD7ziuW2ae3JdHZ5WiQKfxJnjfUCpoXmSCEgaRFsej0qwZh9eglVGU+ Uh1G6UgP4wuL4uEH0dCvMXLriuv9EoepyFXb9r+ehQ5JaFLgARYpIwnaZjK2WdPy+FuZ SzTyl7qW864S6FK/E7UcSiRLSsKLIEfI7lERZl9muN4TVHOLuveRmVweDs9ETs/ykLjP uW1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QwkMHfh7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a70si1048310pge.421.2018.11.07.09.13.44; Wed, 07 Nov 2018 09:13:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QwkMHfh7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731512AbeKHClz (ORCPT + 99 others); Wed, 7 Nov 2018 21:41:55 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54830 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731502AbeKHCly (ORCPT ); Wed, 7 Nov 2018 21:41:54 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181107171037euoutp01df8d23cb9c6b86169655fcd031083910~k5rUSUyYT2205222052euoutp01t for ; Wed, 7 Nov 2018 17:10:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181107171037euoutp01df8d23cb9c6b86169655fcd031083910~k5rUSUyYT2205222052euoutp01t DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1541610637; bh=u3OQdIwMyDulwJrM1Yhs34QsfCPeLNuMuxOJylx/rhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QwkMHfh7E8o/rT/KNf5gCPjlVLquhIZXsSd1EN9tnZg26uzOrA1RYkojlGQI4+q8/ naRVj2hUaObvqmZAKLWHQhZ20Qst/cUkt2tRP5Dz1zb54xtRVJKE62Qg+CQp3VZjdb Uo+pb/qsHDNPOYL4kma+OUESt+M0dHZcWAx2swrY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181107171037eucas1p2a19a258c027e4f024cef2b47e5bc14de~k5rTnaiyh2801828018eucas1p2I; Wed, 7 Nov 2018 17:10:37 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 7A.E9.04441.C8C13EB5; Wed, 7 Nov 2018 17:10:36 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20181107171036eucas1p13253d56b463c8f888ab8f8e418635297~k5rSx-a-s3085730857eucas1p1S; Wed, 7 Nov 2018 17:10:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20181107171036eusmtrp19c67006b1d472036080cd065805b8d20~k5rSmJCax2472724727eusmtrp1g; Wed, 7 Nov 2018 17:10:36 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-69-5be31c8ce940 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 08.23.04128.B8C13EB5; Wed, 7 Nov 2018 17:10:35 +0000 (GMT) Received: from AMDC3778.DIGITAL.local (unknown [106.120.51.20]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181107171035eusmtip25b9724e8357b9e5dedf609decfb222dd~k5rSCDuMI0120301203eusmtip2k; Wed, 7 Nov 2018 17:10:35 +0000 (GMT) From: Lukasz Luba To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: rui.zhang@intel.com, edubezval@gmail.com, daniel.lezcano@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, corbet@lwn.net, b.zolnierkie@samsung.com, krzk@kernel.org, Lukasz Luba Subject: [PATCH v2 02/11] thermal: add irq-mode configuration for trip point Date: Wed, 7 Nov 2018 18:09:44 +0100 Message-Id: <1541610593-28542-3-git-send-email-l.luba@partner.samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541610593-28542-1-git-send-email-l.luba@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKKsWRmVeSWpSXmKPExsWy7djPc7o9Mo+jDS7PM7LYOGM9q8WTA+2M FvM+y1rMP3KO1WL+lWusFufPb2C3uNUgY7HpMZC3sG0Ji8XlXXPYLD73HmG0WHr9IpNF694j 7BZPHvaxOfB5rJm3htFj56y77B6L97xk8ti0qpPN4861PWwem5fUeyzum8zqcfDdHiaPvi2r GD0+b5IL4IrisklJzcksSy3St0vgytjf+J+pYK9KRdvPZawNjNPluhg5OSQETCQOXTnK1MXI xSEksIJRYt2+PWwQzhdGicfts9khnM+MEpPXPmWHadn46BtU1XJGiZb3yxFamndeZuli5OBg E9CT2LGqECQuIjCbUeLzvsVgo5gF7jBKnJqymBlklLCAj0TPlduMIDaLgKrE7Tdr2UBsXgEv ibnrPkCtk5O4ea4TrJ5TwFti3uW3YIMkBA6xS8xtfMQIUeQiMe9zLyuELSzx6vgWqGYZidOT e1gg7GKJsx2r2CDsGon2kzugaqwlDh+/yApyNbOApsT6XfoQYUeJG8cOs4OEJQT4JG68FQQJ MwOZk7ZNZ4YI80p0tAlB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RJPzgVGcVxJvaGpo bmFpaG5sbmxmoSTOe96gMkpIID2xJDU7NbUgtQimj4mDU6qBMWf7gVkex46a1lU+NfotvH/G mfL6kx9/3ZnL6MO1/vXq6yUtN70SIg5WKRssz55x+L5EU1TKzH8n129x/NOo92ojp36wJy/v K0GjCp3wOeU8lUt8/C98LHjHdGzRxN0n2ybYH7x3M9mg/oXtFQ+FzFI1wZMdsuVhh9nDtZKL bmfcChNQEZ0bocRSnJFoqMVcVJwIANf16OmqAgAA X-CMS-MailID: 20181107171036eucas1p13253d56b463c8f888ab8f8e418635297 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181107171036eucas1p13253d56b463c8f888ab8f8e418635297 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181107171036eucas1p13253d56b463c8f888ab8f8e418635297 References: <1541610593-28542-1-git-send-email-l.luba@partner.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Eduardo Valentin Cc: Daniel Lezcano Signed-off-by: Lukasz Luba --- drivers/thermal/of-thermal.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/of-thermal.c b/drivers/thermal/of-thermal.c index 4bfdb4a..1a75946a 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -312,6 +312,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) { @@ -394,6 +408,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, @@ -827,6 +842,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 39fc812..6d41e08 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -406,6 +406,7 @@ 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; + bool irq_mode = false; /* Ignore disabled trip points */ if (test_bit(trip, &tz->trips_disabled)) @@ -419,9 +420,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 5f4705f..b064565 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -103,6 +103,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 *); @@ -196,6 +197,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; void *devdata; int trips; unsigned long trips_disabled; /* bitmap for disabled trips */ @@ -364,6 +366,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 { @@ -371,6 +375,7 @@ struct thermal_trip { int temperature; int hysteresis; enum thermal_trip_type type; + bool irq_mode; }; /* Function declarations */ -- 2.7.4