From patchwork Wed May 25 03:47:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9134635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04DC560221 for ; Wed, 25 May 2016 03:48:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC86B2810D for ; Wed, 25 May 2016 03:48:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E14142825C; Wed, 25 May 2016 03:48:33 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 935932810D for ; Wed, 25 May 2016 03:48:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5Po9-0002hQ-Az; Wed, 25 May 2016 03:48:33 +0000 Received: from mail-pf0-f193.google.com ([209.85.192.193]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5Po5-0002Zx-VG for linux-rockchip@lists.infradead.org; Wed, 25 May 2016 03:48:30 +0000 Received: by mail-pf0-f193.google.com with SMTP id 145so4034218pfz.1 for ; Tue, 24 May 2016 20:48:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TqFyFT58F1YYEtZuaK1a+SmqepP3sQJ9bWMjcoMEg3U=; b=DaPUGAYv8D8aijsg7TINL5kaxAe5FqCtNLpjAKp3dCkYiigQjCV3g9yaA7vIw+YZaN QN/o850iS96M5Wn1KoEOZBQvA3E8rNaf33lvqKSTt/hPCAGdygtPNqxqUcBByY1bbEO7 mPEf4eR3uu4yf6cmKnoMwzM2+5LWwDV/LNsJXq8/TZNzaK7aIsYIfVV0irwko4lqxNPP zmbyC5/GSfnKugulRzQetciSuso5jpCo5sYrK/H26tEo/cSYQaO0vcGfKtlEuma0OxVZ p22u/H1D0M9+4nUzzwtmslUFX4tid43/4ezlitmcmTgnogZLAq/C1aiYSy99Jcegf7iD 1iGA== X-Gm-Message-State: ALyK8tI2HXhn7gDScujoEvuY25Hxo7JvVqgFGr4Ag3S2k79KY3+DDMnXVIPR0W7vu7Kgkg== X-Received: by 10.98.74.218 with SMTP id c87mr2443606pfj.78.1464148089061; Tue, 24 May 2016 20:48:09 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id u127sm57645436pfb.82.2016.05.24.20.48.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 May 2016 20:48:08 -0700 (PDT) From: Caesar Wang To: edubezval@gmail.com, linux-pm@vger.kernel.org Subject: [PATCH v3 2/5] thermal: of: implement .set_trips for device tree thermal zones Date: Wed, 25 May 2016 11:47:46 +0800 Message-Id: <1464148069-26254-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464148069-26254-1-git-send-email-wxt@rock-chips.com> References: <1464148069-26254-1-git-send-email-wxt@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160524_204830_158295_83A9AD56 X-CRM114-Status: GOOD ( 15.50 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangtao@rock-chips.com, javi.merino@arm.com, Heiko Stuebner , Sascha Hauer , dmitry.torokhov@gmail.com, peter@piie.net, dianders@chromium.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, smbarber@google.com, cf@rock-chips.com, briannorris@google.com, Zhang Rui , Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sascha Hauer This patch implemnets .set_trips for device tree thermal zones. As the hardware-tracked trip points is supported by thermal core patch[0]. patch[0] "thermal: Add support for hardware-tracked trip points". Signed-off-by: Sascha Hauer Signed-off-by: Caesar Wang Cc: Zhang Rui Cc: Eduardo Valentin Reviewed-by: Javi Merino --- Changes in v3: - as the Javi comments on https://patchwork.kernel.org/patch/9001311/. - add the select if they set the option for devicetree. Changes in v2: - add the commit in patch[v2 2/5]. drivers/thermal/of-thermal.c | 19 +++++++++++++++++++ include/linux/thermal.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index b8e509c..2d2a06f 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -101,6 +101,17 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz, return data->ops->get_temp(data->sensor_data, temp); } +static int of_thermal_set_trips(struct thermal_zone_device *tz, + int low, int high) +{ + struct __thermal_zone *data = tz->devdata; + + if (!data->ops || !data->ops->set_trips) + return -EINVAL; + + return data->ops->set_trips(data->sensor_data, low, high); +} + /** * of_thermal_get_ntrips - function to export number of available trip * points. @@ -427,6 +438,14 @@ thermal_zone_of_add_sensor(struct device_node *zone, tzd->ops->get_temp = of_thermal_get_temp; tzd->ops->get_trend = of_thermal_get_trend; + + /* + * The thermal zone core will calculate the window if they have set the + * optional set_trips pointer. + */ + if (ops->set_trips) + tzd->ops->set_trips = of_thermal_set_trips; + tzd->ops->set_emul_temp = of_thermal_set_emul_temp; mutex_unlock(&tzd->lock); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 635c4003..f68da05 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -340,12 +340,16 @@ struct thermal_genl_event { * * Optional: * @get_trend: a pointer to a function that reads the sensor temperature trend. + * @set_trips: a pointer to a function that sets a temperature window. When + * this window is left the driver must inform the thermal core via + * thermal_zone_device_update. * @set_emul_temp: a pointer to a function that sets sensor emulated * temperature. */ struct thermal_zone_of_device_ops { int (*get_temp)(void *, int *); int (*get_trend)(void *, long *); + int (*set_trips)(void *, int, int); int (*set_emul_temp)(void *, int); int (*set_trip_temp)(void *, int, int); };