From patchwork Mon Jun 6 11:44: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: 9157937 X-Patchwork-Delegate: eduardo.valentin@ti.com 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 05B0360467 for ; Mon, 6 Jun 2016 11:46:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB81C26907 for ; Mon, 6 Jun 2016 11:46:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E04A92780C; Mon, 6 Jun 2016 11:46:22 +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=-6.9 required=2.0 tests=BAYES_00,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 7DB5726907 for ; Mon, 6 Jun 2016 11:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752042AbcFFLpS (ORCPT ); Mon, 6 Jun 2016 07:45:18 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33238 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751728AbcFFLpQ (ORCPT ); Mon, 6 Jun 2016 07:45:16 -0400 Received: by mail-pf0-f195.google.com with SMTP id u67so1713975pfu.0; Mon, 06 Jun 2016 04:45:16 -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=qcttlzCF7lkmCc4wTD5qxjamS7d73Ksxr9BSdJP4bNc=; b=nJOiSOXGx5zFI+rYvJHT8gtSd6/fGUB3+FxuyHZYSg45Wo5rDAoH7OdjyeIsmYH7lP 3Sw7M/9NEe8jSBnh5qInMKcdFhrwwZBV+k03NQGtnOghVX2SFwQt7NFdb1MSqfMWtHp0 DZ++N9fsxgRm/6FgkdwtZo8+mhk2zuYCUzfI4BI1zr0a0lgUPBvhrB/JinTVOEl7jsah fwz8YB1qtN9cbRtnMe1etMK6VtVQaCJeUU2Xl1PYBeq9bvZrB+geag53A4ZauhV1oNDW G8KYJ/t2Qo1hXmMfxWMf1dfzBzoPdlzEINUBT2PlMe6C7k2qJogzWprfaynOxVdrCH7+ n7oQ== X-Gm-Message-State: ALyK8tIj4pE7nA+hQgu85CDqi24D8tE6+zblzxbu/2hLwHorQD7zjIi7M/G8b5MvmkQ1sA== X-Received: by 10.98.192.83 with SMTP id x80mr24923936pff.88.1465213515921; Mon, 06 Jun 2016 04:45:15 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id g82sm27196446pfj.22.2016.06.06.04.45.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 04:45:15 -0700 (PDT) From: Caesar Wang To: edubezval@gmail.com, linux-pm@vger.kernel.org Cc: Heiko Stuebner , dianders@chromium.org, briannorris@google.com, smbarber@google.com, linux-rockchip@lists.infradead.org, cf@rock-chips.com, huangtao@rock-chips.com, dmitry.torokhov@gmail.com, javi.merino@arm.com, peter@piie.net, Sascha Hauer , Caesar Wang , Zhang Rui , linux-kernel@vger.kernel.org Subject: [PATCH v5 2/5] thermal: of: implement .set_trips for device tree thermal zones Date: Mon, 6 Jun 2016 19:44:46 +0800 Message-Id: <1465213489-14898-3-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465213489-14898-1-git-send-email-wxt@rock-chips.com> References: <1465213489-14898-1-git-send-email-wxt@rock-chips.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 From: Sascha Hauer This patch implements .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 v5: None Changes in v4: - as the Javi comments, %s/implemnets/implements. 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 780e69d..2440b8d 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -342,6 +342,9 @@ 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. * @set_trip_temp: a pointer to a function that sets the trip temperature on @@ -350,6 +353,7 @@ struct thermal_genl_event { 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); };