@@ -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@ideasonboard.com>
@@ -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
@@ -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>;
@@ -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,