From patchwork Thu May 30 13:48:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haylen Chu X-Patchwork-Id: 13680450 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC50EC25B74 for ; Thu, 30 May 2024 13:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rCXJ2Yfn33Mx5oF5TV0FthUytFL0elEA4mxmcT5gHrg=; b=kl+7EjMvrpy+WF V2N4NRrn53vN7ZaBrsdZ3GJXCk4fEbLq4ZrhcmZGZ6Aqu0BMVhFHuCM2ZHgpogLL/9Vf/0TWP3DdS 7QiCJ3O8lttR0xIEXSbEki9V6EjOrF+oRFsO4TqZAYNrmLtxPVX7+JdlZKwM52bkilso4wtJxJtAL +pxqavEykSddr7sBdQEmPYNIGnhE/6g5/rL0clTBbkp5OcJvSULhukjeGhckS2zSr/hy9UxSRLZBp r87ze8lSKWnadkQYHJwqy2C4qzRVBM4sobbCA7ED2abRkVk395PaMFhF04KprNxGO7QvDjBCVvO64 RdogiXT1hNtkBs89C6wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCg9f-00000007Qak-46qg; Thu, 30 May 2024 13:49:19 +0000 Received: from mail-sgaapc01olkn20817.outbound.protection.outlook.com ([2a01:111:f400:feab::817] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCg9c-00000007QYF-41os for linux-riscv@lists.infradead.org; Thu, 30 May 2024 13:49:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVlEyphrYNEqlYzXEgd7GiAkismHwjj61EUer2KF4Rfjq7sVC5QJjV/Jsq9zabuk3m735VJ0gXieb85vQzijYV9u6m2X4ECrklXX3X7iCoXInwxbD5akudnwo8SJqRKMCnJtkm23sK5ZcN/BGotd4Su914V/DTYJdpvBEEec616Iw3NRy+eCyQebe5QQHVKy3/7x9ceypaDuzC/qt28Hro6pUi6AiJQWJ5QHWPdld0o3MUT6uQSayOm8dF8ysXKWXv696dbC3MhKaqLaP4LI9pZFuHW9OMbQsjzf6ctR3olQWmSWYsfVg7ADueuSJtdHkemwE0Vv/7ODUGR9VKZMXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=eEGmuEkXi/wCkmyMBV2vONT62dw/AEOJbhyOvWh1GW4=; b=loTeq4z8livV0bKomBHWyhquqhG/Xg73+oegI72l5RSOUMtjv8jlJ56EXlQDKvl/F3vB6LmQomeRaaojTyVpPwcSL3zPJRXa18xr2kGHc01L2ZyussyElXSc27fbvm8P+tQty25i7nK9XyxubMmg4w1QmazQyvTrNQvh2Z7NTGhkSYZb7YgDN9kBT3ENgusycAY3wDrEcoXIUwDwlg82OgRpJGty3TYlWev3kIuaLKwR3mtxgHYhzDTGHHRcS1673ZLhw8o3J3kHTzzN62OPIonSKulDEkbSHA/pdMlVJd/sgug9oyFryRv8quOjNasx5BMe2FXN2C8xO995fiquoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eEGmuEkXi/wCkmyMBV2vONT62dw/AEOJbhyOvWh1GW4=; b=HPxtMEfAy/c5NMk27sclzzr/zJwg/QOLVRdptq4gQv1Q+Tu1Zm5Y4KVqLJVPjNdf0IUmGfkUGQO9psF2QtLGG6gr29VYExMwd3pMJTwnuUDjH27cLKb627wTAqoM3j/OJ84gk+UIEbbj25vf59Ri/97AKfZBGcfRC1Dh+IRuXm7xKipkH+9ihCeWByRRS2gBByNx9RCCgDDYLs6HJGfPoRFzuC1QZRJSCXm7ItGd3ruK+FaO9rXvjTglzRDOSIhLwiNiurZjkzj1P61xpaUX/LcTkfJttszFJAvZFIHKkRKzsunmMRDvtMkYNjlcaNYwHjU3L5kSKsdi0lswOQPMfQ== Received: from SEYPR01MB4221.apcprd01.prod.exchangelabs.com (2603:1096:101:56::12) by TYSPR01MB5657.apcprd01.prod.exchangelabs.com (2603:1096:400:42c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Thu, 30 May 2024 13:49:05 +0000 Received: from SEYPR01MB4221.apcprd01.prod.exchangelabs.com ([fe80::b674:8f70:6e29:3756]) by SEYPR01MB4221.apcprd01.prod.exchangelabs.com ([fe80::b674:8f70:6e29:3756%4]) with mapi id 15.20.7611.030; Thu, 30 May 2024 13:49:04 +0000 From: Haylen Chu To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Haylen Chu Subject: [PATCH 1/3] dt-bindings: thermal: sophgo,cv180x-thermal: Add Sophgo CV180x thermal Date: Thu, 30 May 2024 13:48:25 +0000 Message-ID: X-Mailer: git-send-email 2.45.1 In-Reply-To: References: X-TMN: [SU+B3YdJ4JmdzkcIigLXR3szeJ0yfAP7] X-ClientProxiedBy: SG2P153CA0036.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::23) To SEYPR01MB4221.apcprd01.prod.exchangelabs.com (2603:1096:101:56::12) X-Microsoft-Original-Message-ID: <20240530134827.53431-1-heylenay@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEYPR01MB4221:EE_|TYSPR01MB5657:EE_ X-MS-Office365-Filtering-Correlation-Id: 344d967f-648b-411a-43c1-08dc80af44ff X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|3430499023|440099019|3412199016|1602099003|1710799017; X-Microsoft-Antispam-Message-Info: 7e5W/w5rFkvBF4P0TkGfdxWPMSExDGTLnGwADNtMcT0ye0CvKgBkZHndOWGcj+0Qdf6UPwBSYiQIvLvZ6IHd9YSglXS6WGxv29zn5MscHUK7+hmlTH1D3ViyKCrYCHMi8YUs83W4tRzK4/3gqCtE/elXiKYBakgU81nGfwq5Z0+JkMBOupYItFAukNqW1SXWbx8FQOrS1l8+6czQqWBYI6q4+/VL9gnl7HJc/CEvMHno09aM5p2OqcycpGQGQ43DMcwlVga7FYJ/5w6wuo9eudCFyDQsSFSVBMld+T/XI1hK4rPz0TiMhlbDTF4awB0oT6PwGCkeTvWmhFE1VB3eVSW9M1pOIoVMIEmyPdRyM5ya7/mFVxf4K7t/xVe0gbTcfqsgKVFqprui27r0Eb9qDbR/h6KSBgtX6zPn+nB1gwtdW/5ou5SNoUmMPs5lUWXG7+3soeA3K87Aqb4uYwKYoOjT0+e4A8GEttOWy0J/sB+VUpWA7I6CLC6x+cgxEVc1745C2GaJBPbXpdPWmscpNLCOB1y9IlG8obqGTP5PE1rW7sWE7tM1YKld1okIQYzhtcvcdpoc6wQvXZtGaxWNSP4NACf++rkiJNtngWoXMb0xy4iE0a2By/EsTdCgDXiryFicOBT5vfgQlLXu4+jtXhbYVhRd6ev6LMVSdV2Vnn0VvURojKAUD4qbWwFRg4YhBnwUF8O3Mgt3OnmjsUIjNQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QXDpuFIsrpo4V9iKvZfdlF4K4vUGOdbc9EDXY9JiOpUmSLMiX0Q1sY8bo31mdSROlOAC8GTjkJbA+I7KUtT0KbLblErpnn0ZvAH1G6jsy+jqvDnW2I32xEzKPBcItiJNPcpJTea8B5AX3HeowUZoCoQ//eg3ZJdj+E2kymjqJzPCvnnbvBvipjoE6SfxcI51q1wpkpPG5Q2Mv8BwJSKx5wAH2ezvCOxpJXiWBBBDSD7DJ8i+Tn0Y+4ScYcegLPF6wsNO5kye21nquyir8z9jA7JqtKA+bm1fnZ1JvH8M5xeQGMSnLmGoKOGk1MxaEPeg4hFKTqrHdjiEweiCcIUhxvYsuKRAOIj48h3uYhgyoXas6RkHFoPb5JRqvLylFJXRLb+AnTUtFy9KAg952uf7ZHyqDDbNklgoeik/NuTbTxLiCmWGDWHlB7JccUK99G5m88+6EZyjmbDNB6Qz2DtvajMRdIA6lItJOs8E95n/aNEM1hCumhgPI91aFrKy4FARjhFS/xMpo3fvBSIR/dPyvaZr72cj7GCvel/wdoiXYPi+7dM6Xw74OTb5BFB6kjMGJ6O1uw2MyyVsnyi5/+D7Wyxm+7ZjqS6Ql35FG4DtXJnEuaL+dDpP1QTgIECoocYo6oEihfIq70+Jw4U8m2qsOlYTxXZrhC7kjEoujCMnSN8mIET1wA+zI2t1moLrBEsQ5tXwKdPV2bmitNaVdBJb00zgTb4Z2fRXk48YWYaTcUAdLC3DzV7+IgZlr0dS96NIe4jepmtdfYWNRi7Yr6/YIRo8FpG3hid3ciPG1jgUEmVNnGoXWw35uHGFHovvTwYsZeYezLlKy3x/vPwOz2apQAoHNDca4RXFraowN+wy4BmIG3vCz9YFLjGVqwSriLIo2GfJV2CV3rW1NZ/m0xRFwhLEG+o8v7H1iUfiXIF3yCSqGQSqQPypG+snZzzIRrZ6mYLLr/DjzqvO7o2/okuhMZRBwzo8A/NGPz1cB2OiBhpbxZnTSxezMAmafVfXu0M61M/+dO5Uu5mBI+V6rs7iVydm2qQz8LnROcLCznwwhZtcA7LMRbHBYCOISCRzwnqTXFvh876chnbenixU3W0YT/qSbHQti21jMhXPvvmY/x0HJN0Ly3w47nA7ONU7WFY4nxEcgOsyc+gTAMdqn7H/BLPNMPZhDNCW5lRAP9F01mepldpirqySZCVXrgbJm27k5o/uf7Zfmj/a5heYbiLp2CS+vRkMikLZI615yTWPdDs= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 344d967f-648b-411a-43c1-08dc80af44ff X-MS-Exchange-CrossTenant-AuthSource: SEYPR01MB4221.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 13:49:04.7341 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYSPR01MB5657 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_064917_025310_68F3410A X-CRM114-Status: GOOD ( 10.56 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add devicetree binding documentation for thermal sensors integrated in Sophgo CV180X SoCs. Signed-off-by: Haylen Chu --- .../thermal/sophgo,cv180x-thermal.yaml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/thermal/sophgo,cv180x-thermal.yaml diff --git a/Documentation/devicetree/bindings/thermal/sophgo,cv180x-thermal.yaml b/Documentation/devicetree/bindings/thermal/sophgo,cv180x-thermal.yaml new file mode 100644 index 000000000000..0364ae6c1055 --- /dev/null +++ b/Documentation/devicetree/bindings/thermal/sophgo,cv180x-thermal.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thermal/sophgo,cv180x-thermal.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo CV180x on-SoC Thermal Sensor + +maintainers: + - Haylen Chu + +description: Binding for Sophgo CV180x on-SoC thermal sensor + +properties: + compatible: + items: + - enum: + - sophgo,cv180x-thermal + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + '#thermal-sensor-cells': + const: 0 + +required: + - compatible + - reg + - clocks + +additionalProperties: false + +examples: + - | + #include + soc_temp: temperature_sensor@30e0000 { + compatible = "sophgo,cv180x-thermal"; + reg = <0x30e0000 0x100>; + clocks = <&clk CLK_TEMPSEN>; + clock-names = "clk_tempsen"; + #thermal-sensor-cells = <0>; + }; +... From patchwork Thu May 30 13:48:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haylen Chu X-Patchwork-Id: 13680451 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16B40C27C43 for ; Thu, 30 May 2024 13:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Bf73x0qwxEDKacU2kAzAlvr3I+91/5UgGJ+Sh9qS9Nk=; b=T07XDLe0amzZ8Z Qq+cJLv4GW5csYLEASCkxrJP9XBf5GLl/duzxSqHIbVh/vj00tzGY2EJTTaiWRqFtY29yNenJIfC4 zt4bIPlw/niy4sWGgXAUG19JHx3z27zuLeD7HUDX5hxGiXPEmdf7jNfb6kLpW/ntKL5P5WJYb45fb hYu2xNcWhUUrqxvQkVAr5SeIECQ10qxuk2HnIv4w1zyubp9HnQdW4MENY5SBAn+RFmD5NlPo0LBlb 3xPQLPuaUJ8L4UXkB28fmO02h0zOPT/OBCUY4bt3quUNgMqHsvNtfZsLZ5+nHg1laUix4U5+Av/ET TSwRNITt0Brdv+JWZJuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCg9j-00000007Qba-3278; Thu, 30 May 2024 13:49:24 +0000 Received: from mail-sgaapc01olkn20817.outbound.protection.outlook.com ([2a01:111:f400:feab::817] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCg9f-00000007QYF-1A2b for linux-riscv@lists.infradead.org; Thu, 30 May 2024 13:49:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EwGNxihuVk4M4+josK/ui3HYxzTY2B3nFrCrkUGSeqYjZkiw6INSwEychwSZTggf4jG7RP2JzoTt3nSCXAZlXmn7t8Ro5UTiFdiC5aN5dpWSnL0sjdIdJqjgaROxOu9ZmV/4emXaYi7VPTs7xeCYLsNQWV3y8/3IRSRrNCQiDDoKXUPdduySZjzSiN728rwn7JXnTni3dDkN8ZQvz/ntdkMogvoFBdfSxVt2ivdICv9QnZrtf6Jp63upEXSR/pPLRUN52koAYoE6YLEKS4KBIUBts4RZB/4cdk3Eheg4ii1GKx74eSyfkE5Jmj0NaLDp4s2nDz+6/WthMff8+mQ7GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=GtGZvbT+opLTcEOyl33/qy+kzhnzNCZA6o30Kwn1ZU0=; b=bqCLsZQ78yXaA4OXgFXulGo8SDvwNKMAK72JwiE8ZiLXVhstm5oibeTYdPcV+oH49/63v7n3GeKrr2wkeCKFbziRrVXbwf4ywbvkW39FqvjYQW8ah/iQAE1SpttyfcFIUJojd4ihes7pToFCrExZ1nFFPG1f3NtlcZ85bi/Yu95ht10MLlcOeWGGWbUkTiCBO49ZWBLFtaIOrbqxgg+tdCDdT+NMZMxF6hfXAP+6ttz7hldE3P/dBDejX3Jb8YXLML73tWvtfbjiNV7dIgDfpSsxLDBc26Yp2XvYA8Mbk9wuDPuFiWFr3G3K4VFrQyIpfUzM0wbbQr0U/JfOfArjrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GtGZvbT+opLTcEOyl33/qy+kzhnzNCZA6o30Kwn1ZU0=; b=QdoOIsERtH0Tas2HUeRc5d9Ye/ekdhfwir0enjsGtPbPgYjPPEUHVEOknowYKClpD41IrIO41AOx6xQG2Ybgq6LLRP0O2gVWQ24llNPUZbDyFm5ry3II67bfXWatgGGFn7gEKk3Yw5ENfCP1HBcrEEhUx7kClcXwJymKQg0nPgVDqBg2Rs/SFu0TNn/XVRx/D8Qqo2EMK/vFLNzRiwK4cO1/T1VYYBl7Zt/k9ls+x+7ndRpGFFq40JBSaieS2tbx/hjjPxIFKaQAt+9aMM1/r7WfJAePwu9oRnuJ/6vKSDKhoSxs2f60l/R5ouJmLkBYLw2jNGC0n3I8qbk7BcBg6Q== Received: from SEYPR01MB4221.apcprd01.prod.exchangelabs.com (2603:1096:101:56::12) by TYSPR01MB5657.apcprd01.prod.exchangelabs.com (2603:1096:400:42c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Thu, 30 May 2024 13:49:08 +0000 Received: from SEYPR01MB4221.apcprd01.prod.exchangelabs.com ([fe80::b674:8f70:6e29:3756]) by SEYPR01MB4221.apcprd01.prod.exchangelabs.com ([fe80::b674:8f70:6e29:3756%4]) with mapi id 15.20.7611.030; Thu, 30 May 2024 13:49:08 +0000 From: Haylen Chu To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Haylen Chu Subject: [PATCH 2/3] riscv: dts: sophgo: cv18xx: Add sensor device and thermal zone Date: Thu, 30 May 2024 13:48:26 +0000 Message-ID: X-Mailer: git-send-email 2.45.1 In-Reply-To: References: X-TMN: [cDqv6Z6241IZmUbL7wqkd8seSOTSEdn2] X-ClientProxiedBy: SG2P153CA0036.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::23) To SEYPR01MB4221.apcprd01.prod.exchangelabs.com (2603:1096:101:56::12) X-Microsoft-Original-Message-ID: <20240530134827.53431-2-heylenay@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEYPR01MB4221:EE_|TYSPR01MB5657:EE_ X-MS-Office365-Filtering-Correlation-Id: cd5c6725-0690-4bef-c82c-08dc80af4735 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|3430499023|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: 4sDYTCID00s/eiq0M545+AAkXR+oaF3ejYE6OQJr4leSLkr9DHLriY9WF3LJJDKlWe8kxsHbDWk1cdD7eaCHoaIju2IUMvValEGJgBofzvXTe8Hs6YWmVG1cw2KQpgWEu6T2VAPaPxaLCc+Ev+20et/N64TU53g3YhDut4TFQHEOZF/iKV3jS2EfA3XI/5KixJ5wrSaJOkWpIOVXUpIJgdDuPzmp8LBl4VrEIWWF3vXMVkVJFok3+acUZWVM9PA21u7VEuJe8MAHhGIuIE+ZKl/0rkTDjksD8bOrDLm5tjh7WJl9m8UEeH6JnaVM3B5mOTH0qHTKWXkrl0Uo5/YIRudo6IVJmKBgjOAy4rmud+4/cbxHWs5ljFarTmGB96ec3w7/G2b0ooXtp4wLc4l+Py6DIGFNtZ341F/qV9wOApOooCWP0Iuo76RKu3hjZ760lOjdrssy8BDxih+kvx4Yz/xaoLeqPKED0Cl/rCFGsOZz0BB72Qqpg2pWXcFrBnZmZL/5iFHX3Mlbz0fyj4hM2rfvnwLwLubXGiE3VcAzwimKROmJCpLUTkp0u2fd7Wl1p7yWnlI8YdLlt+cnzwh9Tm3ZgAgcZ1BP9u5ajmv3IYUi+65hpZV0X+PzaWTBppNC X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OdILJRq6SHzwPtF3IDlMfb2WTC8PVwO1FFGtQY0oLlHA7c8rOA21d8BLifDiOYFkYIa+FBU97D8pRPqJ9KkeLupUY6nX1d9MFkD1D18andCeUy6DSfNas8YKYgQpy0+8AwKz5i54uxaovgVjCI8BJnw+MyOOKWLmgs+76bt675Bg0Dtuw5pg/hEUSKFVxd+Fl6FU13OKqRxvqvb8ovH6GWWPNG196jvXtzTbZeqK3h50xMyjcUOnDGwe50zNJTFHy6r4faslWiV6a9rMCU5i2AsAFy8BZF9b8z9dFEMYlJsDOO1Kemuwn3QnnV3N2FO48YXJZmDVP1hNC+ia7gIrezSjji/vfwpyGSVSgUcfkLiJ8CIBj9uMVpYBh5QtQSmuJSRlTyU1heoibgqzHzVieQdYRkH3s/xZZSjVq55zmKDFyneVdrVto5XCVNN9rXrL91A99F5TDwib+wCnxgqOITFVam5FK8EsVfoYh4eKU8Q6YoPpJLx7KqQUn0XkUK2yoqgAbpZhsE68UG8KYdcDd4y5MGPyoAzbv6JTcWFDtOzUIF+vM3JIsDphuXXcbCBeZLIWTzobm4Szt347+rVJbQFmgxXlNqz5uqc5CLegAf4iNPiTXJFgmDMgTVYFGjt/7obC2S4e30/e2sEGkHOtR8YalFMchVjquiWR009S6hI+m3z87b93l9l4SFohwGvI3AQQSzalPFSBrI1lk9rsHGygbS5nAGswbopYBFdzfhVurycs4VOj0tALWT0pizomgiSAIIeK3PhlTol4hXGbOKSNdUr7ZwcNw5XF8orKFifeVSRVIwER6dHkQ1mw0nyMQeDl1zVN8O0ZRxqfia1Vg9oBjwfMK32F1NnBhA3620uckU7S230JbJH0BYG72tuQsJfKgG/M7/J8FA3LZRefX+UXSaRBjbewm2pYz37BU25prFPDYUsuvZNiVAg/1yBL6CwIX1PCLmAjf0jnUc3DY2Sw2MEFlf2bbiwZVG5os9SyHBKEFtXsF9FMK3RE+eTSShnGusNsuCMS8xvhoJLIrPYPZi5tBCzIC5ZF5RCp0/Ujlzt4IWGJps8elh10Jbef917fPUAlBztxeqPio3UB9XHg12xfsOMJ+Gq16euyHEKst6LJtaYKMok6mpAphpTS5fE7NRNizX39c6LIMUdbnCGEdZufRqkYpe2UULj854wtrw09knFGmAcNxBlKV8G9rPc1o2GkDvIsHHbQ2D3m4eThdhLBk7BznaInaepV2AY= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd5c6725-0690-4bef-c82c-08dc80af4735 X-MS-Exchange-CrossTenant-AuthSource: SEYPR01MB4221.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 13:49:08.4807 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYSPR01MB5657 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_064919_339566_7D022789 X-CRM114-Status: UNSURE ( 8.23 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add common sensor device and thermal zones for Sophgo CV18xx SoCs. Signed-off-by: Haylen Chu --- arch/riscv/boot/dts/sophgo/cv18xx.dtsi | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/cv18xx.dtsi b/arch/riscv/boot/dts/sophgo/cv18xx.dtsi index 891932ae470f..dfb4bb6eb319 100644 --- a/arch/riscv/boot/dts/sophgo/cv18xx.dtsi +++ b/arch/riscv/boot/dts/sophgo/cv18xx.dtsi @@ -310,5 +310,41 @@ clint: timer@74000000 { reg = <0x74000000 0x10000>; interrupts-extended = <&cpu0_intc 3>, <&cpu0_intc 7>; }; + + soc_temp: thermal-sensor@30e0000 { + compatible = "sophgo,cv180x-thermal"; + reg = <0x30e0000 0x100>; + clocks = <&clk CLK_TEMPSEN>; + clock-names = "clk_tempsen"; + #thermal-sensor-cells = <0>; + }; + }; + + thermal-zones { + soc-thermal-0 { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&soc_temp>; + + trips { + soc_passive: soc-passive { + temperature = <75000>; + hysteresis = <5000>; + type = "passive"; + }; + + soc_hot: soc-hot { + temperature = <85000>; + hysteresis = <5000>; + type = "hot"; + }; + + soc_critical: soc-critical { + temperature = <100000>; + hysteresis = <0>; + type = "critical"; + }; + }; + }; }; }; From patchwork Thu May 30 13:48:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haylen Chu X-Patchwork-Id: 13680452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63EA8C27C43 for ; Thu, 30 May 2024 13:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5paAFN3UGDSMv0r1pNZGynyuUCkzBXki7vMedwK7PYw=; b=JHQsR0lqU5mHLl nMJLnsLA2VG7qpW6l3HP0rzm6ADorhU+JVXD5SqdNR1YPY/HQNg/C275+0lTBXWL+V5DTDvqn3xzk s5UzKVIXgXq/VkyH4Ch+fJyhcOIWqI/6q+rY4OxfJqD09U+naK+WKMkJ1Kj2KZ7jJeqhRd8uv+WVt uLVcWeszF2ASi2cZgn/Oq3qkz2w+J3flH0lpU1WOVugg3tEDEsUIgfjSqg9T1AE7RZaIKOZd2/ZQM MQyj2J7SOi9g+vN/SpMFBPdJ1EGWWR9ZtjQE75GEBmi6hIMCGG+az7mPulmTE1aQhFqkLIltI58UE xFxYro1o/TAIzMAUvaCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCg9l-00000007QcK-0fBL; Thu, 30 May 2024 13:49:25 +0000 Received: from mail-sgaapc01olkn20817.outbound.protection.outlook.com ([2a01:111:f400:feab::817] helo=APC01-SG2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCg9h-00000007QYF-0FO4 for linux-riscv@lists.infradead.org; Thu, 30 May 2024 13:49:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZpLR6XCGgVCZs9kwMw8WVQtoG9TGQuhoBJ1ji8xLYm+o+0WnTctDh0/F0RT6WoPiyGaCjnxXHef/j72XFGGqgQol4MLJHWIQGV8lVa8u6GvCq3XY68SZ116gBbe435UAxTmnbdu64eyKm8seLCSQ3NQkFv1aqbWfwfZoqS+yfiPAffmzRY3oiHwLjvcpE61rMFhMY06HJDVxgiJXEKc0U7uhOVfUNZNBx6FwG26IHC/hbLkm6drbq+K5+/bBoP9Wp7TxLRTulVvniwobYr7ZfSAK9PhwbYpeVKwKGuvLF94PDkRDvJJULC2pdbRmzGa+2YbC1XgGRN0m1bx/I6fL9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=sYss9djwK6bL7UY2NUukNDwb58o4m5NbqYrXWUGZlgE=; b=IAS5mYsoZS2H4KsK+thkSzQVG2V0NxMiOBBSF27zj74vI1r9d+PCOAfJvszLsCP/NPZBsq408AhFF7gix2ZuRysXup2rB+gzBxQjAOBIFPY+3rgl514/CkjmutFu5j9u6uJtC72Ya7oIHflz1EfSbIa55cjYe+PiHXvA/xqNurVQn0W998awEaXJPTaEJNj2cVYw2iIzpl+2L6+fvY8hPVZGwwqaapMYc1hsBITmEImtbRXl+Plzo4KPcUczYsFvwMEGjh0y7mpFgUtJAPeGv/JaM45WJtBW4XuQDxe0MFQWSqyNtnzu296zFwJ/owDUMxDXwJJEcGbAENRO2DORKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sYss9djwK6bL7UY2NUukNDwb58o4m5NbqYrXWUGZlgE=; b=LrzWycIRUDpiVhOFPrUAcGW/jCMgljoHsAP+gM8f5X7erI0v5f7q9BVrz+wLzf4SlMC1C0RJkoNRXAtWH73yBCnoXoU8WXB1Kdsf17KFrYJYgPcYrmfU6z2laLOOWVw/qxUtCSBj/31pj1UOa4ulLGj7idqUuPtJfRVAuswCNZS83HchJ09sjg7Q9aO9UJO++EIDtYaLUaDHCBSOAupZMLk5Xfz0BK4SRYzCgwA7wX9iajubdPcP/5lQJAUG3C3F2ezkYhkFZ7U62YHsMFYzjqaia+/VUX6D889zwfrrT2Fgrs187azZmwh5N2RSBz5Ln+YecZUgMZTFeo/lO1vRiA== Received: from SEYPR01MB4221.apcprd01.prod.exchangelabs.com (2603:1096:101:56::12) by TYSPR01MB5657.apcprd01.prod.exchangelabs.com (2603:1096:400:42c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Thu, 30 May 2024 13:49:12 +0000 Received: from SEYPR01MB4221.apcprd01.prod.exchangelabs.com ([fe80::b674:8f70:6e29:3756]) by SEYPR01MB4221.apcprd01.prod.exchangelabs.com ([fe80::b674:8f70:6e29:3756%4]) with mapi id 15.20.7611.030; Thu, 30 May 2024 13:49:12 +0000 From: Haylen Chu To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Haylen Chu Subject: [PATCH 3/3] thermal: cv180x: Add cv180x thermal driver support Date: Thu, 30 May 2024 13:48:27 +0000 Message-ID: X-Mailer: git-send-email 2.45.1 In-Reply-To: References: X-TMN: [YWUfnzWzre1af1lXCVRyc6z7vzbmpc0k] X-ClientProxiedBy: SG2P153CA0036.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::23) To SEYPR01MB4221.apcprd01.prod.exchangelabs.com (2603:1096:101:56::12) X-Microsoft-Original-Message-ID: <20240530134827.53431-3-heylenay@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEYPR01MB4221:EE_|TYSPR01MB5657:EE_ X-MS-Office365-Filtering-Correlation-Id: ccd4b755-f484-42bc-9550-08dc80af4973 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199019|3430499023|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: ArsMR5ClokS1aixcRWy78DLyFJMDpg9/xenEoQiQsx+2W+Xjpusvc+ZOKKaJKRF217YryRuZJuNfzYa8cK9hmt+J6QmJvGtfnVrtrsvTpIcvNLXJx3NlPxC1gTjrSLLqdz8kfweY98UUoqpt02vhdq8zSBzxk8RrTXpYS27a+iuftivfBsE+0us5RsVKMr9iC9eLtFSQrrdNpyGJEh6IBvvuL9uFrTfhO7MdboNkNAjJCk2M1N1pXdN9SKaMzXKfC+XrAcHG9J+A/Z9IgMfz/ev9Nkg0nG331p0KyQI8Y3MvwtXl6BWvGf8rpuIOeuzpm5/2675v5TXQw7iRrl5pQwXPlpFIB/86G7oM9/QzzYhcyjhiX5WGdHVZ4YFdVw/OWYGSkK2T9VMY3ln6eiXiBhYMVE3pcNXLOl0KEE3o5hnhba7jPjNsGMiMpmZ1tFvNIC3gOqFL3514MUdeLwk/nZe1jnR6RFNWqj4zOt38hRIBkoK+OhMY5TNL+XRbYinkLtpGjGzIWlSmS23mA2lD2sblTjSqvpASN5wtcUy3gydn9DeOGCrCorQ/+fnTqIBAmtvqZosPF1l5hZU1cpvxybWKI6EoEnBfCwkLRu1n+9nK9PkrAt5JBXs6RlbgU4rV X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CZKiKaGZdKumqZ/zeYVEyhQO3n7wYsOeWVE/3FkCoPp/uPcmyVAHwfsZZZxfmYS2i6HlijUJJLRaL0+bYmoL2q9zkkK7LAhovId15946hsPekrObMjDVoBK35pMIMtKoMMTft7koK/3tNOAXfP/J+wAjK6wdiZsAVbKGI3b8BTMMY0pKeEmJ29Ww/Y4OyIFOmNRVzCZ6KPLkpEXVnoYa0V0G3zC8GQz6ndRbezXwRgaEstEz+caKil2eAI5pbgAC00bk9JFa7rz+19+wJrMJaV3tUXllKMaKNVmlvdH38LkKSeeCzvAZa/SxAgwPjcOmzIABOntLFNbv2xfPZwGlhDunZ5TO9KVb9ZpCN2Z8gvfYYyQCAh0R/pJhiIkZV1sEVmIG/JXuE5iFbsW1mpef05RmrgvzBB/taG79F5yO6bTPt2boyJx2e347njSPe1aeOXaohquhpFqHjfDtsWTs1UAuXpYaaPOJBIrzCH5rqbDA0xjvh2pMQOFKPlu9edDkV0CCCEiaZSkwTTDaWDTtrYPmH2uKQqXmdknYQCL4VUMZUK644Qi7fqsDSEmbpIlc844TR8VUj59nXm8LkRZXiTsdtUBC0NpFiMCl7B/DbxmxdjExaQpeGPtyl3tr9LZrjC5Cv3Pc/1RIiqcxG4LSHSdXZbt8dJ2gb3l2jOHV5yVxUDdsQEZj/XfxkfSKMhME7ie/PwRFAxVZ/lhztaH78lc592/TUZA3mpCLSIBsYtFAzG3Y1/j6AlZrdxt7dNeWF4jEcLG+QU5RMReAzgrHulAXE+5SDwnYaqdl5abhUCMJMpml1QU4eHciEE9nv/6W3xJZ5mFhsMUICB2clKf5trxRDvCRlAb67PDcR2mFxt4oUCStLk32LThZcvcoN5dyDXKE9rUtRJRWZIg9xDtZomyYefbv6en+tofLiWb/x4Ep9u1dKG04wQ97eLE/T+AzklJ6rez7RDyfart1vNqKq5sXYM70edNUl3xA5FLgXsy/Tvb0I17lvhkKwnkQX5joXPHGTjcPerLazoaO7LUknLrN0IvLdY7fC5R3bQM8cQ67w/6ToWJffqVjIJkT96nkPr2S/T/AhvF0TQ4oKfQFI3NRLN0YK4M/v+G0oWsjAEH1itA0FS3Kf7WcAFm20i5UmdXJz3dipdMr2m4bds6ML8yMnpd3PntfsLL1SHUFPvFGy8InH6gEGeAsjV1iLQO0ixpk4FjjlO24HoR+2S/f0lWZssYXehTsiRWDwhmkUa8= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccd4b755-f484-42bc-9550-08dc80af4973 X-MS-Exchange-CrossTenant-AuthSource: SEYPR01MB4221.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2024 13:49:12.2485 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYSPR01MB5657 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_064921_132828_1F5F3974 X-CRM114-Status: GOOD ( 18.40 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add support for cv180x SoCs integrated thermal sensors. Signed-off-by: Haylen Chu --- drivers/thermal/Kconfig | 6 + drivers/thermal/Makefile | 1 + drivers/thermal/cv180x_thermal.c | 210 +++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+) create mode 100644 drivers/thermal/cv180x_thermal.c diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 204ed89a3ec9..f53c973a361d 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -514,4 +514,10 @@ config LOONGSON2_THERMAL is higher than the high temperature threshold or lower than the low temperature threshold, the interrupt will occur. +config CV180X_THERMAL + tristate "Temperature sensor driver for Sophgo CV180X" + help + If you say yes here you get support for thermal sensor integrated in + Sophgo CV180X SoCs. + endif diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 5cdf7d68687f..5b59bde8a579 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -65,3 +65,4 @@ obj-$(CONFIG_AMLOGIC_THERMAL) += amlogic_thermal.o obj-$(CONFIG_SPRD_THERMAL) += sprd_thermal.o obj-$(CONFIG_KHADAS_MCU_FAN_THERMAL) += khadas_mcu_fan.o obj-$(CONFIG_LOONGSON2_THERMAL) += loongson2_thermal.o +obj-$(CONFIG_CV180X_THERMAL) += cv180x_thermal.o diff --git a/drivers/thermal/cv180x_thermal.c b/drivers/thermal/cv180x_thermal.c new file mode 100644 index 000000000000..618e031b4515 --- /dev/null +++ b/drivers/thermal/cv180x_thermal.c @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 CVITEK Inc. + * Copyright (C) 2024 Haylen Chu + */ + +#include +#include +#include +#include +#include +#include +#include + +#define TEMPSEN_VERSION 0x0 +#define TEMPSEN_CTRL 0x4 +#define TEMPSEN_CTRL_EN BIT(0) +#define TEMPSEN_CTRL_SEL_MASK GENMASK(7, 4) +#define TEMPSEN_CTRL_SEL_OFFSET 4 +#define TEMPSEN_STATUS 0x8 +#define TEMPSEN_SET 0xc +#define TEMPSEN_SET_CHOPSEL_MASK GENMASK(5, 4) +#define TEMPSEN_SET_CHOPSEL_OFFSET 4 +#define TEMPSEN_SET_CHOPSEL_128T 0 +#define TEMPSEN_SET_CHOPSEL_256T 1 +#define TEMPSEN_SET_CHOPSEL_512T 2 +#define TEMPSEN_SET_CHOPSEL_1024T 3 +#define TEMPSEN_SET_ACCSEL_MASK GENMASK(7, 6) +#define TEMPSEN_SET_ACCSEL_OFFSET 6 +#define TEMPSEN_SET_ACCSEL_512T 0 +#define TEMPSEN_SET_ACCSEL_1024T 1 +#define TEMPSEN_SET_ACCSEL_2048T 2 +#define TEMPSEN_SET_ACCSEL_4096T 3 +#define TEMPSEN_SET_CYC_CLKDIV_MASK GENMASK(15, 8) +#define TEMPSEN_SET_CYC_CLKDIV_OFFSET 8 +#define TEMPSEN_INTR_EN 0x10 +#define TEMPSEN_INTR_CLR 0x14 +#define TEMPSEN_INTR_STA 0x18 +#define TEMPSEN_INTR_RAW 0x1c +#define TEMPSEN_RESULT(n) (0x20 + (n) * 4) +#define TEMPSEN_RESULT_RESULT_MASK GENMASK(12, 0) +#define TEMPSEN_RESULT_MAX_RESULT_MASK GENMASK(28, 16) +#define TEMPSEN_RESULT_CLR_MAX_RESULT BIT(31) +#define TEMPSEN_AUTO_PERIOD 0x64 +#define TEMPSEN_AUTO_PERIOD_AUTO_CYCLE_MASK GENMASK(23, 0) +#define TEMPSEN_AUTO_PERIOD_AUTO_CYCLE_OFFSET 0 + +struct cv180x_thermal_zone { + struct device *dev; + void __iomem *base; + struct clk *clk_tempsen; +}; + +static void cv180x_thermal_init(struct cv180x_thermal_zone *ctz) +{ + void __iomem *base = ctz->base; + u32 regval; + + writel(readl(base + TEMPSEN_INTR_RAW), base + TEMPSEN_INTR_CLR); + writel(TEMPSEN_RESULT_CLR_MAX_RESULT, base + TEMPSEN_RESULT(0)); + + regval = readl(base + TEMPSEN_SET); + regval &= ~TEMPSEN_SET_CHOPSEL_MASK; + regval &= ~TEMPSEN_SET_ACCSEL_MASK; + regval &= ~TEMPSEN_SET_CYC_CLKDIV_MASK; + regval |= TEMPSEN_SET_CHOPSEL_1024T << TEMPSEN_SET_CHOPSEL_OFFSET; + regval |= TEMPSEN_SET_ACCSEL_2048T << TEMPSEN_SET_ACCSEL_OFFSET; + regval |= 0x31 << TEMPSEN_SET_CYC_CLKDIV_OFFSET; + writel(regval, base + TEMPSEN_SET); + + regval = readl(base + TEMPSEN_AUTO_PERIOD); + regval &= ~TEMPSEN_AUTO_PERIOD_AUTO_CYCLE_MASK; + regval |= 0x100000 << TEMPSEN_AUTO_PERIOD_AUTO_CYCLE_OFFSET; + writel(regval, base + TEMPSEN_AUTO_PERIOD); + + regval = readl(base + TEMPSEN_CTRL); + regval &= ~TEMPSEN_CTRL_SEL_MASK; + regval |= 1 << TEMPSEN_CTRL_SEL_OFFSET; + regval |= TEMPSEN_CTRL_EN; + writel(regval, base + TEMPSEN_CTRL); +} + +static void cv180x_thermal_deinit(struct cv180x_thermal_zone *ct) +{ + void __iomem *base = ct->base; + u32 regval; + + regval = readl(base + TEMPSEN_CTRL); + regval &= ~(TEMPSEN_CTRL_SEL_MASK | TEMPSEN_CTRL_EN); + writel(regval, base + TEMPSEN_CTRL); + + writel(readl(base + TEMPSEN_INTR_RAW), base + TEMPSEN_INTR_CLR); +} + +static int calc_temp(uint32_t result) +{ + return ((result * 1000) * 716 / 2048 - 273000); +} + +static int cv180x_get_temp(struct thermal_zone_device *tdev, int *temperature) +{ + struct cv180x_thermal_zone *ctz = thermal_zone_device_priv(tdev); + void __iomem *base = ctz->base; + u32 result; + + result = readl(base + TEMPSEN_RESULT(0)) & TEMPSEN_RESULT_RESULT_MASK; + *temperature = calc_temp(result); + + return 0; +} + +static const struct thermal_zone_device_ops cv180x_thermal_ops = { + .get_temp = cv180x_get_temp, +}; + +static const struct of_device_id cv180x_thermal_of_match[] = { + { + .compatible = "sophgo,cv180x-thermal", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, cv180x_thermal_of_match); + +static int cv180x_thermal_probe(struct platform_device *pdev) +{ + struct cv180x_thermal_zone *ctz; + struct thermal_zone_device *tz; + struct resource *res; + + ctz = devm_kzalloc(&pdev->dev, sizeof(*ctz), GFP_KERNEL); + if (!ctz) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ctz->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(ctz->base)) + return dev_err_probe(&pdev->dev, PTR_ERR(ctz->base), + "failed to map tempsen registers\n"); + + ctz->clk_tempsen = devm_clk_get(&pdev->dev, "clk_tempsen"); + if (IS_ERR(ctz->clk_tempsen)) + return dev_err_probe(&pdev->dev, PTR_ERR(ctz->clk_tempsen), + "failed to get clk_tempsen\n"); + + clk_prepare_enable(ctz->clk_tempsen); + + ctz->dev = &pdev->dev; + + cv180x_thermal_init(ctz); + + platform_set_drvdata(pdev, ctz); + + tz = devm_thermal_of_zone_register(&pdev->dev, 0, ctz, + &cv180x_thermal_ops); + if (IS_ERR(tz)) + return dev_err_probe(&pdev->dev, PTR_ERR(tz), + "failed to register thermal zone\n"); + + return 0; +} + +static int cv180x_thermal_remove(struct platform_device *pdev) +{ + struct cv180x_thermal_zone *ctz = platform_get_drvdata(pdev); + + cv180x_thermal_deinit(ctz); + clk_disable_unprepare(ctz->clk_tempsen); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int cv180x_thermal_suspend(struct device *dev) +{ + struct cv180x_thermal_zone *ctz = dev_get_drvdata(dev); + + cv180x_thermal_deinit(ctz); + clk_disable_unprepare(ctz->clk_tempsen); + + return 0; +} + +static int cv180x_thermal_resume(struct device *dev) +{ + struct cv180x_thermal_zone *ctz = dev_get_drvdata(dev); + + clk_prepare_enable(ctz->clk_tempsen); + cv180x_thermal_init(ctz); + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + +static SIMPLE_DEV_PM_OPS(cv180x_thermal_pm_ops, + cv180x_thermal_suspend, cv180x_thermal_resume); + +static struct platform_driver cv180x_thermal_driver = { + .probe = cv180x_thermal_probe, + .remove = cv180x_thermal_remove, + .driver = { + .name = "cv180x-thermal", + .pm = &cv180x_thermal_pm_ops, + .of_match_table = cv180x_thermal_of_match, + }, +}; + +module_platform_driver(cv180x_thermal_driver); + +MODULE_AUTHOR("Haylen Chu "); +MODULE_LICENSE("GPL");