From patchwork Mon Dec 9 21:53:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13900444 X-Patchwork-Delegate: daniel.lezcano@linaro.org Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013007.outbound.protection.outlook.com [52.101.67.7]) (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 0F19D19D89B; Mon, 9 Dec 2024 21:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733781213; cv=fail; b=VkTKlgyxV6Rf9Sg+yOuSHYl7YWQ4jxEVNCU/yRQAX+v89zH8Yz7R6PQSABdZuWlAXwU9Cu+IRBj3xPukFtlURwjHtZ6mtmIpVMohLL2Ts1bB//IURSMCliq+To0WRg7OsRYBSvDlu5t8IcKSsoBNexaaU+71KpV18ebB1jHjqtQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733781213; c=relaxed/simple; bh=r1D6YleI4pfbRMudJcC/mpaiq45dCNo3RsDTZ3TyLf8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=MKOk5miT4kfW9zgahNcrbSmwRfBmpiKj+9Cr+p5Q4Z4A1AWci6kMNBr05LR5Azve8qa1oGA6VsxJxVgZjcQeBUZ0vtH6nbf7Afb4xFMTbkT/0qX80VlHgEPLRTI8oAEnS/4tOXJ2/ItWzx9Ja1sMwT2W2WTwk8Y1z8D09Oy/eyE= 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=cwVRATEp; arc=fail smtp.client-ip=52.101.67.7 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="cwVRATEp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FWSX7dqGC731GCKWw6m8VUFPh6CBoG/9YPtoDVqsp9ZCGmm3q4KuZS22sRqCquWTnpzZAnLyVN9NcoXyA/hN7QLCp/eCb+zvPRLW+VyOmOPum3Zhh7xnxIc9aqCQY8AwLr1jojIjJHVZR4iBuMk7aMj/mApL3RHsddj+cImtCAPZCFajVNdj9gt2EXMgYrncG/24qaL41pV8v9BW+i62RaRI8CmdjmOjHmb1nK3YdyGU+ikUVaPp7+0Q6cvJ7dEirRBkvQRSMokti7X56pnNPVEB0W0k9/7mKWULyzlO1B5C1/qSgXwn9dDxdAGLdPR9Hd5jrsjOPNDKrXTQ4dHBCw== 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=suOON05AsPllKoNx8nhPu0aGIihaOA9mJzYgyDv86gba6MLhfMg5+bZQz/Xy4fJLgm4QQdYReRHTSxiMhv0EIZXalPUdV3hKrGP05dURCB6dFZhDuoSxoeuMt0xY11AZlngohfIeDjkKqjfOiEB+7rw84UtGtDmOLTT/sTaQfI5NrvuIqd6g1g9XxGoB2xLqJTFcbisooVLyuOhu0Y4TmMvPBPlGIlP1dom2chkM9/ZhWl7ohVEhTnDxZaDc5oZAIV9t6NyFDN4tf7hBm9BpVwwaurGojl2D/RgtosLW/q1c+HpQcooB9BscTcKMqzMYlAnBT+RCVRtBLczIQe1RoQ== 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=cwVRATEpu7tNytxcn/CgG/KlcWIOOw3Lh4FAgxus4vs6veJHV3LyeimJyMJgKqEZ5VFPxzM6Z0zjN2yBIRaAeUAxf6YmVMxrk5EVdQu6xT3588l1cdpFmgnZSHVCi8Ld8gUSrZb66ma4O6GiVcqcY4w5PHXBcUCaTM62GY/fRih5iX+1pqam3/cCENcZJK7CnFW9ykyDt8fNVvuhF3EklP6YWJC698ukIt8POQvG5pmH2l6zY+CO3EQYgtP5m7K80JBZiEKPiR/XQ7W8QciD/6P0snxbByvcd05WAPobVmDecUlAFbVWqL2teann8TRacOxsw17HIor3Caw/ibG71Q== 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 DB9PR04MB9818.eurprd04.prod.outlook.com (2603:10a6:10:4ef::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Mon, 9 Dec 2024 21:53:28 +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; Mon, 9 Dec 2024 21:53:26 +0000 From: Frank Li Date: Mon, 09 Dec 2024 16:53:04 -0500 Subject: [PATCH 1/2] dt-bindings: thermal: fsl,imx91-tmu: add bindings for NXP i.MX91 thermal module Message-Id: <20241209-imx91tmu-v1-1-7859c5387f31@nxp.com> References: <20241209-imx91tmu-v1-0-7859c5387f31@nxp.com> In-Reply-To: <20241209-imx91tmu-v1-0-7859c5387f31@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 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=1733781197; l=2218; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=iVQTtCNDQDMEk1P8NXmCJ6s4gReJ2DPWuwpLblkVduE=; b=pkoOOhbdccrJsmUeD8dR0pITRa5/TbrLr5S24g2XYlWeEGQgIVAihdAPB+3Fd2YjcJ2PmQcLd ne0xpHWkXvxB8JCk5wKj+Q2B4RF+yANH85g3qL+bjLSA2Ge2RFZuYAJ X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0158.namprd13.prod.outlook.com (2603:10b6:a03:2c7::13) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DB9PR04MB9818:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d21bea3-4ec0-414d-f4ee-08dd189be910 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|376014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?bsYqPntD7hxAm4OeSgtb9SA8VkRg8/p?= =?utf-8?q?UR6Lz1a3nQRe6fTp/HrwK3VWa7TJrUO1vgRekHGTJkvS7zn3vNeTpAJV/fGJYwHnR?= =?utf-8?q?sVaoZnFUTMDpcM6gd8ZXjekHU5M/v6+yt7MT23BhnjAq1uPDfEmiyVMhLKl3WqmIM?= =?utf-8?q?oE4MZyRx3cYvtb1T5w254G567bvpYVnveAmiAttXAIx2u/h31ZgragwA8t3IWdbOC?= =?utf-8?q?aTFpyVz5uTmN6pshr+V8m3G4n1KhNH03MOxVHuaCSiGy6LKeM5pTQXpnLOf4Ga7lw?= =?utf-8?q?SbtHDfGPEOWx0CYdqpD5mDAX89Uk0yXvaR5CG2nisFfgsKs+0vA9Atz5Wcz1TUnxj?= =?utf-8?q?JdapqyAVakyc4TGByYAaL1N0k7VE6xawBDlVfdPf+8Vzus2RKonL+CFdNN+Bic2X+?= =?utf-8?q?8ahlvUAU83hUOlzxD24jioRFb1MtPbemZccpYUpix3GQBsl/lzDMKFWc3F5BjuFOo?= =?utf-8?q?Rr7nf5oR8kNuNYqCII/k9J/OpPuqkcnfbEYJMA5bv3mpAiOS2nnxESPvLOVoinjBx?= =?utf-8?q?38D3QcIxAsRBSekpdIx0/QRB7JqTC3fSd0ZRghHRWAQZk/E1p/vu6FXDa2r7h4Mfp?= =?utf-8?q?rGqXWlKPJ/DRRrdo7fu1nwFk2vM5cOJduueG+vIdSY11bJ0dTW0WT2RxxQG859zNX?= =?utf-8?q?WvbtrPFdmZV+GcpLi8hFx6VqDOQATK4TaytCXWIk62EdOf8Q435/wIzanKoppAdlM?= =?utf-8?q?fBxKxBUOzzE1Es1hEGIIOK18a4fV0668X/A9gkH2wR85HAsgAisKPeV3qwBLzg4l9?= =?utf-8?q?LaS3O/GP8cCxl5cnKN84Dv5ao1WTA9kiPAuYNcaXpZ3OQ82HgimMeVpAVZfONlQzX?= =?utf-8?q?2eavgWB9hpmWuPDHZTrfW7IpvcgedAg2Y6nfLX7U9H/UAeL0jftCGCbBxyYAAVEyD?= =?utf-8?q?6VlRrUa4d0KNVHV9mz2KKPBFI5t1CrbIxBhkDvILhO+RKOwlGL9BrWU6x9WshKKg0?= =?utf-8?q?MIVchAYDzg1+HXFOpqHMWv671noWrfMpOguHRjnPzIAKOtgz271Iy4pZbnmkEh/fX?= =?utf-8?q?TisrupkFtMVph61ZW9kQB9nfh2aYhGi80atl1Utxrj+f2g5pi/qVe/h43Bw6dCqnP?= =?utf-8?q?hjCSmBJhDktVBIkwfZoHXkAQGtR0JbAbzqdOGG6ZOgWWd5K0TBrBbhe4AhVfaQN+g?= =?utf-8?q?TmqtfV+6PH4jascRo9gWW5L35JWckK2gdRj005uPxpGZZjsMoJqttNayuEsJT7lbI?= =?utf-8?q?YPeW55eWyE5Vdb2Kaw8hkBezr4bq69/vtAMvDvNPeVKQJBlwLLjnllXiNyBm6xhji?= =?utf-8?q?0tWZ2F22Fv0YqgyDh9miPxorM3tIs0lvHynw77SRyg2+yLH6uKre9swHXljlqO/SG?= =?utf-8?q?3InSyPvzsYQb?= 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)(7416014)(52116014)(376014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?NrX4f9wSm24sXJUkaH2UqpbvZNH/?= =?utf-8?q?dkx4P/CO16R3EqoDrChTxQItnkjPXoRiYM34dpqjeQ54ifZ+iE+Gio8T6zpvIzpMW?= =?utf-8?q?0IISj9pfJHdZSo82mHIgTOgXPbAM08o+0ZZdrOJ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N53U/wDsU8n?= =?utf-8?q?bbTMTzEIMgnDkT9n8/qwU7V0tvtG1EzrkC8nVVdweCELQ554XPnO9ZUcKSEiKhegU?= =?utf-8?q?kJrmk8y7GilaQ5HhQE5m8q9YPHjNwhJ6ZvccwsRcDlt0iQ9F1ZFTpFp5THjxXKOxW?= =?utf-8?q?ZAMhf7i9sUGDAEbHIkBpWcWT5q8Bp6Y30wVKNW94aMAiADr35xrDz3ri+1Hk+6Mst?= =?utf-8?q?qhRiLlfByb+g7VPnPf/dBrO6NDgcXvWFV4fzLlfqZp0STSu9Or9ddcOXI0MMmmJcX?= =?utf-8?q?n5KNkoM28pZJ5AoLXEvfJTfc1chGCY8/2b/kChbWDqbTQtYLsgH6EgTxUiqDrsupB?= =?utf-8?q?LSCs4NZsuNdBagCQMuUenAdGSirM6tSaHoEZePxZVpRcSxIknXCeEFy3U/GNYzgKn?= =?utf-8?q?hCVbgahOQIWvGzmW2cEclQ+o2Jux9oxiBMvoOBmWhpCS8aqEaA+4qome7O1Mhx2nA?= =?utf-8?q?P9OwHrRfTwaJcZECvN3Q3BWhdf8+HxkQWiGLdzaubCKgxnCJt/Jlmf/w=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d21bea3-4ec0-414d-f4ee-08dd189be910 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2024 21:53:26.6591 (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: 3fNDkkren3mXRl9ueUifeVqPgiOyAOJR/sltFr7q2PmyCjGZSAL+JorhXbOFnqOFDhM2vgouf6oxfVZaFxm7ZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9818 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 Mon Dec 9 21:53:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13900445 X-Patchwork-Delegate: daniel.lezcano@linaro.org Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013007.outbound.protection.outlook.com [52.101.67.7]) (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 7AC2E19DF75; Mon, 9 Dec 2024 21:53:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733781215; cv=fail; b=G+jtz8Gd8njdGiHGkuqrfT6l4B9Ad4IdIm1Ip9GLWYvO77vYPGo0UPdEsINVxazF7TKIqZK9/F3mTaqK/LxiHXPRd6JYRHmsgJo/bFQv6dmZ33drOdBoRj7wF3r/25HL4Q1c8jXQ2iBclnG+dPv+mbBf3rCQmUa8BnpFbkcYI9Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733781215; c=relaxed/simple; bh=sFExiCv3YKtMjHKSnTrqvKkjdtXeDGb8mombA55K5OI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=N0egRURz4xjD0yk9uajyCOjvKgc5uLk1JhuLlSoO2rqvEu4CbTCA8nZSHO6OAIxcA/zyH+e3Jl5qZAhsfm/ImSNXeq6QYIuV5S/r5KGLFCHrTCci3GWveEE1I067Jp2V2HdhOFC3KvozK3ckp49mfXW5fWII9/Fqdzr2EaRhhck= 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=eeH6EBtg; arc=fail smtp.client-ip=52.101.67.7 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="eeH6EBtg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qNVJBQHFpR8N/k2RFpJiUVHaiPc72vxQog+t1WY3EKZ0+3ENSfmQ2jq0JUPTDELjtj0qQTnDdXJII+RIekJ8MfcrxHeicbVw8fPFOlLfF6aOWU3/31QKxfmV+dOFEwzZZckdSYwDztZlN+94Xhyt2RsbuxmT/0u21edQHmz1cN7nhUjrrQz2VGnpyqSp6tPT8o428XQASMp2QyPVfSYshZC8NbAXeU3nNa+itEu6fGEcWxSR2juKjOJiTniR7xEsOhDpJ8eTM2M+9dvE505BPfRrMvH8MwCv/5G/Kzpg7Hr+Z/7Gy8Hx7nWlRudDrYY276wrDqw8/jysrlaiIl8C0Q== 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=bgtMCLqyqGK1BODw+TI3oOGUb6f940l4cn1sIEKmyyU=; b=m1eCSYlR0CwUVNcRoXId63gZjunGufWy8eJX4H84+SCNVvMmz0OB4C7QakpPC0MjOqpXgSp4/B61flve9VnBLqzWoOFcjQx6QWS7jny/RoOBNtUGbQbtwCJSXkFIL1uSFmoE6ZAT5G4lqmd229GRynaiOljnc+R2WE802Lnb34T+gGSNuV6BK2d9nnIDMPe+bPjMZSkzSs19Fh09/dum+fM94CyFaoaUJ2hZyAtylPQneR2H6JSvHMTsdPphUNT1GMQyzagB1u+l9Q8Ntc84Dy68XguhaU52mJ/z7mk+h1W0THlDttIO2iTGq0fgbwkrWHokiVEuHgs8xfOJih9TRg== 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=bgtMCLqyqGK1BODw+TI3oOGUb6f940l4cn1sIEKmyyU=; b=eeH6EBtgWzEafmvWonaYp8LeUG023nxwUedi/fkgUB97sHHflIwBOtZAeYBSnHeGvJpFRucuP/EzH7t5HsWpsOYWCD6bA1aI9OWLaYhviLjNpYN2U0WPcz6Z1tLJoIo7uTGExsXkNCVj2q3c2kxU98mhxo59GOyTQK0bD3VsJ9q5tdR5CiqQS8gpU+6ZK6xBgfMxmGwyDwVc0LBcSnx3FySOPcPsPIHppNAJ9uMGGeJtorF5qubSjfqxwm+IqJYBFEk3oLcG7IwDTPbTa/hDEWtwDfkYn4dcWpkufDrVZZAUjuTmayt1Xbv/p5Sx3Ox3roO066P5T2qTWAKFPNp9/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 DB9PR04MB9818.eurprd04.prod.outlook.com (2603:10a6:10:4ef::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Mon, 9 Dec 2024 21:53:31 +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; Mon, 9 Dec 2024 21:53:31 +0000 From: Frank Li Date: Mon, 09 Dec 2024 16:53:05 -0500 Subject: [PATCH 2/2] thermal: imx91: Add support for i.MX91 thermal monitoring unit Message-Id: <20241209-imx91tmu-v1-2-7859c5387f31@nxp.com> References: <20241209-imx91tmu-v1-0-7859c5387f31@nxp.com> In-Reply-To: <20241209-imx91tmu-v1-0-7859c5387f31@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 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=1733781197; l=9745; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=nNhwjFBwQVTIDJisSK0WnxFeaeyXNS38R647unJN1/c=; b=oKDonfw2+8yyM63EMa1d/vz7hxajUM7XNdK7zgSes1nQEgHo8FtpgzPMgQ3vBPGoQV7wZbdbf bUBNxv9PS+QBO3Cq7FOIGonyDXvWMiyXspI2LGhmvX2ciFQuE6Gr8uP X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0158.namprd13.prod.outlook.com (2603:10b6:a03:2c7::13) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DB9PR04MB9818:EE_ X-MS-Office365-Filtering-Correlation-Id: 7df96c2b-6f5b-4b01-86c7-08dd189bebb0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|376014|1800799024|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q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ocCHxuRNWQIsz46CST4nrsW+bVAoz?= =?utf-8?q?PqTmCy3AhlDJPEF1FGlYj3wIlaHjGSlXhIc+ZB589I4s+8WU81nuVDswjjfJFvZ3J?= =?utf-8?q?6y2xiXX6BecyBRIjCI9RRDwonKEp/M2od0CRHQYVL/IYyF0tOrEzZTE6U9l6twaCb?= =?utf-8?q?euEiNhWMKp7p4NSzfDaZgdXULNGZTHWJbA5S5G1lU7rPJAZtHvIEzKQIgiMafIA3C?= =?utf-8?q?DEq658BlAahL+K2yz4rB3RZAuRxiQR+4n9j/hSKPgeFSkPSv9FCIV3PiZrAPkM7iO?= =?utf-8?q?PwzX6HFYn/9g6w0h5FuAXKlBlmnsKkeu8ml8vkEqDOu4Z2NKdu4/kc3CGmyTWcMD3?= =?utf-8?q?kiUv24s7ycezVmDUavNmMtSc/UWV+qlIFH6iW6vqTfDv12G3l5oT6FxeftSH9CuJs?= =?utf-8?q?fgLvMa1UdHY82P6JuUemwNTb8YQvOzkkHI/LluMPaUsfQEAsloQlOToqqis/EUaZL?= =?utf-8?q?yg0Rf04iQxvcfA0jOJXdNUab6k4he6CcM2p8uuD35h4Ei7f/2jxpAPg=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)(7416014)(52116014)(376014)(1800799024)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?dzupxsSxFvLw7CrFL+f4PbqTyxS8?= =?utf-8?q?CoXh1+1YlOthQHO39fCHtIcikte6N4oWV/AyRg33KugMZRbSitlKhpN89XTY4JwOZ?= =?utf-8?q?+pnzpPToK+cRqGwB8/TGwKMhdfj4PS0o7HkohS/z1KGktZJ0L0ddDkd8bIDvF48Yj?= =?utf-8?q?oXKwCN7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EFq06l4lyoqtXbPHkBfYsbGewryBfAA+NWXv9msSa?= =?utf-8?q?pxnQJ2CAk79pBS/7/ELwtUNwdvWIMmKjZEbaIVIQTa9fZHj1TvTYVM+qntxuKJer3?= =?utf-8?q?BG/Quo3MyJLXyQ/xB8coc6+7WjTXWwNY0kh4AnbfU7U/hAGUA08He97FYWvNNS+D1?= =?utf-8?q?b4zKnFHtTyC9OJjQ75ZUSCZjQawEVqBHtzuUyxx7mz3B8R3Kt+y8vR3XOex6snonL?= =?utf-8?q?PsOQeN1vfNjx+Arvi9GVKvdgLGP+wrC1jkf5RnyJjyQj912VVwoUFO8it1P6xNl+b?= =?utf-8?q?1OqWXYKx8cICFmiQ7sJBoG6+CWutZVgZWQzX/EN8cy0gxXz/yqyxT+3YFfNvNga8S?= =?utf-8?q?9f5d9fJ4ynZXxu+q2kRFjg3YDnTJaF8LbLYSFtEkyvkzMM7AXnKT8Q+/GVDyUHngJ?= =?utf-8?q?wv8ML7zNTSCIrqFmQGYByEBY7Ft5drZ1tyuta9BRxk6iQgQEWedKVSoc=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7df96c2b-6f5b-4b01-86c7-08dd189bebb0 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2024 21:53:31.0660 (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: XRFnw2C5Vy9xp75nQVlQ4B8PAnqI720i5vepGNA2E4lbgZTHy4aBFQPTBWJJfEY8iFV5U9fmsAoINxZ9Le95YQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9818 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 --- drivers/thermal/Kconfig | 10 ++ drivers/thermal/Makefile | 1 + drivers/thermal/imx91_thermal.c | 281 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 292 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..19c4dafe9c7a9 --- /dev/null +++ b/drivers/thermal/imx91_thermal.c @@ -0,0 +1,281 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2024 NXP. + */ + +#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 DATA_INT_MASK GENMASK(14, 7) +#define DATA_FRAC_MASK GENMASK(6, 0) + +#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 PERIOD_CTRL 0x270 +#define MEAS_FREQ_MASK GENMASK(23, 0) + +#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 0xB561BC2DU +#define DEFAULT_TRIM2_CONFIG 0x65D4U + +struct tmu_sensor { + struct imx91_tmu *priv; + struct thermal_zone_device *tzd; +}; + +struct imx91_tmu { + void __iomem *base; + struct clk *clk; + struct device *dev; + struct tmu_sensor sensors; +}; + +static void imx91_tmu_start(struct imx91_tmu *tmu, bool start) +{ + if (start) + writel_relaxed(CTRL1_START, tmu->base + CTRL1_SET); + else + writel_relaxed(CTRL1_STOP, tmu->base + CTRL1_SET); +} + +static void imx91_tmu_enable(struct imx91_tmu *tmu, bool enable) +{ + if (enable) + writel_relaxed(CTRL1_EN, tmu->base + CTRL1_SET); + else + writel_relaxed(CTRL1_EN, tmu->base + CTRL1_CLR); +} + +static int imx91_tmu_get_temp(struct thermal_zone_device *tz, int *temp) +{ + struct tmu_sensor *sensor = thermal_zone_device_priv(tz); + struct imx91_tmu *tmu = sensor->priv; + int val; + int ret; + + ret = readl_relaxed_poll_timeout(tmu->base + STAT0, val, + val & STAT0_DRDY0_IF_MASK, 1000, + 40000); + if (ret) + return -EAGAIN; + + val = readl_relaxed(tmu->base + DATA0) & 0xffffU; + *temp = val * 1000L / 64L; + if (*temp < TMU_TEMP_LOW_LIMIT || *temp > TMU_TEMP_HIGH_LIMIT) + return -EAGAIN; + + 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; + int ret; + u32 trim1, trim2; + + 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 imx91_tmu *tmu; + unsigned long rate; + u32 div; + int ret; + int i = 0; + + 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_prepared(&pdev->dev, NULL); + if (IS_ERR(tmu->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(tmu->clk), "failed to get tmu clock\n"); + + tmu->sensors.priv = tmu; + tmu->sensors.tzd = devm_thermal_of_zone_register(&pdev->dev, i, &tmu->sensors, &tmu_tz_ops); + if (IS_ERR(tmu->sensors.tzd)) + return dev_err_probe(&pdev->dev, PTR_ERR(tmu->sensors.tzd), + "failed to register thermal zone sensor\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; + + /* 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); + + /* + * Set measure mode + * 00b - Single oneshot measurement + * 01b - Continuous measurement + * 10b - Periodic oneshot measurement + */ + writel_relaxed(FIELD_PREP(CTRL1_MEAS_MODE_MASK, 0x3), tmu->base + CTRL1_CLR); + writel_relaxed(FIELD_PREP(CTRL1_MEAS_MODE_MASK, 0x1), tmu->base + CTRL1_SET); + + /* + * Set Periodic Measurement Frequency to 25Hz: + * tMEAS_FREQ = tCONV_CLK * PERIOD_CTRL[MEAS_FREQ]. -> + * PERIOD_CTRL(MEAS_FREQ) = (1000 / 25) / (1000 / 4000000); + * Where tMEAS_FREQ = Measurement period and tCONV_CLK = 1/fCONV_CLK. + * This field should have value greater than count corresponds + * to time greater than summation of conversion time, power up + * delay, and six times of conversion clock time. + * tMEAS_FREQ > (tCONV + tPUD + 6 * tCONV_CLK). + * tCONV is conversion time determined by CTRL1[RESOLUTION]. + */ + writel_relaxed(FIELD_PREP(MEAS_FREQ_MASK, 0x27100), tmu->base + PERIOD_CTRL); + + /* enable the monitor */ + imx91_tmu_enable(tmu, true); + imx91_tmu_start(tmu, true); + + 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 __maybe_unused imx91_tmu_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 __maybe_unused imx91_tmu_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 SIMPLE_DEV_PM_OPS(imx91_tmu_pm_ops, + imx91_tmu_suspend, imx91_tmu_resume); + +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");