Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2401101lqp; Sun, 24 Mar 2024 17:57:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQ7abxDQxXuTrkOyy9kpsAXFLsFia1D/6XbnprgJP9lIo9iwxEbGBioq4VPEUk5uHGjfphKgZdmtYJqah7KZExsUOfVUJmpDkrcEJCaA== X-Google-Smtp-Source: AGHT+IFoujH5j3JUpbOetLXc8MCXD9w1VqyCHKz+6X5h8ZaONhxtY5e6OsVboIdBjTKF9dkp723n X-Received: by 2002:a05:620a:5717:b0:788:3f49:1ca4 with SMTP id wi23-20020a05620a571700b007883f491ca4mr5877145qkn.43.1711328253371; Sun, 24 Mar 2024 17:57:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711328253; cv=pass; d=google.com; s=arc-20160816; b=kESmp0j5ING96kZPe4PpLiDJSAOQgz4Eckv5hVbs1YIgJdxK5xY/yhEEkNYSZzuGDg td/nTupIOHbel+0j8TM3PzFB6E4LSX2cyqYLTu+s5cFjusbN9lYnQ7QvWE5sThoWWEWi uFzETz4D/9ZEP9Xi6hCYMN7lTHYET0vRRNEvCpo/AG3Ag6YCCsSbradgLJXT1NjiqQw+ QKae2765WYCx75G+oLywnprGcJbXzCFwC6/c6Jjm438kr5A8/Hbml1GH1djmqydB3qjO YQn/d9SsNTI6NqdqHf/okYBzEQhi5RsewLrtdawYhDNMo3E8jL8w9O1GKxPCKJ0cRA+3 lIpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=3339GJEqVPvvBZI5TNVAjK2hdpTd/rEO+ll91fKCeac=; fh=r1WMkugsGxqamZ7PxJSEMgIPNU2PW7bIi8XBOy6Zr6E=; b=eCQFQl3o5MT2KWc0yTyuXj3omSf9VmCXb6xeBhIqFCQAU4SJK7H2ntALzYX59Bhep/ Nqd7X8VhqQURsvNuE596x9/6EhQHOcX0W+8SqkYQH+18O+WXvtJqZKinC1e2RId7F3SB xRK+rn+CAOhRWxWsvfzbt9q0RmhgvwYMryUcgs0KQAq2CxKQMMyzBrj8hdbhqyPSgZOM vMg2rvrsgS+E18qnvHkSlsn+yMqbld6jYxMz20sLZwuHi/K8GKncbhQ6Kn6s/VN/ealX yTAZ59PhZ0oqDniBFOPPue41VD3KsveUvYtChEBl8VTLe97kSdx3v6PDH3sdMfdO6M8U WvCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UfwJkYbz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g2-20020a05620a218200b0078a46385de1si3947180qka.682.2024.03.24.17.57.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:57:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UfwJkYbz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1DFB41C244D9 for ; Mon, 25 Mar 2024 00:57:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C0E91BF521; Sun, 24 Mar 2024 22:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UfwJkYbz" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 30D4F1BF503; Sun, 24 Mar 2024 22:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320331; cv=none; b=OxwwBGitsvwSQySZIq1LhqZGh3KubxXgIzyHWZP3xDPsDWIWmh6DKNtQEFvzR7SiMhBeeBz6zJAgI8ElA2f0nID5wPU/iumzTLwEZhxGoFSc48br31beTgu4P6sxXOYIhd/ITjU87+27ZsNUYLN1ISrDh+5d7p1UX0p/zH2/aUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320331; c=relaxed/simple; bh=q9cK5+CVva2zWZ5121iREcxRFvY+SrqSNGS/pgZCZmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SKY7ULGow0g57gcGqKJ2gnmA1xRsnundoTX4P0gT/Cut2Gj2C3q6NweS7hARCGjDO8LurbJhOpRo4wUkZPRnuX3OD8QjOpeaIQqdM8+D9vgf8XsqxiQdDoCAvFGU6g9R5yfmhfUpLVvquwszhQpCDG5YYnoDkL7u7CH+ZMdafXw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UfwJkYbz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49CA4C43390; Sun, 24 Mar 2024 22:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320331; bh=q9cK5+CVva2zWZ5121iREcxRFvY+SrqSNGS/pgZCZmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UfwJkYbzltux2Oj9D+w6gNybp7/lnuQ3tEVKe4jg9koyQpvXsiEY76PYv103wwns6 Mr/7qOV5orOsoqsW8B+3zeb4w6IsoRHPRCFVbHdkIh7qE3Myp0Bt0lX2alb1zRbz2l ft/PfoAdHenK3gNpUz7wvSpC0aGHrKAT7uvmRNPMY7bkDdlkMTkl3/JpxoZ0UcNinj +v7Yxo0Y539p1C706B61vqeqNTlgi1TWa/pNcBR6Hs0dpULlRLJtOrUQL46mN/HTOO +IwW1QR+ttQhEm0Oaw0Gx6l3LxeSKTTKppySLHkCWkW6xOplyvAS1OAVF/ps9w4M0/ z1OVUs+c0UX1w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Peng Fan , Sascha Hauer , Daniel Lezcano , Sasha Levin Subject: [PATCH 6.8 638/715] thermal/drivers/qoriq: Fix getting tmu range Date: Sun, 24 Mar 2024 18:33:37 -0400 Message-ID: <20240324223455.1342824-639-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Peng Fan [ Upstream commit 4d0642074c67ed9928e9d68734ace439aa06e403 ] TMU Version 1 has 4 TTRCRs, while TMU Version >=2 has 16 TTRCRs. So limit the len to 4 will report "invalid range data" for i.MX93. This patch drop the local array with allocated ttrcr array and able to support larger tmu ranges. Fixes: f12d60c81fce ("thermal/drivers/qoriq: Support version 2.1") Tested-by: Sascha Hauer Signed-off-by: Peng Fan Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20240226003657.3012880-1-peng.fan@oss.nxp.com Signed-off-by: Sasha Levin --- drivers/thermal/qoriq_thermal.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index ccc2eea7f9f54..404f01cca4dab 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -57,6 +57,9 @@ #define REGS_TTRnCR(n) (0xf10 + 4 * (n)) /* Temperature Range n * Control Register */ +#define NUM_TTRCR_V1 4 +#define NUM_TTRCR_MAX 16 + #define REGS_IPBRR(n) (0xbf8 + 4 * (n)) /* IP Block Revision * Register n */ @@ -71,6 +74,7 @@ struct qoriq_sensor { struct qoriq_tmu_data { int ver; + u32 ttrcr[NUM_TTRCR_MAX]; struct regmap *regmap; struct clk *clk; struct qoriq_sensor sensor[SITES_MAX]; @@ -182,17 +186,17 @@ static int qoriq_tmu_calibration(struct device *dev, struct qoriq_tmu_data *data) { int i, val, len; - u32 range[4]; const u32 *calibration; struct device_node *np = dev->of_node; len = of_property_count_u32_elems(np, "fsl,tmu-range"); - if (len < 0 || len > 4) { + if (len < 0 || (data->ver == TMU_VER1 && len > NUM_TTRCR_V1) || + (data->ver > TMU_VER1 && len > NUM_TTRCR_MAX)) { dev_err(dev, "invalid range data.\n"); return len; } - val = of_property_read_u32_array(np, "fsl,tmu-range", range, len); + val = of_property_read_u32_array(np, "fsl,tmu-range", data->ttrcr, len); if (val != 0) { dev_err(dev, "failed to read range data.\n"); return val; @@ -200,7 +204,7 @@ static int qoriq_tmu_calibration(struct device *dev, /* Init temperature range registers */ for (i = 0; i < len; i++) - regmap_write(data->regmap, REGS_TTRnCR(i), range[i]); + regmap_write(data->regmap, REGS_TTRnCR(i), data->ttrcr[i]); calibration = of_get_property(np, "fsl,tmu-calibration", &len); if (calibration == NULL || len % 8) { -- 2.43.0