From patchwork Sat Feb 11 08:47:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 55759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1401946wrn; Sat, 11 Feb 2023 00:52:21 -0800 (PST) X-Google-Smtp-Source: AK7set+HW67gQPk0m+LHURAhgXitQAdt0DiYvW83Kdd4GVI+Oiy1QjKeCSfCJ6oJOAn662nzWZQ+ X-Received: by 2002:a17:902:da83:b0:196:8db5:fd67 with SMTP id j3-20020a170902da8300b001968db5fd67mr21934545plx.2.1676105540869; Sat, 11 Feb 2023 00:52:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676105540; cv=none; d=google.com; s=arc-20160816; b=bneH/lijbJpWFzB/QHbahcy7I4fJosNpBE8tTE/cQ9u9S35BoCHpypxEIvTvhuLJvB AttLqPAcjHx426CEex0Oklvl6PEiHCAdb5JqYpmdexbnniSzAw7D707FhKHCstZYhgih JHXq0vGcQAyU6DTV4acw+c2ciFSh+2bNnjW5he/rbeDYzhbhzVY1IZ4+N6OQUhzvjiHW Cf5+wa/pJ108WbzTVa80Skk3MST5xh+3qpX4vlkVvNkYMF7AKTFNF9pSiDDrweAYU5hT b723zP1Riy7D4AymCAZBSc5a2Aa8drMPHREPuP8pg+3uXZ+hfMG2M7e6kNfH6IXo/R7S nrpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KMMoPN3yx7rPxTh80p9/d8pL920KeFfOdeDGLR7XEsw=; b=s66YqTZsz60uNIObEWX0kRDMqYPHL5IbozhKMu7x+1vu9NMO8/ehv6o0aOkyb8mEDi 0BpfnxaZYmNl42d19ZtyVcip4e/qFsv74rALZ2bah6sjIR6lrxC3Weg/r+VF9u3u02LO Lr6llTVbSid3/HbjFST0qaUHr6OtuKtn8ExOs/5CZuecvyOa412YULSw//Gzh8LIG5XS fj5oyAu+qjXbkSNPYt+3K7jVO6O5D6Zv65UafHYl435J7yblXX77cZeWgMdG/XUBhIYu /rkphnxjU1UhdxsOC8IkW32CiJO5dyJW/sc5hNKzFmn3OXkXB3YMPJXZ2tCFBliC08oj EVyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=gt80nmDQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a170902834a00b0019927ca0fa0si5843802pln.280.2023.02.11.00.52.08; Sat, 11 Feb 2023 00:52:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=gt80nmDQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbjBKIr4 (ORCPT + 99 others); Sat, 11 Feb 2023 03:47:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbjBKIrx (ORCPT ); Sat, 11 Feb 2023 03:47:53 -0500 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A795FF0 for ; Sat, 11 Feb 2023 00:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=7jcF/omJnwxC/i 6JNLhKdL2UNNtPjvGVIvLcMusdQ2Q=; b=gt80nmDQsq6E8qMN6VW8xtOK5Yo3tB HXcEh63VVERc/9DFJ4Jqwt/hkSDF6zVnONQ86gi6M03FQMm27o+ol54YnWBMMNix 5yVl48aRsKSW3EWIUKr9zxdIbugS4VQnH3+ec/PlNHuXNTLBSLTrnTgLg7OioWh3 /qEasfEudw1do= Received: (qmail 2337537 invoked from network); 11 Feb 2023 09:47:30 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 11 Feb 2023 09:47:30 +0100 X-UD-Smtp-Session: l3s3148p1@qLMNqmj0CJcujntl From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yoshihiro Shimoda , Wolfram Sang , Duy Nguyen , =?utf-8?q?Niklas_S=C3=B6derlund?= , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFT 1/3] drivers/thermal/rcar_gen3_thermal: introduce 'info' structure Date: Sat, 11 Feb 2023 09:47:25 +0100 Message-Id: <20230211084728.27832-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230211084728.27832-1-wsa+renesas@sang-engineering.com> References: <20230211084728.27832-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757524043418285301?= X-GMAIL-MSGID: =?utf-8?q?1757524043418285301?= More items to describe the TSCs are needed soon, so encapsulate the current 'ths_tj_1' item into a struct. Signed-off-by: Duy Nguyen Signed-off-by: Wolfram Sang --- drivers/thermal/rcar_gen3_thermal.c | 41 ++++++++++++++++++----------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index 2bd69d613d99..bfccb91bda21 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -77,6 +77,10 @@ struct equation_coefs { int b2; }; +struct rcar_thermal_info { + int ths_tj_1; +}; + struct rcar_gen3_thermal_tsc { void __iomem *base; struct thermal_zone_device *zone; @@ -92,6 +96,7 @@ struct rcar_gen3_thermal_priv { void (*thermal_init)(struct rcar_gen3_thermal_priv *priv, struct rcar_gen3_thermal_tsc *tsc); int ptat[3]; + const struct rcar_thermal_info *info; }; static inline u32 rcar_gen3_thermal_read(struct rcar_gen3_thermal_tsc *tsc, @@ -364,52 +369,58 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_priv *priv, 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_thermal_info rcar_m3w_thermal_info = { + .ths_tj_1 = 116, +}; + +static const struct rcar_thermal_info rcar_gen3_thermal_info = { + .ths_tj_1 = 126, +}; + 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_m3w_thermal_info, }, { .compatible = "renesas,r8a774b1-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, { .compatible = "renesas,r8a774e1-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, { .compatible = "renesas,r8a7795-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, { .compatible = "renesas,r8a7796-thermal", - .data = &rcar_gen3_ths_tj_1_m3_w, + .data = &rcar_m3w_thermal_info, }, { .compatible = "renesas,r8a77961-thermal", - .data = &rcar_gen3_ths_tj_1_m3_w, + .data = &rcar_m3w_thermal_info, }, { .compatible = "renesas,r8a77965-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, { .compatible = "renesas,r8a77980-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, { .compatible = "renesas,r8a779a0-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, { .compatible = "renesas,r8a779f0-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, { .compatible = "renesas,r8a779g0-thermal", - .data = &rcar_gen3_ths_tj_1, + .data = &rcar_gen3_thermal_info, }, {}, }; @@ -464,7 +475,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; unsigned int i; @@ -479,6 +489,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) if (soc_device_match(r8a7795es1)) priv->thermal_init = rcar_gen3_thermal_init_r8a7795es1; + priv->info = of_device_get_match_data(dev); platform_set_drvdata(pdev, priv); if (rcar_gen3_thermal_request_irqs(priv, pdev)) @@ -518,7 +529,7 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev) struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; priv->thermal_init(priv, tsc); - rcar_gen3_thermal_calc_coefs(priv, tsc, *ths_tj_1); + rcar_gen3_thermal_calc_coefs(priv, tsc, priv->info->ths_tj_1); zone = devm_thermal_of_zone_register(dev, i, tsc, &priv->ops); if (IS_ERR(zone)) { From patchwork Sat Feb 11 08:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 55760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1402537wrn; Sat, 11 Feb 2023 00:54:50 -0800 (PST) X-Google-Smtp-Source: AK7set/j0Mph0F6TQWVSrqd7T3Si1ztASvfRppzPxTrDj+UtHM140WWLKTVQ8to5ATqGhaTEDW5s X-Received: by 2002:a17:902:ce83:b0:193:38ce:7bb8 with SMTP id f3-20020a170902ce8300b0019338ce7bb8mr21274749plg.37.1676105690142; Sat, 11 Feb 2023 00:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676105690; cv=none; d=google.com; s=arc-20160816; b=cgWy1Me3kTFBRoVDn6YKJd7NbrrGKs3TBglHx2Bl4cwClDZ3iG4XSpf6stFePY5wRF it/MBVU5VXwtnQ5rQ4ZsJwnXeGZa+kD42ia8PtxB7KM1B1FsIPziF4DFk3LIYWGK+G95 jgr+p0Ez13B9cvm3J9y58IHLtsughp2d9wW55vD7PMZNr76saZZ03KTVRzFMbkqnjT6u 8oJCnGMUQDXJmNWMg+l6GlyWlV8SzWJtIolYx252fVK8sIqo70a13Xv3H16cmKoB0xhp He8KibJpptPyf3DZdSuXQzcqqVSYhObv3NGgz4O8JDporNonvuw9mu/gZoEqf7TUtArJ P1Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jq+4qyZgjn7Ux2ZPfRgOnvin67k5jNYNMyXMT0aIWkM=; b=07EcajcPbVv0tdJBakmLR/Trwdh+nIwhBmAGMgrYuH63yFwkSKq8nljeyv4+iDdxvK Xctq1H/j3fFbvRPDBGsjpT0kuMVpC3KekpeyTcYwYDbPhjRbU/W6Fn/JRDJpD1gGYSmL Hp9oUr3h/uIfRvhGmF0Gdn5WlEkwQPMSnPUvVeUlNboNiTPfCrVHfINA/l1ZGnnedkhX NrMat9lfOWnSYax3UVjG2fLZBBoq8u6XjLb03lfp5oecbQyjRJcvnp3zBXmaGyVgSOok VawuTwE/qCkQuGXD3nTBNahvPgl5Zi4vpzj/u2H1ueZCeS8F1P0ZT9kkGj0TwJmWXGtW Dzaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=MZZ588Sp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a170902c44c00b001948e6ba8f3si1327145plm.315.2023.02.11.00.54.37; Sat, 11 Feb 2023 00:54:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=MZZ588Sp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbjBKIsA (ORCPT + 99 others); Sat, 11 Feb 2023 03:48:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjBKIrx (ORCPT ); Sat, 11 Feb 2023 03:47:53 -0500 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BC531ABCA for ; Sat, 11 Feb 2023 00:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=/YjnQpFhErZubY 7S1AQiEv/HeNJShkh37dU+bd91wQU=; b=MZZ588SppR9zVxOnE+9kGXUuely904 8JczVC5OO785aSQ+EGpgAFgv9/dejLLl3oReVhDgA96y87RYE8zrum4LQolkBaAA 8Vwrz5uxV1y8uq5Gs1SqmYtwYa8oXVG+r+fFwHujy0JQ+9f+CoxJB4OlNb6MUL3m 7GROMyPGH0tOQ= Received: (qmail 2337587 invoked from network); 11 Feb 2023 09:47:31 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 11 Feb 2023 09:47:31 +0100 X-UD-Smtp-Session: l3s3148p1@TTIYqmj0Dpcujntl From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yoshihiro Shimoda , Wolfram Sang , =?utf-8?q?Niklas_S=C3=B6de?= =?utf-8?q?rlund?= , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFT 2/3] drivers/thermal/rcar_gen3_thermal: refactor reading fuses into seprarate function Date: Sat, 11 Feb 2023 09:47:26 +0100 Message-Id: <20230211084728.27832-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230211084728.27832-1-wsa+renesas@sang-engineering.com> References: <20230211084728.27832-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757524200328608167?= X-GMAIL-MSGID: =?utf-8?q?1757524200328608167?= Gen4 will be very different, so refactor Gen3 access into separate call first. Signed-off-by: Wolfram Sang --- drivers/thermal/rcar_gen3_thermal.c | 60 +++++++++++++++++------------ 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index bfccb91bda21..c88ca7e04710 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -77,8 +77,11 @@ struct equation_coefs { int b2; }; +struct rcar_gen3_thermal_priv; + struct rcar_thermal_info { int ths_tj_1; + void (*read_fuses)(struct rcar_gen3_thermal_priv *priv); }; struct rcar_gen3_thermal_tsc { @@ -259,6 +262,34 @@ static const struct soc_device_attribute r8a7795es1[] = { { /* sentinel */ } }; +static void rcar_gen3_thermal_read_fuses_gen3(struct rcar_gen3_thermal_priv *priv) +{ + unsigned int i; + + /* + * Set the pseudo calibration points with fused values. + * PTAT is shared between all TSCs but only fused for the first + * TSC while THCODEs are fused for each TSC. + */ + priv->ptat[0] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT1) & + GEN3_FUSE_MASK; + priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT2) & + GEN3_FUSE_MASK; + priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT3) & + GEN3_FUSE_MASK; + + for (i = 0; i < priv->num_tscs; i++) { + struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; + + tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE1) & + GEN3_FUSE_MASK; + tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE2) & + GEN3_FUSE_MASK; + tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE3) & + GEN3_FUSE_MASK; + } +} + static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) { unsigned int i; @@ -266,7 +297,8 @@ static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) /* If fuses are not set, fallback to pseudo values. */ thscp = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_THSCP); - if ((thscp & THSCP_COR_PARA_VLD) != THSCP_COR_PARA_VLD) { + if (!priv->info->read_fuses || + (thscp & THSCP_COR_PARA_VLD) != THSCP_COR_PARA_VLD) { /* Default THCODE values in case FUSEs are not set. */ static const int thcodes[TSC_MAX_NUM][3] = { { 3397, 2800, 2221 }, @@ -291,29 +323,7 @@ static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) return false; } - /* - * Set the pseudo calibration points with fused values. - * PTAT is shared between all TSCs but only fused for the first - * TSC while THCODEs are fused for each TSC. - */ - priv->ptat[0] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT1) & - GEN3_FUSE_MASK; - priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT2) & - GEN3_FUSE_MASK; - priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN3_PTAT3) & - GEN3_FUSE_MASK; - - for (i = 0; i < priv->num_tscs; i++) { - struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; - - tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE1) & - GEN3_FUSE_MASK; - tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE2) & - GEN3_FUSE_MASK; - tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN3_THCODE3) & - GEN3_FUSE_MASK; - } - + priv->info->read_fuses(priv); return true; } @@ -371,10 +381,12 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_priv *priv, static const struct rcar_thermal_info rcar_m3w_thermal_info = { .ths_tj_1 = 116, + .read_fuses = rcar_gen3_thermal_read_fuses_gen3, }; static const struct rcar_thermal_info rcar_gen3_thermal_info = { .ths_tj_1 = 126, + .read_fuses = rcar_gen3_thermal_read_fuses_gen3, }; static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { From patchwork Sat Feb 11 08:47:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 55761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1402687wrn; Sat, 11 Feb 2023 00:55:32 -0800 (PST) X-Google-Smtp-Source: AK7set/JAMWsJQPlyt5u5N4BBJDp0GwiHSoT/3HtXAROOWz5EYFFQj1rZpuGIFuw6v3deDHNptL6 X-Received: by 2002:a17:902:cec4:b0:19a:839d:b682 with SMTP id d4-20020a170902cec400b0019a839db682mr1977800plg.17.1676105732170; Sat, 11 Feb 2023 00:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676105732; cv=none; d=google.com; s=arc-20160816; b=VGg9Al1rYvccWbBediBBfUwF37pTi3JwsxHaPoYI3c/uQjhWb74hRxBNP9qpt/naIg Ir6jHo0KUQKOP5KrIMVni0sy4vlng+YWgTYgOqZV6kp06dM+Uacp+xWnZ7pKtuEjjZbo jW9EtUpd/mGh3H2cCGkMT1WpfUjNEIIABmpLhY3oAXh5GzZvvIh48JpVsZZ1o2fHHBKd opjsygXIAqVjoHCWQiec3w3UUxadKrryCP5H9t17cwK6KVf9PWg2x+sNodwZaqyzrQVp twR8ZhqlszAiQP0I8HSwdAKCB6AQ3BOG5+mZaEMmrOzqQ9W27bDPPOXLgDBWS3OM+Ode NQig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Nt3FQecHcSKUmSfGSDqmY2T66GGHG2+jaSWlhtGcIqM=; b=08BW1xbLfX2J3KGD/kJgImLOh5JLH35tI5pCXkiFoWQoadLgtw9StvqsR6H07Dcufn qfFIMOWV/1LPiwXFexabXuwjYZYgY+eeO3kpMyblLhvAcn1pTde7JLws8jZIMvkOCexK mLpg1wF5gGLNjsvoGQHX3EckKMYb7lUAxXmfvmCMn6wQBUXqeBNe5ujhJehi4DRSqZeB 8pf+myCvA5QR3xY2oIc2X2wTVyN2zu5vwSaIKVXZ31GfmLb0HHEdthtUzDUgJ3kz+hy9 GpjmbRROxnvBaf9iA57fhPRaYhxc/ck55THM43LFol6FTLc0GOANmuNOdhWGxfoh0D7m mTBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=zW5Mo8ae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a170902834a00b0019927ca0fa0si5843802pln.280.2023.02.11.00.55.19; Sat, 11 Feb 2023 00:55:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=zW5Mo8ae; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229875AbjBKIsD (ORCPT + 99 others); Sat, 11 Feb 2023 03:48:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229795AbjBKIrx (ORCPT ); Sat, 11 Feb 2023 03:47:53 -0500 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35D8E1ABD2 for ; Sat, 11 Feb 2023 00:47:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=Jx7o8QihIEH+So U0qPHGJo9go5TwIrNL7ms7y9pC4hg=; b=zW5Mo8ae/jQ3krkTnEBpbIonlYgV7A KyDFk2YiGK5VZ4okIRcV8f/3GB+wqrBwJwFfb9HlLssDjEw+P/XNfnL2n3nY4dIi 4A7OpTLptFJ3vP+jHUHwBBgdvAssuk0dAgqgDHxdPHOuTM3GdMkN0q8qOuH0DpBx AcctyjT6I+uYE= Received: (qmail 2337650 invoked from network); 11 Feb 2023 09:47:31 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 11 Feb 2023 09:47:31 +0100 X-UD-Smtp-Session: l3s3148p1@zxwiqmj0Fpcujntl From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: Yoshihiro Shimoda , Wolfram Sang , Duy Nguyen , =?utf-8?q?Niklas_S=C3=B6derlund?= , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFT 3/3] drivers/thermal/rcar_gen3_thermal: add reading fuses for Gen4 Date: Sat, 11 Feb 2023 09:47:27 +0100 Message-Id: <20230211084728.27832-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230211084728.27832-1-wsa+renesas@sang-engineering.com> References: <20230211084728.27832-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757524244577088381?= X-GMAIL-MSGID: =?utf-8?q?1757524244577088381?= The registers are differently named and at different offsets, but their functionality is the same as for Gen3. Signed-off-by: Duy Nguyen Signed-off-by: Wolfram Sang --- drivers/thermal/rcar_gen3_thermal.c | 44 +++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c index c88ca7e04710..8a02b3d2f8b1 100644 --- a/drivers/thermal/rcar_gen3_thermal.c +++ b/drivers/thermal/rcar_gen3_thermal.c @@ -38,6 +38,12 @@ #define REG_GEN3_PTAT2 0x60 #define REG_GEN3_PTAT3 0x64 #define REG_GEN3_THSCP 0x68 +#define REG_GEN4_THSFMON00 0x180 +#define REG_GEN4_THSFMON01 0x184 +#define REG_GEN4_THSFMON02 0x188 +#define REG_GEN4_THSFMON15 0x1BC +#define REG_GEN4_THSFMON16 0x1C0 +#define REG_GEN4_THSFMON17 0x1C4 /* IRQ{STR,MSK,EN} bits */ #define IRQ_TEMP1 BIT(0) @@ -66,6 +72,7 @@ #define MCELSIUS(temp) ((temp) * 1000) #define GEN3_FUSE_MASK 0xFFF +#define GEN4_FUSE_MASK 0xFFF #define TSC_MAX_NUM 5 @@ -290,6 +297,34 @@ static void rcar_gen3_thermal_read_fuses_gen3(struct rcar_gen3_thermal_priv *pri } } +static void rcar_gen3_thermal_read_fuses_gen4(struct rcar_gen3_thermal_priv *priv) +{ + unsigned int i; + + /* + * Set the pseudo calibration points with fused values. + * PTAT is shared between all TSCs but only fused for the first + * TSC while THCODEs are fused for each TSC. + */ + priv->ptat[0] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON01) & + GEN4_FUSE_MASK; + priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON02) & + GEN4_FUSE_MASK; + priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON00) & + GEN4_FUSE_MASK; + + for (i = 0; i < priv->num_tscs; i++) { + struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; + + tsc->thcode[0] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON16) & + GEN4_FUSE_MASK; + tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON17) & + GEN4_FUSE_MASK; + tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON15) & + GEN4_FUSE_MASK; + } +} + static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv) { unsigned int i; @@ -389,6 +424,11 @@ static const struct rcar_thermal_info rcar_gen3_thermal_info = { .read_fuses = rcar_gen3_thermal_read_fuses_gen3, }; +static const struct rcar_thermal_info rcar_gen4_thermal_info = { + .ths_tj_1 = 126, + .read_fuses = rcar_gen3_thermal_read_fuses_gen4, +}; + static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { { .compatible = "renesas,r8a774a1-thermal", @@ -428,11 +468,11 @@ static const struct of_device_id rcar_gen3_thermal_dt_ids[] = { }, { .compatible = "renesas,r8a779f0-thermal", - .data = &rcar_gen3_thermal_info, + .data = &rcar_gen4_thermal_info, }, { .compatible = "renesas,r8a779g0-thermal", - .data = &rcar_gen3_thermal_info, + .data = &rcar_gen4_thermal_info, }, {}, };