From patchwork Wed Nov 7 17:09:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 10672681 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 058E613BF for ; Wed, 7 Nov 2018 17:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8ACE2BFF2 for ; Wed, 7 Nov 2018 17:11:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCCBC2CC36; Wed, 7 Nov 2018 17:11:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5846D2BFF2 for ; Wed, 7 Nov 2018 17:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731461AbeKHCnC (ORCPT ); Wed, 7 Nov 2018 21:43:02 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54831 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728180AbeKHClz (ORCPT ); Wed, 7 Nov 2018 21:41:55 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181107171037euoutp01c06772414be8310d6c39cd3c9211e057~k5rUSHWtE2287822878euoutp01I for ; Wed, 7 Nov 2018 17:10:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181107171037euoutp01c06772414be8310d6c39cd3c9211e057~k5rUSHWtE2287822878euoutp01I 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 ibnrPkCtk5O4ea4TrJ5TwFti3uW3YIMkBA6xS8xtfMQIUeQiMe9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9t9hIrzgxt7g0L10vOT93EyMwUrYd+7llB2PXu+BDjAIcjEo8vBo7HkYL sSaWFVfmHmKU4GBWEuHtXf0oWog3JbGyKrUoP76oNCe1+BCjKdBRE5mlRJPzgVGcVxJvaGpo bmFpaG5sbmxmoSTOe96gMkpIID2xJDU7NbUgtQimj4mDU6qBMWf7gVkex46a1lU+NfotvH/G mfL6kx9/3ZnL6MO1/vXq6yUtN70SIg5WKRssz55x+L5EU1TKzH8n129x/NOo92ojp36wJy/v K0GjCp3wOeU8lUt8/C98LHjHdGzRxN0n2ybYH7x3M9mg/oXtFQ+FzFI1wZMdsuVhh9nDtZKL bmfcChNQEZ0bocRSnJFoqMVcVJwIANf16OmqAgAA X-CMS-MailID: 20181107171036eucas1p13253d56b463c8f888ab8f8e418635297 X-Msg-Generator: CA 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 */