Re: [RFC PATCH 0/2] Clause-22/Clause-45 MDIO regmap support

From: Andrew Lunn
Date: Fri Jun 04 2021 - 16:38:27 EST


On Fri, Jun 04, 2021 at 06:25:15PM +0100, Mark Brown wrote:
> On Thu, Jun 03, 2021 at 08:25:08PM +0200, Sander Vanheule wrote:
>
> > 1. I've opted to just ignore any bits that lie beyond the allowed address
> > width. Would it be cleaner to raise an error instead?
>
> It doesn't *really* matter, enforcement is probably a bit better as it
> might catch bugs.

I would agree with that. The mostly likely problem is that somebody
misses the difference between C22 and C45 and instantiates the wrong
sort of regmap. You can quickly detect a C22 regmap being used for C45
due to the range difference.

> > 2. Packing of the clause-45 register addresses (16 bit) and adressed device
> > type (5 bit) is the same as in the mdio subsystem, resulting in a 21 bit
> > address. Is this an appropriate way to pack this information into one
> > address for the regmap interface?
>
> Either that or pass the type in when instantiating the regmap (it sounds
> like it should be the same for all registers on the device?).

A device can implement both C22 and C45. There is also a standardized
way to perform C45 access over C22, using two registers in C22 space.
But this assumes the device is an Ethernet PHY, or is at least making
use of the Ethernet PHY way of doing this tunnelling. But i doubt any
Ethernet PHY driver will ever use regmap.

Where i see regmap-mdio being used it for non-Ethernet PHY
devices. That mostly means Ethernet Switches and oddball devices like
this like LED controller. Broadcom also have a generic PHY driver
talking over MDIO to hardware.

Andrew