Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5283546imm; Tue, 16 Oct 2018 08:00:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV622k2U5duL1FOtf3o2qKhA3dc4MS2Q1Od8T9QE4ZRekNN9NhzF0ghCPghbB1fDYUH4XwRsD X-Received: by 2002:a17:902:b182:: with SMTP id s2-v6mr21725703plr.84.1539702018795; Tue, 16 Oct 2018 08:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539702018; cv=none; d=google.com; s=arc-20160816; b=jHMxJ6Nc6pCmN8EablbwvZLHZ4KmazGBeh+AL/b+6sUJRxvVwnuBI9KPF0E9U8LzIJ 8/SWBK4eyybXrJq2U60/rfgZCVEZY6SVsUyRvrRG2nfLjJiwiVIOg7TZTuDfadTv8QdE vdS1KAGAWrj4XQ03AAVZVjnypnC2dzoY3VitQCcTV/+MMpxoqVhyXR+spI3yP33yXyZt 8yT6/2BmQiJD4Q6zG53tcl40O56BNFrXMtLI7FvJSE9lSXSja6HIRpzh3izQqtS8pdUK 6T+uUDfsXOfk2/r/3i9m6Yja0YZQghrGN9SAgW6a+YCuXjjU2CTx6l5Mq8WS/bSvKm31 4kHg== 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:message-id :in-reply-to:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=ZaON51JdJUOdRku3RBbdEjVhfEGCUlhxysvABCFT0aA=; b=AYQ7upoA/F559f2c8gqvLxYxB5OIcRicSundKtW2MnAvBfo2POM1poKqJ6acKH6n/z h6/LEIT7YIH0MJGIkq41vmSvG1v++UaDKKSWYzfEM6G6/GT2zdBJ7e23C3iUc0/JpUWc LFzmNwIgDnxwCwB9ydq3CcGOldiSVPbSOmkBuf5+WP6PTVnTvOsErOcb9fitknWvOAod +i9fC2ISm1V8I7rbIIRWPU6hmMAdQGfY9A60YOfAK0XYG7lzGVPFfGnycHCQJ1n94Tu3 guQgbGTIBSPtGrCt3fwjkRcxrIB/KCNbuX6dz0A4d4qKa3g39pgiXu9FDpvXPahQyBQi MgSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="o4nqu/Ud"; 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 e5-v6si15828110pln.190.2018.10.16.08.00.03; Tue, 16 Oct 2018 08:00:18 -0700 (PDT) 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="o4nqu/Ud"; 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 S1727290AbeJPWrg (ORCPT + 99 others); Tue, 16 Oct 2018 18:47:36 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:39254 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727197AbeJPWre (ORCPT ); Tue, 16 Oct 2018 18:47:34 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181016145644euoutp0267d52dea68ca3f1318fade82fa7d2356~eHqIxX7my0414504145euoutp02g for ; Tue, 16 Oct 2018 14:56:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181016145644euoutp0267d52dea68ca3f1318fade82fa7d2356~eHqIxX7my0414504145euoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539701804; bh=ZaON51JdJUOdRku3RBbdEjVhfEGCUlhxysvABCFT0aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4nqu/UdlHVcFVXjVp5JZGJ4+fy+CiTUOWlOkdPgd34YYk9j3OjEh4n51wVQFsugE oefnaxUQFc/xH34OseqdsCibylPScsuv0kI4Y8Eb8WDctCnhV+98edckyL9FYQVvq8 Id6x82s6v9UYEf2i2gbJoBy4dzfc6RAk14+pRl+A= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181016145643eucas1p20b76fcfe67c67680ebf1ec88c18222cb~eHqH3OWhp0771207712eucas1p2l; Tue, 16 Oct 2018 14:56:43 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C2.C2.04441.B2CF5CB5; Tue, 16 Oct 2018 15:56:43 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20181016145642eucas1p2d3cfc208d3f401bfe662d6df071cc3b8~eHqHE9TOU2133821338eucas1p2M; Tue, 16 Oct 2018 14:56:42 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20181016145642eusmtrp1d3c59afc722ee70e20b7a75b0fed2106~eHqG2E-DX1176711767eusmtrp1z; Tue, 16 Oct 2018 14:56:42 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-c3-5bc5fc2b2857 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 1C.D9.04284.A2CF5CB5; Tue, 16 Oct 2018 15:56:42 +0100 (BST) Received: from AMDC3778.DIGITAL.local (unknown [106.120.51.20]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20181016145641eusmtip23d41a8d2e82508875a1544c042728100~eHqGUckWn2834528345eusmtip2B; Tue, 16 Oct 2018 14:56:41 +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, Lukasz Luba Subject: [PATCH 02/11] thermal: add irq-mode configuration for trip point Date: Tue, 16 Oct 2018 16:56:13 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539701782-26852-1-git-send-email-l.luba@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSbUhTYRTHeXZ3766j2XVKPvgWrYRM0izDS4kZ9OFKSAV+qX3IpZcp6dRd NTWhle9illkavszZZtbQpuY700pnU3xfoUuttCwxNNAVLQrLeWd9+53/Of//OTw8OCJsQt3w WFkyLZdJ4kQYn9v+8uf4Qd/fA+JDbR0E2Xxfh5KLz/MAqbR4kjWGMZSseT2FkjMKD7Ll4ybU 5mq45KvuKoy03DQAsm56kkPm9Bh45OJCMRYqoBqUDYDqqnjLo9T6ZQ7Voi3AqLkpPUY91Vyj 1MWlKPXiq55DFbdqAWVp8TrLv8APjqbjYlNpuX9IJD9mdukXL7FnX9rgHxWiAOVehcABh0Qg VG1sgELAx4XEIwCzRucQtvgG4EC11l5YAGzsGuRuW7J7Z7lsox5AlUkD/lmMmjZeIcBxjPCD ndokm+5CVAJo6VXzbAVCDAE4U9/OsUU5E2Ewbz5ni7mEN2y9vmpf4QXfjBUgNnYgTsMZs2rr Dkj08uDK0AKwNQREKhx5vI6yhlPQaG60szP8YmzlsewBh0uL7KEMHM3XYixnwryhTvvMcdhv nERtVyOED9R1+7PySWidbOLYZEg4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njc0slMR5zxtURgkJpCeWpGanphakFsH0MXFwSjUwGrrobxB/5pLzP6N3n813Kb/bjBEv pT6kzw+R2/CUPZMr6Pil8GvsR648C3KKT+c+o+bivFiPq3dRVPuyl46u7z/an3talCv80Fro Yfbyjz2ez5Im+Sc3dNQqpl48/EJcseV+Fmt1b991Nu0fWkqftXRVj4Te3+du9vSQjlbQp38X Zm8Pf3xSiaU4I9FQi7moOBEAmv4XAKMCAAA= Message-Id: <20181016145642eucas1p2d3cfc208d3f401bfe662d6df071cc3b8~eHqHE9TOU2133821338eucas1p2M@eucas1p2.samsung.com> X-CMS-MailID: 20181016145642eucas1p2d3cfc208d3f401bfe662d6df071cc3b8 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181016145642eucas1p2d3cfc208d3f401bfe662d6df071cc3b8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181016145642eucas1p2d3cfc208d3f401bfe662d6df071cc3b8 References: <1539701782-26852-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 int 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 4f28165..db0942a 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -289,6 +289,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) { @@ -371,6 +385,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, @@ -779,6 +794,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 2c6d72a..f569532 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -404,6 +404,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)) @@ -417,9 +418,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