From patchwork Wed Nov 20 12:03:35 2024 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: 13881095 X-Patchwork-Delegate: geert@linux-m68k.org Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACAF417BB2E; Wed, 20 Nov 2024 12:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732104248; cv=none; b=A+wfs5G2dabtJdOJWLPXQrJoJ4bbrqO49WTS/SnPhz7JHSOzV3X7EbQw3NJwVESxLnFKGCEYXWJQCemv9jPw5QCQ2QKjD+N+HzkRIHffb2RVh5EfF/8VVqw1QTzeNUYv8T/jBFn3Df+eyvuaQRLOtVbN+eqzCvlIPVh1SEoIlX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732104248; c=relaxed/simple; bh=i2CBklWPXlJ3JbhxuVqap6XIRKIU1MG1yfP7QRnWXeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JgrsxoR/kIc5BGwNITixlfe2cBgCr3dfqIjP4lNm4cK1s4z/noWrHtydVY3KnBOSC4jTssvAkwUPxY7NyHtF4hD2p/f1EgardWIHL0lYiYo5/FNzU4U4Fheqq6wBZU43H9CsuEKRq8Nh9Ct2jWsoFIEdTaaAgN0M4pVhthnU9KQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=mf+f3LE5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QVEDTfIh; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="mf+f3LE5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QVEDTfIh" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id 9F2CD1380140; Wed, 20 Nov 2024 07:04:05 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-11.internal (MEProxy); Wed, 20 Nov 2024 07:04:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1732104245; x=1732190645; bh=9TipcHQ7iM6nQRgz7dpD1Gjx1n7NzOrPEylSULkgCdU=; b= mf+f3LE57lA4JIbxZQ9uEd7oVqIBsc3rRzrkIOYQW1QoFvtyUOuIM33wSxp4fYsi QdhzIyea+G5aQ0U3AZXDvkPNJoiKkKrdQXtZkj13Ktrc1QVOq5Zu3rGJWMwjICCO x9Il1QqLlLJ5nhAVhFpr/gDGDbFbu2+YvSpSwg/DRpc0UDQNu5aHbfVTta5pBa8o VUr5Tc9B3qKWbwaVOl3wucSokxeV3MBvsywOxBnTLjIEfRVKJ4aJJ5Wtt0bHqPXW +QY2RV6QPrTJTSMA40TM6gB+Kb0lxSqgbq/EWN2pt1OcJSOQK6uD0kfesXsRp18O JSdg5GxGS7S2bCVYZrHU2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1732104245; x= 1732190645; bh=9TipcHQ7iM6nQRgz7dpD1Gjx1n7NzOrPEylSULkgCdU=; b=Q VEDTfIhdT2So2KlmS+hqdHYpdIpBGtxwgu5xE25tkB3nUHHyQpn8w8vBHIocCcR3 e9tVkUHnztgeiKpKhDCTVKrwCUPWJJOC7o7NpH+1T4AffEMD9yVTXpzgIjxUf+Yk q3lR3V0XZ6r44JmtY/iPqS83O5fXcGgSVl5rvZUJwHJflK9SOXHBu7zkbYe9eUln fSn6+c445y8eoxziLB2gMufiWql6Q4uW0nPXrx9u2xcA7UA9CVQKzS9uYVAsfIaP k0GhG+0SXvwfEzjh96zbDqOXG6WEaJICvAY7fcVCZlgpPxTaROogEUua2SpHSZnK WdsLhGz8U/vGLVGMzvcdQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfeeggdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeen ucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsohguvg hrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgrthht vghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegffelfe egnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhhi khhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtghpth htohepjedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprhgrfhgrvghlsehkvghr nhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrh hordhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgt phhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtoheplhhinh hugidqrhgvnhgvshgrshdqshhotgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhope hnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrshesrhgrghhnrghtvggthhdr shgv X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 Nov 2024 07:04:04 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v2 1/2] thermal: rcar_gen3: Use lowercase hex constants Date: Wed, 20 Nov 2024 13:03:35 +0100 Message-ID: <20241120120336.1063979-2-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241120120336.1063979-1-niklas.soderlund+renesas@ragnatech.se> References: <20241120120336.1063979-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The style of the driver is to use lowercase hex constants, correct the few outlines. Signed-off-by: Niklas Söderlund --- * Changes since v1 - Update a few more defines not related to the fuses missed and pointed out by Geert, thanks! --- drivers/thermal/renesas/rcar_gen3_thermal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/thermal/renesas/rcar_gen3_thermal.c b/drivers/thermal/renesas/rcar_gen3_thermal.c index 810f86677461..95b636f79e07 100644 --- a/drivers/thermal/renesas/rcar_gen3_thermal.c +++ b/drivers/thermal/renesas/rcar_gen3_thermal.c @@ -21,11 +21,11 @@ /* Register offsets */ #define REG_GEN3_IRQSTR 0x04 #define REG_GEN3_IRQMSK 0x08 -#define REG_GEN3_IRQCTL 0x0C +#define REG_GEN3_IRQCTL 0x0c #define REG_GEN3_IRQEN 0x10 #define REG_GEN3_IRQTEMP1 0x14 #define REG_GEN3_IRQTEMP2 0x18 -#define REG_GEN3_IRQTEMP3 0x1C +#define REG_GEN3_IRQTEMP3 0x1c #define REG_GEN3_THCTR 0x20 #define REG_GEN3_TEMP 0x28 #define REG_GEN3_THCODE1 0x50 @@ -38,9 +38,9 @@ #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 +#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) @@ -57,11 +57,11 @@ /* THSCP bits */ #define THSCP_COR_PARA_VLD (BIT(15) | BIT(14)) -#define CTEMP_MASK 0xFFF +#define CTEMP_MASK 0xfff #define MCELSIUS(temp) ((temp) * 1000) -#define GEN3_FUSE_MASK 0xFFF -#define GEN4_FUSE_MASK 0xFFF +#define GEN3_FUSE_MASK 0xfff +#define GEN4_FUSE_MASK 0xfff #define TSC_MAX_NUM 5 From patchwork Wed Nov 20 12:03:36 2024 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: 13881096 X-Patchwork-Delegate: geert@linux-m68k.org Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AC721A255A; Wed, 20 Nov 2024 12:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732104251; cv=none; b=ZnGY39WxEW+1q5pqdrRJDc+WlDeCE/kSetweKyR3rlQo5GtGgYNXDEJQuBEY2dExZzhxpMG6eOz+k6DWTbCZbJGTVU4Yj6wOvJaEogoQjBlPCo2/ENxvI1xWQHfRcTj2Afxw1j9GeVMgtRKSC6amweUkJkKzelu75h2HOSU7QJo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732104251; c=relaxed/simple; bh=hEd3g7fDPK11l/5d5FbPMXrF8PX2Wj8EbZwusGCBJlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GLS0peK9zg1iOphJelhTFmP87JEPgKsnmb6+MCu2XVr1G7ZULnoD9x2Hj3Ltl/XY81cYAL5IMqEkTVNq4pHqEOHpUXO9OEUr0xSgu0DU04+/SA0doiG88XjEviBjG5D7AgtI3glAJp800IpEWgeAv8Xx/F4cYlM8psjKJTxwvwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b=mb5tlaod; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=3LqxJQaW; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech.se header.i=@ragnatech.se header.b="mb5tlaod"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="3LqxJQaW" Received: from phl-compute-11.internal (phl-compute-11.phl.internal [10.202.2.51]) by mailfout.phl.internal (Postfix) with ESMTP id AD81813806B6; Wed, 20 Nov 2024 07:04:08 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Wed, 20 Nov 2024 07:04:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1732104248; x=1732190648; bh=BUZASvGHhI99mp2A2UEOVv5dmxCopVfkBTQJrK0adBI=; b= mb5tlaodyBqoO9yheyScyNuwfZLkpP/7rcJ+rcFLh9TgREfHPG0pCqnmdj86uU33 UTJH4SpQPODv6rsqlLtmCzETN6XxNqolkNPe0WCT0EfWLag8f7DYCqvWkEEmANhs mQeFZ7XaSzoSRlVx0d6uJkaipa2dOduzK9hEMyzMFVqFq1IS5xRyJu8gHsLit4Ht eL4V8seVCJkluYNeQKcekkZ4vYWyc5sX7FHY7AQ6oJcKrKMP4EBzDLe1B8lMau0s VMF6fsqY+3a0qwe3X5xicJVcVA3WEvtc50tZc37Nk/8qyNYyzNeccli3ZSNn3p4D LYjg4NjWFXuSuXTIgXAkFA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1732104248; x= 1732190648; bh=BUZASvGHhI99mp2A2UEOVv5dmxCopVfkBTQJrK0adBI=; b=3 LqxJQaW/0dxgiu7pTOvpaVaC+3mFOsGP0Av1k6YwXeqkfIZpNf17KWODDAWkUseC Xd/udivMbtbXsMhVyEaI1lO4/O1+SucD61FG4rg0OfBKL4oRoehQL1FogOWACMIU WZHeO3kqSJl+K8+RgVYGYsj0XhwmBnt5ZBMGLXoI3DwJM/ydkR/FZ7ieIpPlJ1Cx 1BaYn95qQiJ3Ou8iuujCudIfYMdjwiDnlbUuMv7FA4RbwXY/xpodaBxPZgrgp0RG B6qEbKa27+/BuM8QcOSWYxUNUvJjl5a4DUTbGlDsxnqhOZb1h6NFEGXjExpPRPcr 8aquueK25WV0XzTZZcirQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfeeggdefhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeen ucfhrhhomheppfhikhhlrghsucfunpguvghrlhhunhguuceonhhikhhlrghsrdhsohguvg hrlhhunhguodhrvghnvghsrghssehrrghgnhgrthgvtghhrdhsvgeqnecuggftrfgrthht vghrnhepheeigfeuveeutdefhfehgeekvedtleeuueekveefudehhffhjeffgfegffelfe egnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepnhhi khhlrghsrdhsohguvghrlhhunhgusehrrghgnhgrthgvtghhrdhsvgdpnhgspghrtghpth htohepjedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprhgrfhgrvghlsehkvghr nhgvlhdrohhrghdprhgtphhtthhopegurghnihgvlhdrlhgviigtrghnoheslhhinhgrrh hordhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgt phhtthhopehluhhkrghsiidrlhhusggrsegrrhhmrdgtohhmpdhrtghpthhtoheplhhinh hugidqrhgvnhgvshgrshdqshhotgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphht thhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhope hnihhklhgrshdrshhouggvrhhluhhnugdorhgvnhgvshgrshesrhgrghhnrghtvggthhdr shgv X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 Nov 2024 07:04:08 -0500 (EST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH v2 2/2] thermal: rcar_gen3: Reuse logic to read fuses on Gen3 and Gen4 Date: Wed, 20 Nov 2024 13:03:36 +0100 Message-ID: <20241120120336.1063979-3-niklas.soderlund+renesas@ragnatech.se> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241120120336.1063979-1-niklas.soderlund+renesas@ragnatech.se> References: <20241120120336.1063979-1-niklas.soderlund+renesas@ragnatech.se> Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The hardware calibration is fused on some, but not all, Gen3 and Gen4 boards. The calibrations values are the same on both generations but located at different register offsets. Instead of having duplicated logic to read the and store the values create a helper function to do the reading and just feed it with the correct register addresses for each generation, Signed-off-by: Niklas Söderlund --- drivers/thermal/renesas/rcar_gen3_thermal.c | 79 ++++++++------------- 1 file changed, 31 insertions(+), 48 deletions(-) diff --git a/drivers/thermal/renesas/rcar_gen3_thermal.c b/drivers/thermal/renesas/rcar_gen3_thermal.c index 95b636f79e07..5f54e235da2f 100644 --- a/drivers/thermal/renesas/rcar_gen3_thermal.c +++ b/drivers/thermal/renesas/rcar_gen3_thermal.c @@ -253,60 +253,43 @@ static irqreturn_t rcar_gen3_thermal_irq(int irq, void *data) return IRQ_HANDLED; } +static void rcar_gen3_thermal_fetch_fuses(struct rcar_gen3_thermal_priv *priv, + u32 ptat0, u32 ptat1, u32 ptat2, + u32 thcode0, u32 thcode1, u32 thcode2, + u32 mask) +{ + /* + * 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], ptat0) & mask; + priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], ptat1) & mask; + priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], ptat2) & mask; + + for (unsigned int i = 0; i < priv->num_tscs; i++) { + struct rcar_gen3_thermal_tsc *tsc = priv->tscs[i]; + + tsc->thcode[0] = rcar_gen3_thermal_read(tsc, thcode0) & mask; + tsc->thcode[1] = rcar_gen3_thermal_read(tsc, thcode1) & mask; + tsc->thcode[2] = rcar_gen3_thermal_read(tsc, thcode2) & mask; + } +} + 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; - } + rcar_gen3_thermal_fetch_fuses(priv, + REG_GEN3_PTAT1, REG_GEN3_PTAT2, REG_GEN3_PTAT3, + REG_GEN3_THCODE1, REG_GEN3_THCODE2, REG_GEN3_THCODE3, + GEN3_FUSE_MASK); } 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_THSFMON16) & - GEN4_FUSE_MASK; - priv->ptat[1] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON17) & - GEN4_FUSE_MASK; - priv->ptat[2] = rcar_gen3_thermal_read(priv->tscs[0], REG_GEN4_THSFMON15) & - 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_THSFMON01) & - GEN4_FUSE_MASK; - tsc->thcode[1] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON02) & - GEN4_FUSE_MASK; - tsc->thcode[2] = rcar_gen3_thermal_read(tsc, REG_GEN4_THSFMON00) & - GEN4_FUSE_MASK; - } + rcar_gen3_thermal_fetch_fuses(priv, + REG_GEN4_THSFMON16, REG_GEN4_THSFMON17, REG_GEN4_THSFMON15, + REG_GEN4_THSFMON01, REG_GEN4_THSFMON02, REG_GEN4_THSFMON00, + GEN4_FUSE_MASK); } static bool rcar_gen3_thermal_read_fuses(struct rcar_gen3_thermal_priv *priv)