[PATCH v13 0/8] i2c-atr and FPDLink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

You can find v12 from:

https://lore.kernel.org/all/20230425072601.51031-1-tomi.valkeinen@xxxxxxxxxxxxxxxx/

Diff to v12 is included below.

The changes are:

- Change the i2c-alias-pool to u32 array. The i2c-atr.c will reject any
  addresses that have bits in the upper 16 bits. This could be changed
  later if those bits are needed.

- Add maxItems to ub960's i2c-alias-pool. ub960 has 4 rx ports, and each
  can have 8 aliases, so the absolute maximum is 32.

 Tomi

Luca Ceresoli (1):
  i2c: add I2C Address Translator (ATR) support

Tomi Valkeinen (7):
  dt-bindings: i2c: Add I2C Address Translator (ATR)
  dt-bindings: media: add TI DS90UB913 FPD-Link III Serializer
  dt-bindings: media: add TI DS90UB953 FPD-Link III Serializer
  dt-bindings: media: add TI DS90UB960 FPD-Link III Deserializer
  media: i2c: add DS90UB960 driver
  media: i2c: add DS90UB913 driver
  media: i2c: add DS90UB953 driver

 .../devicetree/bindings/i2c/i2c-atr.yaml      |   34 +
 .../bindings/media/i2c/ti,ds90ub913.yaml      |  133 +
 .../bindings/media/i2c/ti,ds90ub953.yaml      |  134 +
 .../bindings/media/i2c/ti,ds90ub960.yaml      |  427 ++
 Documentation/i2c/i2c-address-translators.rst |   96 +
 Documentation/i2c/index.rst                   |    1 +
 MAINTAINERS                                   |   16 +
 drivers/i2c/Kconfig                           |    9 +
 drivers/i2c/Makefile                          |    1 +
 drivers/i2c/i2c-atr.c                         |  710 +++
 drivers/media/i2c/Kconfig                     |   47 +
 drivers/media/i2c/Makefile                    |    3 +
 drivers/media/i2c/ds90ub913.c                 |  906 ++++
 drivers/media/i2c/ds90ub953.c                 | 1400 ++++++
 drivers/media/i2c/ds90ub960.c                 | 4049 +++++++++++++++++
 include/linux/i2c-atr.h                       |  116 +
 include/media/i2c/ds90ub9xx.h                 |   22 +
 17 files changed, 8104 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-atr.yaml
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ti,ds90ub913.yaml
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ti,ds90ub953.yaml
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml
 create mode 100644 Documentation/i2c/i2c-address-translators.rst
 create mode 100644 drivers/i2c/i2c-atr.c
 create mode 100644 drivers/media/i2c/ds90ub913.c
 create mode 100644 drivers/media/i2c/ds90ub953.c
 create mode 100644 drivers/media/i2c/ds90ub960.c
 create mode 100644 include/linux/i2c-atr.h
 create mode 100644 include/media/i2c/ds90ub9xx.h

Interdiff against v12:
diff --git a/Documentation/devicetree/bindings/i2c/i2c-atr.yaml b/Documentation/devicetree/bindings/i2c/i2c-atr.yaml
index 470cc6c9af35..1939ab339bfc 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-atr.yaml
+++ b/Documentation/devicetree/bindings/i2c/i2c-atr.yaml
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/i2c/i2c-atr.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: Common i2c address translator properties.
+title: Common i2c address translator properties
 
 maintainers:
   - Tomi Valkeinen <tomi.valkeinen@xxxxxxxxxxxxxxxx>
@@ -20,7 +20,7 @@ description:
 
 properties:
   i2c-alias-pool:
-    $ref: /schemas/types.yaml#/definitions/uint16-array
+    $ref: /schemas/types.yaml#/definitions/uint32-array
     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
diff --git a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml
index 1d5362bea09a..289737721c2c 100644
--- a/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/ti,ds90ub960.yaml
@@ -13,6 +13,9 @@ description:
   The TI DS90UB9XX devices are FPD-Link video deserializers with I2C and GPIO
   forwarding.
 
+allOf:
+  - $ref: /schemas/i2c/i2c-atr.yaml#
+
 properties:
   compatible:
     enum:
@@ -37,7 +40,8 @@ properties:
       Specifier for the GPIO connected to the PDB pin.
 
   i2c-alias-pool:
-    $ref: /schemas/i2c/i2c-atr.yaml#/properties/i2c-alias-pool
+    minItems: 1
+    maxItems: 32
 
   links:
     type: object
@@ -225,7 +229,7 @@ required:
   - clock-names
   - ports
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
@@ -245,7 +249,7 @@ examples:
 
         powerdown-gpios = <&pca9555 7 GPIO_ACTIVE_LOW>;
 
-        i2c-alias-pool = /bits/ 16 <0x4a 0x4b 0x4c 0x4d 0x4e 0x4f>;
+        i2c-alias-pool = <0x4a 0x4b 0x4c 0x4d 0x4e 0x4f>;
 
         ports {
           #address-cells = <1>;
diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c
index 402182a04efd..8ca1daadec93 100644
--- a/drivers/i2c/i2c-atr.c
+++ b/drivers/i2c/i2c-atr.c
@@ -428,10 +428,12 @@ static int i2c_atr_parse_alias_pool(struct i2c_atr *atr)
 	struct device *dev = atr->dev;
 	unsigned long *alias_use_mask;
 	size_t num_aliases;
-	u16 *aliases;
+	unsigned int i;
+	u32 *aliases32;
+	u16 *aliases16;
 	int ret;
 
-	ret = fwnode_property_count_u16(dev_fwnode(dev), "i2c-alias-pool");
+	ret = fwnode_property_count_u32(dev_fwnode(dev), "i2c-alias-pool");
 	if (ret < 0) {
 		dev_err(dev, "Failed to count 'i2c-alias-pool' property: %d\n",
 			ret);
@@ -443,32 +445,56 @@ static int i2c_atr_parse_alias_pool(struct i2c_atr *atr)
 	if (!num_aliases)
 		return 0;
 
-	aliases = kcalloc(num_aliases, sizeof(*aliases), GFP_KERNEL);
-	if (!aliases)
+	aliases32 = kcalloc(num_aliases, sizeof(*aliases32), GFP_KERNEL);
+	if (!aliases32)
 		return -ENOMEM;
 
-	ret = fwnode_property_read_u16_array(dev_fwnode(dev), "i2c-alias-pool",
-					     aliases, num_aliases);
+	ret = fwnode_property_read_u32_array(dev_fwnode(dev), "i2c-alias-pool",
+					     aliases32, num_aliases);
 	if (ret < 0) {
 		dev_err(dev, "Failed to read 'i2c-alias-pool' property: %d\n",
 			ret);
-		kfree(aliases);
-		return ret;
+		goto err_free_aliases32;
+	}
+
+	aliases16 = kcalloc(num_aliases, sizeof(*aliases16), GFP_KERNEL);
+	if (!aliases16) {
+		ret = -ENOMEM;
+		goto err_free_aliases32;
+	}
+
+	for (i = 0; i < num_aliases; i++) {
+		if (!(aliases32[i] & 0xffff0000)) {
+			aliases16[i] = aliases32[i];
+			continue;
+		}
+
+		dev_err(dev, "Failed to parse 'i2c-alias-pool' property: I2C flags are not supported\n");
+		ret = -EINVAL;
+		goto err_free_aliases16;
 	}
 
 	alias_use_mask = bitmap_zalloc(num_aliases, GFP_KERNEL);
 	if (!alias_use_mask) {
-		kfree(aliases);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto err_free_aliases16;
 	}
 
+	kfree(aliases32);
+
 	atr->num_aliases = num_aliases;
-	atr->aliases = aliases;
+	atr->aliases = aliases16;
 	atr->alias_use_mask = alias_use_mask;
 
 	dev_dbg(dev, "i2c-alias-pool has %zu aliases", atr->num_aliases);
 
 	return 0;
+
+err_free_aliases16:
+	kfree(aliases16);
+err_free_aliases32:
+	kfree(aliases32);
+	return ret;
 }
 
 struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev,
-- 
2.34.1




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux