All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/7] Introduce a generic regmap-based MDIO driver
@ 2023-03-24  9:36 Maxime Chevallier
  2023-03-24  9:36 ` [RFC 1/7] regmap: add a helper to translate the register address Maxime Chevallier
                   ` (7 more replies)
  0 siblings, 8 replies; 27+ messages in thread
From: Maxime Chevallier @ 2023-03-24  9:36 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, rafael, Colin Foster,
	Vladimir Oltean, Lee Jones, davem, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, Heiner Kallweit, Russell King
  Cc: Maxime Chevallier, linux-kernel, netdev, thomas.petazzoni

Hello everyone,

When the Altera TSE PCS driver was initially introduced, there were
comments by Russell that the register layout looked very familiar to the
existing Lynx PCS driver, the only difference being that the TSE PCS
driver is memory-mapped whereas the Lynx PCS driver sits on an MDIO bus.

Since then, I've sent a followup to create a wrapper around Lynx, that
would create a virtual MDIO bus driver that would translate the mdio
operations to mmio operations [1].

Discussion ensued, and we agreed that we could make this more generic,
the idea being that this PCS isn't the only example of such a device,
that memory-maps an mdio-like register layout

Vladimir mentionned that some ocelot devices have the same kind of
problematic, but this time the devices sits on a SPI bus, exposing MDIO
registers.

This series therefore introduces a new "virtual" mdio driver, that would
translate MDIO accesses to an underlying regmap. That way, we can use
the whole phylink and phylib logic to configure the device (as phylink
interacts with mdiodevice's).

One issue encountered is that the MDIO registers have a stride of 1,
and we need to translate that to a higher stride for memory-mapped
devices. This is what the first 3 patches of this series do.

Then, patch 4 addresses a small inconsistency found in the only user of
regmap's reg_downshift.

Patch 5 introduces the new MDIO driver, while patch 6 makes use of it
by porting altera_tse to the Lynx PCS.

Finally patch 7 drops the TSE PCS driver, as it is no longer needed.

This series is a RFC as is still has a few shortcomings, but due to
various subsystems being involved, I'm sending it as a whole so that
reviewers can get a clear view of the big picture, the end-goal and the
various problems faces.

The existing shortcomings are :
 - The virtual MDIO bus driver can only have 1 mdio-device on it. If we
   have multiple ones that are memory-mapped onto the same range (with
   an offset, for example), we can't address them and we would have to
   create one such virtual bus driver per device. I don't know as of
   today if the problem will show-up for some users

 - With this series, we can also convert dwmac_socfpga to Lynx, but I've
   left this out for now

 - The renaming of regmap.format.reg_downshift to regmap.format.reg_shift
   can be confusing, as regmap.reg_shift also exists and has another
   meaning. I'm very bad at naming, so any suggestion is welcome.

Thanks,

Maxime

[1] : https://lore.kernel.org/all/20230210190949.1115836-1-maxime.chevallier@bootlin.com/

Maxime Chevallier (7):
  regmap: add a helper to translate the register address
  regmap: check for alignment on translated register addresses
  regmap: allow upshifting register addresses before performing
    operations
  mfd: ocelot-spi: Change the regmap stride to reflect the real one
  net: mdio: Introduce a regmap-based mdio driver
  net: ethernet: altera-tse: Convert to mdio-regmap and use PCS Lynx
  net: pcs: Drop the TSE PCS driver

 MAINTAINERS                                   |  14 +-
 drivers/base/regmap/internal.h                |   2 +-
 drivers/base/regmap/regmap.c                  |  55 +++---
 drivers/mfd/ocelot-spi.c                      |   4 +-
 drivers/net/ethernet/altera/altera_tse.h      |   1 +
 drivers/net/ethernet/altera/altera_tse_main.c |  54 +++++-
 drivers/net/mdio/Kconfig                      |  11 ++
 drivers/net/mdio/Makefile                     |   1 +
 drivers/net/mdio/mdio-regmap.c                |  85 ++++++++++
 drivers/net/pcs/Kconfig                       |   6 -
 drivers/net/pcs/Makefile                      |   1 -
 drivers/net/pcs/pcs-altera-tse.c              | 160 ------------------
 include/linux/mdio/mdio-regmap.h              |  25 +++
 include/linux/pcs-altera-tse.h                |  17 --
 include/linux/regmap.h                        |  15 +-
 15 files changed, 223 insertions(+), 228 deletions(-)
 create mode 100644 drivers/net/mdio/mdio-regmap.c
 delete mode 100644 drivers/net/pcs/pcs-altera-tse.c
 create mode 100644 include/linux/mdio/mdio-regmap.h
 delete mode 100644 include/linux/pcs-altera-tse.h

-- 
2.39.2


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2023-05-22  6:26 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24  9:36 [RFC 0/7] Introduce a generic regmap-based MDIO driver Maxime Chevallier
2023-03-24  9:36 ` [RFC 1/7] regmap: add a helper to translate the register address Maxime Chevallier
2023-03-24  9:36 ` [RFC 2/7] regmap: check for alignment on translated register addresses Maxime Chevallier
2023-03-24 18:51   ` Mark Brown
2023-03-30  9:45     ` Maxime Chevallier
2023-03-30 14:06       ` Mark Brown
2023-03-30 16:39       ` Colin Foster
2023-03-24  9:36 ` [RFC 3/7] regmap: allow upshifting register addresses before performing operations Maxime Chevallier
2023-03-24 12:08   ` Andrew Lunn
2023-03-24  9:36 ` [RFC 4/7] mfd: ocelot-spi: Change the regmap stride to reflect the real one Maxime Chevallier
2023-03-24 12:11   ` Andrew Lunn
2023-03-24 12:48     ` Maxime Chevallier
2023-03-24 15:48       ` Colin Foster
2023-03-24 17:56         ` Colin Foster
2023-03-30  9:53           ` Maxime Chevallier
2023-03-27  0:02       ` Andrew Lunn
2023-03-30  9:46         ` Maxime Chevallier
2023-03-24  9:36 ` [RFC 5/7] net: mdio: Introduce a regmap-based mdio driver Maxime Chevallier
2023-03-24 12:48   ` kernel test robot
2023-04-01 13:41   ` Vladimir Oltean
2023-03-24  9:36 ` [RFC 6/7] net: ethernet: altera-tse: Convert to mdio-regmap and use PCS Lynx Maxime Chevallier
2023-03-24 16:45   ` kernel test robot
2023-03-24 17:06   ` kernel test robot
2023-03-24  9:36 ` [RFC 7/7] net: pcs: Drop the TSE PCS driver Maxime Chevallier
2023-05-15 11:48   ` Vladimir Oltean
2023-05-22  6:26     ` Maxime Chevallier
2023-03-24 20:37 ` (subset) [RFC 0/7] Introduce a generic regmap-based MDIO driver Mark Brown

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.