From patchwork Mon Jul 8 16:12:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Farouk Bouabid X-Patchwork-Id: 13726832 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 12CE5C3271E for ; Mon, 8 Jul 2024 16:14:20 +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:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jkIRx4OMDxlmDE4Xv429o23pmwXLH5kQs6J56M8UPII=; b=w+lDOKWGOdkqpQSnNj+n5k+yps Xsk5qKVOK8RRlMXv2/+RGyZGIymj7GO6FqDrTemkslVCI0Lh4CbIaLWsJR6ij98Gqnwt/eOK91YoC gPbK/RJIf81onTl7hQ1dP46CXb7zkrH6paLnI6akZtfnoECvZO3uUXeLqfl/FP77/3/fwdjEdp2Fl oeK4wpmp9wjR+x0kNNJ/IHxB981F3FJn+uRkMUvUpLUmXTa/pq6cr0RBuOXRTRt+0dE6XVlxqVFl7 w9rJbzZ38aq+2BGOtG13bHEnbUzyWHDa8tQGITNO94BEv6iucJqMVzz1c0DWHKbUpb3BBse6uPSAz jIWQ55Ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQr0L-00000004OOY-0mvd; Mon, 08 Jul 2024 16:14:17 +0000 Received: from mail-am6eur05on20709.outbound.protection.outlook.com ([2a01:111:f403:2612::709] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQqzV-00000004Nxm-1k9o; Mon, 08 Jul 2024 16:13:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RU+pK7M/VUauv7AQzj8zsHUeAqSa+cZTsZEqw5FtUJ2n4ogO3ZHnRnbczZPpP7Obh5ZfMeZNnbIPP5n21jHxUDJtfFEZkj222iuBoYpu4AM50d4ujb8GJIJHQ3tnRdaAhqOSICbr4+q9zOnrEuJSIQ93lqSRjs9FcCAxpDXFXhhAaP5VkGDbFrBpme4HVzLQnDFKAZQjVW4YJVEiiyA5TtQ0dpk/A7Y+uq3BnXja/T+9+OExnQh6PxAo2eYkuzcEEuHVUjGl5LrI+c/aifFzXbsNhx3+vFBE/YmZg/zEK64DoN0jiiOFuSYBr31METYuv9xIXA/ajWwMdDrQzQpTAw== 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=Iuhp9T1QHEFE9Wfc7m8ueDzm/rOJFzpQw2ytUIQmKMI=; b=G+UiW0SQ067odd6SesRnZ1pot/8wthy9ZcRCigwASE0lkzLc4mNJ2HlqkQk0STPPhhpcfyOJ31YvRPQHfsxXTRtTMRL3Z+yr6jz8UHe6qbdN7Mh7cQvibOCM0DD0KlUPamODCK0Qim0VRePgNp9S2N+0KoW7LUq05isfq8Xe6pPfR36WUyDrNu8Ym5i2ZyGVmOH7DNOztdIbmSsysF/qtAF/wOZ+NLCeJWaOy5F87PTqD/BQ3kBP7aScSC3Ejer+l56JYTxQJP/I+ynEUeWwF7xBVzyc2OEvVMhs6BFmJUNXJSJsK16Vc24DufJsha1D4wUzXjWMHs03YW8m1XMb1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cherry.de; dmarc=pass action=none header.from=cherry.de; dkim=pass header.d=cherry.de; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cherry.de; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Iuhp9T1QHEFE9Wfc7m8ueDzm/rOJFzpQw2ytUIQmKMI=; b=SSANh13Jjnnjf86NnwyXiluAKeoGqSUVT7QHNQHofxIBHjuCRolZ3uxi32C6NJ8c5KFn2vE0Br8JiMTWV9gPBJVyBXFYbnb7eJhyPfZTP9ivByeQ92UGzyxynKGwJrqoD/5pehFw6rM9KTlhVE7ehmHQIrwQys3K4my2fJHwgIs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cherry.de; Received: from DU0PR04MB9562.eurprd04.prod.outlook.com (2603:10a6:10:321::10) by GV1PR04MB9055.eurprd04.prod.outlook.com (2603:10a6:150:1e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 16:13:13 +0000 Received: from DU0PR04MB9562.eurprd04.prod.outlook.com ([fe80::ad4d:8d53:1663:d181]) by DU0PR04MB9562.eurprd04.prod.outlook.com ([fe80::ad4d:8d53:1663:d181%4]) with mapi id 15.20.7741.033; Mon, 8 Jul 2024 16:13:13 +0000 From: Farouk Bouabid Date: Mon, 08 Jul 2024 18:12:15 +0200 Subject: [PATCH v5 4/8] hwmon: (amc6821) add support for tsd,mule Message-Id: <20240708-dev-mule-i2c-mux-v5-4-71446d3f0b8d@cherry.de> References: <20240708-dev-mule-i2c-mux-v5-0-71446d3f0b8d@cherry.de> In-Reply-To: <20240708-dev-mule-i2c-mux-v5-0-71446d3f0b8d@cherry.de> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Farouk Bouabid , Quentin Schulz , Peter Rosin , Jean Delvare , Guenter Roeck , Heiko Stuebner Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org X-Mailer: b4 0.14.0 X-ClientProxiedBy: VE1PR03CA0057.eurprd03.prod.outlook.com (2603:10a6:803:118::46) To DU0PR04MB9562.eurprd04.prod.outlook.com (2603:10a6:10:321::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9562:EE_|GV1PR04MB9055:EE_ X-MS-Office365-Filtering-Correlation-Id: 847aaefb-ef19-4dfa-bec2-08dc9f68de1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|52116014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?U3GfrNvHbuEBxhJhnEiNVsjrhI3kSpP?= =?utf-8?q?/4EyQiDjfGOLVmadGd0CRfygfSuvyGsZg/SZp+s/txhrJYdLGpPBoMxWA6VIttDxI?= =?utf-8?q?QhSRPamexa2WtaWCSq8P1xIyRAppKt6FnpkoiCclzVYGnfjs0ut21WjNVA5++x4oq?= =?utf-8?q?9TzgBr4g0is4X4hKrEMzzWpJsa3lti0Kc9EVgae7GqS60qMdHXzVlSAcb4x+Ncr0O?= =?utf-8?q?8/TeXMDNpjBiQJflSmJijnUBYvw/hfmY+UA7sw83FjrSsg8AcN6UrBhum6DjfMuqr?= =?utf-8?q?p0/p80SZsiGTAswzylW56PH4DgBjCpebs6a3djUrAeXDzlm+azLarh4BqVOrQqmKD?= =?utf-8?q?mNsZjku2W1P4EjKmDua55n62yE1J8R2w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c3WBuUcb3aU6xdSKRw745lupDMDZ+Li3Sv?= =?utf-8?q?TA7cneWIG28znW74EH2MmZoLPcqa1I2rxIYvPHlcV8z+PpDIkCBqlv6cEKsRxuO56?= =?utf-8?q?hKCH9TtHImeZfXjyyXjyfVMkwwwKUU+PTa+cDh8W8JRjh8f74x4MTjk=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9562.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(52116014)(376014)(921020)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?1iA46S+FUuCaKJHe4hHRhio0fyrt?= =?utf-8?q?yOyD1NKIu5HsbpP/ISsBJZnTaYV9bz4q1QURLHYfD7kr7X1r0E6UPgA7KaiA1BdL2?= =?utf-8?q?7gS+Q+K+4vrf/GiSJYWI775JnDN1FTy9/qYsd/DQ+p4JX8IrO1c7trBw7pP/Jlj46?= =?utf-8?q?orKsvd53eutnFTnuaxXhe3r8RAR35pXGUVpa3m0k4jKsjoh0Cmvw8m/2x1LzCKWoL?= =?utf-8?q?k7qQMf7LdzmEw+ocRnXot5iobh7UFfiF9kZcvRew8BoE7PVwD75PCoCWSOpSsLLS2?= =?utf-8?q?MU28VKSF68ONPgYeyXRFNI4Ec9UIuD72P8kTSnG2VcBF4mZAq1LdLG2kU6W7zbEKS?= =?utf-8?q?+k7DQBStseEnO5OvY85CaboInuGhT4AiFC+sSk70DA+La5HOs4WOJzU3fJN4E1NnQ?= =?utf-8?q?KiyJThWbpx2+fZ2y72yNWxloju+oT7pdwPzZ6lPxhvEqvOdH1Zw73NbT67ubVJ1B0?= =?utf-8?q?m88YjI0cTq8bO9V7PDVvmGe3/i+QnevGJfRbF7oM+fCp/NqSbZY/YAZ2R93vS/321?= =?utf-8?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utf-8?q?NpQsYetMp2O97TKdiGdEM/fSBdMMIcIIsahQAghZtqRiElbUF/Yf3+e2AKx07ojy3?= =?utf-8?q?524LTauwXmgHVTgnlUZpBCE7Y81nnQW9YvbWRus8OTA/fvc3SEbf25wWqkrhtxePb?= =?utf-8?q?1QIh7PSq3psThAgzaQ47oLrROP0nMKnBGg=3D=3D?= X-OriginatorOrg: cherry.de X-MS-Exchange-CrossTenant-Network-Message-Id: 847aaefb-ef19-4dfa-bec2-08dc9f68de1d X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9562.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 16:13:13.2394 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5e0e1b52-21b5-4e7b-83bb-514ec460677e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7qrU/ktXOr4qYFP2FQCA6iTQxLhxRwVLU1u64Tyln4r1xMRCLK838tFwbek9ePImZxajHBaT13R/EkIT7L7Wf9sd04Iuo5r+4J8E14wGY0U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9055 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240708_091325_574921_64ED82EB X-CRM114-Status: GOOD ( 14.75 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Theobroma Systems Mule is an MCU that emulates a set of I2C devices, among which is an amc6821 and other devices that are reachable through an I2C-mux. The devices on the mux can be selected by writing the appropriate device number to an I2C config register (amc6821: reg 0xff) Implement "tsd,mule" compatible to instantiate the I2C-mux platform device when probing the amc6821. Signed-off-by: Farouk Bouabid --- drivers/hwmon/amc6821.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c index 0661cc6a6f8e..93c3b79b5f13 100644 --- a/drivers/hwmon/amc6821.c +++ b/drivers/hwmon/amc6821.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -895,8 +896,17 @@ static const struct regmap_config amc6821_regmap_config = { .cache_type = REGCACHE_MAPLE, }; +static const struct regmap_config amc6821_mule_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 0xff, + .volatile_reg = amc6821_volatile_reg, + .cache_type = REGCACHE_MAPLE, +}; + static int amc6821_probe(struct i2c_client *client) { + const struct regmap_config *config; struct device *dev = &client->dev; struct amc6821_data *data; struct device *hwmon_dev; @@ -907,7 +917,10 @@ static int amc6821_probe(struct i2c_client *client) if (!data) return -ENOMEM; - regmap = devm_regmap_init_i2c(client, &amc6821_regmap_config); + config = of_device_is_compatible(dev->of_node, "tsd,mule") ? + &amc6821_mule_regmap_config : &amc6821_regmap_config; + + regmap = devm_regmap_init_i2c(client, config); if (IS_ERR(regmap)) return dev_err_probe(dev, PTR_ERR(regmap), "Failed to initialize regmap\n"); @@ -917,6 +930,13 @@ static int amc6821_probe(struct i2c_client *client) if (err) return err; + if (of_device_is_compatible(dev->of_node, "tsd,mule")) { + err = devm_of_platform_populate(dev); + if (err) + return dev_err_probe(dev, err, + "Failed to create sub-devices\n"); + } + hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, data, &amc6821_chip_info, amc6821_groups); @@ -934,6 +954,9 @@ static const struct of_device_id __maybe_unused amc6821_of_match[] = { { .compatible = "ti,amc6821", }, + { + .compatible = "tsd,mule", + }, { } };