Re: [PATCH v10 5/8] dt-bindings: media: add TI DS90UB960 FPD-Link III Deserializer

Tomi Valkeinen
2023-04-20T07:30:49Z

On 18/04/2023 16:06, Wolfram Sang wrote:
>
>> + i2c-alias-pool:
>> + $ref: /schemas/types.yaml#/definitions/uint16-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
>> + 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.
>
> After some initial discussion with Tomi on IRC, this question is
> probably more for Luca:
>
> Why is "i2c-alias-pool" in the drivers binding and not a regular i2c

Where should be the binding documented? A new
Documentation/devicetree/bindings/i2c/i2c-atr.yaml file that only
contains the i2c-alias-pool?

> binding? Same question for the implementation of the alias-pool
> handling. Shouldn't this be in the i2c-atr library? I'd think managing
> the list of aliases would look all the same in the drivers otherwise?

I think this is fine, but I also think that we need to keep the door
open to other kinds of alias management. We only have a single user for
this for now. A driver/device might have other requirements for its
i2c-atr. Say, a pool per link, or perhaps runtime events may affect the
pool.

If we dictate the use of i2c-alias-pool property and the i2c-atr will
automatically get an alias from that pool, i2c-atr won't be usable for
the hypothetical drivers that have other needs.

With that in mind the current binding and i2c-atr.c is safe, as the
i2c-atr.c isn't even aware of the pool.

We can easily re-arrange the code later if and when we get more users
and understand their needs. But the bindings are important to get
right(-ish) now. So:

- Is the "i2c-alias-pool" property a driver property or a common
property for all drivers using i2c-atr?

- It the property mandatory or optional? It must be optional, as a setup
(meaning, e.g., what cameras you happen to connect) might not have any
i2c addressable remote devices, in which case the driver doesn't even
need i2c-atr (even if it supports i2c-atr). But is it optional even in
the case where the driver needs i2c-atr? In other words, do we allow
some other way to manage the aliases?

How does this sound:

- If "i2c-alias-pool" is present in the DT data of the device passed to
i2c_atr_new(), i2c_atr_new() will parse the property. i2c-atr.c will
export functions to get a new alias and to release a previously reserved
alias. The driver can use those functions in attach/detach_client()
callbacks. In other words, the alias pool management wouldn't be fully
automatic inside the i2c-atr, but it would provide helpers for the
driver to do the common work.

- If "i2c-alias-pool" is not present, i2c-atr.c will behave as it does
now, and expects the driver to manage the aliases.

Also, looking at the ub960 code... I don't think this will simplify the
attach/detach_client callbacks much. Most of the code in those functions
is about managing the UB960's registers related to ATR, not managing the
address pool itself. However, it will remove the probe time
"i2c-alias-pool" parsing from the driver, which is nice.

Tomi