From patchwork Tue Dec 10 21:27:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13902085 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2069.outbound.protection.outlook.com [40.107.247.69]) (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 5A623232375 for ; Tue, 10 Dec 2024 21:27:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733866051; cv=fail; b=NE+NIVwhG13lN0vfmMF2EdVY7me7wySzVFMoOia6ewPrSQpS4SXlDm4Yi1LS4LDyGM8wFFmJCGU46fY+PijptzRvvQaccrtcyTeEyeMWKuSV9BgjAoCvRBB/duFSXTO3LGrMe1F80bK9c5CThhMY7x8lTFzeUr5RJzcB+iKCnt4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733866051; c=relaxed/simple; bh=r1D6YleI4pfbRMudJcC/mpaiq45dCNo3RsDTZ3TyLf8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=r9mNGwbEnrml4iP5Rf1XFh6e6lIkK3IDpIpl4gakP21omhsN071lGPXKZd9HVN9SFa48yhLUSCxVl+IoHRFbnljBPkAeNX0ksfGGDgdPQyjVIeFFsHeC1gF7qYVkgZWgUx4FUk1ahE6mqRK18gr4xDwYVEqPME+OcBL6/QFFm50= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=JJc+OSj/; arc=fail smtp.client-ip=40.107.247.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="JJc+OSj/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UbjlfOCYQTPmFKL1Pv3M/6PW45AFeLgQxS6x6qe5EkY0YpKPBuuZPiDtjR6xPljzAZw18U+wqqNRHDaDXkPLvK3K+tRk15RXLWabYHP7tiTdda+AIQRKKZGN6rAPilNCvdnwX3AeEKg22Pe2/XkfTD2ZpULMgd7v5BrskVsCMx5eh1YLPNuATfohJgCdaZ/zrpN7CLz7zNzOfcPFKgwGEbKheCWVH+YNGhVAlSE3yoI/D4mScf0s1uozdJYTF39VP958pclrOEEabKU3CyT5leMaRMW9Si2JQUUnpmS4RxSbaLdxIe1Yq7hF3I6zgj/hvJazCpZya3DG3N8+aXXDHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4UwDRaceH7GvnQ/QxRniWA3dsOW7A2WQ6w6+nm1UCs4=; b=ko5p34okMZNFNCxUikhWNkddrDKcJKN1R4lAJEUTXfsjfBb3Huko6FZ/FUKkGJOwwc4C1bSfS2828KLG6JXbRwR3cgYzm015NaZplXF8Mc22mZcjQZ5QnsfQZQo6A2ppmcys61hsJeiFA0U/J0+vrmsmoGeMXq4sX9OSx4wWMse23etjd+J8h467migRbJKNwQWfTp8xY8GLeNj9TiyU3GLjao+lizw9kGKyWcpSySwfdchIRbw8b2+2lrg4cVv4G1DRTr+hQ6KPuUtk4BFySlkgDLhrBoLzzqZeL7pe9pHu3lTXJGiXKa31wVgvFka9ojEuzSs4Jo/A7l+AC43sTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4UwDRaceH7GvnQ/QxRniWA3dsOW7A2WQ6w6+nm1UCs4=; b=JJc+OSj/2mdPknoMpbETsXuCl33bI+ML4sxO6GwunJABOqhPDUbjeRy8lPcjpiHAy/udXhOD/sYNYyKv1tA7HuUH+BIlyk5YvqOE1+g9Rl9Ra9fSmwnEjvLhCWwpovo6nTULCwr7uNDaCZdJ1hFPaxCgnbZbhxqgZQbxupx1axGz4a2NA3XQSdaRdwVQplG/igZUprAp3K+fgw73AzY42Gg1EOZhP7WV0Z3ACB/BT8zHuCWyCOCKOkTvPCbEtvMxtkZMIkEsYMm+VAqK8DzA1d5jpK7nbCYZY/QkDtfSEyfHNg5p4Yk5PMMvT7AY2H23gRUDgvw6h5z7eljQ61Ky/Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PA4PR04MB7550.eurprd04.prod.outlook.com (2603:10a6:102:f0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 21:27:26 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Tue, 10 Dec 2024 21:27:26 +0000 From: Frank Li Date: Tue, 10 Dec 2024 16:27:02 -0500 Subject: [PATCH v2 1/2] dt-bindings: thermal: fsl,imx91-tmu: add bindings for NXP i.MX91 thermal module Message-Id: <20241210-imx91tmu-v2-1-5032aad4d88e@nxp.com> References: <20241210-imx91tmu-v2-0-5032aad4d88e@nxp.com> In-Reply-To: <20241210-imx91tmu-v2-0-5032aad4d88e@nxp.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pengfei Li , Marco Felsch Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733866037; l=2218; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=iVQTtCNDQDMEk1P8NXmCJ6s4gReJ2DPWuwpLblkVduE=; b=rNb9Ka3yqYp3yTiT2byc7uTGso57JLa+SycObjqKs378GeRKCu77j8YJwHGP7cJtYPN4fQ/i+ CYnpF2lm90UAmTVE9rmtPFRU0db67qHDdPD20iBtJ4v5FMSMtuKTiNM X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0P220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::28) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PA4PR04MB7550:EE_ X-MS-Office365-Filtering-Correlation-Id: 10fe0484-095d-4415-bfc0-08dd1961715d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?P9s4eSSwJbt3i/t0vW+G3UxZa2kAxVX?= =?utf-8?q?yVolQkDnlSfzWjwGn4ERrcxdSVzyD3OEYHTXezfXX9de9LiL+d4aGpXXILtBhZcQd?= =?utf-8?q?v+3KmMubjuAOhsnxfnmKBv3ZZRK9GB8FKMu2OsObGUpYcJ+vC4d/GhBDo0MCbgqmC?= =?utf-8?q?hfA6FEo+nvagI6ia8dfNq3qs60eYCY1qb/od5x6YKK1XHr0qtcfZs+UpXgBDmmslz?= =?utf-8?q?hLOMeABH8kXhZZUbODvmstV45hVrDJ3q28pkWPBN493PtUc0Xj34bq96NNKm1tEmD?= =?utf-8?q?G1ZryhhsfwvaY4I6BDI6tz8ViWYamsSci0WxI/E8YsHWEmS71yx9OLpQNUoR6lrTX?= =?utf-8?q?t3NxqlGNH1IPmEpqGrHIc8s2lNWTjEdTKZFjHDHdds3CjmcLgmnGqHNl+Kmo18e45?= =?utf-8?q?1hdnc7jnePjfeIV2sa6gPHsES9be9Iu4n3cUL9Dg2e4b3WeE8kYJu8WFlO8dNakZl?= =?utf-8?q?yPfafY76g1mCJfFS8V48EeyHmNocfwRjVMD+Kq/FRiM9T2z+O9hy2+9juu8vE2AC/?= =?utf-8?q?r30kb7bHatxmBwco09//tjoEtmqXif8bmYfvzkYzVRaT6JAn6yqJ7H2nb1lGKpHYI?= =?utf-8?q?zFxl1vhe25shOpZ9EelNxNHtv7RXQmTBjBWR9GicWQXb1S5Lw+xn58K5ZgGDjSlwl?= =?utf-8?q?gVUONe++wp4WopAm4HH0HuDw4bPsVfwH/RFeGsXwexxuX1ThVb7LJ36YNE1qRijKa?= =?utf-8?q?mq8uCRByEVy03ZaIdZr28bYvzIyEqSW8ZFyjJV6tP3EaxYrwfKFhij0B9Ru5Xq5hc?= =?utf-8?q?ILQqnvRP/UdmZtvQTu8sB1O6p+Cdz2/+eeXMKt6FmPK6H6xwE4vipkwLvtjT2jbjU?= =?utf-8?q?GdqdtvSvRQf9mQ2KJGvNu9+LvsyyIyggfYTBKkTp5CAnb2jtefFSY0xHLX8wk6zqT?= =?utf-8?q?IcyFVt0pnTdSDgevF79BE3s1OsHJ5hN+20okR9UYDTOBMPqb+iTgOB85UNzjL1Cu9?= =?utf-8?q?aKg9tnfQzIRsd6PVPKk7+I1GHihqhlbsABZOapQR/rimF0+f1rFt/pt0uNqs6jYkR?= =?utf-8?q?iRYgOIfrZPhzv/h89HgRoL/5gScVasjbFDJyd4XBx7LZQo+a7cmy3RR1MAdAwGiRf?= =?utf-8?q?Q5lMHUo5HdQtd94VgKyjgRalzq31GWszIw3B6cPNKErclmq1sAcRwTThkr9R8ImTU?= =?utf-8?q?56OZ95OnSU13mBOirWAHLd+Pc35O2sQu5oi0TGAa8IpKkSGm7nMgKHmVzX4kznfwY?= =?utf-8?q?uu2xb3/zOLkwGLLu8V67TMxcujDUwTE1DLE63Z/xJ3i8Nh6U3uw0JDG2zyS2007ew?= =?utf-8?q?99hOtJsQ8mcB8UUpv0nIwIMYw8b3lCcmUoF2PxeKGOhtFsvdjQsaKT95JpR9P7ORk?= =?utf-8?q?mKQMEJdI5iP/?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xetvNLqnar+uH3Yp9WUeq/i1HKE+?= =?utf-8?q?oZ4kE6qQN2zKJOzKDlXdZRxhXAmjCpmhfGK0VV+GSb2Aufk8VKc+WnuM1PshVDV4K?= =?utf-8?q?0aPHYQOKej6jGQ5ETHAMIXPdi0JsmfHnm7ZrOJgGvJZIAhLvtyLr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= =?utf-8?q?ekM8hZK63AgDkJk9o+R4piGk/0Mhwl6RDwM9HDWJdxSRzYC/kA5YyM0/1xq5/rzqa?= =?utf-8?q?4ByYQR1jzlUfVhde60EEaq0K0o5HOgRuZAo9FUi57VBertk8un7VGSTogRk3+roJm?= =?utf-8?q?euzWk6HqKlr9qa1tSFtsXLy92J4wiJTitt/XoTlJYXLfdxL3QuB2vzAiJtLeFFDoi?= =?utf-8?q?EPfRGzuZ6/1EM4hEURLNSjbbp1fNo/and8730DNLFccAhM7z/5fUXgVxTSJetrJvo?= =?utf-8?q?t5k67k450PHrqqci9Tt4pL/iRL86OMHYXNEEA6Yb2mfKT+eEpsOC4qw/YE0fj9zNA?= =?utf-8?q?/nQURGqB/Uc6BOcKfwgoeJEeejZ4NpaswZC38TISBQQ2FYddmjRr4UPw/hPB04gem?= =?utf-8?q?PlVK/GnNUK7fUaWMWbZRVV9QyJmsydWQOrLEr/MN5cHGYCzMgDmUL1uy0JEPRk2St?= =?utf-8?q?GHGjZdGuL5HmWYi1QFF9k95YLkt4zpw/t1E7F9B/2V98K7tok8SLgJ25B6gNtDYPB?= =?utf-8?q?XY3RdiMJpetd?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10fe0484-095d-4415-bfc0-08dd1961715d X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 21:27:26.1808 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4ftYrw2OXEbMpfkDajQxnQcc0G+OwUfKeL/QWbE3bjbJXatq9DAjj0IT4h+d59hZoIMOuK1UBuEo6Cyq5cehsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7550 From: Pengfei Li Add bindings documentation for i.MX91 thermal modules. Signed-off-by: Pengfei Li Signed-off-by: Frank Li --- .../devicetree/bindings/thermal/fsl,imx91-tmu.yaml | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/Documentation/devicetree/bindings/thermal/fsl,imx91-tmu.yaml b/Documentation/devicetree/bindings/thermal/fsl,imx91-tmu.yaml new file mode 100644 index 0000000000000..f5898db1006c6 --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/fsl,imx91-tmu.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/fsl,imx91-tmu.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX91 Thermal + +maintainers: + - Pengfei Li + +description: + i.MX91 features a new temperature sensor. It includes programmable + temperature threshold comparators for both normal and privileged + accesses and allows a programmable measurement frequency for the + Periodic One-Shot Measurement mode. Additionally, it provides + status registers for indicating the end of measurement and threshold + violation events. + +properties: + compatible: + items: + - const: fsl,imx91-tmu + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + nvmem-cells: + items: + - description: Phandle to the trim control 1 provided by ocotp + - description: Phandle to the trim control 2 provided by ocotp + + nvmem-cell-names: + items: + - const: trim1 + - const: trim2 + + "#thermal-sensor-cells": + enum: [0, 1] + +required: + - compatible + - reg + - clocks + - '#thermal-sensor-cells' + +additionalProperties: false + +examples: + - | + #include + + thermal-sensor@44482000 { + compatible = "fsl,imx91-tmu"; + reg = <0x44482000 0x1000>; + #thermal-sensor-cells = <0>; + clocks = <&clk IMX93_CLK_TMC_GATE>; + nvmem-cells = <&tmu_trim1>, <&tmu_trim2>; + nvmem-cell-names = "trim1", "trim2"; + }; + +... From patchwork Tue Dec 10 21:27:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13902086 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2085.outbound.protection.outlook.com [40.107.103.85]) (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 DF17323239E for ; Tue, 10 Dec 2024 21:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733866056; cv=fail; b=sL6jNUxfdvp1w+7c0YV99JfbUwyUXbjhWIJeuKb9oOm4tMcZHpy5Xr6TlNJsoitfXUEYbMukEP5Fiz5zeKPlAEQhXM/pvWZ+hvXkwVAatv9rp2bTyLPotBwGhIlQ/apza+S7I0Pt/GzejWEpO2GgLSZUfsewMKQbBUCHRS9K+Vg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733866056; c=relaxed/simple; bh=UBRH/DZ+712KxK9ZDlNSlCh6M3g3qSAyI/ZL35VH1OU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=LxmugOeDntdnaNySm0qNukAz2i1CBeNh+2bfMOmva8BAryHTCd2/ZAEXqqUeA/nNYG3ild15Hzib95Z50pb9B8F0fsCpfC6m/nJlh8YpwIV9hixEDoTsvf4s77iCODZ4UwRudi/fhy/HDr9e/519YnsY8fjErihX/5XLNQ3RdRU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=DYSJN+kj; arc=fail smtp.client-ip=40.107.103.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="DYSJN+kj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ueofw3H2iiPyQ2ZFg/wBYbWb04MhvV1t43TWYB7cahEL28X77W9eTftniWlnxlfDXwVig75NCqpiYqswxJL72F9yiPwgU8qJdwagAF3GKe/YUVk13oezjc0f2NIuWnOXSTdcYlrKmtM0/UBm5XyBsAOSkVniksqRAjEb56LnzK/YctzmPC+iCoodd2bGNv9KE3XIWu+UoxKdrKzTev6g3a+ZknkGfM9VByNwaIEcVUB+kd4Pc1URxxV7roT6uW0+ng4NF3HMOKvosoF78ZhsQ1CpIiZkuhiRysRjBcWw0xqDf1UF6GlpsJ4SoFmVeMmreSSTiJqKVL8e3bg7b8/IxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eKuh2jrYk7ZziHGoSy1nV2WC7g4UIPaOeOprVp6g0hw=; b=X+f1VImxa+vYQJafinOis0L55qSTJGNhwmL4qWwsUpbl0CiP1mtzGxu6/J2f2PThOrYbqSYQsyYWjmVYuV9Yo8pDbmaTs4blmpBDF6sjxSxp49QyEPi0DzRdIpoxIbOw2ht7oQe4wruvfjkZtbm2IfDyeWRhY7sqNnhJ0yM2m2cuji0lIuzCcL4nUrTsv/qt3uiVNGtGxpVHYoIxpEvI+FcJ0I0AdPB7g0RjujzEKgFLka02kAX6rn9kzsiKzx8jIdPgmsEv3tFwetXPJoJ95XZIZgUS7+zZguUhiGn95yK2aFHP5I7gVE38etRc4fnMdDFQk2zNJWFeDTG8ZjzkJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eKuh2jrYk7ZziHGoSy1nV2WC7g4UIPaOeOprVp6g0hw=; b=DYSJN+kje0BnGFNq3sOnGRelXxmXwnKlisY5ckEvsK/0MpRGICt4YpBeYseQLOYxa3ptf6755m/TDpwuQekzAgKxM2WkZa+NXDyDW8IsZU3i6804so5jWJAz6VeygFYGNbJn0h1wBwcGDrRprCES/IC7zSces0mWWTKwc7iciTFu7nPJIxs4r7jHGgTx/+342uRzqavcA08fxNUDDcQA2IhZTsZ5NRzrzOpMfPDd6AM4/3cQKnRvPIF523yAob7iavAWfBQ+izV08oUFr2j1/vYy5joNG9tDjRTlx7JLp5WJElov2On20dOTXv06j8Lm0yZPa+43T8p/U3xdtlAWhA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by PA4PR04MB7550.eurprd04.prod.outlook.com (2603:10a6:102:f0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Tue, 10 Dec 2024 21:27:30 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8230.010; Tue, 10 Dec 2024 21:27:30 +0000 From: Frank Li Date: Tue, 10 Dec 2024 16:27:03 -0500 Subject: [PATCH v2 2/2] thermal: imx91: Add support for i.MX91 thermal monitoring unit Message-Id: <20241210-imx91tmu-v2-2-5032aad4d88e@nxp.com> References: <20241210-imx91tmu-v2-0-5032aad4d88e@nxp.com> In-Reply-To: <20241210-imx91tmu-v2-0-5032aad4d88e@nxp.com> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pengfei Li , Marco Felsch Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Frank Li , Peng Fan X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733866037; l=9362; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=GaTapRVMfFiP49k8WRVidYkY+FWOXePac372dgGJZ+Q=; b=C/pECoT9LFUgiheY2l7kSsB4nDk9ANUu0WALyWaP+LGXAP7eHfODra31o+yMdlK46RO8Y3wne JscyjrDtXUzB1mqdKe9jgn0XE/E46mGhtUrbvUYoFqZLJ5xIbjyNnKJ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0P220CA0018.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::28) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PA4PR04MB7550:EE_ X-MS-Office365-Filtering-Correlation-Id: f5e46868-6744-4e22-4a0f-08dd1961741e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?b6c6lMLT39zkis3M40x4TtLtc3/swxb?= =?utf-8?q?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cuM1JIZTFRrAeYOVObWe9k5ZPQxj5UQpf4Cz436lik0b4uzNmaFG8i0+6WneOsb?= =?utf-8?q?vLco63wAygeHBcCZMKhRIOTTBAnxUPPAL/2pPF8+C9diuHKeHPiXR9g9GstIcXgrs?= =?utf-8?q?+o2sysMbalg+qaoszL/rVcn0glDI8ZipnfWx2g+tQDSktjQxTazgVbAH20SxzaThR?= =?utf-8?q?B2hUy3yo6AobS3qsWhWoavvcVkZIDQsuNvKKURP13ep8Soe/verRH8oqF2lSN+jgd?= =?utf-8?q?pRsojjWSuDbGmnWeQLKDoZuGxU5sv5MOSlltTCTx3WsfzwVVH/Usyw/M5+djbJ6e/?= =?utf-8?q?9bUXFZCcTG7m+VQJO3by7hfgNzcLunL7IglRY9386+98McW3mMlIi0cNrsfjnz7UT?= =?utf-8?q?ghgGtwXSbr7Vc9JUo10MGOzoFdtOLgZefohe5ab4KHTHbxVcLxZm7B9XF7j/FA1HO?= =?utf-8?q?dmmk0nScnH7vXVQh7l/q7SedsZeoMX7aADEmR31Szd/kqYGZmC8CTO0=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?IkUb7RNzPIWQuzmLNT75x+sUXOK2?= =?utf-8?q?2ncs+yQWTxByQr59ndVXCMY/Ox4XDvcR9e5U6qNoztN/sHH7XYfBgLSidRo2wokXh?= =?utf-8?q?F4WSucLP35tm+nlLW3SvS59VXWQ8AbSBUIwKwi9Lx18VmFhuEcBhmpVIJt723A30p?= =?utf-8?q?ZsBJG6s78Rjq9gxr0euLdi4wTlmk2Tz61X/iL0CBf3l6616jybZAuJvp1l5TKH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Lqp?= =?utf-8?q?xk/NdQl8fCEsSo/dXO9LVld70Gl74HGtK3Ker9QZ6lYVS79IJj/iZKeE8aTZ7mbd7?= =?utf-8?q?4KEbRZr+e7v2y7XPf/Ic3yZ3sSw5xsuXTd6muYl7g+ncDUGUkoHauD9KR4aiP238+?= =?utf-8?q?vqYbCfDdcivs9pDt5dTNGy8MghfwF+a7kGsV4Ul0UktzL2SuIIuRJgkHQ9JdDCR9i?= =?utf-8?q?j67AItYATozWwQAzkVQtTKvjvy6DMfYoofUJ5UL6hyT0Yhr4i2n2SF0RL/NA9sekC?= =?utf-8?q?JFO4eqjy8gR4OYemUJeRYW/KaLRS07Wv5IS37ZZb6MsQT/KUgRuG0K9Vpg6J/y5re?= =?utf-8?q?i/63M3RSy5oSriSn/WDx3u6pvxFzyJIUi44bw/JjudWyRt5uu8cn1/0Zwldaxlt0M?= =?utf-8?q?VwtDoQsOCxWLSR0zpj2odIuL45UQsZ2iSPcds5IHFHQEGbd7n2v3IIsGLkOMXEIXJ?= =?utf-8?q?5D9gPapq1G5k?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5e46868-6744-4e22-4a0f-08dd1961741e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2024 21:27:30.8167 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FL245M2iodEP6gHvbLFSXtz2sUd4XYPzKmUviD9X5hmZdhE4dtS1kc/Sswyat6i3y0Q4A0axq8kEl+2cw+Tovw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7550 From: Pengfei Li Introduce support for the i.MX91 thermal monitoring unit, which features a single sensor for the CPU. The register layout differs from other chips, necessitating the creation of a dedicated file for this. Signed-off-by: Pengfei Li Signed-off-by: Peng Fan Signed-off-by: Frank Li --- change from v1 to v2 - use low case for hexvalue - combine struct imx91_tmu and tmu_sensor - simplify imx91_tmu_start() and imx91_tmu_enable() - use s16 for imx91_tmu_get_temp(), which may negative value - use reverse christmas tree style - use run time pm - use oneshot to sample temp - register thermal zone after hardware init --- drivers/thermal/Kconfig | 10 ++ drivers/thermal/Makefile | 1 + drivers/thermal/imx91_thermal.c | 265 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 276 insertions(+) diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index d3f9686e26e71..da403ed86aeb1 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -296,6 +296,16 @@ config IMX8MM_THERMAL cpufreq is used as the cooling device to throttle CPUs when the passive trip is crossed. +config IMX91_THERMAL + tristate "Temperature sensor driver for NXP i.MX91 SoC" + depends on ARCH_MXC || COMPILE_TEST + depends on OF + help + Support for Temperature sensor found on NXP i.MX91 SoC. + It supports one critical trip point and one passive trip point. The + cpufreq is used as the cooling device to throttle CPUs when the passive + trip is crossed. + config K3_THERMAL tristate "Texas Instruments K3 thermal support" depends on ARCH_K3 || COMPILE_TEST diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 9abf43a74f2bb..08da241e6a598 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -50,6 +50,7 @@ obj-$(CONFIG_ARMADA_THERMAL) += armada_thermal.o obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o obj-$(CONFIG_IMX_SC_THERMAL) += imx_sc_thermal.o obj-$(CONFIG_IMX8MM_THERMAL) += imx8mm_thermal.o +obj-$(CONFIG_IMX91_THERMAL) += imx91_thermal.o obj-$(CONFIG_MAX77620_THERMAL) += max77620_thermal.o obj-$(CONFIG_QORIQ_THERMAL) += qoriq_thermal.o obj-$(CONFIG_DA9062_THERMAL) += da9062-thermal.o diff --git a/drivers/thermal/imx91_thermal.c b/drivers/thermal/imx91_thermal.c new file mode 100644 index 0000000000000..ebb59eda92951 --- /dev/null +++ b/drivers/thermal/imx91_thermal.c @@ -0,0 +1,265 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CTRL0 0x0 + +#define STAT0 0x10 +#define STAT0_DRDY0_IF_MASK BIT(16) + +#define DATA0 0x20 + +#define THR_CTRL01 0x30 +#define THR_CTRL23 0x40 + +#define CTRL1 0x200 +#define CTRL1_SET 0x204 +#define CTRL1_CLR 0x208 +#define CTRL1_EN BIT(31) +#define CTRL1_START BIT(30) +#define CTRL1_STOP BIT(29) +#define CTRL1_RES_MASK GENMASK(19, 18) +#define CTRL1_MEAS_MODE_MASK GENMASK(25, 24) +#define CTRL1_MEAS_MODE_SINGLE 0 +#define CTRL1_MEAS_MODE_CONTINUES 1 +#define CTRL1_MEAS_MODE_PERIODIC 2 + +#define REF_DIV 0x280 +#define DIV_EN BIT(31) +#define DIV_MASK GENMASK(23, 16) + +#define PUD_ST_CTRL 0x2B0 +#define PUDL_MASK GENMASK(23, 16) + +#define TRIM1 0x2E0 +#define TRIM2 0x2F0 + +#define TMU_TEMP_LOW_LIMIT -40000 +#define TMU_TEMP_HIGH_LIMIT 125000 + +#define DEFAULT_TRIM1_CONFIG 0xb561bc2d +#define DEFAULT_TRIM2_CONFIG 0x65d4 + +struct imx91_tmu { + void __iomem *base; + struct clk *clk; + struct device *dev; + struct thermal_zone_device *tzd; +}; + +static void imx91_tmu_start(struct imx91_tmu *tmu, bool start) +{ + u32 val = start ? CTRL1_START : CTRL1_STOP; + + writel_relaxed(val, tmu->base + CTRL1_SET); +} + +static void imx91_tmu_enable(struct imx91_tmu *tmu, bool enable) +{ + u32 reg = enable ? CTRL1_SET : CTRL1_CLR; + + writel_relaxed(CTRL1_EN, tmu->base + reg); +} + +static int imx91_tmu_get_temp(struct thermal_zone_device *tz, int *temp) +{ + struct imx91_tmu *tmu = thermal_zone_device_priv(tz); + s16 data; + int ret; + u32 val; + + ret = pm_runtime_resume_and_get(tmu->dev); + if (ret < 0) + return ret; + + ret = readl_relaxed_poll_timeout(tmu->base + STAT0, val, + val & STAT0_DRDY0_IF_MASK, 1000, + 40000); + if (ret) + return -EAGAIN; + + /* DATA0 is 16bit signed number */ + data = readw_relaxed(tmu->base + DATA0); + *temp = data * 1000 / 64; + if (*temp < TMU_TEMP_LOW_LIMIT || *temp > TMU_TEMP_HIGH_LIMIT) + return -EAGAIN; + + pm_runtime_put(tmu->dev); + + return 0; +} + +static struct thermal_zone_device_ops tmu_tz_ops = { + .get_temp = imx91_tmu_get_temp, +}; + +static int imx91_init_from_nvmem_cells(struct imx91_tmu *tmu) +{ + struct device *dev = tmu->dev; + u32 trim1, trim2; + int ret; + + ret = nvmem_cell_read_u32(dev, "trim1", &trim1); + if (ret) + return ret; + + ret = nvmem_cell_read_u32(dev, "trim2", &trim2); + if (ret) + return ret; + + if (trim1 == 0 || trim2 == 0) + return -EINVAL; + + writel_relaxed(trim1, tmu->base + TRIM1); + writel_relaxed(trim2, tmu->base + TRIM2); + + return 0; +} + +static int imx91_tmu_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct imx91_tmu *tmu; + unsigned long rate; + u32 div; + int ret; + + tmu = devm_kzalloc(&pdev->dev, sizeof(struct imx91_tmu), GFP_KERNEL); + if (!tmu) + return -ENOMEM; + + tmu->dev = &pdev->dev; + + tmu->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(tmu->base)) + return PTR_ERR(tmu->base); + + tmu->clk = devm_clk_get_enabled(dev, NULL); + if (IS_ERR(tmu->clk)) + return dev_err_probe(dev, PTR_ERR(tmu->clk), "failed to get tmu clock\n"); + + platform_set_drvdata(pdev, tmu); + + /* disable the monitor during initialization */ + imx91_tmu_enable(tmu, false); + imx91_tmu_start(tmu, false); + + ret = imx91_init_from_nvmem_cells(tmu); + if (ret) { + writel_relaxed(DEFAULT_TRIM1_CONFIG, tmu->base + TRIM1); + writel_relaxed(DEFAULT_TRIM2_CONFIG, tmu->base + TRIM2); + } + + /* The typical conv clk is 4MHz, the output freq is 'rate / (div + 1)' */ + rate = clk_get_rate(tmu->clk); + div = (rate / 4000000) - 1; + if (div > FIELD_GET(DIV_MASK, DIV_MASK)) + return -EINVAL; + + /* Set divider value and enable divider */ + writel_relaxed(DIV_EN | FIELD_PREP(DIV_MASK, div), tmu->base + REF_DIV); + + /* Set max power up delay: 'Tpud(ms) = 0xFF * 1000 / 4000000' */ + writel_relaxed(FIELD_PREP(PUDL_MASK, 100U), tmu->base + PUD_ST_CTRL); + + /* + * Set resolution mode + * 00b - Conversion time = 0.59325 ms + * 01b - Conversion time = 1.10525 ms + * 10b - Conversion time = 2.12925 ms + * 11b - Conversion time = 4.17725 ms + */ + writel_relaxed(FIELD_PREP(CTRL1_RES_MASK, 0x3), tmu->base + CTRL1_CLR); + writel_relaxed(FIELD_PREP(CTRL1_RES_MASK, 0x1), tmu->base + CTRL1_SET); + + writel_relaxed(CTRL1_MEAS_MODE_MASK, tmu->base + CTRL1_CLR); + writel_relaxed(FIELD_PREP(CTRL1_MEAS_MODE_MASK, CTRL1_MEAS_MODE_SINGLE), + tmu->base + CTRL1_SET); + + clk_disable_unprepare(tmu->clk); + pm_runtime_set_suspended(dev); + pm_runtime_enable(dev); + + tmu->tzd = devm_thermal_of_zone_register(dev, 0, tmu, &tmu_tz_ops); + if (IS_ERR(tmu->tzd)) + return dev_err_probe(dev, PTR_ERR(tmu->tzd), + "failed to register thermal zone sensor\n"); + + return 0; +} + +static void imx91_tmu_remove(struct platform_device *pdev) +{ + struct imx91_tmu *tmu = platform_get_drvdata(pdev); + + /* disable tmu */ + imx91_tmu_start(tmu, false); + imx91_tmu_enable(tmu, false); +} + +static int imx91_tmu_runtime_suspend(struct device *dev) +{ + struct imx91_tmu *tmu = dev_get_drvdata(dev); + + /* disable tmu */ + imx91_tmu_start(tmu, false); + imx91_tmu_enable(tmu, false); + + clk_disable_unprepare(tmu->clk); + + return 0; +} + +static int imx91_tmu_runtime_resume(struct device *dev) +{ + struct imx91_tmu *tmu = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(tmu->clk); + if (ret) + return ret; + + imx91_tmu_enable(tmu, true); + imx91_tmu_start(tmu, true); + + return 0; +} + +static const struct dev_pm_ops imx91_tmu_pm_ops = { + SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) + RUNTIME_PM_OPS(imx91_tmu_runtime_suspend, imx91_tmu_runtime_resume, NULL) +}; + +static const struct of_device_id imx91_tmu_table[] = { + { .compatible = "fsl,imx91-tmu", }, + { }, +}; +MODULE_DEVICE_TABLE(of, imx91_tmu_table); + +static struct platform_driver imx91_tmu = { + .driver = { + .name = "i.MX91_thermal", + .pm = pm_ptr(&imx91_tmu_pm_ops), + .of_match_table = imx91_tmu_table, + }, + .probe = imx91_tmu_probe, + .remove = imx91_tmu_remove, +}; +module_platform_driver(imx91_tmu); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("i.MX91 Thermal Monitor Unit driver"); +MODULE_LICENSE("GPL");