From: Corey Minyard <cminyard@mvista.com>
To: Patrick Venture <venture@google.com>
Cc: Hao Wu <wuhaotsh@google.com>,
qemu-arm@nongnu.org, Havard Skinnemoen <hskinnemoen@google.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 0/2] hw/i2c: Adds pca954x i2c mux switch device
Date: Tue, 6 Apr 2021 11:47:31 -0500 [thread overview]
Message-ID: <20210406164731.GP7167@minyard.net> (raw)
In-Reply-To: <CAO=notzJbWTn-KNurHs6HdzoLkFQRaKeNSdzBmufSu-eViRfww@mail.gmail.com>
On Tue, Apr 06, 2021 at 08:41:50AM -0700, Patrick Venture wrote:
> On Mon, Apr 5, 2021 at 12:58 PM Corey Minyard <cminyard@mvista.com> wrote:
> >
> > On Sat, Apr 03, 2021 at 03:28:08PM -0700, Patrick Venture wrote:
> > > The i2c mux device pca954x implements two devices:
> > > - the pca9546 and pca9548.
> > >
> > > Patrick Venture (2):
> > > hw/i2c/core: add reachable state boolean
> > > hw/i2c: add pca954x i2c-mux switch
> >
> > Looking this over, the code looks good, but I have a few general
> > questions:
> >
> > * Can you register the same slave address on different channels? That's
> > something you could do with real hardware and might be required at
> > some time. It looks like to me that you can't with this patch set,
> > but maybe I'm missing something.
>
> If I understand the hardware's implementation properly you can have
> collisions, and this allows for collisions. I'm not sure what you
> mean by having both accessible. For instance, on hardware you can
> have a switch with N channels, and on two of the channels there is an
> eeprom at 50. But you're unable to talk to both eeproms at the same
> time, because the addresses collide -- so how would the hardware know
> which you're talking to? My understanding of the behavior in this
> collision case is that it just talks to the first one that responds
> and can lead to unexpected things.
I wasn't talking about the collision case, I was talking about two
devices at the same address on two different channels. (In a collision,
BTW, both devices will generaly be active and you will get undefined
results.)
My understanding of what you are doing, and I may be wrong, is that you
are adding the devices to the main bus and using an enable/disable to
turn the devices on/off depending on which channel is enabled.
It does look like you can add multiple devices to the same bus at the
same address, so I do think that works.
>
> There is a board, the quanta-q71l where we had to set the
> idle-disconnect because there were two muxes on the same bus, with
> conflicting addresses, and so we had to use idle disconnect explicitly
> to make the software happy talking to the hardware -- not ideal as
> having two devices behind different channels, but ultimately it's the
> same idea because the devices are conflicting.
>
> >
> > * Can you add devices to the secondary I2C busses on the mux using the
> > standard QEMU device model, or is the function call required?
>
> I added the function call because I didn't see a clean way to bridge
> the issue as well as, the quasi-arbitrary bus numbering used by the
> kernel isn't how the hardware truly behaves, and my goal was to
> implement closer to the hardware. I thought about adding an I2cBus to
> the device and then you'd be able to access it, but wasn't sure of a
> nice clean way to plumb that through -- I considered adding/removing
> devices from the parent i2c bus instead of the boolean reachable, but
> that seemed way less clean - although do-able.
The only way I can think of with the method that you are using would be
to add a mux and channel to the i2c device, but that's not very natural.
The patch I did implements it by plumbing through, like you say. It's a
little bit of a hack, but not too bad.
>
> >
> > I ask because I did a pca9540 and pca9541 device, but I've never
> > submitted it because I didn't think it would ever be needed. It takes a
> > different tack on the problem; it creates the secondary busses as
> > standard QEMU I2C busses and bridges them. You can see it at
> >
> > github.com:cminyard/qemu.git master-i2c-rebase
> >
>
> I'll have to take a look at your approach, but the idea that it
> wouldn't be needed sounds bizarre to me as nearly all BMC-based qemu
> boards leverage i2c muxes to handle their PCIe slot i2c routing.
Yeah, I don't work in that world :). I can see the need there, and
nobody has asked up til now. I wish I had pushed it in earlier, then
your job would have been a lot easier.
-corey
>
> > If you design can do the things I ask, then it's better. If not, then
> > I'm not sure.
> >
> > -corey
> >
> > >
> > > MAINTAINERS | 6 +
> > > hw/i2c/Kconfig | 4 +
> > > hw/i2c/core.c | 6 +
> > > hw/i2c/i2c_mux_pca954x.c | 182 +++++++++++++++++++++++++++++++
> > > hw/i2c/meson.build | 1 +
> > > hw/i2c/trace-events | 5 +
> > > include/hw/i2c/i2c.h | 3 +
> > > include/hw/i2c/i2c_mux_pca954x.h | 60 ++++++++++
> > > 8 files changed, 267 insertions(+)
> > > create mode 100644 hw/i2c/i2c_mux_pca954x.c
> > > create mode 100644 include/hw/i2c/i2c_mux_pca954x.h
> > >
> > > --
> > > 2.31.0.208.g409f899ff0-goog
> > >
prev parent reply other threads:[~2021-04-06 16:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-03 22:28 [PATCH 0/2] hw/i2c: Adds pca954x i2c mux switch device Patrick Venture
2021-04-03 22:28 ` [PATCH 1/2] hw/i2c/core: add reachable state boolean Patrick Venture
2021-04-03 22:28 ` [PATCH 2/2] hw/i2c: add pca954x i2c-mux switch Patrick Venture
2021-04-05 19:58 ` [PATCH 0/2] hw/i2c: Adds pca954x i2c mux switch device Corey Minyard
2021-04-06 15:41 ` Patrick Venture
2021-04-06 15:55 ` Patrick Venture
2021-04-06 18:36 ` Corey Minyard
2021-04-06 22:21 ` Patrick Venture
2021-04-06 23:39 ` Corey Minyard
2021-04-07 23:25 ` Patrick Venture
2021-04-06 16:47 ` Corey Minyard [this message]
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=20210406164731.GP7167@minyard.net \
--to=cminyard@mvista.com \
--cc=hskinnemoen@google.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=venture@google.com \
--cc=wuhaotsh@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.