From patchwork Sat Aug 10 08:03:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13759445 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 C77FEC3DA7F for ; Sat, 10 Aug 2024 08:04:07 +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: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:In-Reply-To:References: List-Owner; bh=MVD0Z/7sruTYZhKIzp85WtjJpNtvgUc4OAD3b55tBmQ=; b=ba30adGRKYbUfY PtdxLgh9f2QrBj5t2D6AHLKdJRB6LRfqS45Sk04YyGhn2IC9WFYAZLIvpX0YUAc12Bg2JxDe1NSHV wo7Yfgh8xKNPVEgBihBAUti7Fjh+ivGuWPBURU1Mq9yfmaPNP0U/d+IKhkM26MrLu1shXQceOoFSZ mi/Grx0l0urycctJiTSVZZiQ1/T2/Gal+lNqaYoboh+dHDI9xUl515FbUsq7s4FtwbAMthExOXu9S sjzjOBsNEoOo/tYv5sAoDxfHkxn27Z1PPLyOiTlV6Q5fg7GUnOn8DX9At1Yp+nYUKzC9dPeCf9cX7 ht8T+gdhdG77NiQVm3hw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sch4z-0000000DVwm-1e7u; Sat, 10 Aug 2024 08:04:01 +0000 Received: from mail-mw2nam04olkn20805.outbound.protection.outlook.com ([2a01:111:f403:2c0a::805] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sch4w-0000000DVvh-47ma for linux-riscv@lists.infradead.org; Sat, 10 Aug 2024 08:04:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Qn6bYJo4DDY/gGFfQvSrRdsITQvs8skjGEbwvcQrSNnCJe3oJgTfLgTT4Wqxxx8cIWwI3Gi90QXJnnts38bUTpW9Uwm+h4MKDBXoUKAIRbcNJDuMb+43epSqypKTWJ3hFYIwudatVoFeVJFkfgYmDVU22DtMdICvriT3fNTBSpGuMNgHOw91NfwnDQrzQo+kQnkbxSfH/Tz/HuW33nni5YdkLt+2pQKQaXiSC5EIxLD1peczKZciUR7NeOFJTC1oSpB72Fk+Ldq/EJxa3RmD3Uzey535cFUsOeMEcT8L+axO+HorXTVjhPRXp65ultIdmgMSSDUjnwsweIMx2kDCxg== 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=Mi3Az0JRlQjKq+1wQWxafTGjvrVZazpXaXtVblE35I0=; b=UYnZD0Oj3wMRJHlCX5cQjeqdDuW3AvRtxM8NLC2POMookpti+4iQ5WW1UopD1Si+K89vE4nMIpAvcZR/INQG1ulc+Tr0TLW31515g0UkdxY5dJ4GhJNA+YWeFtSSbfAA6V4j8fieibnhZfYxzy9XmGmlwQrkG2MhYhyergZnLJ769+1MM0KKBjaNG2zrD2cAyyjuyvvjJLDqrm2iViuYi6F4L6o/lW4coUu2OCddvi5uttip7H1QVIFIIuBc2SBPYfk7Hko2qZZghnj5SDE8F5Ifl0dEi95WkFKCAE+XQuI7Hivel7llW40RoXOfjljuCRpqsyuXoYtUQ7ctuFSBaQ== 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=Mi3Az0JRlQjKq+1wQWxafTGjvrVZazpXaXtVblE35I0=; b=ExPgPpOwnbrurTK7djWgV13tvdz8XdX5Dryb17X6KKCy/UAUZyW4bD2tol3mYbhfk532EdRbA/NJc6moaYGVxMPjGryUgjfa1PJFUsPTaf+bk0nF+SjvFW/yJcGp6AhsW8zjwkzl8MynOmH3cZB9vSd4FTqo4JDnDxk2jHKdSDb5as3G5FJsUg7KXKebZcvse4kirdia4qeSzEQwYmPkAEwzhh48G2GRdEQp8p/kcdqepiJis2iTs2HPOgYkpwhOxHO9nmUYOOlWBqOZnmS9hN8cngF80CQ8QBuWeo7vMp5utXDc3oZ1FeflI7kwOzAwD5+pXPhCn3QNbgDVz4wZMA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by PH7PR20MB5117.namprd20.prod.outlook.com (2603:10b6:510:1b0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.24; Sat, 10 Aug 2024 08:03:50 +0000 Received: from IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149]) by IA1PR20MB4953.namprd20.prod.outlook.com ([fe80::ab0b:c0d3:1f91:d149%4]) with mapi id 15.20.7849.015; Sat, 10 Aug 2024 08:03:50 +0000 From: Inochi Amaoto To: Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Chao Wei , Lad Prabhakar , Drew Fustini , Sunil V L , Hal Feng Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v10 0/4] riscv: sophgo: Add SG2042 external hardware monitor support Date: Sat, 10 Aug 2024 16:03:13 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 X-TMN: [fUL1MM2j2DHRk5Sq2Af3uE7/7Ch5OAk7b+ng64cyD6c=] X-ClientProxiedBy: TYCP286CA0154.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:383::19) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240810080314.382409-1-inochiama@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR20MB4953:EE_|PH7PR20MB5117:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a649d99-a707-4c97-74bd-08dcb912f831 X-Microsoft-Antispam: BCL:0;ARA:14566002|8060799006|19110799003|15080799003|5072599009|461199028|1602099012|440099028|4302099013|3412199025|1710799026; X-Microsoft-Antispam-Message-Info: niZzoufR1FtIbRAcByuqxhSu52kGc7NGr53bu1N9OlUm2GTL8xpvIIPHC+RcrRGo04v0985rRt/FupH6Z2No50zvoWB9bMGBo8FPwDfXUlCUqxnSrRA23MwkhCsBB3JzaKaADIQW7PrT2IQdyDmeYYp3HMz2ysOKhThBu4wm+xy4dP6qxtyprhNG5VDAzq7PJ5uORazBFke66leW1bWO7HVUiyvb3fvouDGJZJVFokO1iwmUR6RtT1W8HwLfcnO+7n7vrWnd8ZrkJZRKJyC72Kcn99mD/t+zTY3dg/OqrVrgrjbMPZYRAi/N1YE5zXxzLytplV8KFjisUf9EA5ParZaENYQQGPUXcZ+VM9KTV8r14k6wG79+wxI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ykUTomko6JxBV4B8OYgcPAMXpYVuZ2UpUIvtlKGnFeUc649V5vgSFeejNhVBn/I9DDY/pBioRoAwTSEKsi3nifq3fH9qyq140kiaPZb+jZWas2SXhIuYTjsqsJyRKhEEforW0+vAPHjLUjoPEX98SQFx0mh4ZWza9MlOg21irIWo0SPV8av1SZ+4S42FHcSN3nUbgm9Rn3aCczKYUqIESwId9NHKf8lSp10iyVXiGXbnVdcYGDf5sbSac2cltgx/CptjMezhjr7GEh1Y4yqQUhriFG2DZDLFvGUf8Pxuz5Okzrmg2ydYuwLB/SJKzLXTilyL4vvxdxqLlo+WmcdrO2EgZIOeaSd7KznnBZX+lGVesYZnwMZbYRzuLuF+0rC6Cm3yyInKULPgLx2yjyKGEnMO8GtdyX/F8UaQ8LhuUMHVwGiFm5Ldb734ub+1PEU+FOmDXTGkZhgnLdstFZWXB5uY+ExdO339iFu+q0A+hsgoom7344HEAlNbWrzyZZousyL9snVVZi+s3vBge7b+uMMOwB7Bj/G/wg1V9ZnLbVmHyIp4wFEbB8EH23bz9Ql8FuMtdB01jlWPZNzu8jGkttr/URzcXUD4QD/bgSbcNDWDj7YdzTFipdEwbjeOn9FESRiUCq5DkHxdpLSQetCuzFtzTrhZBGzL9hsyIbwJeqvDXGVMqCk8+76rrGXLUqSTEcu4fIbtFJxAKI2PKgGc5a8N/2/w6MZymrkYS9wpb X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a649d99-a707-4c97-74bd-08dcb912f831 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Aug 2024 08:03:50.6542 (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: PH7PR20MB5117 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240810_010359_059414_3FE1C3EC X-CRM114-Status: GOOD ( 12.89 ) 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 the onboard hardware monitor for SG2042. Can be tested with OpenSBI v1.5. The patch require the following i2c patch: https://lore.kernel.org/all/IA1PR20MB4953DB82FB7D75BF8409FFF4BBB72@IA1PR20MB4953.namprd20.prod.outlook.com/ Changed from v9: 1. remove missed wrong return value. 2. add documentation for the other interface of the driver. 3. rename repower_action to repower_policy. 4. use break to unify "return 0" in is_visible function. Changed from v8: 1. rename critical_action to repower_action, and add some comment 2. remove unnecessary wrap function 3. use guard macro to simplify mutex process. Changed from v7: 1. add mutex protected and fix the return value when writing "critical_action" Changed from v6: 1. restore the driver name to sg2042-mcu 2. remove unnecessary wrap function and check in the driver. 3. add dts and config entry. Changed from v5: 1. rename driver name to sgmcu as it will support more sophgo chip. 2. move some attr to debugfs. 3. add standard crit_hyst support 4. add documentation Changed from v4: 1. use fix patch for binding ref. 2. use unevaluatedProperties instead of additionalProperties for binding Changed from v3: 1. add thermal-sensor check. 2. change node type from syscon to hwmon Changed from v2: 1. fix bindings id path. Changed from v1: 1. Move patch from soc to hwmon. 2. Fix typo. Inochi Amaoto (4): dt-bindings: hwmon: Add Sophgo SG2042 external hardware monitor support drivers: hwmon: sophgo: Add SG2042 external hardware monitor support riscv: dts: sophgo: Add mcu device for Milk-V Pioneer riscv: defconfig: Enable MCU support for SG2042 .../hwmon/sophgo,sg2042-hwmon-mcu.yaml | 43 ++ Documentation/hwmon/index.rst | 1 + Documentation/hwmon/sg2042-mcu.rst | 77 ++++ .../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 60 +++ arch/riscv/configs/defconfig | 1 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/sg2042-mcu.c | 388 ++++++++++++++++++ 8 files changed, 582 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/sophgo,sg2042-hwmon-mcu.yaml create mode 100644 Documentation/hwmon/sg2042-mcu.rst create mode 100644 drivers/hwmon/sg2042-mcu.c base-commit: d2d190621b60d77496d36659e1621b20c897b25d prerequisite-patch-id: 5e7221ed1c63bb4d68e4a2a0141440e32d29e397 --- 2.46.0