From patchwork Sat Aug 17 02:21:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13766899 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 CD5EEC3DA4A for ; Sat, 17 Aug 2024 02:23:19 +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=w8Pbq3HL2EVTXP4ozSIhRNfLt0xiGr1P9fKQX7PYwyc=; b=jR7X0Id3QseVuH O3lyNKbvntXr59EfI8KQbSJ0UPK1A+k3pBdSeGS3reUOm3JywObbjc/Nf56rXq3ap+NZdusrNc3B+ xuLFIOaPpyWqQ4XY4jl28ROSPkSCAuLi7FYWB2DblXjausq6/5w2Nhffq5kOeUwVV0Tb1crpKfxty lv4O+e3AlaqkkWAaWXyn+PEMBqcjSjPpFzfNhoTBrc8eYj2hHSD8kAROXvlG1N3hTvHwbfdCyToq7 BjGtNKRQoq4eL8h6aeWb14E+4/cAxKZKRjePpk98Fw3HbXZwRnAbMdOi8HsF0QWnUab9+O8zJmE75 Mn0Et5hkxfU63COdmmXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sf95y-0000000EUvW-1gr3; Sat, 17 Aug 2024 02:23:10 +0000 Received: from mail-dm6nam10acsn20800.outbound.protection.outlook.com ([2a01:111:f400:7e88::800] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sf95u-0000000EUuN-0pr9 for linux-riscv@lists.infradead.org; Sat, 17 Aug 2024 02:23:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vbNKghWU84k8imnHRphHh+WL0ufxJsM7XCqiQYbRdHh0EK+MgRjVdM29lJ1BFOCDYDx2SzV5gklI949tvorbepe7+yNlcaxq/yU8VUE1rN2gu1+aYtxj8if5rMGrhRcxUGEXLX+SSWzmJUZsxiwctG08DXB/d+ohRKpMQf/PRYgxhgrt05jKRntflGZH11RDOFvpmrLKXc4+x2j6fI1tWSIvOm3Yvj2bsgWp3pS791g/RMqtqHX8J8Uq/AHjCGEIGqpcTpyRDHlx/H62ZTX8pu8jrPZLj/o27f2vuSr8Hc6uk51WnnVqHung6v6QofhEZ9U/bvM5jKre6TdYuOJK5A== 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=tq4qGHTJqYcAIh2eSe6DX9dUuYHlkUSeYIfkyk+wZFg=; b=F44YGdrWPDeMCaDWyxyUTJQGr6doYzdXyOZjvYUDYaGB6Iq8Wez3IfVcvQo1UXhfMBsR1YZLYmVGtp5slhyyXjw48uwZHa+RSKAaYnk6EBfIzazC7tVPxDrOUGi6iK8VuB5XZX/6IbYnFs64AeQyQLxSTaY9w9Ri+4DhvKRl+R2jfsWJE/pT5qPMGSF7KuVC4nMqce2ys9ADIOdt3flOKGR5zv56vOLi9VcyKl0NXm+8ED72A9hSSKRjsQT3D4kAfekS3wROw5LHUmh1Va87HZcSmigeg72xg5yelwJzWyA3bM0RnnlcaeRTxu0yjeQQHVB2kxEXDngnoi4yq1i4kw== 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=tq4qGHTJqYcAIh2eSe6DX9dUuYHlkUSeYIfkyk+wZFg=; b=T/aL0wacVEDqRJwnGvw8E9lzFYHHlnVA/IvV9xhjhl6HltczULHfT0DlBKma30MyWf9WmwmPbxRzWWz0YHRmzwHPws3JgpjRl6B1T0jsPvoo09bGVCI2cv253pGrez0ww20iOdebuN7aGXb3YEzU58jm2mAG4gErQFlzFj87NtpXSmf0oMoPcLDRfnR+Ip1AhFLP+EQ77CFo1mAomFXQJ8jbWqn9XIrtQmWZ7PJWPHHrsUHDnKP/iamDdFxaToGKA4UUJKXk6sYpW3KqtL4hUph89ncdKjLKIvYWQPbYCso6YhNJuChPD0i9p7R7M0srPYG+SSosrBDnkJgFfjQDnA== Received: from IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) by PH8PR20MB5337.namprd20.prod.outlook.com (2603:10b6:510:1bc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.19; Sat, 17 Aug 2024 02:22:51 +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.7875.019; Sat, 17 Aug 2024 02:22:51 +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 , Yangyu Chen , Sunil V L , Anup Patel , Lad Prabhakar , 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 v11 0/4] riscv: sophgo: Add SG2042 external hardware monitor support Date: Sat, 17 Aug 2024 10:21:59 +0800 Message-ID: X-Mailer: git-send-email 2.46.0 X-TMN: [rI2EJhsrZzllPRsU1tLDwtSicwMi9nICDSt6UxZL0oQ=] X-ClientProxiedBy: TYCP286CA0078.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b3::15) To IA1PR20MB4953.namprd20.prod.outlook.com (2603:10b6:208:3af::19) X-Microsoft-Original-Message-ID: <20240817022201.360862-1-inochiama@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: IA1PR20MB4953:EE_|PH8PR20MB5337:EE_ X-MS-Office365-Filtering-Correlation-Id: bd495841-1cad-44af-6af1-08dcbe637ea0 X-Microsoft-Antispam: BCL:0;ARA:14566002|461199028|19110799003|15080799003|8060799006|5072599009|1602099012|3412199025|4302099013|440099028|1710799026; X-Microsoft-Antispam-Message-Info: 6o+aQYhBuEDHscHnUNAumv0oca4diNYdGJoP0aM0bflgTdvQ/OBBjpxtwbXr7FoF9oxPah8wjievY37jUAjH6Pq1556JrjMWSqSXPYwsSyWEcqRbzh3b0ZnnT3fpP+N8QkQYZ6j+FO8/qGpKkC3K89bb5iD2oBdEZsUu5ERj8oVBd6rAQzqZckIf1jRzwJfGO+gdhWsucMhycwqlBKV7pWjJDRz0UWEC8tsHouuK++XDd3u9Dvzo3MqPpOZnQaJxw0vFEUxBmZtgfmRs/m3siblZCxlou9rDdtZsn6F+k6/uWGaZT2mdLRALwqy8CmMBbCmyMXqQmtWxHKsPory1QvOtCXZM7m6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DNau+SZak2xMRO1w8gDTzodUwy9zm7FdSvFEsiAHGpythpP27Ts/15lx+M/ATnaxpf6S1PvuzUHnjyJMeE5UGhn2kaLaDGHfPz823ZOZ/HlsiO+VrMvFBg6B8Ifvfu0X2oD//SwsbwS/6Hs1NX9AWFc41TlBM5CUkjHWBcon1hebdSdTxlU1S8shcrSq5o8PsCZ+7uRb0AuN7UFERisJ6bYvIoyrAj6xIvo7C2CF40aJkYBkt8JLYc+wf8uk0DzN/DPFddn1yV18VuxSUNIAL72UFXQwq4tmAdb8DyRhuOaZEOuoEAF0FcMxADGaPt6GPtbudHO3mwFG7X7V7oqYnV078GgZi7AgcKBssF06p7ojZE/6vUMJoXmgBhPM8mfwILMUsbDjBfSyZ5dAQ4kUAWnoK2ZRPnJuFdWvNtTTStOm04KnUcD+VqjdRMfESCbzE1u8DDediN+h0R09/EmzIYFE6TSpbDEcXsAiIvauezhWfUa4AVf6NoOfD2MK0X4ZuYLQPJru06aEHgHaVV0N4wHv3z99vE3ccNYbE+8LsZVzurWvGqW7l/SYmbfXfYS++4Ljzs0t6i51AqGQIvkuptlhk9wjnpI2Gudhma/xDNetaIekvLnSh+tqr67yDtCjr2V5e4iCRideMIgxNFg5kpVXWI3J2fuQC5G/brdAcst/vjxun1BRrXRtHfVQ0hJ5R2szioe9qn7u3EVloMO7ARGH3QdqGQb/+zgj9wof07LAndP70E3cnnteiezOLqQ X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd495841-1cad-44af-6af1-08dcbe637ea0 X-MS-Exchange-CrossTenant-AuthSource: IA1PR20MB4953.namprd20.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2024 02:22:51.7557 (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: PH8PR20MB5337 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_192306_277567_4A6FF7FF X-CRM114-Status: GOOD ( 12.53 ) 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. This patch is based on sophgo/for-next: https://github.com/sophgo/linux/tree/sg2000/for-next Changed from v10: 1. fix the hwmon entry permission. 2. remention the extra entry postion in the document. Changed from v9: 1. remove missed wrong return value. 2. add document 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 | 78 ++++ .../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, 583 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: 3e2b6b3302bb40c75756c74c38ee30cf34cd2879 prerequisite-patch-id: 5e7221ed1c63bb4d68e4a2a0141440e32d29e397