
Hello Philip,
On 18.10.23 18:10, Simon Glass wrote:
Hi Philip,
On Wed, 18 Oct 2023 at 05:00, Philip Oberfichtner <pro@denx.de mailto:pro@denx.de> wrote:
Hi Heiko,
On Wed, Oct 18, 2023 at 06:31:57AM +0200, Heiko Schocher wrote:
[...]
May Philip can use uclass_get_device_by_phandle and try a list of possible UCLASS candidates, like UCLASS_RTC, UCLASS_I2C_EEPROM, UCLASS_POWER,... and if found, check if parent is UCLASS_I2C...
may not so expensive ...
Looks more cheap and elegant than the other variants indeed. But I'm not sure if we can maintain generality using this approach.
What if the specific I2C driver is not included in the build, because the devices "actual" functionality is not required?
Then the device will not be bound and the function will fail. There needs to be a node and a bound device.
Yep.
Or what if a driver for the specific device does not even exist in U-Boot?
Wouldn't the device fail to probe then?
The DT should specify the compatible string so the correct i2c driver is used. If there isn't one,I believe it uses I2C_GENERIC but you'll need to check it.
Yes, needs a check.
But... that is the real issue with that approach (more or less with all bootcounter drivers?) ... if you assume that the device driver is not there, may there is missing device init/probe stuff, so also may the bootcounter will not work!
The i2c device should know, that some registers, mem (or whatever) is used for bootcounter function, so that it does not use this space for other device stuff ... to make bootcounters correct, we need something like a MFD approach here ... and register a bootcounter within that... so init/probe stuff is always done, and registers/mem is reserved ...
But unfortunately we do not have this...
Please correct me if I'm wrong, I'd give it a shot in that case. Otherwise I'll try it with the aforementioned device_find_global_by_ofnode() followed by device_bind_driver() using UCLASS_I2C_GENERIC (I hope that works).
That is the same approach, I think. But anyway I think Heiko knows more about this than me.
Hmm... yes, with UCLASS_I2C_GENERIC it could also work, but see my comment above ...
bye, Heiko