From: Timur Tabi <timur@freescale.com>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: Andy Fleming <afleming@freescale.com>,
David Miller <davem@davemloft.net>,
ddaney.cavm@gmail.com, devicetree-discuss@lists.ozlabs.org,
netdev@vger.kernel.org
Subject: Re: [PATCH] [v3] netdev/phy: add MDIO bus multiplexer driven by a memory-mapped device
Date: Fri, 24 Aug 2012 15:00:32 -0500 [thread overview]
Message-ID: <5037DD60.8090206@freescale.com> (raw)
In-Reply-To: <5037DB43.60704@wwwdotorg.org>
Stephen Warren wrote:
>> +This is a special case of a MDIO bus multiplexer. A memory-mapped device,
>> +like an FPGA, is used to control which child bus is connected. The mdio-mux
>> +node must be a child of the memory-mapped device. The driver currently only
>> +supports devices with eight-bit registers.
>
> That last sentence seems like a property of the driver, not the binding;
> I could easily anticipate allowing the size to be 1 or 2 or 4, and a
> driver adapter to that in the future.
True, but I couldn't think of a better place to mention this. Adding
support for multi-byte registers also requires handling the endianness of
those registers. I have that problem with the mdio-mux-gpio driver. That
driver assumes that the GPIO bits are numbered in little-endian order, so
my device tree on my big-endian CPU (PowerPC) lists the GPIO pins in
reverse order.
> Otherwise, this binding looks great now.
Do you still want me to scrub any references to the register size
requirement from the document?
>> +++ b/drivers/net/phy/mdio-mux-mmioreg.c
>
>> +static int mdio_mux_mmioreg_switch_fn(int current_child, int desired_child,
>> + void *data)
>> +{
>> + struct mdio_mux_mmioreg_state *s = data;
>> +
>> + if (current_child ^ desired_child) {
>> + void *p = ioremap(s->phys, 1);
>> + uint8_t x, y;
>> +
>> + if (!p)
>> + return -ENOMEM;
>
> Why not map it during probe?
I thought about that, but I generally don't like mappings that exist for
all eternity even though they're rarely used. Once the interface is up,
we don't expect any bus muxing to occur.
>
>> + x = ioread8(p);
>> + y = (x & ~s->mask) | desired_child;
>> + if (x != y) {
>
> Isn't that always true, given if (current_child ^ desired_child) above?
If current_child == -1, but the bus is already muxed properly, then
there's no point in setting it. Do you want me to remove the test, or add
a comment?
--
Timur Tabi
Linux kernel developer at Freescale
WARNING: multiple messages have this Message-ID (diff)
From: Timur Tabi <timur@freescale.com>
To: Stephen Warren <swarren@wwwdotorg.org>
Cc: Andy Fleming <afleming@freescale.com>,
David Miller <davem@davemloft.net>, <ddaney.cavm@gmail.com>,
<devicetree-discuss@lists.ozlabs.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH] [v3] netdev/phy: add MDIO bus multiplexer driven by a memory-mapped device
Date: Fri, 24 Aug 2012 15:00:32 -0500 [thread overview]
Message-ID: <5037DD60.8090206@freescale.com> (raw)
In-Reply-To: <5037DB43.60704@wwwdotorg.org>
Stephen Warren wrote:
>> +This is a special case of a MDIO bus multiplexer. A memory-mapped device,
>> +like an FPGA, is used to control which child bus is connected. The mdio-mux
>> +node must be a child of the memory-mapped device. The driver currently only
>> +supports devices with eight-bit registers.
>
> That last sentence seems like a property of the driver, not the binding;
> I could easily anticipate allowing the size to be 1 or 2 or 4, and a
> driver adapter to that in the future.
True, but I couldn't think of a better place to mention this. Adding
support for multi-byte registers also requires handling the endianness of
those registers. I have that problem with the mdio-mux-gpio driver. That
driver assumes that the GPIO bits are numbered in little-endian order, so
my device tree on my big-endian CPU (PowerPC) lists the GPIO pins in
reverse order.
> Otherwise, this binding looks great now.
Do you still want me to scrub any references to the register size
requirement from the document?
>> +++ b/drivers/net/phy/mdio-mux-mmioreg.c
>
>> +static int mdio_mux_mmioreg_switch_fn(int current_child, int desired_child,
>> + void *data)
>> +{
>> + struct mdio_mux_mmioreg_state *s = data;
>> +
>> + if (current_child ^ desired_child) {
>> + void *p = ioremap(s->phys, 1);
>> + uint8_t x, y;
>> +
>> + if (!p)
>> + return -ENOMEM;
>
> Why not map it during probe?
I thought about that, but I generally don't like mappings that exist for
all eternity even though they're rarely used. Once the interface is up,
we don't expect any bus muxing to occur.
>
>> + x = ioread8(p);
>> + y = (x & ~s->mask) | desired_child;
>> + if (x != y) {
>
> Isn't that always true, given if (current_child ^ desired_child) above?
If current_child == -1, but the bus is already muxed properly, then
there's no point in setting it. Do you want me to remove the test, or add
a comment?
--
Timur Tabi
Linux kernel developer at Freescale
next prev parent reply other threads:[~2012-08-24 20:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 19:10 [PATCH] [v3] netdev/phy: add MDIO bus multiplexer driven by a memory-mapped device Timur Tabi
2012-08-24 19:10 ` Timur Tabi
2012-08-24 19:51 ` Stephen Warren
2012-08-24 20:00 ` Timur Tabi [this message]
2012-08-24 20:00 ` Timur Tabi
2012-08-24 20:04 ` Stephen Warren
2012-08-30 16:55 ` David Miller
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=5037DD60.8090206@freescale.com \
--to=timur@freescale.com \
--cc=afleming@freescale.com \
--cc=davem@davemloft.net \
--cc=ddaney.cavm@gmail.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=swarren@wwwdotorg.org \
/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.