Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7265896rwr; Tue, 25 Apr 2023 10:18:01 -0700 (PDT) X-Google-Smtp-Source: AKy350ZR+ryFy1eiyGINTFfTNcg9hnvECZdAw5VHUj3wur4epNfg34bXpynjXmEY6SK0uRM6E1Aw X-Received: by 2002:a05:6a20:d2ca:b0:d6:c92:9925 with SMTP id ir10-20020a056a20d2ca00b000d60c929925mr21135005pzb.31.1682443081027; Tue, 25 Apr 2023 10:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682443081; cv=none; d=google.com; s=arc-20160816; b=uEmKnkXSYViiUK3eUAotcP83aH+QHce+X3voXSaMh6F1NdUweh8MZIwrp5S7CQvczc xQX9/M3Q3HTK3Ev29v0xN69pLzd7tBAZ/q5Rp7kjBO7fVDusLTtAotv8CcRCN5xSkEvB Evqetyw6jr8LkVF0bNgzGgFQW18WFfg3h4sme4oOYy7pHIgloZahqh1QD0B2+0/r8m0x 4QpQgzy9AddJhm83t9+I7mzHgOK5FxR+DhgODuU9emQZq5AIptIbo8L9XjYvpD+QD02p X0SetOgchHNUdB/Bh818Hv0fgd79QTOUAN7B4iL61HNO+hTGceV6FhPGZEFNVxvKW4aI PiuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Yzu6w9WOniFz1mjvEavwP3dT0w7oV2bISDbejOiYeZA=; b=BMVahLot05Mcj7BaNlfxSNjDB1WKSFu+9X0TNJTxf+Ahhs9KQ8hanihppeq/E3lizq f3DUUx0diAwxGrbnc9ggR0iLbVLb9eafzO77TZHEWBv91Hj+YPfQEQLCrMaZ/TWK4DAY dtmmuduWDZHLxvjyxV5jAgYEkNCKSXnbMGsOy9q1l/ni4cNsMucLrB9ttw6wI4aDi6/H LHcs2K21SgHTw8H7OMLAtHzLOwy+ZWx2jPVT7RTaVOfSHU90JhOyfKQ1/O2+XCIVf8L8 BuHrnxDlUQPblI1ZUzFusc5zwcGdyL1GlkCLoxq32TtR9nmIl5lwlwCSs5tNxHmhj6iJ VaCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t67-20020a625f46000000b0063b1f577d29si14476256pfb.192.2023.04.25.10.17.48; Tue, 25 Apr 2023 10:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234725AbjDYRNw (ORCPT + 99 others); Tue, 25 Apr 2023 13:13:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231337AbjDYRNv (ORCPT ); Tue, 25 Apr 2023 13:13:51 -0400 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B73E71; Tue, 25 Apr 2023 10:13:50 -0700 (PDT) Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6a5d9853d97so2373749a34.2; Tue, 25 Apr 2023 10:13:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682442829; x=1685034829; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yzu6w9WOniFz1mjvEavwP3dT0w7oV2bISDbejOiYeZA=; b=b8dsZ8VfXDXdLr7lQncoFnaSADO+PVBY44TKer/wLhyNz1lNXMYFDbGTkDqpX8vI47 2vxhAn2h8mOYSBl9WojMJg8Dgk0qmEk32iBGfKL80A1Vduuv8+iBgyokMJef0AclE6wJ XFjhRJbw2gN8v/NJJgx0IgdTcmVM/cehkiDNK5wvnKEHD/7uVQUjZ3/IFNI7bzzSSGn+ 3eHwDDtN/DpqeC0d8UpbbhizSvnx3yqTT0Ki7fsP6N1kDJpSf8l2/7yfRqXAcOBPEj9f 119dyYzqbq6ZjW3rsoOEYRBe7KGlFfAek1ktPW7HZ+4J1e9dv6xZ7tJWegL6WnSQpHcE OR2A== X-Gm-Message-State: AAQBX9fnmFa+D4MkhVg9C/3hSTLS4Xm9LiLvK1FabKquP3v/0MTuJ89R mqiIAXNyi7h8dG2NuPFzYg== X-Received: by 2002:aca:2816:0:b0:38e:f0c4:2106 with SMTP id 22-20020aca2816000000b0038ef0c42106mr2332695oix.5.1682442829177; Tue, 25 Apr 2023 10:13:49 -0700 (PDT) Received: from robh_at_kernel.org (66-90-144-107.dyn.grandenetworks.net. [66.90.144.107]) by smtp.gmail.com with ESMTPSA id g4-20020a0568080dc400b0038e4c6fb8e0sm5792314oic.58.2023.04.25.10.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 10:13:48 -0700 (PDT) Received: (nullmailer pid 1966662 invoked by uid 1000); Tue, 25 Apr 2023 17:13:47 -0000 Date: Tue, 25 Apr 2023 12:13:47 -0500 From: Rob Herring To: Tomi Valkeinen Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, Krzysztof Kozlowski , Wolfram Sang , Luca Ceresoli , Andy Shevchenko , Matti Vaittinen , Laurent Pinchart , Mauro Carvalho Chehab , Peter Rosin , Liam Girdwood , Mark Brown , Sakari Ailus , Michael Tretter , Hans Verkuil , Mike Pagano , Krzysztof =?utf-8?Q?Ha=C5=82asa?= , Marek Vasut , Satish Nagireddy , Luca Ceresoli , Andy Shevchenko Subject: Re: [PATCH v11 1/7] i2c: add I2C Address Translator (ATR) support Message-ID: <20230425171347.GB1957523-robh@kernel.org> References: <20230421101833.345984-1-tomi.valkeinen@ideasonboard.com> <20230421101833.345984-2-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230421101833.345984-2-tomi.valkeinen@ideasonboard.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 21, 2023 at 01:18:27PM +0300, Tomi Valkeinen wrote: > From: Luca Ceresoli > > An ATR is a device that looks similar to an i2c-mux: it has an I2C > slave "upstream" port and N master "downstream" ports, and forwards > transactions from upstream to the appropriate downstream port. But it > is different in that the forwarded transaction has a different slave > address. The address used on the upstream bus is called the "alias" > and is (potentially) different from the physical slave address of the > downstream chip. > > Add a helper file (just like i2c-mux.c for a mux or switch) to allow > implementing ATR features in a device driver. The helper takes care or > adapter creation/destruction and translates addresses at each transaction. > > Signed-off-by: Luca Ceresoli > Signed-off-by: Tomi Valkeinen > Reviewed-by: Andy Shevchenko > --- > .../devicetree/bindings/i2c/i2c-atr.yaml | 34 + > Documentation/i2c/i2c-address-translators.rst | 96 +++ > Documentation/i2c/index.rst | 1 + > MAINTAINERS | 8 + > drivers/i2c/Kconfig | 9 + > drivers/i2c/Makefile | 1 + > drivers/i2c/i2c-atr.c | 684 ++++++++++++++++++ > include/linux/i2c-atr.h | 116 +++ > 8 files changed, 949 insertions(+) > create mode 100644 Documentation/devicetree/bindings/i2c/i2c-atr.yaml > create mode 100644 Documentation/i2c/i2c-address-translators.rst > create mode 100644 drivers/i2c/i2c-atr.c > create mode 100644 include/linux/i2c-atr.h > > diff --git a/Documentation/devicetree/bindings/i2c/i2c-atr.yaml b/Documentation/devicetree/bindings/i2c/i2c-atr.yaml > new file mode 100644 > index 000000000000..d7f73d98110d > --- /dev/null > +++ b/Documentation/devicetree/bindings/i2c/i2c-atr.yaml > @@ -0,0 +1,34 @@ > +# SPDX-License-Identifier: GPL-2.0 Dual license. > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/i2c/i2c-atr.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Common i2c address translator properties. Drop hard stop. > + > +maintainers: > + - Tomi Valkeinen > + > +description: > + An I2C Address Translator (ATR) is a device with an I2C slave parent > + ("upstream") port and N I2C master child ("downstream") ports, and > + forwards transactions from upstream to the appropriate downstream port > + with a modified slave address. The address used on the parent bus is > + called the "alias" and is (potentially) different from the physical > + slave address of the child bus. Address translation is done by the > + hardware. > + > +properties: > + i2c-alias-pool: > + $ref: /schemas/types.yaml#/definitions/uint16-array We do support some flags in the upper 16-bits of I2C addresses. Any of those possibly needed here? > + description: > + I2C alias pool is a pool of I2C addresses on the main I2C bus that can be > + used to access the remote peripherals on the serializer's I2C bus. The > + addresses must be available, not used by any other peripheral. Each > + remote peripheral is assigned an alias from the pool, and transactions to > + that address will be forwarded to the remote peripheral, with the address > + translated to the remote peripheral's real address. This property is not > + needed if there are no I2C addressable remote peripherals. > + > +additionalProperties: true > +...