From nobody Fri May 9 15:08:51 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 5EA411E9B3C; Tue, 1 Apr 2025 08:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743495065; cv=none; b=hvBVDGoLujO3LovpKg4rg5y4wcgKm7/oPXxGNAHPsActtWTqgeYudEBWvG/v8BTzPxWr8gKDcWytZUwSLUBAOZAYfhD5TqNNtcny/8UU98vrmRPfLgnfYlcfxLrW9JXfUUx3s8ocUz4hHlA4veSf8ZxOEEhV8lDZuTrApARLdFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743495065; c=relaxed/simple; bh=0/XEeqL3S2KUXmALG2T2yy1ksxatgEi2IgV/5+0o/Lc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pEaOgIKlTaysH86QVfPNOTjbgFJXIAW0VIrNcUv80Klmuvub9CQSNbdB7ILwjHPyoMhQ1ZmKp+ik9Ped4UUkxZ7wJ8ah3x5xbBQPVtHGd0WZH8kH6veRCujfs7PQdM+EBPVlJ6/QxoBDP6Vg09qztQvvC8WkPxjtkmlsl6pC8AI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=RxNGMpSR; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RxNGMpSR" Received: by mail.gandi.net (Postfix) with ESMTPA id 9A770433F6; Tue, 1 Apr 2025 08:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1743495056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=igMWkyz++SDitFI41TTlJl8kgNuFossuqgfrszue8Go=; b=RxNGMpSRdhy5XE9XwtMvKTNgeio+ZJFCO+OvXvnKbLpf/9qA3Ibk/3YMMkrBB5ChiRDzMV xTrNL0htswUUhdPqPQWYFhOVv0J6t1xGm70ec2ZbPosNG/nudgXKFEvAIYMHnSEmE1biaA eWXqT1UMkxil909gFj7fmfAKDtesN8tKm0caPzg+1/+3gnnBAVPgdBg08OALo7eIuYebM9 fFjNmdb7I0hAPCxERBnT2ujzRwn++rv/SqWI5VZNhob5ZxvQwFt4QAG+dh8pirCiKuY5o1 yDFFHDirX4asHAzTkP3RLzKm0rblinjGWRFiUWxp3PKDHFfyJnIl1S8kC4rFQA== From: Herve Codina <herve.codina@bootlin.com> To: Wolfram Sang <wsa+renesas@sang-engineering.com>, Andi Shyti <andi.shyti@kernel.org>, Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>, Conor Dooley <conor+dt@kernel.org> Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree-spec@vger.kernel.org, Luca Ceresoli <luca.ceresoli@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Herve Codina <herve.codina@bootlin.com> Subject: [PATCH 1/2] schemas: i2c: Avoid extra characters in i2c nodename pattern Date: Tue, 1 Apr 2025 10:10:39 +0200 Message-ID: <20250401081041.114333-2-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250401081041.114333-1-herve.codina@bootlin.com> References: <20250401081041.114333-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukedvvdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppedvrgdtudemvgdtrgemvdegieemjeejledtmedviegtgeemvgdvvdemiedtfegumeehkegrnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegvtdgrmedvgeeimeejjeeltdemvdeitgegmegvvddvmeeitdefugemheekrgdphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduvddprhgtphhtthhopeifshgrodhrvghnvghsrghssehsrghnghdqvghnghhinhgvvghrihhnghdrtghomhdprhgtphhtthhopegrnhguihdrshhhhihtiheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhosghhsehkvghrnhgvlhdrohhrghdprhgtphhtt hhopehkrhiikhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegtohhnohhrodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqihdvtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopeguvghvihgtvghtrhgvvgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" Current nodename pattern doesn't limit the end of name for an i2c node. It can match 'i2c@10-foo'. In order to avoid matching to an incorrect name, avoid any extra characters in nodename pattern. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- dtschema/schemas/i2c/i2c-controller.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtschema/schemas/i2c/i2c-controller.yaml b/dtschema/schemas/i2= c/i2c-controller.yaml index 487e669..018d266 100644 --- a/dtschema/schemas/i2c/i2c-controller.yaml +++ b/dtschema/schemas/i2c/i2c-controller.yaml @@ -14,7 +14,7 @@ maintainers: =20 properties: $nodename: - pattern: "^i2c(@.*)?" + pattern: "^i2c(@.*)?$" =20 i2c-bus: type: object --=20 2.49.0 From nobody Fri May 9 15:08:51 2025 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) (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 1A1FC1E9B00; Tue, 1 Apr 2025 08:11:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743495065; cv=none; b=Ep/iEybKRqoi3bXHEyeo2oXqBpib6+4xcUjfuMJeVwiWTsjqTIm9S9sAYAuy8Mg49Xn92LYdv/Mcmoo8yD7IFkXGvhqsA/mIGopD5waQNl5EmM5KQ5c7kb0y/0i058BQfASUzGo3T5zL4fyV7NxJrNEBfIbXAJ0/J5y8w+Riq2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743495065; c=relaxed/simple; bh=tkCjRPi4FgO+9xzbgaJ6uPZ+TD9w57gzzaDTHbIFUgQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H+d+P4TcwYGw5tS2PlqxrfznMAePerR+355Oo1rzDo/flpbXpnGKZMlHZ4Mo9y9wz4BfOX5WMLNbKzBkRRK418/QPHFDy74dvDpfb97/rUZh/wLxKwgSVI6OuzL36s3AVXKtboEA4sNT1wMZwtMdwkea//d6NRcrxqKGNGtWFWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=NQQPT4xg; arc=none smtp.client-ip=217.70.183.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="NQQPT4xg" Received: by mail.gandi.net (Postfix) with ESMTPA id C26FA433E9; Tue, 1 Apr 2025 08:10:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1743495060; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c1pNziZfZZIH7XSR1sTc/u8QqrFfQOPsIYe5ZDNfFK4=; b=NQQPT4xgjDAuaec16lHAZjD3ckPxh+fyl8H8mZug6HqWn60DoLI5NUGiKzrXelCz2kOMRh 5vdJBFweXhG7BS2pfFleNDDxnTaE7t927tfL7pLeEw+cZOcPgcPrGy538uMiyOz8QFU539 KgbpbfXTZh9cXbW0zco1WrPGaoOFV/lOE5K5Dt3kw3LCk+v2af5KrqS5UrtL2U3m30OVqZ tv1mTm1FUBHrX7NVcBNLUManRFY16IGHGxE9IB/5ivR+7SsXADUskYtRD8CA+1/EvTeucn vNnBUky2sYQBbScgP2yjpnu79L2HRIJ4K0Uaetbc8aECXQTuP2fmqj/mCXl3OQ== From: Herve Codina <herve.codina@bootlin.com> To: Wolfram Sang <wsa+renesas@sang-engineering.com>, Andi Shyti <andi.shyti@kernel.org>, Rob Herring <robh@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>, Conor Dooley <conor+dt@kernel.org> Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree-spec@vger.kernel.org, Luca Ceresoli <luca.ceresoli@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Herve Codina <herve.codina@bootlin.com> Subject: [PATCH 2/2] schemas: i2c: Introduce I2C bus extensions Date: Tue, 1 Apr 2025 10:10:40 +0200 Message-ID: <20250401081041.114333-3-herve.codina@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250401081041.114333-1-herve.codina@bootlin.com> References: <20250401081041.114333-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddukedvvdelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefjvghrvhgvucevohguihhnrgcuoehhvghrvhgvrdgtohguihhnrgessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepheffiefgjeeuleeuueffleeufefglefhjefhheeigedukeetieeltddthfffkeffnecukfhppedvrgdtudemvgdtrgemvdegieemjeejledtmedviegtgeemvgdvvdemiedtfegumeehkegrnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvdgrtddumegvtdgrmedvgeeimeejjeeltdemvdeitgegmegvvddvmeeitdefugemheekrgdphhgvlhhopehlohgtrghlhhhoshhtrdhlohgtrghlughomhgrihhnpdhmrghilhhfrhhomhephhgvrhhvvgdrtghoughinhgrsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopeduvddprhgtphhtthhopeifshgrodhrvghnvghsrghssehsrghnghdqvghnghhinhgvvghrihhnghdrtghomhdprhgtphhtthhopegrnhguihdrshhhhihtiheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhosghhsehkvghrnhgvlhdrohhrghdprhgtphhtt hhopehkrhiikhdoughtsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegtohhnohhrodgutheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqihdvtgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopeguvghvihgtvghtrhgvvgesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" An I2C bus can be wired to the connector and allows an add-on board to connect additional I2C devices to this bus. Those additional I2C devices could be described as sub-nodes of the I2C bus controller node however for hotplug connectors described via device tree overlays there is additional level of indirection, which is needed to decouple the overlay and the base tree: --- base device tree --- i2c1: i2c@abcd0000 { compatible =3D "xyz,i2c-ctrl"; i2c-bus-extension@0 { i2c-bus =3D <&i2c_ctrl>; }; ... }; i2c5: i2c@cafe0000 { compatible =3D "xyz,i2c-ctrl"; i2c-bus-extension@0 { i2c-bus =3D <&i2c-sensors>; }; ... }; connector { i2c_ctrl: i2c-ctrl { i2c-parent =3D <&i2c1>; #address-cells =3D <1>; #size-cells =3D <0>; }; i2c-sensors { i2c-parent =3D <&i2c5>; #address-cells =3D <1>; #size-cells =3D <0>; }; }; --- device tree overlay --- ... // This node will overlay on the i2c-ctrl node of the base tree i2c-ctrl { eeprom@50 { compatible =3D "atmel,24c64"; ... }; }; ... --- resulting device tree --- i2c1: i2c@abcd0000 { compatible =3D "xyz,i2c-ctrl"; i2c-bus-extension@0 { i2c-bus =3D <&i2c_ctrl>; }; ... }; i2c5: i2c@cafe0000 { compatible =3D "xyz,i2c-ctrl"; i2c-bus-extension@0 { i2c-bus =3D <&i2c-sensors>; }; ... }; connector { i2c-ctrl { i2c-parent =3D <&i2c1>; #address-cells =3D <1>; #size-cells =3D <0>; eeprom@50 { compatible =3D "atmel,24c64"; ... }; }; i2c-sensors { i2c-parent =3D <&i2c5>; #address-cells =3D <1>; #size-cells =3D <0>; }; }; Here i2c-ctrl (same goes for i2c-sensors) represent the part of I2C bus that is on the hot-pluggable add-on. On hot-plugging it will physically connect to the I2C adapter on the base board. Let's call the 'i2c-ctrl' node an "extension node". In order to decouple the overlay from the base tree, the I2C adapter (i2c@abcd0000) and the extension node (i2c-ctrl) are separate nodes. The extension node is linked to the I2C bus controller in two ways. The first one with the i2c-bus-extension available in I2C controller sub-node and the second one with the i2c-parent property available in the extension node itself. The purpose of those two links is to provide the link in both direction from the I2C controller to the I2C extension and from the I2C extension to the I2C controller. Signed-off-by: Herve Codina <herve.codina@bootlin.com> Reviewed-by: Ayush Singh <ayush@beagleboard.org> --- dtschema/schemas/i2c/i2c-controller.yaml | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/dtschema/schemas/i2c/i2c-controller.yaml b/dtschema/schemas/i2= c/i2c-controller.yaml index 018d266..509b581 100644 --- a/dtschema/schemas/i2c/i2c-controller.yaml +++ b/dtschema/schemas/i2c/i2c-controller.yaml @@ -30,6 +30,13 @@ properties: minimum: 1 maximum: 5000000 =20 + i2c-parent: + $ref: /schemas/types.yaml#/definitions/phandle + description: + In case of an I2C bus extension, reference to the I2C bus controller + this extension is connected to. In other word, reference the I2C bus + controller on the fixed side that drives the bus extension. + i2c-scl-falling-time-ns: description: Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C @@ -159,6 +166,25 @@ allOf: - i2c-scl-has-clk-low-timeout =20 patternProperties: + 'i2c-bus-extension@[0-9a-f]+$': + type: object + description: + An I2C bus extension connected to an I2C bus. Those extensions allow= to + decouple I2C busses when they are wired to connectors. + + properties: + reg: + maxItems: 1 + + i2c-bus: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Reference to the extension bus. + + required: + - reg + - i2c-bus + '@[0-9a-f]+$': type: object =20 @@ -221,3 +247,44 @@ dependentRequired: i2c-digital-filter-width-ns: [ i2c-digital-filter ] =20 additionalProperties: true + +examples: + # I2C bus extension example involving an I2C bus controller and a connec= tor. + # + # +--------------+ +-------------+ +-------------+ + # | i2c@abcd0000 | | Connector | | Addon board | + # | (i2c1) +-----+ (i2c-addon) +-----+ (device@10) | + # | | | | | | + # +--------------+ +-------------+ +-------------+ + # + # The i2c1 I2C bus is wired from a I2C controller to a connector. It is + # identified at connector level as i2c-addon bus. + # An addon board can be connected to this connector and connects a device + # (device@10) to this i2c-addon extension bus. + - | + i2c1: i2c@abcd0000 { + compatible =3D "xyz,i2c-ctrl"; + reg =3D <0xabcd0000 0x100>; + #address-cells =3D <1>; + #size-cells =3D <0>; + + i2c-bus-extension@0 { + reg =3D <0>; + i2c-bus =3D <&i2c_addon>; + }; + }; + + connector { + i2c_addon: i2c-addon { + i2c-parent =3D <&i2c1>; + #address-cells =3D <1>; + #size-cells =3D <0>; + + device@10 { + compatible =3D "xyz,foo"; + reg =3D <0x10>; + }; + }; + }; + +... --=20 2.49.0