From patchwork Wed Jul 7 13:13:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 12362557 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C52FC07E9B for ; Wed, 7 Jul 2021 13:13:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 633C26199E for ; Wed, 7 Jul 2021 13:13:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231575AbhGGNQY (ORCPT ); Wed, 7 Jul 2021 09:16:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbhGGNQX (ORCPT ); Wed, 7 Jul 2021 09:16:23 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20DFDC061760 for ; Wed, 7 Jul 2021 06:13:42 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id q17so3025738wrv.2 for ; Wed, 07 Jul 2021 06:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Z/t4CGD6lK/wI3C8RkHXXrZaiSgvDd9+19bQ4kCEFaU=; b=RADpEqNaVLlpROdv1XXCYl2UPFMcx1pM6fbmXGmH+gKqX+9n9pUAgw2G16blT2kcIS ETYb0GOrTGPtISo9U0s8HeDHgHf51VIc/oJlXZ5idYdbWpQ58L/X4ccgm1mxD3sP+pc8 3LscWHNBHdA3OF3K0HgEyEOfU+5PnHOrJc7rHIhquJw/t9R2kG6H9EMJES55ElWwxwc7 dRYBUj0MiUPWXPbH2nfu9WwAZqKSUekTrK/jIGC27H+15YbPYnMqSVQA6TU18NZeiM74 5Rkr46OpspsGC+APoo87gar0TDzQvEXyRD8htfYp5VXOih8i1y8GoTCPuxf4hB1p3ze3 d2hg== 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:mime-version:content-transfer-encoding; bh=Z/t4CGD6lK/wI3C8RkHXXrZaiSgvDd9+19bQ4kCEFaU=; b=nswApt//1w6NWFenZ45twWfmFI7CHC5lBK/yrBD2Q5NQd/TjThp7Y1LF+9zjQ+QcqF /CR+yWB1ebDds0mxyXNNGUeSPzn+/0W2MYP8CHMChf8IOT1Mpeqsr9mRT+YwJuiL8F8O nwYKpPw3/k2f8pqcQtVPMnShDgM++wYuaQWv+B6Juqf8gYhlmQbMLuEtFxVI7zpT7TDi BTaJTdup5LHiqpCVygkmcyZG1mCAHTLG0iiXE1yhqtNUKoBBHpWJhpE7HMov4zOEAwb7 jp1Z7pVoa1KtR7wGnV/+GuA+P+7rJzhwNItmeBg7JDiKRjsbtFACUt/j7dJD/TSo+qCv RP0w== X-Gm-Message-State: AOAM530kkpdWiVwC5m6Q2zRRuvbhQg6RTz8Gdq5uwfJvFZmMmn2yQkIX GwxZLrHe5lUZ1+OOy8sC343N9GGsOvD1wg== X-Google-Smtp-Source: ABdhPJydMuikwObnVEYluJdDMfadZYhP/Slwd47Db8z14t/7v79rjFofEaclJbDU+LAWDrfa4J/TEw== X-Received: by 2002:adf:ce84:: with SMTP id r4mr15207462wrn.397.1625663620725; Wed, 07 Jul 2021 06:13:40 -0700 (PDT) Received: from bismarck.berto.se (p4fca2710.dip0.t-ipconnect.de. [79.202.39.16]) by smtp.googlemail.com with ESMTPSA id l20sm19233670wmq.3.2021.07.07.06.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 06:13:40 -0700 (PDT) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Daniel Lezcano , linux-pm@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 1/3] thermal: rcar_gen3_thermal: Create struct for OF match data Date: Wed, 7 Jul 2021 15:13:04 +0200 Message-Id: <20210707131306.4098443-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210707131306.4098443-1-niklas.soderlund+renesas@ragnatech.se> References: <20210707131306.4098443-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Prepare for storing more information in the OF match data by using a struct instead of a single integer value. There is no functional change. Signed-off-by: Niklas Söderlund Reviewed-by: Geert Uytterhoeven --- drivers/thermal/rcar_gen3_thermal.c | 39 +++++++++++++++++++---------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index fdf16aa34eb470c7..770f1daae5379053 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -79,6 +79,10 @@ struct equation_coefs { int b2; }; +struct rcar_gen3_thermal_info { + int ths_tj_1; +}; + struct rcar_gen3_thermal_tsc { void __iomem *base; struct thermal_zone_device *zone; @@ -88,6 +92,7 @@ struct rcar_gen3_thermal_tsc { }; struct rcar_gen3_thermal_priv { + const struct rcar_gen3_thermal_info *info; struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; unsigned int num_tscs; void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc); @@ -243,44 +248,50 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) usleep_range(1000, 2000); } -static const int rcar_gen3_ths_tj_1 = 126; -static const int rcar_gen3_ths_tj_1_m3_w = 116; +static const struct rcar_gen3_thermal_info rcar_gen3_thermal_gen3 = { + .ths_tj_1 = 126, +}; + +static const struct rcar_gen3_thermal_info rcar_gen3_thermal_m3w = { + .ths_tj_1 = 116, +}; + static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { { .compatible = "renesas,r8a774a1-thermal", - .data = &rcar_gen3_ths_tj_1_m3_w, + .data = &rcar_gen3_thermal_m3w, }, { .compatible = "renesas,r8a774b1-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_gen3, }, { .compatible = "renesas,r8a774e1-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_gen3, }, { .compatible = "renesas,r8a7795-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_gen3, }, { .compatible = "renesas,r8a7796-thermal", - .data = &rcar_gen3_ths_tj_1_m3_w, + .data = &rcar_gen3_thermal_m3w, }, { .compatible = "renesas,r8a77961-thermal", - .data = &rcar_gen3_ths_tj_1_m3_w, + .data = &rcar_gen3_thermal_m3w, }, { .compatible = "renesas,r8a77965-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_gen3, }, { .compatible = "renesas,r8a77980-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_gen3, }, { .compatible = "renesas,r8a779a0-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_gen3, }, {}, }; @@ -307,7 +318,6 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) { struct rcar_gen3_thermal_priv *priv; struct device *dev = &pdev->dev; - const int *ths_tj_1 = of_device_get_match_data(dev); struct resource *res; struct thermal_zone_device *zone; int ret, i; @@ -320,6 +330,8 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + priv->info = of_device_get_match_data(dev); + priv->thermal_init = rcar_gen3_thermal_init; if (soc_device_match(r8a7795es1)) priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1; @@ -352,7 +364,8 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) priv->tscs[i] = tsc; priv->thermal_init(tsc); - rcar_gen3_thermal_calc_coefs(tsc, ptat, thcodes[i], *ths_tj_1); + rcar_gen3_thermal_calc_coefs(tsc, ptat, thcodes[i], + priv->info->ths_tj_1); zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, &rcar_gen3_tz_of_ops); From patchwork Wed Jul 7 13:13:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 12362559 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CC39C07E9C for ; Wed, 7 Jul 2021 13:13:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 153CF61A2B for ; Wed, 7 Jul 2021 13:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbhGGNQ2 (ORCPT ); Wed, 7 Jul 2021 09:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbhGGNQY (ORCPT ); Wed, 7 Jul 2021 09:16:24 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD860C061765 for ; Wed, 7 Jul 2021 06:13:43 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id j34so1810686wms.5 for ; Wed, 07 Jul 2021 06:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b+ppEpbWRmkGcXeCKQo2IL+aAX51yIlSVHR4b05C1K8=; b=qrkDi2z0KEFxwHixTE+5hcregz3SPAnVZlVlM2tCjltIMgPE289xWale/Yqzzn+aOF Bofy/ZyU9GTmOTDJoD78VFztGTV3BERwWaa/xMb7M9AYEqM4/Ht+DPHuT9suC5nnDw/b qjvaTEAV+B3t7KeAeimR2ecMAm4H3cpaClnAn+7T3QBxLI67OIfxhEsVzqrMH13wh2oz W+1IDVsXGIdP1pLwCeHVUo4fl9BVDClCKUr5ReQYcA5hLSFY3DIhWDRvnT5uOBacTykK a2pJNtE2j5WlKYARgfXLOTEYp9X1XcZh5pos7xsdY1HaOPmLcHsun07d74KBlUrxvU0O lY+Q== 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:mime-version:content-transfer-encoding; bh=b+ppEpbWRmkGcXeCKQo2IL+aAX51yIlSVHR4b05C1K8=; b=EzSZgvXP0YBgcDp7Hm1tYUQSZa41bDhRogEtndZq4GfvQ7wu36zrckbNzTmErQc22+ 7g3ong3PVSzaAJFKp9JhuLy5Gh2oh/1nD53kg4fIfbezA2Rd9cc4DKIiofNdU8TSwGI4 5L4RpwvvNPPgVbSk5RezKunvtvdx1POt2uwj46r42sTfbQi9srev8OaD07czjmTPb2Km gYQRJjtRDRiFa1ez25sFEzldf5oJvfC21obhaAysTpfBkhwHMuJ2jBSmzZQEfLe1Br8U OCzn0f7PTMX64Rau9W99cUob1rgDlbhJCwG552ZYRiBXg8UsvI+6azsBAyqgdcbh/Sl9 dO8A== X-Gm-Message-State: AOAM531TOOcnpHFMw2ItfNvJqvdFQ2rb13QLmysqTL1dqx/DsMJeVFBU KSd1A4RGCUtzn4yD07lmzZYyNg== X-Google-Smtp-Source: ABdhPJzQfcK5I06QTwGrVPF8P+x3RVJWCIybxr92Wgi8gv3cliCqh0fHDSdOQV8WvXWNa8kE08eiJQ== X-Received: by 2002:a1c:f414:: with SMTP id z20mr6954905wma.94.1625663621379; Wed, 07 Jul 2021 06:13:41 -0700 (PDT) Received: from bismarck.berto.se (p4fca2710.dip0.t-ipconnect.de. [79.202.39.16]) by smtp.googlemail.com with ESMTPSA id l20sm19233670wmq.3.2021.07.07.06.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 06:13:41 -0700 (PDT) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Daniel Lezcano , linux-pm@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 2/3] thermal: rcar_gen3_thermal: Add support for hardware trip points Date: Wed, 7 Jul 2021 15:13:05 +0200 Message-Id: <20210707131306.4098443-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210707131306.4098443-1-niklas.soderlund+renesas@ragnatech.se> References: <20210707131306.4098443-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org All supported hardware except V3U is capable of generating interrupts to the CPU when the temperature go below or above a set value. Use this to implement support for the set_trip() feature of the thermal core on supported hardware. The V3U have its interrupts routed to the ECM module and therefore can not be used to implement set_trip() as the driver can't be made aware of when the interrupt triggers. Each TSC is capable of tracking up-to three different temperatures while only two are needed to implement the tracking of the thermal window. Signed-off-by: Niklas Söderlund --- drivers/thermal/rcar_gen3_thermal.c | 130 ++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 770f1daae5379053..a438e05e7ca7f20e 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -81,6 +81,7 @@ struct equation_coefs { struct rcar_gen3_thermal_info { int ths_tj_1; + bool have_irq; }; struct rcar_gen3_thermal_tsc { @@ -95,7 +96,8 @@ struct rcar_gen3_thermal_priv { const struct rcar_gen3_thermal_info *info; struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM]; unsigned int num_tscs; - void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc); + void (*thermal_init)(struct rcar_gen3_thermal_priv *priv, + struct rcar_gen3_thermal_tsc *tsc); }; static inline u32 rcar_gen3_thermal_read(struct rcar_gen3_thermal_tsc *tsc, @@ -195,16 +197,75 @@ static int rcar_gen3_thermal_get_temp(void *devdata, int *temp) return 0; } +static int rcar_gen3_thermal_mcelsius_to_temp(struct rcar_gen3_thermal_tsc *tsc, + int mcelsius) +{ + int celsius, val; + + celsius = DIV_ROUND_CLOSEST(mcelsius, 1000); + if (celsius <= INT_FIXPT(tsc->tj_t)) + val = celsius * tsc->coef.a1 + tsc->coef.b1; + else + val = celsius * tsc->coef.a2 + tsc->coef.b2; + + return INT_FIXPT(val); +} + +static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high) +{ + struct rcar_gen3_thermal_tsc *tsc = devdata; + u32 irqmsk = 0; + + if (low != -INT_MAX) { + irqmsk |= IRQ_TEMPD1; + rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP1, + rcar_gen3_thermal_mcelsius_to_temp(tsc, low)); + } + + if (high != INT_MAX) { + irqmsk |= IRQ_TEMP2; + rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP2, + rcar_gen3_thermal_mcelsius_to_temp(tsc, high)); + } + + rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, irqmsk); + + return 0; +} + static const struct thermal_zone_of_device_ops rcar_gen3_tz_of_ops = { .get_temp = rcar_gen3_thermal_get_temp, + .set_trips = rcar_gen3_thermal_set_trips, }; +static const struct thermal_zone_of_device_ops rcar_gen3_tz_of_ops_no_irq = { + .get_temp = rcar_gen3_thermal_get_temp, +}; + +static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data) +{ + struct rcar_gen3_thermal_priv *priv = data; + unsigned int i; + u32 status; + + for (i = 0; i < priv->num_tscs; i++) { + status = rcar_gen3_thermal_read(priv->tscs[i], REG_GEN3_IRQSTR); + rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_IRQSTR, 0); + if (status) + thermal_zone_device_update(priv->tscs[i]->zone, + THERMAL_EVENT_UNSPECIFIED); + } + + return IRQ_HANDLED; +} + static const struct soc_device_attribute r8a7795es1[] = { { .soc_id = "r8a7795", .revision = "ES1.*" }, { /* sentinel */ } }; -static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc) +static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_priv *priv, + struct rcar_gen3_thermal_tsc *tsc) { rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR); rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0); @@ -215,6 +276,9 @@ static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F); rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); + if (priv->info->have_irq) + rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, + IRQ_TEMPD1 | IRQ_TEMP2); rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN); @@ -228,7 +292,8 @@ static void rcar_gen3_thermal_init_r8a7795es1(struct rcar_gen3_thermal_tsc *tsc) usleep_range(1000, 2000); } -static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) +static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_priv *priv, + struct rcar_gen3_thermal_tsc *tsc) { u32 reg_val; @@ -240,6 +305,9 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0); rcar_gen3_thermal_write(tsc, REG_GEN3_IRQMSK, 0); + if (priv->info->have_irq) + rcar_gen3_thermal_write(tsc, REG_GEN3_IRQEN, + IRQ_TEMPD1 | IRQ_TEMP2); reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR); reg_val |= THCTR_THSST; @@ -250,10 +318,16 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc) static const struct rcar_gen3_thermal_info rcar_gen3_thermal_gen3 = { .ths_tj_1 = 126, + .have_irq = true, }; static const struct rcar_gen3_thermal_info rcar_gen3_thermal_m3w = { .ths_tj_1 = 116, + .have_irq = true, +}; + +static const struct rcar_gen3_thermal_info rcar_gen3_thermal_v3u = { + .ths_tj_1 = 126, }; static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { @@ -291,7 +365,7 @@ static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { }, { .compatible = "renesas,r8a779a0-thermal", - .data = &rcar_gen3_thermal_gen3, + .data = &rcar_gen3_thermal_v3u, }, {}, }; @@ -314,8 +388,37 @@ static void rcar_gen3_hwmon_action(void *data) thermal_remove_hwmon_sysfs(zone); } +static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv, + struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + unsigned int i; + char *irqname; + int ret, irq; + + for (i = 0; i < 2; i++) { + irq = platform_get_irq(pdev, i); + if (irq < 0) + return irq; + + irqname = devm_kasprintf(dev, GFP_KERNEL, "%s:ch%d", + dev_name(dev), i); + if (!irqname) + return -ENOMEM; + + ret = devm_request_threaded_irq(dev, irq, NULL, + rcar_gen3_thermal_irq, + IRQF_ONESHOT, irqname, priv); + if (ret) + return ret; + } + + return 0; +} + static int rcar_gen3_thermal_probe(struct platform_device *pdev) { + const struct thermal_zone_of_device_ops *tz_of_ops; struct rcar_gen3_thermal_priv *priv; struct device *dev = &pdev->dev; struct resource *res; @@ -338,6 +441,15 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); + tz_of_ops = &rcar_gen3_tz_of_ops_no_irq; + if (priv->info->have_irq) { + ret = rcar_gen3_thermal_request_irqs(priv, pdev); + if (ret) + return ret; + + tz_of_ops = &rcar_gen3_tz_of_ops; + } + pm_runtime_enable(dev); pm_runtime_get_sync(dev); @@ -363,12 +475,12 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) priv->tscs[i] = tsc; - priv->thermal_init(tsc); + priv->thermal_init(priv, tsc); rcar_gen3_thermal_calc_coefs(tsc, ptat, thcodes[i], priv->info->ths_tj_1); zone = devm_thermal_zone_of_sensor_register(dev, i, tsc, - &rcar_gen3_tz_of_ops); + tz_of_ops); if (IS_ERR(zone)) { dev_err(dev, "Can't register thermal zone\n"); ret = PTR_ERR(zone); @@ -414,8 +526,12 @@ static int __maybe_unused rcar_gen3_thermal_resume(struct device *dev) for (i = 0; i < priv->num_tscs; i++) { struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; + struct thermal_zone_device *zone = tsc->zone; - priv->thermal_init(tsc); + priv->thermal_init(priv, tsc); + if (priv->info->have_irq) + rcar_gen3_thermal_set_trips(tsc, zone->prev_low_trip, + zone->prev_high_trip); } return 0; From patchwork Wed Jul 7 13:13:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 12362561 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5134C07E95 for ; Wed, 7 Jul 2021 13:13:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B57661A2B for ; Wed, 7 Jul 2021 13:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbhGGNQ2 (ORCPT ); Wed, 7 Jul 2021 09:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbhGGNQY (ORCPT ); Wed, 7 Jul 2021 09:16:24 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E086C061764 for ; Wed, 7 Jul 2021 06:13:43 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id u8so2992307wrq.8 for ; Wed, 07 Jul 2021 06:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h+AugMQI9wEQJZOdDBg6Ny4letwAdD9I7PJCkMpNv4o=; b=pefpTcaYn4Nfe7B5MTQmCN1CJH5GS2ZQQJEJpWwaYrdA258XI8yOS0Jn7HPrSxMTdL FtOJbxGSRDTaMTdb1cJKx1ydl6cvODQsUFYW60n8FDL5iCFVw7eFJDOwQLxl0s/rP/+K viHa26MESqX9mbAu60CLuQ75R1xZ5xz7J4go85vd0UNfRnZNhb2HpmfCV/sVgA+U+YIt VOHd3ehtKj/t5OiAADE5nceovLRIk+5M2yDaFKNdpYCbTcmFg4kfSjMs+M4ac99qdgOT urDawe7yYz6y+7DzGwwNbp9rOKLhH2LtI9KOlvfX0yS47RlzEMrhKOiRM1R6NQWcQYt2 zjuw== 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:mime-version:content-transfer-encoding; bh=h+AugMQI9wEQJZOdDBg6Ny4letwAdD9I7PJCkMpNv4o=; b=WLW5SujSK6vt28e0w1wuITv8bqT9bRknf5I09oj82mwamQ1OqYmuutRG0wAq9IGrRV NT7faK40sjhwbp3F44J7qj8VPkzdDyFuqX+aOqogbwOqlgCbk9KBTFZ7oFzAald8j//E YgYJQE7QoS4khRzJaPhRf5FYVXYZUhTS34o7EFGez1GGkOxCnR4UCkC3I8+oykEm8Z4B Z7lSVuzsqVWBxo+ODB1gRlx2lYeBzZ7En97ECyLjD0mzZX+PgSq9hh1pr+UOr8tGvH1S b/adCI9tZqQytlM8PWiDx0YajT7TUAR3VkvAkz0so4ebEa22BYK34wwTR4K3idJE6Nd9 HR4Q== X-Gm-Message-State: AOAM533Qwnp6MvneeF/oZhd1YVcoE3gWdm9TQpIFhNpiWY/lze6OJzzk oVo3MEqE1yo/ZU+PFio2QMYKVg== X-Google-Smtp-Source: ABdhPJzMkC9Mt8OgsxeFtKkKFT+EZttdMm3T3q/B0gsgzmUtD609Ly+wXMVcIQfqj131ccQIgXwSPA== X-Received: by 2002:adf:fa4c:: with SMTP id y12mr28402844wrr.302.1625663622019; Wed, 07 Jul 2021 06:13:42 -0700 (PDT) Received: from bismarck.berto.se (p4fca2710.dip0.t-ipconnect.de. [79.202.39.16]) by smtp.googlemail.com with ESMTPSA id l20sm19233670wmq.3.2021.07.07.06.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 06:13:41 -0700 (PDT) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: Daniel Lezcano , linux-pm@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 3/3] thermal: rcar_gen3_thermal: Fix datatype for loop counter Date: Wed, 7 Jul 2021 15:13:06 +0200 Message-Id: <20210707131306.4098443-4-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210707131306.4098443-1-niklas.soderlund+renesas@ragnatech.se> References: <20210707131306.4098443-1-niklas.soderlund+renesas@ragnatech.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org The loop counter 'i' should be unsigned int to match struct rcar_gen3_thermal_priv num_tscs where it's stored. Signed-off-by: Niklas Söderlund --- drivers/thermal/rcar_gen3_thermal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index a438e05e7ca7f20e..8ca4bfee7bca4122 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -423,7 +423,8 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *res; struct thermal_zone_device *zone; - int ret, i; + unsigned int i; + int ret; /* default values if FUSEs are missing */ /* TODO: Read values from hardware on supported platforms */