From: Heiko Schocher <hs@denx.de>
To: Simon Glass <sjg@chromium.org>, Philip Oberfichtner <pro@denx.de>
Cc: u-boot@lists.denx.de, trini@konsulko.com
Subject: Re: [PATCH 2/2] bootcount: Add driver model I2C driver
Date: Wed, 18 Oct 2023 06:31:57 +0200 [thread overview]
Message-ID: <1ba8ea25-bad0-b66f-b189-67754c488103@denx.de> (raw)
In-Reply-To: <CAPnjgZ2OZka03fG5Bt49JxoLn-VHy5TB81r6_uXTy+K5SOGYOw@mail.gmail.com>
Hello Simon,
On 18.10.23 05:33, Simon Glass wrote:
> Hi Philip,
>
> On Tue, 17 Oct 2023 at 06:57, Philip Oberfichtner <pro@denx.de> wrote:
>>
>> Hi Simon,
>>
>> maybe you can give me a hint on how to implement this cleanly in driver
>> model?
>>
>> To sum it up, I'd like to have a phandle pointing to *any* I2C device,
>> not knowing which UCLASS actually fits. Then the device and the parent
>> bus should be probed/prepared such that dm_i2c_read() can be used.
>>
>> Any ideas on this?
>
> I suggest a phandle to the i2c device.
Yep!
> You can use oftree_get_by_phandle() to get the node and then
> device_find_global_by_ofnode() to get the device.
>
> This is expensive, although eventually I suspect we will fix that with
> OF_LIVE. I think it should be implemented as a new function in i2c.h
> so we can change the impl later easily.
Yes, please.
> If you want to be more efficient you could do something like:
>
> int phandle = ??
>
> struct uclass *uc;
> struct udevice *bus;
>
> uclass_id_foreach_dev(UCLASS_I2C, bus, uc) {
> struct udevice *dev;
>
> device_foreach_child(dev, bus) {
> if (!dev_read_u32(dev, "phandle", &val) && val == phandle)
> return dev;
> }
> }
>
> but honestly now I look at it, that is awful. We try to avoid exposing
> the internals of phandle because it allows us to (one day) maintain a
> list of them.
Yes, please not ... a list of phandles would be great we can than
walk through, yes, may in future...
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 ...
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs@denx.de
next prev parent reply other threads:[~2023-10-18 4:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-13 9:43 [PATCH 0/2] bootcount: Replace I2C legacy implementation by driver model Philip Richard Oberfichtner
2023-10-13 9:43 ` [PATCH 1/2] bootcount: Remove legacy I2C driver Philip Richard Oberfichtner
2023-10-13 11:21 ` Heiko Schocher
2023-10-13 11:35 ` Philip Oberfichtner
2023-10-13 12:10 ` Heiko Schocher
2023-10-13 9:43 ` [PATCH 2/2] bootcount: Add driver model " Philip Richard Oberfichtner
2023-10-13 11:28 ` Heiko Schocher
2023-10-13 12:58 ` Philip Oberfichtner
2023-10-17 12:55 ` Philip Oberfichtner
2023-10-18 3:33 ` Simon Glass
2023-10-18 4:31 ` Heiko Schocher [this message]
2023-10-18 10:58 ` Philip Oberfichtner
2023-10-18 16:10 ` Simon Glass
2023-10-20 3:18 ` Heiko Schocher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1ba8ea25-bad0-b66f-b189-67754c488103@denx.de \
--to=hs@denx.de \
--cc=pro@denx.de \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox