From patchwork Fri Apr 26 16:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Farouk Bouabid X-Patchwork-Id: 13645093 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 1BF00C04FFE for ; Fri, 26 Apr 2024 16:50:52 +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=F+jKCK9QhvC5IGPGLCNmCxl6trjMi48huSrNdLq/Jmw=; b=iJ5CCDLeiApH/rWOepaOW9Y7yE yogOs0CzKeRGR1mGPZXsk2uwIoRVO+0wp8E9EO3ILcDZxg+2xT9YQYRXmd85F5NpRNdekrVMzVgpu BpL+5jrwARka0SmuObk30JiXf5LHopn5GrYENCLETsx5Dq/bxi99I0OKaxjCD2L58BVNc0lizxkSX zgnrOUKXplhwvSwPwCFFnb43vX6dyWlc0COoBzeR9qmM7WAijQlk4z17HFHWaw4EIXlT+vYXbFPgc SK7yaTpVK5lvCIA4QiEbK9eNQFa0hsaPiNGpoV80CQveNWezzSAk2pLQrBsiLwSRnRrO9gY4/yClW oFYblUgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0OmV-0000000DJeg-2Aev; Fri, 26 Apr 2024 16:50:39 +0000 Received: from mail-db3eur04on072a.outbound.protection.outlook.com ([2a01:111:f400:fe0c::72a] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0OmT-0000000DJdc-0bKP; Fri, 26 Apr 2024 16:50:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VWCcHj8Z22PM5c5O1CjJFcHSrwPqaCgR48MwnFENNSHYu88G3OkrFr2Nr00AYGUxLS6XcdDxQgUBiFgt57rd3n3bMXTRTSHMQySBCH2Zn7SA7Ea8F90AJm+PLVibNKnOKepNMkVV1Z33aGJ4PCur/FnFk+iG6KBT0rUTQVdROPB6KOu/BMrDu4f0xpbNsz+lXsHZZfiCThwIk1D9G03VmfX+GIxyO2SzHdSDVHFAv45HBfBdPJAbQsKEUkGQJFVGBfVFqURD8aYefVVpchSUIOpnxpKVyUA50Ub8eDPcixX39IzK0R/4hhFWraMr+NLM/2fm4uD5H0GiIm8f+jItGg== 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=BOZ4y9LpmO3SIsxBmkTLzn2Xo1D8twp3LSzmvFtE+a0=; b=nrk0RqR7KD0syFtm48tRnOnPluZVC84PE2cdjwetFIZ+vq2CK0c1yvy6G5Xl+/riEP0tnrqeT95NWl42F4gCqLd0QDPSRvMVKY1vQzTZhgPctpesO+2JPW8swp5TXxiI0RCNYDkGBSxvcbbHIbEO4dGrJidRo2N3h15lGX3WFc9jMf0eVQBAwdreDWaMCCrk7tRU712NTFrWGCTvV9cRu/n8CeX2STH1KFarDUzJAGxPcSHM48QM7Ur9+BTf4lEGq8ppkeyKmHQUWr5VT2kM1wCWDYL+BnjJ9ygysgYNp4Y/jAQdSxGck1nfVwUAj9O0aV55fV39sUfKV1yyc09ZHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=theobroma-systems.com; dmarc=pass action=none header.from=theobroma-systems.com; dkim=pass header.d=theobroma-systems.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=theobroma-systems.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BOZ4y9LpmO3SIsxBmkTLzn2Xo1D8twp3LSzmvFtE+a0=; b=jLIE7gozIYwukbmwqUCzdK6/FIjGr+M0zoQWm+DN7Quvnj6DeZeOrBzxLJtD0P2SKd2zNRR1PwZ3Nve2i7Pz7yKpZReHwS6SlZ5LWkN+0YC4VjhuLiG7oM9876jLabVJacOnp5FViSBuNPjJprDJ1xOWrsT+p4sCeEACXLnXmXP5CvQgLvrtqteJioQ/aUGtca3p/UgzR4wO8szDMYcBI9mmNw+vAI+t6/eBtEUbIYtCqxn5YO++pIGyU75Rflo4u/vpeSIDJYRHOpO+FT87VW5pwHmZ37vnJE8fq6drhLAItAg7v4YV/Jm2ZtkxA0ikxxkPJjlBtRLGZcsCbKAihA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=theobroma-systems.com; Received: from VE1PR04MB6382.eurprd04.prod.outlook.com (2603:10a6:803:122::31) by VI0PR04MB10230.eurprd04.prod.outlook.com (2603:10a6:800:240::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Fri, 26 Apr 2024 16:50:25 +0000 Received: from VE1PR04MB6382.eurprd04.prod.outlook.com ([fe80::59d9:878d:65f0:3936]) by VE1PR04MB6382.eurprd04.prod.outlook.com ([fe80::59d9:878d:65f0:3936%4]) with mapi id 15.20.7472.044; Fri, 26 Apr 2024 16:50:25 +0000 From: Farouk Bouabid Date: Fri, 26 Apr 2024 18:49:32 +0200 Subject: [PATCH 1/7] i2c: mux: add the ability to share mux-address with child nodes Message-Id: <20240426-dev-mule-i2c-mux-v1-1-045a482f6ffb@theobroma-systems.com> References: <20240426-dev-mule-i2c-mux-v1-0-045a482f6ffb@theobroma-systems.com> In-Reply-To: <20240426-dev-mule-i2c-mux-v1-0-045a482f6ffb@theobroma-systems.com> To: Wolfram Sang , Peter Rosin , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Quentin Schulz , Heiko Stuebner Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Farouk Bouabid X-Mailer: b4 0.13.0 X-ClientProxiedBy: VI1PR08CA0261.eurprd08.prod.outlook.com (2603:10a6:803:dc::34) To VE1PR04MB6382.eurprd04.prod.outlook.com (2603:10a6:803:122::31) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6382:EE_|VI0PR04MB10230:EE_ X-MS-Office365-Filtering-Correlation-Id: 01dcd41a-a324-4c5a-b457-08dc6610f831 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?hMmsHCro9nB6ECTvue7+x06TibQOJXc?= =?utf-8?q?ABSu6urxiA4VQxk21b7swa35AVkDw45HfP5iuHoH+yll+TmuenGbQ4gRlgRBmTqKM?= =?utf-8?q?WvRsZQkelGz7U6Eh/pzvnGrXkUFsFiuPnEgWMveGwDB26ztIPqVt9dkLUMOsJKqiC?= =?utf-8?q?OoJMwLZmWxGK/NrlOxuH2n5gR2SDxYGjmtxNxIY4RgFpCLfGOH1NG++xq/T5Qa1t/?= =?utf-8?q?LAk/s1dGjODKnFMfaEmuEO2F3V+iQxxpSTD62eSW+QJ2Na+AJnuQx3H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Ayuw?= =?utf-8?q?rlCQ7z7ww/RRaVe3irSDNSFwN/jDiJEUb4uKNxEwj3PUdjvMDgVe5wxrTblyohhya?= =?utf-8?q?WFb65wERQd+JLQFZtM3re7qUSBJnLgsahuNnr8GH08VCONqn7oNPDfzYDk5gsRtQj?= =?utf-8?q?uqVZhmOagGpWcLxh/M4J/jJf/JQ5Sx1eWLg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6382.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(7416005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?z0EQ9AXF40papnYfGZ1Y7blHgpFu?= =?utf-8?q?AZdHgkhhh88ATDMBsY96Vm2ApQ0kwYA6UN9C/YeAoI7QnI3pz5x17A93AcGD0gjdb?= =?utf-8?q?p5qdZCpSeO7/Hc6tm/y+Q8UhdIkeJ/Nj4st6cdmpWgrk8+8CWsKK3t4yP4+AWuBrp?= =?utf-8?q?0UMbaaJdZpqwUte86RzcENGY9qx+KSAc1In/vS4JGey65zKPQmJY5ZIWwQ3phwi7U?= =?utf-8?q?EbREkzDPCbJQUlNd3TC8sNEqVTvU0BkKcHhC1UqRjU02fjJITOJCYe7OVND9SrVM5?= =?utf-8?q?9iI2xCTUDCqPYRbKNoVx5HJUT2Kt7Gitklf7yxhfdUL6Gush5q1J3i7jM+HO5aAhc?= =?utf-8?q?Q4QCN1YJB6a6Ovx0lXpD/tW4PBB31RT0j1ZB3/tXqEZwLdPVRIFhbazbENt/gHfLP?= =?utf-8?q?x8qAJrZYh8o3CX/VqF9IAu+1EIqSCQkz4UZEqrDURu7M0mVFpsgzwGMaJWdKNxnCq?= =?utf-8?q?ToNsniibMct8jo67xS4cyjL56Xr533IkpPiXkjdz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oGBVQ/cJ6Gjy9x/TAqbfyY8HSbyTVpx?= =?utf-8?q?HuO37QG4GW89Ro3DR+hGboCXYPdrmeFr8UdKuDdJpfhZq35eTokLWoshEDqTZtIOc?= =?utf-8?q?wv2qUbdXu649M9pEARTmOZj0rIpDg83rKFB9xLFv9v8PrFcZ9FY7AWzUnaJNgqlAF?= =?utf-8?q?zbiDS0G8gQV8qJQEIBQjozY1C2KJYCElHzCIaR8PoTwse4NQTTuyqQI=3D?= X-OriginatorOrg: theobroma-systems.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01dcd41a-a324-4c5a-b457-08dc6610f831 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6382.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2024 16:50:25.1088 (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: s31FsMxDOfV7owdLmFX60Fksqy+dhoPm+0I5FmeNv1h6Y2P1UPM2FD25PXg6OSI0A7K/V1PCMCy4vq76ABHWvnKu/W2074f4SMgPtC69b2XZaoJdip3iFUUIx/py5FS9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10230 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240426_095037_232540_FA049F78 X-CRM114-Status: GOOD ( 16.36 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow the mux to have the same address as a child device. This is useful when the mux can only use an i2c-address that is used by a child device because no other addresses are free to use. eg. the mux can only use address 0x18 which is used by amc6821 connected to the mux. Signed-off-by: Farouk Bouabid --- drivers/i2c/i2c-mux.c | 10 +++++++++- include/linux/i2c-mux.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index 57ff09f18c37..f5357dff8cc5 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -331,7 +331,6 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, priv->adap.owner = THIS_MODULE; priv->adap.algo = &priv->algo; priv->adap.algo_data = priv; - priv->adap.dev.parent = &parent->dev; priv->adap.retries = parent->retries; priv->adap.timeout = parent->timeout; priv->adap.quirks = parent->quirks; @@ -348,6 +347,15 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, else priv->adap.class = class; + /* + * When creating the adapter, the node devices are checked for i2c address + * match with other devices on the parent adapter, among which is the mux itself. + * If a match is found the node device is not probed successfully. + * Allow the mux to have the same address as a child device by skipping this check. + */ + if (!(muxc->share_addr_with_children)) + priv->adap.dev.parent = &parent->dev; + /* * Try to populate the mux adapter's of_node, expands to * nothing if !CONFIG_OF. diff --git a/include/linux/i2c-mux.h b/include/linux/i2c-mux.h index 98ef73b7c8fd..17ac68bf1703 100644 --- a/include/linux/i2c-mux.h +++ b/include/linux/i2c-mux.h @@ -21,6 +21,7 @@ struct i2c_mux_core { unsigned int mux_locked:1; unsigned int arbitrator:1; unsigned int gate:1; + unsigned int share_addr_with_children:1; void *priv;