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: 811274 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2114.outbound.protection.outlook.com [40.107.20.114]) (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 2060C1487C6; Mon, 8 Jul 2024 16:13:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.114 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720455205; cv=fail; b=G825XRBv1FSWYwa/D4ziuXhsi/qaSz6jio7sDZvSofMcGd6EwibPQCZsMINtzK9cu6EjenomusECGrZL4qHhCzk6+rhdgp3taIggkfVQJUlGvmqWu6oFipZnWm246Jq5Wcz5WA2b1aQ0SqB4C82t7siJWi+LSC2DhIt7+NKo0QI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720455205; c=relaxed/simple; bh=N26xW5ZbC/263wDEtAd6u+B0wIf5K1mGerf90NpudD0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=R3UMj0eWr8ceX2jCeeFRL9zTt1E8bcFjh92O8zzUbS324r7zfmMg/E+8TrojByqXm3jUEOljOtJ7dirz1I+WWEslMiL62L5TgX7h62n/Rt2BxeHJ7oE7JduWXDhqWZD6B9boiCL12DqK2GIQ45bcmId5iaFBuxyWsV2o6eitwOM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=cherry.de; spf=pass smtp.mailfrom=cherry.de; dkim=pass (1024-bit key) header.d=cherry.de header.i=@cherry.de header.b=SSANh13J; arc=fail smtp.client-ip=40.107.20.114 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=cherry.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cherry.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cherry.de header.i=@cherry.de header.b="SSANh13J" 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) Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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?mNsZjku2W1P4EjKmDua55n62yE1J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Anoyc3WBuUcb3aU6xdSKRw745lupDMDZ+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?= =?ut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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 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", + }, { } };