From patchwork Tue Sep 25 09:02:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613707 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-2.web.codeaurora.org (Postfix) with ESMTP id F38C2112B for ; Tue, 25 Sep 2018 09:03:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E12332836F for ; Tue, 25 Sep 2018 09:03:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4A6C29307; Tue, 25 Sep 2018 09:03:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 4BC8B2836F for ; Tue, 25 Sep 2018 09:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbeIYPKP (ORCPT ); Tue, 25 Sep 2018 11:10:15 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34164 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728317AbeIYPKO (ORCPT ); Tue, 25 Sep 2018 11:10:14 -0400 Received: by mail-wm1-f65.google.com with SMTP id j25-v6so12031985wmc.1 for ; Tue, 25 Sep 2018 02:03:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OZ13DAcracUk8ECXRhZzoH+2ruBFRvOw19LoCvex9TQ=; b=TX+zyk2yMB85ok2KiqzJvZnSaiL9mgIg40Cql/dIOJgkjKtACF146jhkyKkuqVe5MW MMk8FW7QNx98TzIo+hNdYV5yDiVV1X0bV5+59jVE2ln28Y1Y74DobGx55stxdKmXOSOI lc01di//q6BRsnZchp2qAOhPKhA50VB9ID/pY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OZ13DAcracUk8ECXRhZzoH+2ruBFRvOw19LoCvex9TQ=; b=HbLer+wYurkGwbldEKjYBsZg5XEjW9Th50KtIkxVYhLTY3jBLLC3i4004lkXkYJjcT CAZKqFt3y3dNKxfZkg2VC4EYUsKtyYZIkbrZZ8URjtgycLStGWxJ6V5uvvxFOIyN1SXG sP7U33uEe9qDylawCfz8OROwXMGm28lm0AZtmZfM8IgyCW43nb2PSrKgVL9iT30I76SF 71MRUBe52TgxqyUW+QUbYbQlGkbzn61sGIZmEerCu57KkzOTF8t2ZbZ6TEE2GgMizfhB jDQ655A8iHpyfgDiRZc6SVi2wPphqgq2no2mSIUCD+CS/tdWtkIZER+F2IPDmTHl/8jH o+jw== X-Gm-Message-State: ABuFfoirIc+1B+aad/8V4PYdPT6jTsS8epmWXkvpeGNEWT2LwxjnAyk+ 3uA3T8EgfbNCoi3JPXuGg00pXw== X-Google-Smtp-Source: ACcGV6095yJNvkrVkcdlv9gJ0yMzrFsOoQymXOwzGfvMKJyALnatN9g6Wt+aswH7g+n6SI9FlOBfRw== X-Received: by 2002:a1c:f11a:: with SMTP id p26-v6mr68368wmh.92.1537866220410; Tue, 25 Sep 2018 02:03:40 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.03.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:03:35 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 01/14] thermal/drivers/hisi: Change the platform data pointer to sensor ops Date: Tue, 25 Sep 2018 11:02:59 +0200 Message-Id: <1537866192-12320-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Group the temperature sensor specific ops into a single structure and assign it to hisi thermal data structure. Change the platform data pointer to reference the specific sensor ops instead of the probe functions. Moving out those allow to split the code to self-encapsulate the sensor object. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 60 ++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 761d055..9794cfe 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -64,11 +64,18 @@ struct hisi_thermal_sensor { uint32_t thres_temp; }; -struct hisi_thermal_data { +struct hisi_thermal_data; + +struct hisi_thermal_ops { int (*get_temp)(struct hisi_thermal_data *data); int (*enable_sensor)(struct hisi_thermal_data *data); int (*disable_sensor)(struct hisi_thermal_data *data); int (*irq_handler)(struct hisi_thermal_data *data); + int (*probe)(struct hisi_thermal_data *data); +}; + +struct hisi_thermal_data { + const struct hisi_thermal_ops *ops; struct platform_device *pdev; struct clk *clk; struct hisi_thermal_sensor sensor; @@ -374,11 +381,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) struct resource *res; int ret; - data->get_temp = hi6220_thermal_get_temp; - data->enable_sensor = hi6220_thermal_enable_sensor; - data->disable_sensor = hi6220_thermal_disable_sensor; - data->irq_handler = hi6220_thermal_irq_handler; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->regs = devm_ioremap_resource(dev, res); if (IS_ERR(data->regs)) { @@ -409,11 +411,6 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) struct device *dev = &pdev->dev; struct resource *res; - data->get_temp = hi3660_thermal_get_temp; - data->enable_sensor = hi3660_thermal_enable_sensor; - data->disable_sensor = hi3660_thermal_disable_sensor; - data->irq_handler = hi3660_thermal_irq_handler; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); data->regs = devm_ioremap_resource(dev, res); if (IS_ERR(data->regs)) { @@ -435,7 +432,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp) struct hisi_thermal_data *data = __data; struct hisi_thermal_sensor *sensor = &data->sensor; - *temp = data->get_temp(data); + *temp = data->ops->get_temp(data); dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", sensor->id, *temp, sensor->thres_temp); @@ -453,7 +450,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) struct hisi_thermal_sensor *sensor = &data->sensor; int temp = 0; - data->irq_handler(data); + data->ops->irq_handler(data); hisi_thermal_get_temp(data, &temp); @@ -502,14 +499,30 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, return 0; } +static const struct hisi_thermal_ops hi6220_ops = { + .get_temp = hi6220_thermal_get_temp, + .enable_sensor = hi6220_thermal_enable_sensor, + .disable_sensor = hi6220_thermal_disable_sensor, + .irq_handler = hi6220_thermal_irq_handler, + .probe = hi6220_thermal_probe, +}; + +static const struct hisi_thermal_ops hi3660_ops = { + .get_temp = hi3660_thermal_get_temp, + .enable_sensor = hi3660_thermal_enable_sensor, + .disable_sensor = hi3660_thermal_disable_sensor, + .irq_handler = hi3660_thermal_irq_handler, + .probe = hi3660_thermal_probe, +}; + static const struct of_device_id of_hisi_thermal_match[] = { { .compatible = "hisilicon,tsensor", - .data = hi6220_thermal_probe + .data = &hi6220_ops, }, { .compatible = "hisilicon,hi3660-tsensor", - .data = hi3660_thermal_probe + .data = &hi3660_ops, }, { /* end */ } }; @@ -527,7 +540,6 @@ static void hisi_thermal_toggle_sensor(struct hisi_thermal_sensor *sensor, static int hisi_thermal_probe(struct platform_device *pdev) { struct hisi_thermal_data *data; - int (*platform_probe)(struct hisi_thermal_data *); struct device *dev = &pdev->dev; int ret; @@ -538,13 +550,9 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->pdev = pdev; platform_set_drvdata(pdev, data); - platform_probe = of_device_get_match_data(dev); - if (!platform_probe) { - dev_err(dev, "failed to get probe func\n"); - return -EINVAL; - } + data->ops = of_device_get_match_data(dev); - ret = platform_probe(data); + ret = data->ops->probe(data); if (ret) return ret; @@ -555,7 +563,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) return ret; } - ret = data->enable_sensor(data); + ret = data->ops->enable_sensor(data); if (ret) { dev_err(dev, "Failed to setup the sensor: %d\n", ret); return ret; @@ -583,7 +591,7 @@ static int hisi_thermal_remove(struct platform_device *pdev) hisi_thermal_toggle_sensor(sensor, false); - data->disable_sensor(data); + data->ops->disable_sensor(data); return 0; } @@ -593,7 +601,7 @@ static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - data->disable_sensor(data); + data->ops->disable_sensor(data); return 0; } @@ -602,7 +610,7 @@ static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - return data->enable_sensor(data); + return data->ops->enable_sensor(data); } #endif From patchwork Tue Sep 25 09:03:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613711 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-2.web.codeaurora.org (Postfix) with ESMTP id E189D15E8 for ; Tue, 25 Sep 2018 09:04:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D00342836F for ; Tue, 25 Sep 2018 09:04:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C462C294E2; Tue, 25 Sep 2018 09:04:00 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 163CC2836F for ; Tue, 25 Sep 2018 09:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728463AbeIYPKU (ORCPT ); Tue, 25 Sep 2018 11:10:20 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46728 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728436AbeIYPKT (ORCPT ); Tue, 25 Sep 2018 11:10:19 -0400 Received: by mail-wr1-f65.google.com with SMTP id z3-v6so10627869wrr.13 for ; Tue, 25 Sep 2018 02:03:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JKtye1UkuEcXKPFhNVW7GNxXrGnc1c47iAdiNPq2Uxg=; b=cbdFeuBrE/DKJJz1QSZJFGPjEAFse41UeHzPKMZERRGt78pGqap+46Di+4OVPQcwzE l6jZrWxI0t16pbiLxIBXRHXKQZh+1cJgRSvKvA4223WBrOP7jJw9txR+eBP5fzsDoxC1 wDgRHAuoHLqv4a0XOIhNGzjKfsHOWV2R9cHJI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JKtye1UkuEcXKPFhNVW7GNxXrGnc1c47iAdiNPq2Uxg=; b=QqSII8CPQ0pk7v5UDGrR7idt9dDdqfwrxjin/TmsJZV3Fda8S6XOjytf1gj68D6Xhu GuYdQ+MhqskN6mKS4gHC8Ko8xxoyuYLzSPGHiUzFG+3T9wxIklcrgxQlyPlNXLIqlS+g QjjNU/z3FGbVqWec2p5YQFYfEuT0IAsRG7UKXW3fm+gY4Vr/cG7kNjKrACfVHltHOmAs zVjW5Tj8u6BXPwx0kfngWSwOULcwQFtVo9qvYGpK4BfPzySgVfx/ZrD0i423nKC7xuPh AxZTH1LOT3B5kDmYMuP6kJ7gSKtTpOsBmhLoZsGvcKZE6Zr9CCxsx7+9WBl8hIxbTkxs D+CQ== X-Gm-Message-State: ABuFfogoVtr1TM5a7upoRbtG2kDpVtdKX5JeAWTJviTbOvM5B9EJ1e6Y TTt9OevmJcxMti40Ed8N3yZo3Q== X-Google-Smtp-Source: ACcGV60hy0uv8FF5bS7cCENqvmk2aNuViXQFWD2ZPkRUG8aCrpwxXVFml2l2Lo4a78zSzRwC00d3Dw== X-Received: by 2002:adf:80a3:: with SMTP id 32-v6mr1131wrl.231.1537866225446; Tue, 25 Sep 2018 02:03:45 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:03:42 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 02/14] thermal/drivers/hisi: Change the driver to be sensor oriented Date: Tue, 25 Sep 2018 11:03:00 +0200 Message-Id: <1537866192-12320-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 In order to support multiple sensors, we have to change the code to deal with sensors and not the hisi thermal structure. Add a back pointer to the hisi thermal structure (containerof is not a good option because later we convert the sensor field to a pointer). Change the functions parameters to take a sensor instead of this hisi thermal 'data' structure. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 72 ++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 9794cfe..1fdda55 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -58,27 +58,28 @@ #define HI6220_DEFAULT_SENSOR 2 #define HI3660_DEFAULT_SENSOR 1 +struct hisi_thermal_data; + struct hisi_thermal_sensor { + struct hisi_thermal_data *data; struct thermal_zone_device *tzd; uint32_t id; uint32_t thres_temp; }; -struct hisi_thermal_data; - struct hisi_thermal_ops { - int (*get_temp)(struct hisi_thermal_data *data); - int (*enable_sensor)(struct hisi_thermal_data *data); - int (*disable_sensor)(struct hisi_thermal_data *data); - int (*irq_handler)(struct hisi_thermal_data *data); + int (*get_temp)(struct hisi_thermal_sensor *sensor); + int (*enable_sensor)(struct hisi_thermal_sensor *sensor); + int (*disable_sensor)(struct hisi_thermal_sensor *sensor); + int (*irq_handler)(struct hisi_thermal_sensor *sensor); int (*probe)(struct hisi_thermal_data *data); }; struct hisi_thermal_data { const struct hisi_thermal_ops *ops; + struct hisi_thermal_sensor sensor; struct platform_device *pdev; struct clk *clk; - struct hisi_thermal_sensor sensor; void __iomem *regs; int irq; }; @@ -273,30 +274,40 @@ static inline void hi6220_thermal_hdak_set(void __iomem *addr, int value) (value << 4), addr + HI6220_TEMP0_CFG); } -static int hi6220_thermal_irq_handler(struct hisi_thermal_data *data) +static int hi6220_thermal_irq_handler(struct hisi_thermal_sensor *sensor) { + struct hisi_thermal_data *data = sensor->data; + hi6220_thermal_alarm_clear(data->regs, 1); return 0; } -static int hi3660_thermal_irq_handler(struct hisi_thermal_data *data) +static int hi3660_thermal_irq_handler(struct hisi_thermal_sensor *sensor) { - hi3660_thermal_alarm_clear(data->regs, data->sensor.id, 1); + struct hisi_thermal_data *data = sensor->data; + + hi3660_thermal_alarm_clear(data->regs, sensor->id, 1); return 0; } -static int hi6220_thermal_get_temp(struct hisi_thermal_data *data) +static int hi6220_thermal_get_temp(struct hisi_thermal_sensor *sensor) { + struct hisi_thermal_data *data = sensor->data; + return hi6220_thermal_get_temperature(data->regs); } -static int hi3660_thermal_get_temp(struct hisi_thermal_data *data) +static int hi3660_thermal_get_temp(struct hisi_thermal_sensor *sensor) { - return hi3660_thermal_get_temperature(data->regs, data->sensor.id); + struct hisi_thermal_data *data = sensor->data; + + return hi3660_thermal_get_temperature(data->regs, sensor->id); } -static int hi6220_thermal_disable_sensor(struct hisi_thermal_data *data) +static int hi6220_thermal_disable_sensor(struct hisi_thermal_sensor *sensor) { + struct hisi_thermal_data *data = sensor->data; + /* disable sensor module */ hi6220_thermal_enable(data->regs, 0); hi6220_thermal_alarm_enable(data->regs, 0); @@ -307,16 +318,18 @@ static int hi6220_thermal_disable_sensor(struct hisi_thermal_data *data) return 0; } -static int hi3660_thermal_disable_sensor(struct hisi_thermal_data *data) +static int hi3660_thermal_disable_sensor(struct hisi_thermal_sensor *sensor) { + struct hisi_thermal_data *data = sensor->data; + /* disable sensor module */ - hi3660_thermal_alarm_enable(data->regs, data->sensor.id, 0); + hi3660_thermal_alarm_enable(data->regs, sensor->id, 0); return 0; } -static int hi6220_thermal_enable_sensor(struct hisi_thermal_data *data) +static int hi6220_thermal_enable_sensor(struct hisi_thermal_sensor *sensor) { - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_data *data = sensor->data; int ret; /* enable clock for tsensor */ @@ -352,10 +365,10 @@ static int hi6220_thermal_enable_sensor(struct hisi_thermal_data *data) return 0; } -static int hi3660_thermal_enable_sensor(struct hisi_thermal_data *data) +static int hi3660_thermal_enable_sensor(struct hisi_thermal_sensor *sensor) { unsigned int value; - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_data *data = sensor->data; /* disable interrupt */ hi3660_thermal_alarm_enable(data->regs, sensor->id, 0); @@ -432,7 +445,7 @@ static int hisi_thermal_get_temp(void *__data, int *temp) struct hisi_thermal_data *data = __data; struct hisi_thermal_sensor *sensor = &data->sensor; - *temp = data->ops->get_temp(data); + *temp = data->ops->get_temp(sensor); dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", sensor->id, *temp, sensor->thres_temp); @@ -450,7 +463,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) struct hisi_thermal_sensor *sensor = &data->sensor; int temp = 0; - data->ops->irq_handler(data); + data->ops->irq_handler(sensor); hisi_thermal_get_temp(data, &temp); @@ -470,10 +483,10 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) } static int hisi_thermal_register_sensor(struct platform_device *pdev, - struct hisi_thermal_data *data, struct hisi_thermal_sensor *sensor) { int ret, i; + struct hisi_thermal_data *data = sensor->data; const struct thermal_trip *trip; sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, @@ -549,21 +562,20 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->pdev = pdev; platform_set_drvdata(pdev, data); - + data->sensor.data = data; data->ops = of_device_get_match_data(dev); ret = data->ops->probe(data); if (ret) return ret; - ret = hisi_thermal_register_sensor(pdev, data, - &data->sensor); + ret = hisi_thermal_register_sensor(pdev, &data->sensor); if (ret) { dev_err(dev, "failed to register thermal sensor: %d\n", ret); return ret; } - ret = data->ops->enable_sensor(data); + ret = data->ops->enable_sensor(&data->sensor); if (ret) { dev_err(dev, "Failed to setup the sensor: %d\n", ret); return ret; @@ -591,7 +603,7 @@ static int hisi_thermal_remove(struct platform_device *pdev) hisi_thermal_toggle_sensor(sensor, false); - data->ops->disable_sensor(data); + data->ops->disable_sensor(&data->sensor); return 0; } @@ -601,7 +613,7 @@ static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - data->ops->disable_sensor(data); + data->ops->disable_sensor(&data->sensor); return 0; } @@ -610,7 +622,7 @@ static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - return data->ops->enable_sensor(data); + return data->ops->enable_sensor(&data->sensor); } #endif From patchwork Tue Sep 25 09:03:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613709 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-2.web.codeaurora.org (Postfix) with ESMTP id 31548112B for ; Tue, 25 Sep 2018 09:03:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2329E2908E for ; Tue, 25 Sep 2018 09:03:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1771F2931C; Tue, 25 Sep 2018 09:03:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 B243F2908E for ; Tue, 25 Sep 2018 09:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728580AbeIYPKY (ORCPT ); Tue, 25 Sep 2018 11:10:24 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54173 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727678AbeIYPKY (ORCPT ); Tue, 25 Sep 2018 11:10:24 -0400 Received: by mail-wm1-f66.google.com with SMTP id b19-v6so12515691wme.3 for ; Tue, 25 Sep 2018 02:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HwYZFcnFZ79mwFslZ96x0gM5YC++omWUey3iWIx22vk=; b=ZC9Ti9KhOgRCMuao2UPV1SrhW3WxdLEqc3hqIXa9RS5QGznBokFYD8lvQLEELTz0gs GjJ3B2Z8QwPivFTCfPGj2YY0Ep1gT1MW+JftbeFy9zVidQbPIvUkKZX0kkJx0n45gTnJ 4I4UIcTGjhDE8IO12oWJ5XjdJeiTWbGp7TXcE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HwYZFcnFZ79mwFslZ96x0gM5YC++omWUey3iWIx22vk=; b=o5qHGT5xvPgw7JafQoMgXOL28ZaGmSk+0y5dWD0unYUFJJpbDJgxQZD7Qkdv3aHYG0 dag3/TbdJkS/Ppu8icT6k/95XgWiUK+RHlxqMiObGKnZsFQvdDX0kL6mgeQLIDoca1U7 0E1O8ZOddI8CsPDhcP6cWhXK9agmLhmc87Qa4ysL4uCuKkyAgtxm10InxAydboUVu/RO Q1l43/TsEquJZ5YdYDphxx0oghGOvPU53AYdphSRvmz5bi8hFEUEIYYQCTNTPjpY1ZP9 2lacQORpAHyFC6aiBoD//jtXOMMCEPcZyhaxlhzMVXTD9QBOx6Nw2RayX2gomyTc+PYz 4d9g== X-Gm-Message-State: ABuFfoipFsfbfObcPM51FG5EOXhI2+bkwZgln+5W+bi734qk/QZ1tj+u FL74Z2zVNR/aF8OfXF9M86BgTg== X-Google-Smtp-Source: ACcGV63hg4yas5kJ0bADbIeAlHjupbj8mQHdod1EXaTVPHF6NcV4NRrB+/e4+/aCDSQzNkS6D+S2Iw== X-Received: by 2002:a1c:9355:: with SMTP id v82-v6mr60555wmd.128.1537866229953; Tue, 25 Sep 2018 02:03:49 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.03.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:03:47 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 03/14] thermal/drivers/hisi: Set the thermal zone private data to the sensor pointer Date: Tue, 25 Sep 2018 11:03:01 +0200 Message-Id: <1537866192-12320-4-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Store the sensor pointer in the thermal zone private data and use it in the callback functions. That allows to continue the conversion to sensor oriented code where the pointers are the sensors. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 1fdda55..567fde6 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -442,8 +442,8 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) static int hisi_thermal_get_temp(void *__data, int *temp) { - struct hisi_thermal_data *data = __data; - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_sensor *sensor = __data; + struct hisi_thermal_data *data = sensor->data; *temp = data->ops->get_temp(sensor); @@ -465,7 +465,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) data->ops->irq_handler(sensor); - hisi_thermal_get_temp(data, &temp); + hisi_thermal_get_temp(sensor, &temp); if (temp >= sensor->thres_temp) { dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", @@ -486,11 +486,10 @@ static int hisi_thermal_register_sensor(struct platform_device *pdev, struct hisi_thermal_sensor *sensor) { int ret, i; - struct hisi_thermal_data *data = sensor->data; const struct thermal_trip *trip; sensor->tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, - sensor->id, data, + sensor->id, sensor, &hisi_of_thermal_ops); if (IS_ERR(sensor->tzd)) { ret = PTR_ERR(sensor->tzd); From patchwork Tue Sep 25 09:03:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613713 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-2.web.codeaurora.org (Postfix) with ESMTP id D865216B1 for ; Tue, 25 Sep 2018 09:04:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB1B72836F for ; Tue, 25 Sep 2018 09:04:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF02229342; Tue, 25 Sep 2018 09:04:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 584032836F for ; Tue, 25 Sep 2018 09:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728659AbeIYPKd (ORCPT ); Tue, 25 Sep 2018 11:10:33 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36461 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbeIYPKd (ORCPT ); Tue, 25 Sep 2018 11:10:33 -0400 Received: by mail-wr1-f66.google.com with SMTP id e1-v6so22478473wrt.3 for ; Tue, 25 Sep 2018 02:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n7P2OSw8y61wcHZXfde/sCT0rh4Lfv8tdnBhTgzGYnU=; b=LQ/xRaZnZ/dByBF9rTFaqMOVQLxUFJsdsQuNwcwYXVMOiE7ZzLbROcZKTmIbOpZ7TN AFsSF6M724qkJoYhG7DpaOM+diUc+jLwuKIRT6vYf8jSkGcQ/mOc6zEjdMH5c8j2Kgyd bpbUEU+Zci6i7DYhWpNqC+AEv/rWss5sWztRg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n7P2OSw8y61wcHZXfde/sCT0rh4Lfv8tdnBhTgzGYnU=; b=fpu7F0aApoJ6sQ+EUXXKTX/O1+5IGJ9mMv6Zk3qD2NsJvdoHdnstuG5BF9S8DkALCh 3cYRmdyqfdIIDpgvS+XSVPIbGDwz6+z61+vNRLdLON3D3VBGyxYJngoM6cL+OAhOmYVa gAk2pz8T1sj/O9mWatKwzzcELl+VNpyK9gU5b54krCs3ipA/3E9DlO4UulrXxOf/CW63 J5exDniiIOJGpXyIc4kbhPtHosOmLKjojze+rDtW4VQtRByGAxlBE+FgZPnqge+SXqXI K+gv7SAH/DR0UNThcebAgqSaBkQ+JMAju1Ow/FXIhBe7H4+ugpCGOm6+C4bQgLr/MXVi djhg== X-Gm-Message-State: ABuFfogJ/I05kmC60AYclxIx3wvTft/GY655+X34xP3qYeXCqA7ta9Ty wsS0lsAMnZPg3IndlfE/H6SIyg== X-Google-Smtp-Source: ACcGV60mDHOmUD35l0uF2lPStiIueUCz2vCAOHzvHOURJmTuNlK5tExCmgR/b9nxFZ4CxpzhMHhgbg== X-Received: by 2002:adf:8425:: with SMTP id 34-v6mr12377wrf.153.1537866239922; Tue, 25 Sep 2018 02:03:59 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.03.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:03:52 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 04/14] thermal/drivers/hisi: Factor out the probe functions Date: Tue, 25 Sep 2018 11:03:02 +0200 Message-Id: <1537866192-12320-5-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 The hi6220 and the hi3660 probe functions are doing almost the same operations, they can share 90% of their code. Factor out the probe functions by moving the common code in the common probe function. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 567fde6..7287818 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -391,16 +391,8 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) { struct platform_device *pdev = data->pdev; struct device *dev = &pdev->dev; - struct resource *res; int ret; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - data->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(data->regs)) { - dev_err(dev, "failed to get io address\n"); - return PTR_ERR(data->regs); - } - data->clk = devm_clk_get(dev, "thermal_clk"); if (IS_ERR(data->clk)) { ret = PTR_ERR(data->clk); @@ -409,10 +401,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) return ret; } - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return data->irq; - data->sensor.id = HI6220_DEFAULT_SENSOR; return 0; @@ -420,21 +408,6 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) static int hi3660_thermal_probe(struct hisi_thermal_data *data) { - struct platform_device *pdev = data->pdev; - struct device *dev = &pdev->dev; - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - data->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(data->regs)) { - dev_err(dev, "failed to get io address\n"); - return PTR_ERR(data->regs); - } - - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return data->irq; - data->sensor.id = HI3660_DEFAULT_SENSOR; return 0; @@ -553,6 +526,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) { struct hisi_thermal_data *data; struct device *dev = &pdev->dev; + struct resource *res; int ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -564,6 +538,17 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->sensor.data = data; data->ops = of_device_get_match_data(dev); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + data->regs = devm_ioremap_resource(dev, res); + if (IS_ERR(data->regs)) { + dev_err(dev, "failed to get io address\n"); + return PTR_ERR(data->regs); + } + + data->irq = platform_get_irq(pdev, 0); + if (data->irq < 0) + return data->irq; + ret = data->ops->probe(data); if (ret) return ret; From patchwork Tue Sep 25 09:03:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613717 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-2.web.codeaurora.org (Postfix) with ESMTP id 3CBA3112B for ; Tue, 25 Sep 2018 09:04:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EAD72836F for ; Tue, 25 Sep 2018 09:04:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20C4E29307; Tue, 25 Sep 2018 09:04:24 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 85C582836F for ; Tue, 25 Sep 2018 09:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727075AbeIYPKy (ORCPT ); Tue, 25 Sep 2018 11:10:54 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33445 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727678AbeIYPKt (ORCPT ); Tue, 25 Sep 2018 11:10:49 -0400 Received: by mail-wr1-f67.google.com with SMTP id f10-v6so1444222wrs.0 for ; Tue, 25 Sep 2018 02:04:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=KM+fLMLgAtVQ6xfbHs0UQ7I/JbpTkxZz5SZVWDJdJ+JmlMxOk9U46qFHjE/DWvHi1p OokmN5ZIS8bWWyoEPYrmf42HIgs4P8DEqvVivJBZinAowF0rt4V92+qC2ynHUF62dcEb OzQoR0KNoHJWvpOCTkwgX8ZvGe6hYsgMDhcVk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B/n+YtvzBVLiSdVatyBy/SAfk8TXmG/YGKWWQu5FHyA=; b=J2WcM1ipLec3KnbcKBwMeLOjAKJIrT86E4h+sEuRwc6NbVQZoF+d3/+bAdFew2Bdab 4c0sVbW0r7kFgCV2eT31p91E4c1GZJN0P9NhkS4/qoLpINcxYCNl+ZVLhQWatXArl4r/ CqIdVroBnUx7Tt9ouumS9TnxSeODW8gYO42Uvjl7c3RhOOHyyQaiL5ugYjHPlKKrfRv2 JW2geFuivEhdET33uPN/pP5uWIYzev9hOn8RisS9duurZKwzS8wJzBmDEKYVoTp20hae bl+pjcrW17SWluGeXkQ7ZrpnwotGSTDnJohZbEcAnVz+v0F6qeAstVnS/jNG6lscMAzd bWFQ== X-Gm-Message-State: ABuFfogvtD6MsO2O4qEwOnyHqoFP/XDVqSGfZsQ0i9xfyFE0xFeeD8CW FGTC+qBM11X+A8kOfjKKUzshzQ== X-Google-Smtp-Source: ACcGV620Nr6oA7oi55omovmBdbQuRa8B16xOGsnxLgBP5k7rPh1/BQboaxY4+4SsCyuY8AY1zFqEhQ== X-Received: by 2002:a5d:5391:: with SMTP id d17-v6mr11507wrv.191.1537866254938; Tue, 25 Sep 2018 02:04:14 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:03 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 05/14] thermal/drivers/hisi: Prepare to support multiple sensors Date: Tue, 25 Sep 2018 11:03:03 +0200 Message-Id: <1537866192-12320-6-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Convert the 'sensor' field to a pointer and propagate the change in the file. Havintg a pointer, gives us the opportunity to define multiple sensors. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 7287818..87b82fb 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -77,10 +77,11 @@ struct hisi_thermal_ops { struct hisi_thermal_data { const struct hisi_thermal_ops *ops; - struct hisi_thermal_sensor sensor; + struct hisi_thermal_sensor *sensor; struct platform_device *pdev; struct clk *clk; void __iomem *regs; + int nr_sensors; int irq; }; @@ -401,14 +402,29 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) return ret; } - data->sensor.id = HI6220_DEFAULT_SENSOR; + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + if (!data->sensor) + return -ENOMEM; + + data->sensor[0].id = HI6220_DEFAULT_SENSOR; + data->sensor[0].data = data; + data->nr_sensors = 1; return 0; } static int hi3660_thermal_probe(struct hisi_thermal_data *data) { - data->sensor.id = HI3660_DEFAULT_SENSOR; + struct platform_device *pdev = data->pdev; + struct device *dev = &pdev->dev; + + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + if (!data->sensor) + return -ENOMEM; + + data->sensor[0].id = HI3660_DEFAULT_SENSOR; + data->sensor[0].data = data; + data->nr_sensors = 1; return 0; } @@ -433,7 +449,7 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { struct hisi_thermal_data *data = dev; - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_sensor *sensor = &data->sensor[0]; int temp = 0; data->ops->irq_handler(sensor); @@ -444,7 +460,7 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", temp, sensor->thres_temp); - thermal_zone_device_update(data->sensor.tzd, + thermal_zone_device_update(data->sensor[0].tzd, THERMAL_EVENT_UNSPECIFIED); } else { @@ -535,7 +551,6 @@ static int hisi_thermal_probe(struct platform_device *pdev) data->pdev = pdev; platform_set_drvdata(pdev, data); - data->sensor.data = data; data->ops = of_device_get_match_data(dev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -553,13 +568,13 @@ static int hisi_thermal_probe(struct platform_device *pdev) if (ret) return ret; - ret = hisi_thermal_register_sensor(pdev, &data->sensor); + ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]); if (ret) { dev_err(dev, "failed to register thermal sensor: %d\n", ret); return ret; } - ret = data->ops->enable_sensor(&data->sensor); + ret = data->ops->enable_sensor(&data->sensor[0]); if (ret) { dev_err(dev, "Failed to setup the sensor: %d\n", ret); return ret; @@ -575,7 +590,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) } } - hisi_thermal_toggle_sensor(&data->sensor, true); + hisi_thermal_toggle_sensor(&data->sensor[0], true); return 0; } @@ -583,11 +598,11 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - struct hisi_thermal_sensor *sensor = &data->sensor; + struct hisi_thermal_sensor *sensor = &data->sensor[0]; hisi_thermal_toggle_sensor(sensor, false); - data->ops->disable_sensor(&data->sensor); + data->ops->disable_sensor(sensor); return 0; } @@ -597,7 +612,7 @@ static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - data->ops->disable_sensor(&data->sensor); + data->ops->disable_sensor(&data->sensor[0]); return 0; } @@ -606,7 +621,7 @@ static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); - return data->ops->enable_sensor(&data->sensor); + return data->ops->enable_sensor(&data->sensor[0]); } #endif From patchwork Tue Sep 25 09:03:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613719 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-2.web.codeaurora.org (Postfix) with ESMTP id EA99015E8 for ; Tue, 25 Sep 2018 09:04:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD79D2836F for ; Tue, 25 Sep 2018 09:04:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D12A329307; Tue, 25 Sep 2018 09:04:30 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 568F72836F for ; Tue, 25 Sep 2018 09:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727767AbeIYPLB (ORCPT ); Tue, 25 Sep 2018 11:11:01 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35565 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727606AbeIYPLB (ORCPT ); Tue, 25 Sep 2018 11:11:01 -0400 Received: by mail-wr1-f68.google.com with SMTP id o16so9159722wrx.2 for ; Tue, 25 Sep 2018 02:04:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WEayJ7v/hmTPrXvagArEZzBi0kAZmXnqnjkohn08PO0=; b=Sb0oe1lbClXkht5v1ucQ3Geuyw1Ij5+Gor0f/HIPYD6vunyMzaHIsQXNOU94M6JgPR /xx/ji5DaC/y69kOUsBpzHZwzBe+f6wfR7nTUaRL1GqcYR/Qszu4BTwADC/H6Sz5Ctp8 oOPFPbXb2d2JxKGgMgBxIA2m5jg18jipV/6E0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WEayJ7v/hmTPrXvagArEZzBi0kAZmXnqnjkohn08PO0=; b=L5MkF73s6ggOxRs5Y8mBIOrmfe8JUGvh7dQHCdVGLxKnjLjN3hCQhg6PF2Gxrg+SSV bop6RYFuC7Ivou+4IRGJvqorEoN12Ihsp4Zkmk/L6gLdsJhQAe1l2nLbFc574nUH59ot n+d2CQ/WH+nTZkHhUBwZzHxX/VLC32zrx+oIWY5lGQV6doLBGt1eqyVSNDB0HHevGsCl rVLgn7nHZ1+O39LvE8ZmYptPof2QAzVS9nQi+pw+3RZJd095sM7ZUZ0poOlg9adeGuOU mDGKHny78olV8P05Er5Z8MTI9VwEkAjT3KhhjKdDy6JC849/XlyeYQpMuiN/Py/qCXCy NYLA== X-Gm-Message-State: ABuFfogMY5xkzfAg9lz3BEFzD+8ixhs33Oe3CC4CJe6GuV/fzTMSe4ro adqQxEtsCVC7NmVvrGD6c4S2Vw== X-Google-Smtp-Source: ACcGV63CfrfPsly/btiBIuAuGid3UQ/py6M/MKulwWcpEQhMRzT/QS/Wu+nIbTz6WW5Aq7xYVLEd7w== X-Received: by 2002:a5d:448d:: with SMTP id j13-v6mr40153wrq.236.1537866266930; Tue, 25 Sep 2018 02:04:26 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:25 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 06/14] thermal/drivers/hisi: Add multiple sensors support Date: Tue, 25 Sep 2018 11:03:04 +0200 Message-Id: <1537866192-12320-7-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Change the code as it is dealing with several sensors. For git-bisect compatibility (compilation and booting), assume the DT is not yet changed and we have a single interrupt. Next changes will support multiple interrupt sorted by their name. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 79 +++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 87b82fb..a5756f6 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -448,8 +448,8 @@ static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) { - struct hisi_thermal_data *data = dev; - struct hisi_thermal_sensor *sensor = &data->sensor[0]; + struct hisi_thermal_sensor *sensor = dev; + struct hisi_thermal_data *data = sensor->data; int temp = 0; data->ops->irq_handler(sensor); @@ -457,15 +457,17 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev) hisi_thermal_get_temp(sensor, &temp); if (temp >= sensor->thres_temp) { - dev_crit(&data->pdev->dev, "THERMAL ALARM: %d > %d\n", - temp, sensor->thres_temp); + dev_crit(&data->pdev->dev, + "sensor <%d> THERMAL ALARM: %d > %d\n", + sensor->id, temp, sensor->thres_temp); - thermal_zone_device_update(data->sensor[0].tzd, + thermal_zone_device_update(sensor->tzd, THERMAL_EVENT_UNSPECIFIED); } else { - dev_crit(&data->pdev->dev, "THERMAL ALARM stopped: %d < %d\n", - temp, sensor->thres_temp); + dev_crit(&data->pdev->dev, + "sensor <%d> THERMAL ALARM stopped: %d < %d\n", + sensor->id, temp, sensor->thres_temp); } return IRQ_HANDLED; @@ -543,7 +545,7 @@ static int hisi_thermal_probe(struct platform_device *pdev) struct hisi_thermal_data *data; struct device *dev = &pdev->dev; struct resource *res; - int ret; + int i, ret; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) @@ -560,37 +562,41 @@ static int hisi_thermal_probe(struct platform_device *pdev) return PTR_ERR(data->regs); } - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return data->irq; - ret = data->ops->probe(data); if (ret) return ret; - ret = hisi_thermal_register_sensor(pdev, &data->sensor[0]); - if (ret) { - dev_err(dev, "failed to register thermal sensor: %d\n", ret); - return ret; - } + for (i = 0; i < data->nr_sensors; i++) { + struct hisi_thermal_sensor *sensor = &data->sensor[i]; - ret = data->ops->enable_sensor(&data->sensor[0]); - if (ret) { - dev_err(dev, "Failed to setup the sensor: %d\n", ret); - return ret; - } + ret = hisi_thermal_register_sensor(pdev, sensor); + if (ret) { + dev_err(dev, "failed to register thermal sensor: %d\n", + ret); + return ret; + } + + data->irq = platform_get_irq(pdev, 0); + if (data->irq < 0) + return data->irq; - if (data->irq) { ret = devm_request_threaded_irq(dev, data->irq, NULL, - hisi_thermal_alarm_irq_thread, - IRQF_ONESHOT, "hisi_thermal", data); + hisi_thermal_alarm_irq_thread, + IRQF_ONESHOT, "hisi_thermal", + sensor); if (ret < 0) { dev_err(dev, "failed to request alarm irq: %d\n", ret); return ret; } - } - hisi_thermal_toggle_sensor(&data->sensor[0], true); + ret = data->ops->enable_sensor(sensor); + if (ret) { + dev_err(dev, "Failed to setup the sensor: %d\n", ret); + return ret; + } + + hisi_thermal_toggle_sensor(sensor, true); + } return 0; } @@ -598,11 +604,14 @@ static int hisi_thermal_probe(struct platform_device *pdev) static int hisi_thermal_remove(struct platform_device *pdev) { struct hisi_thermal_data *data = platform_get_drvdata(pdev); - struct hisi_thermal_sensor *sensor = &data->sensor[0]; + int i; - hisi_thermal_toggle_sensor(sensor, false); + for (i = 0; i < data->nr_sensors; i++) { + struct hisi_thermal_sensor *sensor = &data->sensor[i]; - data->ops->disable_sensor(sensor); + hisi_thermal_toggle_sensor(sensor, false); + data->ops->disable_sensor(sensor); + } return 0; } @@ -611,8 +620,10 @@ static int hisi_thermal_remove(struct platform_device *pdev) static int hisi_thermal_suspend(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); + int i; - data->ops->disable_sensor(&data->sensor[0]); + for (i = 0; i < data->nr_sensors; i++) + data->ops->disable_sensor(&data->sensor[i]); return 0; } @@ -620,8 +631,12 @@ static int hisi_thermal_suspend(struct device *dev) static int hisi_thermal_resume(struct device *dev) { struct hisi_thermal_data *data = dev_get_drvdata(dev); + int i, ret = 0; + + for (i = 0; i < data->nr_sensors; i++) + ret |= data->ops->enable_sensor(&data->sensor[i]); - return data->ops->enable_sensor(&data->sensor[0]); + return ret; } #endif From patchwork Tue Sep 25 09:03:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613721 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-2.web.codeaurora.org (Postfix) with ESMTP id DF9AC15E8 for ; Tue, 25 Sep 2018 09:04:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1F382836F for ; Tue, 25 Sep 2018 09:04:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C60A129307; Tue, 25 Sep 2018 09:04:32 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 6AA2F2836F for ; Tue, 25 Sep 2018 09:04:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726927AbeIYPLC (ORCPT ); Tue, 25 Sep 2018 11:11:02 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44198 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbeIYPLC (ORCPT ); Tue, 25 Sep 2018 11:11:02 -0400 Received: by mail-wr1-f67.google.com with SMTP id v16-v6so22463242wro.11 for ; Tue, 25 Sep 2018 02:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=twKUT5AkgFgWw/t/b6bDn1W7sM2Rq3ji9heE8FRQKeo=; b=bwrASE8SJsryrgfQp4OcrgICX1ooVdFQ8ivP+hUg1MrkP2Piwfyyl56tQV7tpvs4vJ J2dxuWJ4Ixf9xZgYy09bXWorJ6l0ku8qJ5Kq7fPRKZN6n9ORds4a0M1+v5yEniW1APBH y/DKqJudolhwzSHhpJTNylGgZSsOgYIq3GBuM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=twKUT5AkgFgWw/t/b6bDn1W7sM2Rq3ji9heE8FRQKeo=; b=A+rf5hSj5I2B5g/U8iZ9nScIlKQjvCnGhWL30j4ZW6pvYIkn3eKKq5Tv5NGQbwcVBJ 33PkFtAnC1Mc7E+mQu3+BcR5rpVeRwoZm1lMAMtlEpXqQW0rGJvvliArXnHyqc/7nur1 doH7D19/sfj+3+aaPghc5XXtgqlAyqs0j791GENgd6Wioou0om3lyd33niNrRCYbNpFn vpx1gZd9bUctjCEypZWsgbZ9fA+G8ItobEnjFHANqX4cZiuU6wI5Met5CvOUZiN2gsNa 9jcMZB4o8RJoBBNpRoHg1rhzw0wIGKpx1xX7Gz5gaI0db9ZZgxH1m/28efBGXKIGwRPj KT0g== X-Gm-Message-State: ABuFfog01Vriqbdcz8hQtgzMuAuhqo9CDyfef7i3IliO7N0bBtDhRkXi jyPFwZTS+ff8zclczW5wFtJdMA== X-Google-Smtp-Source: ACcGV61fzTmdR4BPLrmgBB61wZJaUvDg22lvoj0ZJSjQXUZ5up4w/aemDRqx6zCaR0n2k0YA1gXJUg== X-Received: by 2002:a5d:4185:: with SMTP id m5-v6mr97633wrp.8.1537866268768; Tue, 25 Sep 2018 02:04:28 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:28 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 07/14] thermal/drivers/hisi: Replace macro name with relevant sensor location Date: Tue, 25 Sep 2018 11:03:05 +0200 Message-Id: <1537866192-12320-8-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Change the macro name in order to give a better indication of the sensor location. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index a5756f6..a542cb3 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -55,8 +55,8 @@ #define HI3660_TEMP_STEP (205) #define HI3660_TEMP_LAG (4000) -#define HI6220_DEFAULT_SENSOR 2 -#define HI3660_DEFAULT_SENSOR 1 +#define HI6220_CLUSTER0_SENSOR 2 +#define HI3660_BIG_SENSOR 1 struct hisi_thermal_data; @@ -406,7 +406,7 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) if (!data->sensor) return -ENOMEM; - data->sensor[0].id = HI6220_DEFAULT_SENSOR; + data->sensor[0].id = HI6220_CLUSTER0_SENSOR; data->sensor[0].data = data; data->nr_sensors = 1; @@ -422,7 +422,7 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) if (!data->sensor) return -ENOMEM; - data->sensor[0].id = HI3660_DEFAULT_SENSOR; + data->sensor[0].id = HI3660_BIG_SENSOR; data->sensor[0].data = data; data->nr_sensors = 1; From patchwork Tue Sep 25 09:03:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613725 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-2.web.codeaurora.org (Postfix) with ESMTP id 2D81B15E8 for ; Tue, 25 Sep 2018 09:04:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E4302836F for ; Tue, 25 Sep 2018 09:04:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 125D029307; Tue, 25 Sep 2018 09:04: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 91C832836F for ; Tue, 25 Sep 2018 09:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbeIYPLG (ORCPT ); Tue, 25 Sep 2018 11:11:06 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39767 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728753AbeIYPLF (ORCPT ); Tue, 25 Sep 2018 11:11:05 -0400 Received: by mail-wr1-f65.google.com with SMTP id s14-v6so22455686wrw.6 for ; Tue, 25 Sep 2018 02:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fOZ6rfysb+Hiuh5cPbqLhry8YsLUdhlmW/oJcrqQRxA=; b=hcVBj09/LPgzagzXbG9tfUX8oRAsiwmFID99WPVrdOQGmbC1/0KZ9FWpIpwqpIRwUp s0EdWA/zagjvvwkOeDckhfYfza+coZ2FjWx/hC0xW5q2qvV+REWF/BYRpH/agpwbHgjp swl2HELI+DPy1jSvRSc+6SD4QrEnNdJPpCZXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fOZ6rfysb+Hiuh5cPbqLhry8YsLUdhlmW/oJcrqQRxA=; b=gViU8tR5RsI01LrGMaqmGQBSwKLzl4e79kmPgZBhwk4iMw+1K7o6kaAZxsszrKLQjN yGvYYtpap73s5gjazgj44DW8dARJAGgqzssqiOIMGAvbNeVbFmA7yyPoAWtSmh/CmsKk eJazOUT53gYUEVRqRGPyKWmmgju7o5PRv0STYcLBdIXN8jKz8WU2unlnRpIiB80a5Eta VEE6xDOVHYRDTOTNGYItb4ETkzDnUmLbp9aKY3+y2mnsmQdPT/2diVCiL77q5T75cz++ eR2BGY+F25kdvuYlwr1+EflOcQDADmqVnBVfr2icpHa+Wbatuk6YUaRjFxGC3OS3Ax1e rj/w== X-Gm-Message-State: ABuFfohy8J4DEeKfQcwdhsAzFwHEEUpFBISmx9V1ME6yg52ttqDu2V3b 7oPacQBQHXt4h7h1/rRP/3Jwfw== X-Google-Smtp-Source: ACcGV626nFqoIkfxnZMLcFwr/69sx3ju/W/3gsoTKroQryZiFvQWISxo5AubYpFvC6zc/q0+fBW2HA== X-Received: by 2002:a5d:448d:: with SMTP id j13-v6mr40484wrq.236.1537866271365; Tue, 25 Sep 2018 02:04:31 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:30 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui , Rob Herring , Mark Rutland , Wei Xu , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-arm-kernel@lists.infradead.org (moderated list:ARM/HISILICON SOC SUPPORT) Subject: [PATCH 08/14] ARM64: dts: hisilicon: Add tsensor interrupt name Date: Tue, 25 Sep 2018 11:03:06 +0200 Message-Id: <1537866192-12320-9-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Add the interrupt names for the sensors, so the code can rely on them instead of dealing with index which are prone to error. The name comes from the Hisilicon documentation found on internet. Signed-off-by: Daniel Lezcano --- .../bindings/thermal/hisilicon-thermal.txt | 3 ++ arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 63 +++++++++++----------- arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 1 + 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt index cef716a..3edfae3 100644 --- a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt @@ -7,6 +7,7 @@ region. - interrupt: The interrupt number to the cpu. Defines the interrupt used by /SOCTHERM/tsensor. +- interrupt-names: The interrupt names for the different sensors - clock-names: Input clock name, should be 'thermal_clk'. - clocks: phandles for clock specified in "clock-names" property. - #thermal-sensor-cells: Should be 1. See ./thermal.txt for a description. @@ -18,6 +19,7 @@ for Hi6220: compatible = "hisilicon,tsensor"; reg = <0x0 0xf7030700 0x0 0x1000>; interrupts = <0 7 0x4>; + interrupt-names = "tsensor_intr"; clocks = <&sys_ctrl HI6220_TSENSOR_CLK>; clock-names = "thermal_clk"; #thermal-sensor-cells = <1>; @@ -28,5 +30,6 @@ for Hi3660: compatible = "hisilicon,hi3660-tsensor"; reg = <0x0 0xfff30000 0x0 0x1000>; interrupts = ; + interrupt-names = "tsensor_a73"; #thermal-sensor-cells = <1>; }; diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi index f432b0a..bf8a479 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi @@ -1081,46 +1081,47 @@ compatible = "hisilicon,hi3660-tsensor"; reg = <0x0 0xfff30000 0x0 0x1000>; interrupts = ; + interrupt-names = "tsensor_a73"; #thermal-sensor-cells = <1>; }; - thermal-zones { + thermal-zones { - cls0: cls0 { - polling-delay = <1000>; - polling-delay-passive = <100>; - sustainable-power = <4500>; + cls0: cls0 { + polling-delay = <1000>; + polling-delay-passive = <100>; + sustainable-power = <4500>; - /* sensor ID */ - thermal-sensors = <&tsensor 1>; + /* sensor ID */ + thermal-sensors = <&tsensor 1>; - trips { - threshold: trip-point@0 { - temperature = <65000>; - hysteresis = <1000>; - type = "passive"; - }; + trips { + threshold: trip-point@0 { + temperature = <65000>; + hysteresis = <1000>; + type = "passive"; + }; - target: trip-point@1 { - temperature = <75000>; - hysteresis = <1000>; - type = "passive"; - }; - }; + target: trip-point@1 { + temperature = <75000>; + hysteresis = <1000>; + type = "passive"; + }; + }; - cooling-maps { + cooling-maps { map0 { - trip = <&target>; - contribution = <1024>; - cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; - }; + trip = <&target>; + contribution = <1024>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; map1 { - trip = <&target>; - contribution = <512>; - cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; - }; - }; - }; - }; + trip = <&target>; + contribution = <512>; + cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + }; }; }; diff --git a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi index 247024d..9eae986 100644 --- a/arch/arm64/boot/dts/hisilicon/hi6220.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi6220.dtsi @@ -841,6 +841,7 @@ compatible = "hisilicon,tsensor"; reg = <0x0 0xf7030700 0x0 0x1000>; interrupts = ; + interrupt-names = "tsensor_intr"; clocks = <&sys_ctrl 22>; clock-names = "thermal_clk"; #thermal-sensor-cells = <1>; From patchwork Tue Sep 25 09:03:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613723 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-2.web.codeaurora.org (Postfix) with ESMTP id 8EFBD15E8 for ; Tue, 25 Sep 2018 09:04:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F6082836F for ; Tue, 25 Sep 2018 09:04:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7257329307; Tue, 25 Sep 2018 09:04:43 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 1FC252836F for ; Tue, 25 Sep 2018 09:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726586AbeIYPLH (ORCPT ); Tue, 25 Sep 2018 11:11:07 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43664 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728799AbeIYPLH (ORCPT ); Tue, 25 Sep 2018 11:11:07 -0400 Received: by mail-wr1-f65.google.com with SMTP id z14-v6so4965360wrs.10 for ; Tue, 25 Sep 2018 02:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=24xEIGND92Wry87aRP5S+r2CoVI/mGeClIEhmLV7kWE=; b=QFkBO4n0OJHz1OCdkarXuxWrZ1/9HdldlP+H6dN4WG6Q84n0T4V3bXkg++3crFFLHc ifJLjRg+Q/WygElxH6nJ13OH/0ilBVh9yE+oUKMQez9cFKKHkcgSsC6GJy1XV/eS0M0F /5XeDdoNK08NyuYvFggL4yvQAh7txa6zDBqzc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=24xEIGND92Wry87aRP5S+r2CoVI/mGeClIEhmLV7kWE=; b=HesfS+WIiDlgQY97u+Nfy3ja5u3lUG7Xjg6QZLyLZQWVncGdpV8PjO+2dcHIFVX/zm jDSTXG8oYKQsC/7r3IruJY057fDFpBP+u0dd3F9oFggXS9N/n+bHU1Tu6YShxYwB5+ZC 6Ka8xul3dA4HsP4A/S2KK2dt5zsPpaZjTA8GPP+6eTT+bBorKfCVoIwYEZBiyc4IIJag Hbfvt3nYTAioAHrYp6iWOuCsE8E2YLs71LKSvatAUkcsH0qRCQqRa/dQpqPJ70MVZdkB h/A4GFeFA3BJwn/4lS1VqfpS1TC+gtX3d9X5JdHH+OAad0gvbvoN1PaxPqC3fnrGLKQn Z9CA== X-Gm-Message-State: ABuFfojEL3cs9Hnfc+rAMKMMrfqwbGrR/+SFnddVW5ETWoO5laCPMVGE OwGIlJ9e02ZFTCWDjLSghmwq+w== X-Google-Smtp-Source: ACcGV63OLoXsZVmu8be4qAjDQjiS6MZC+2pQZRumfLVZKin2P/kkh1npiFECmkYGkF3kpacm3Wjq/g== X-Received: by 2002:adf:a925:: with SMTP id u34-v6mr14366wrc.175.1537866273230; Tue, 25 Sep 2018 02:04:33 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:32 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 09/14] thermal/drivers/hisi: Use platform_get_irq_byname Date: Tue, 25 Sep 2018 11:03:07 +0200 Message-Id: <1537866192-12320-10-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 As we have the interrupt names defines, replace platform_get_irq() by platform_get_irq_byname(), so no confusion can be made when getting the interrupt with the sensor id. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index a542cb3..941c2c4 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -63,6 +63,7 @@ struct hisi_thermal_data; struct hisi_thermal_sensor { struct hisi_thermal_data *data; struct thermal_zone_device *tzd; + const char *irq_name; uint32_t id; uint32_t thres_temp; }; @@ -407,6 +408,7 @@ static int hi6220_thermal_probe(struct hisi_thermal_data *data) return -ENOMEM; data->sensor[0].id = HI6220_CLUSTER0_SENSOR; + data->sensor[0].irq_name = "tsensor_intr"; data->sensor[0].data = data; data->nr_sensors = 1; @@ -423,6 +425,7 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) return -ENOMEM; data->sensor[0].id = HI3660_BIG_SENSOR; + data->sensor[0].irq_name = "tsensor_a73"; data->sensor[0].data = data; data->nr_sensors = 1; @@ -576,13 +579,13 @@ static int hisi_thermal_probe(struct platform_device *pdev) return ret; } - data->irq = platform_get_irq(pdev, 0); + data->irq = platform_get_irq_byname(pdev, sensor->irq_name); if (data->irq < 0) return data->irq; ret = devm_request_threaded_irq(dev, data->irq, NULL, hisi_thermal_alarm_irq_thread, - IRQF_ONESHOT, "hisi_thermal", + IRQF_ONESHOT, sensor->irq_name, sensor); if (ret < 0) { dev_err(dev, "failed to request alarm irq: %d\n", ret); From patchwork Tue Sep 25 09:03:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613727 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-2.web.codeaurora.org (Postfix) with ESMTP id 1276D112B for ; Tue, 25 Sep 2018 09:04:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02A8A2836F for ; Tue, 25 Sep 2018 09:04:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB2BC29307; Tue, 25 Sep 2018 09:04: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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 608962836F for ; Tue, 25 Sep 2018 09:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbeIYPLS (ORCPT ); Tue, 25 Sep 2018 11:11:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39791 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727823AbeIYPLS (ORCPT ); Tue, 25 Sep 2018 11:11:18 -0400 Received: by mail-wr1-f66.google.com with SMTP id s14-v6so22456529wrw.6 for ; Tue, 25 Sep 2018 02:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FjybuiDBSw9NEcO9lVDeNrywfT+itTu22LbecoDEATI=; b=bZX5Iqq+b+ebjBjrTvEni6eoWVpbN44VEylr0iEpPtrISQsPBJ+t86e/AERKMVtKr6 yNfuI/lHspqvFYZmN7WAOvBdg53P8O63wJXVxSGHKCBMArTB/hDeflvQ7F6tmQiIzQMu 8qMgf3qWrKBcZoGHdlM48fT9x61DQ8wq9Xqq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FjybuiDBSw9NEcO9lVDeNrywfT+itTu22LbecoDEATI=; b=dr7/iAGVZbtF7qPiMaY+PyUfInLhCUZdJMfLZx9+kycW01VwfLd2K3Hh3n+t4RsJRM 7533+ePf3qkwmFCVHOdiYVAfeQlU1MbtS6u34auJG1mbQ2Cs9TTerUdwZfLqy4Zd++uK 0hJzift+FjLsg5zNZ+sbJpS3qmRrirNBy6+9f84eYZbXeO4I9vGcjJu+THdCuitUJ7wB qlGQ0N7r8/XFbf4J1XYNpMiEq+w6sY5tMWjKzJT/PM9EG5vC7FeA8fsCq0qCf67mpoCQ MxgX7o4m8NBcqRJVsSvglz6QgJrxDG7ukI/yANuUbcPebKa4FT4zcps8lyD+tCWxAvz2 d+cg== X-Gm-Message-State: ABuFfogo3ObWm8b/I6dHosipxdbfo8/s1jaa6gL7atQDK98GZb9Lldkw L/vU7cZdvOtP4LIqGugD8Cqcow== X-Google-Smtp-Source: ACcGV60c+zvgyXqfFi9kBVufYxmfYw6GVgvZbVU6AhOdKAbmf4fY/l0kJbHz3HlEDhZTke6Ba5mUtw== X-Received: by 2002:adf:fdca:: with SMTP id i10-v6mr37238wrs.276.1537866284739; Tue, 25 Sep 2018 02:04:44 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:36 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui , Rob Herring , Mark Rutland , Wei Xu , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-arm-kernel@lists.infradead.org (moderated list:ARM/HISILICON SOC SUPPORT) Subject: [PATCH 10/14] ARM64: dts: hisilicon: Add interrupt names for the tsensors Date: Tue, 25 Sep 2018 11:03:08 +0200 Message-Id: <1537866192-12320-11-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Add the missing interrupts for the temperature sensors as well as their names. Signed-off-by: Daniel Lezcano --- Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt | 8 ++++++-- arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt index 3edfae3..4cb8add 100644 --- a/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt +++ b/Documentation/devicetree/bindings/thermal/hisilicon-thermal.txt @@ -29,7 +29,11 @@ for Hi3660: tsensor: tsensor@fff30000 { compatible = "hisilicon,hi3660-tsensor"; reg = <0x0 0xfff30000 0x0 0x1000>; - interrupts = ; - interrupt-names = "tsensor_a73"; + interrupts = , + , + , + ; + interrupt-names = "tsensor_a73", "tsensor_a53", + "tsensor_g3d", "tsensor_modem"; #thermal-sensor-cells = <1>; }; diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi index bf8a479..dd398cb 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi @@ -1080,8 +1080,12 @@ tsensor: tsensor@fff30000 { compatible = "hisilicon,hi3660-tsensor"; reg = <0x0 0xfff30000 0x0 0x1000>; - interrupts = ; - interrupt-names = "tsensor_a73"; + interrupts = , + , + , + ; + interrupt-names = "tsensor_a73", "tsensor_a53", + "tsensor_g3d", "tsensor_modem"; #thermal-sensor-cells = <1>; }; From patchwork Tue Sep 25 09:03:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613735 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-2.web.codeaurora.org (Postfix) with ESMTP id 92A9E112B for ; Tue, 25 Sep 2018 09:05:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 841662908E for ; Tue, 25 Sep 2018 09:05:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 782D72931C; Tue, 25 Sep 2018 09:05:19 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 183492908E for ; Tue, 25 Sep 2018 09:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbeIYPLu (ORCPT ); Tue, 25 Sep 2018 11:11:50 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38668 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726356AbeIYPL2 (ORCPT ); Tue, 25 Sep 2018 11:11:28 -0400 Received: by mail-wm1-f65.google.com with SMTP id z16-v6so6329022wmi.3 for ; Tue, 25 Sep 2018 02:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2GO8tdB0VqF/b2ulgCZCuFFs0ie3KdkmUxeTxxbYG3I=; b=KOyh3egXVnoup8Dg4CvBj/Aq3XnB2Z9Jn0rwy6SseExGuOW/eWS4yRRbJpX7hLf7f7 3pa0iMIQy0wrYn+04NfvD3SqceW9W1svCl3IywZ70NMtIkJy/JqRewnMHs/115//+MVh tMmjyJ3gAe78KtjmMXn3uIsWF7P5AZXlmGz/M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2GO8tdB0VqF/b2ulgCZCuFFs0ie3KdkmUxeTxxbYG3I=; b=LGZ0uzaN3wuP27e1F4aLEA0pHOjvLAyoj/fOY5M0pDv7Gbdz+26HiK4qx0sHn17yii uykDamNySF0iILnIBIzzVJY33aFhYp//q5pKcJuVALla1e+wy7gbOdTzi3lkLT+fBHBs 3tY4s8r99MsQ5ZyEY+rsYm6D/aH/9RVWoaH7futx5j15ECDKBBfbhPk9igkVvYDn/ihk cXrGwIE/zINvw+Mrm59ecyoxQec8NALz168ihwnoN7Rb5l44xfUj33TiJHwFywLFjMiF 4iwLqm+MnPiGJVw8pNGJ7hfO9nUlQ6bQK4a8rKIcAp/VVxF1Yg6vYQ9KAQFLzG4Kjtqd X7HA== X-Gm-Message-State: ABuFfoglTbpXaQYlyrf2bD3jfsvSw+TAv3ATjmZLW1APbJmBYHgx4x2h nHL9h4jz3ZPuzshSBcY7o4A5lA== X-Google-Smtp-Source: ACcGV635Xv/YujAroy4RRVeSE5kz/CceBXIU0wiFoXgaUYKj0MI1RlWwagysKD496PbRnZDZVX08EQ== X-Received: by 2002:a1c:7d51:: with SMTP id y78-v6mr55960wmc.37.1537866293946; Tue, 25 Sep 2018 02:04:53 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:51 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 11/14] thermal/drivers/hisi: Remove pointless irq field Date: Tue, 25 Sep 2018 11:03:09 +0200 Message-Id: <1537866192-12320-12-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 The irq field in the data structure is pointless as the scope of its usage is just to request the interrupt. It can be replaced by a local variable. Use the 'ret' variable to get the interrupt number. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 941c2c4..87d8a13 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -83,7 +83,6 @@ struct hisi_thermal_data { struct clk *clk; void __iomem *regs; int nr_sensors; - int irq; }; /* @@ -579,16 +578,16 @@ static int hisi_thermal_probe(struct platform_device *pdev) return ret; } - data->irq = platform_get_irq_byname(pdev, sensor->irq_name); - if (data->irq < 0) - return data->irq; + ret = platform_get_irq_byname(pdev, sensor->irq_name); + if (ret < 0) + return ret; - ret = devm_request_threaded_irq(dev, data->irq, NULL, + ret = devm_request_threaded_irq(dev, ret, NULL, hisi_thermal_alarm_irq_thread, IRQF_ONESHOT, sensor->irq_name, sensor); if (ret < 0) { - dev_err(dev, "failed to request alarm irq: %d\n", ret); + dev_err(dev, "Failed to request alarm irq: %d\n", ret); return ret; } From patchwork Tue Sep 25 09:03:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613737 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-2.web.codeaurora.org (Postfix) with ESMTP id 8F30F15E8 for ; Tue, 25 Sep 2018 09:05:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8227B2836F for ; Tue, 25 Sep 2018 09:05:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 761B129307; Tue, 25 Sep 2018 09:05:25 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI autolearn=ham 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 A1B912836F for ; Tue, 25 Sep 2018 09:05:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727570AbeIYPLa (ORCPT ); Tue, 25 Sep 2018 11:11:30 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43698 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728892AbeIYPL3 (ORCPT ); Tue, 25 Sep 2018 11:11:29 -0400 Received: by mail-wr1-f66.google.com with SMTP id z14-v6so4966657wrs.10 for ; Tue, 25 Sep 2018 02:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xaKoq2Z5i+AH80JWe8GKSoRR6ISgaXZtO2Gfftl5H7k=; b=ewS1y75l1+/fHRqN/ts2a8WT3bknw2zaVcpHBeb2sONr4psMZ1KR2jC/1E204J2bpL S/QO/x51Ws1NGos9hHrjUx4/n0dJa3KuNN6u68uOALxcth+qHAPDFFfKN19QejfUDfn0 L6QMSU13bwzIrbYBsKJFjqM1OQ01k67v/XA8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xaKoq2Z5i+AH80JWe8GKSoRR6ISgaXZtO2Gfftl5H7k=; b=T9RVZ26rGw2BRo+Ls5oF+p0efMFLlYaGfrMDUXN1jiN6h37C0HySyXsbXvErGM6EWR x/WZGa1P41I4fZv+ce9Vx9/58MA79UXnM2K1324VkCEdDSwaSZ61F7pLw7g1AGTO8HLM bYYfdb2LxfltOAdHLyT3ily+6hN04VqZ0108Byfet8tNKkC4L6FA8DD7XsNvZC/bDwmF dNH3CTfgDBFEsUR5OGoS3E+L2QscXqfAm/sgvRGFAz0Wju/5AT88CDnv+9W0pNQRE0BK NZCK2y7fARwWiVEnACZnfdpVVUjXWOyarhzObh62PHS2bb9W3oJ1wZwhf83Wd7eK6pmS Gxbg== X-Gm-Message-State: ABuFfoj4/6/Ie36WXCkG+KIDksg2oF76+RT0Tt8e6mRnz7Y0q+RDMhEz pCbXwulInwEK/m6c7uXwvmmBww== X-Google-Smtp-Source: ACcGV60DSO+4ufxrVn78qtJyKBJTRYz+N5GtL2nJ+l2UzA0ZVfx8IWyPHlvtx9l7kCRbqF7xM4YsVw== X-Received: by 2002:adf:a599:: with SMTP id g25-v6mr90065wrc.88.1537866295905; Tue, 25 Sep 2018 02:04:55 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:55 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 12/14] thermal/drivers/hisi: Add more sensors channel Date: Tue, 25 Sep 2018 11:03:10 +0200 Message-Id: <1537866192-12320-13-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Add the sensor channels id for the little, g3d and modem. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index 87d8a13..ba89cb9 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -56,7 +56,12 @@ #define HI3660_TEMP_LAG (4000) #define HI6220_CLUSTER0_SENSOR 2 +#define HI6220_CLUSTER1_SENSOR 1 + +#define HI3660_LITTLE_SENSOR 0 #define HI3660_BIG_SENSOR 1 +#define HI3660_G3D_SENSOR 2 +#define HI3660_MODEM_SENSOR 3 struct hisi_thermal_data; From patchwork Tue Sep 25 09:03:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613729 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-2.web.codeaurora.org (Postfix) with ESMTP id 9CC2D112B for ; Tue, 25 Sep 2018 09:05:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E8142836F for ; Tue, 25 Sep 2018 09:05:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80E6C294E2; Tue, 25 Sep 2018 09:05:02 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 1CB5A2836F for ; Tue, 25 Sep 2018 09:05:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727550AbeIYPLc (ORCPT ); Tue, 25 Sep 2018 11:11:32 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42365 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728916AbeIYPLc (ORCPT ); Tue, 25 Sep 2018 11:11:32 -0400 Received: by mail-wr1-f66.google.com with SMTP id b11-v6so6263949wru.9 for ; Tue, 25 Sep 2018 02:04:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UxB+GfDnTMjmOE1hd6mzvwMVcjkzKsZWm7O8IKgj40I=; b=e3cGzg/5ZKmcHoe7SSPCL70kclr+7cbEHw/gHo/lBo4C03IhBJkg5X2aC0Mdt0+6LL fH20z4P33tGqwCx6Wi9oEnfmaBZyFlFxToUm1b/kL4DtGH9Y0/+fDAKuwymHCt77vfkh +M5YnvdqKhs58yE5vtzmv3U/2bqAHBgZTUQUg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UxB+GfDnTMjmOE1hd6mzvwMVcjkzKsZWm7O8IKgj40I=; b=Py7/hmhUUeDs6AeDLZ01x/M88AmX4wTI948cboYwF8rTp5FjRK0a68vQBdBT/31ULT SshLbyJz2OIYksOJqicLUqkPRtLOBt8O6AZYK0f4PI8TPVP4FdJ4CQgoQw/L/AY/wDd3 xYNLVsY6KQdiDESgmQ+wzknh/XfwakvSLdGN1YBj1nm5vHTsGB/jeLu5JtXADnI8lbPc ezypiOIRSQPAA7NdwQKaQ8m3W+FidR8KFeLLuKGKrNvvRDigIYLH96SJkYw6r+dW/VcX 3oJr29Q+ukN16BTCfKzhMlE2iq42EvIprrCVR3yEMSWkzY0PRhhOhf0U3Gn189m8ZzBF JhOw== X-Gm-Message-State: ABuFfoj7NJHh3V2PKiOOWHlMVT3j/nLfIkwyNxpOYuJQQAowVQT8mAcW FeA4N9nNa+hdDvuwsFsi/ZNUTA== X-Google-Smtp-Source: ACcGV62FS5T/3AUdXnrZKKhjtO9deCg0kBIywTFXZk8+z9UA6Oa3JWEvifWf3kQAtO/3YbZIBaKZ9Q== X-Received: by 2002:adf:a925:: with SMTP id u34-v6mr16176wrc.175.1537866298105; Tue, 25 Sep 2018 02:04:58 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:57 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Wei Xu , Rob Herring , Mark Rutland , linux-arm-kernel@lists.infradead.org (moderated list:ARM/HISILICON SOC SUPPORT), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH 13/14] ARM64: dts: hisilicon: Add dual clusters thermal zones for hi3660 Date: Tue, 25 Sep 2018 11:03:11 +0200 Message-Id: <1537866192-12320-14-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 Add a thermal zone for the little cluster, so we can handle two sensors managing each a cluster on the SoC. Signed-off-by: Daniel Lezcano --- arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 97 ++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 34 deletions(-) diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi index dd398cb..6df7d9f 100644 --- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi +++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi @@ -1090,42 +1090,71 @@ }; thermal-zones { + tz_a53: tz_a53 { + polling-delay = <1000>; + polling-delay-passive = <100>; + sustainable-power = <4500>; + + /* sensor ID */ + thermal-sensors = <&tsensor 0>; + + trips { + a53_temp_threshold: trip-point@0 { + temperature = <65000>; + hysteresis = <1000>; + type = "passive"; + }; + + a53_temp_target: trip-point@1 { + temperature = <75000>; + hysteresis = <1000>; + type = "passive"; + }; + }; - cls0: cls0 { - polling-delay = <1000>; - polling-delay-passive = <100>; - sustainable-power = <4500>; - - /* sensor ID */ - thermal-sensors = <&tsensor 1>; - - trips { - threshold: trip-point@0 { - temperature = <65000>; - hysteresis = <1000>; - type = "passive"; - }; - - target: trip-point@1 { - temperature = <75000>; - hysteresis = <1000>; - type = "passive"; - }; - }; - - cooling-maps { + cooling-maps { map0 { - trip = <&target>; - contribution = <1024>; - cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; - }; - map1 { - trip = <&target>; - contribution = <512>; - cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; - }; - }; - }; + trip = <&a53_temp_target>; + contribution = <512>; + cooling-device = <&cpu0 + THERMAL_NO_LIMIT + THERMAL_NO_LIMIT>; + }; + }; + }; + + tz_a73: tz_a73 { + polling-delay = <1000>; + polling-delay-passive = <100>; + sustainable-power = <4500>; + + /* sensor ID */ + thermal-sensors = <&tsensor 1>; + + trips { + a73_temp_threshold: trip-point@0 { + temperature = <65000>; + hysteresis = <1000>; + type = "passive"; + }; + + a73_temp_target: trip-point@1 { + temperature = <75000>; + hysteresis = <1000>; + type = "passive"; + }; + }; + + cooling-maps { + map0 { + trip = <&a73_temp_target>; + contribution = <1024>; + cooling-device = <&cpu4 + THERMAL_NO_LIMIT + THERMAL_NO_LIMIT>; + }; + }; + }; }; }; }; From patchwork Tue Sep 25 09:03:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 10613731 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-2.web.codeaurora.org (Postfix) with ESMTP id 3CF3315E8 for ; Tue, 25 Sep 2018 09:05:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F9692836F for ; Tue, 25 Sep 2018 09:05:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2336429307; Tue, 25 Sep 2018 09:05:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 C60992836F for ; Tue, 25 Sep 2018 09:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728953AbeIYPLf (ORCPT ); Tue, 25 Sep 2018 11:11:35 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43707 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728915AbeIYPLe (ORCPT ); Tue, 25 Sep 2018 11:11:34 -0400 Received: by mail-wr1-f68.google.com with SMTP id z14-v6so4966917wrs.10 for ; Tue, 25 Sep 2018 02:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2c10kVYZmaRE2YAvTe8xN2YzBOeCiX1ots/Bs3skCvA=; b=dI792yemZWGQzfz6P+lbysSZCE+Qgm0Rv/p1vw0/yIWguhd24AI/9xNBXL9QAOe8qi WmZ2mtf3GKG2j1FO+o/ZogAfHEpMC4FUXdtEOO9K5a54yUzDUgIdJ5g6rJuz2bxVn08M y9PhFzkYxxDDrDOe9lyWawRU33so4h6KCxHzs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2c10kVYZmaRE2YAvTe8xN2YzBOeCiX1ots/Bs3skCvA=; b=NSdq3h+7DLjMcjRqBeDVjsqY47xWYxj+0Lr3X7v7LqB+IS2xrmHWpIJHkKGKblR/BN usUrGXrdl69EpsWxK1TPVVdsF2Nza9+GZK1otb6GlhQgShE2EkakO3Rp8uvT2MJgYBEo qVATInpOyB/Bd3JTvwtZSLJKH+h+kCvU0EgsrVHeyv5nhTS10Bii30HY8miA6p8fDkkg Z3vUN6vJ32U2lUeqhQj2hn8oVBKr06tLF/hVFwAwMp5J3t2jw8ncXe8ZDyxxG0C3GgoH y/FDW5dN5lW0oqF7IOeHTLRoFXYa/ARY38gmQukI3sxl9tYQ6ZR9iOVW5qigeK0Jq5Fe udUA== X-Gm-Message-State: ABuFfojBkzoszhA8YjBJvc1MbzVfZkhOa5HITmCcyCwnPOCT4Ff5WFBS s8clC9HuNrH1D4PLukRkb9PRZw== X-Google-Smtp-Source: ACcGV60+/ljwuO8yKwpnFa1rZygDRXkqLMIjt5uOCwQfhX0TEWu0l/iLM3Fv9x6PKzml8z6VIhaLMA== X-Received: by 2002:a5d:5391:: with SMTP id d17-v6mr14805wrv.191.1537866300122; Tue, 25 Sep 2018 02:05:00 -0700 (PDT) Received: from localhost.localdomain (251.150.136.77.rev.sfr.net. [77.136.150.251]) by smtp.gmail.com with ESMTPSA id y206-v6sm1523828wmg.14.2018.09.25.02.04.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 02:04:59 -0700 (PDT) From: Daniel Lezcano To: edubezval@gmail.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, daniel.lezcano@linaro.org, leo.yan@linaro.org, Zhang Rui Subject: [PATCH 14/14] thermal/drivers/hisi: Add the dual clusters sensors for hi3660 Date: Tue, 25 Sep 2018 11:03:12 +0200 Message-Id: <1537866192-12320-15-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> References: <1537866192-12320-1-git-send-email-daniel.lezcano@linaro.org> 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 The code is ready to support multiple sensors on the hi3660. The DT defines a thermal zone per cluster. Add the little cluster sensor and let it bind with the thermal zone. Signed-off-by: Daniel Lezcano --- drivers/thermal/hisi_thermal.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/hisi_thermal.c b/drivers/thermal/hisi_thermal.c index ba89cb9..c4111a9 100644 --- a/drivers/thermal/hisi_thermal.c +++ b/drivers/thermal/hisi_thermal.c @@ -424,14 +424,20 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data) struct platform_device *pdev = data->pdev; struct device *dev = &pdev->dev; - data->sensor = devm_kzalloc(dev, sizeof(*data->sensor), GFP_KERNEL); + data->nr_sensors = 2; + + data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) * + data->nr_sensors, GFP_KERNEL); if (!data->sensor) return -ENOMEM; data->sensor[0].id = HI3660_BIG_SENSOR; data->sensor[0].irq_name = "tsensor_a73"; data->sensor[0].data = data; - data->nr_sensors = 1; + + data->sensor[1].id = HI3660_LITTLE_SENSOR; + data->sensor[1].irq_name = "tsensor_a53"; + data->sensor[1].data = data; return 0; } @@ -443,8 +449,8 @@ static int hisi_thermal_get_temp(void *__data, int *temp) *temp = data->ops->get_temp(sensor); - dev_dbg(&data->pdev->dev, "id=%d, temp=%d, thres=%d\n", - sensor->id, *temp, sensor->thres_temp); + dev_dbg(&data->pdev->dev, "tzd=%p, id=%d, temp=%d, thres=%d\n", + sensor->tzd, sensor->id, *temp, sensor->thres_temp); return 0; }