diff mbox series

[net-next] regmap: Rework regmap_mdio_c45_{read|write} for new C45 API.

Message ID 20230116111509.4086236-1-michael@walle.cc (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net-next] regmap: Rework regmap_mdio_c45_{read|write} for new C45 API. | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 386 this patch: 386
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/build_clang success Errors and warnings before: 119 this patch: 119
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 383 this patch: 383
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Walle Jan. 16, 2023, 11:15 a.m. UTC
From: Andrew Lunn <andrew@lunn.ch>

The MDIO subsystem is getting rid of MII_ADDR_C45 and thus also
encoding associated encoding of the C45 device address and register
address into one value. regmap-mdio also uses this encoding for the
C45 bus.

Move to the new C45 helpers for MDIO access and provide regmap-mdio
helper macros.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michael Walle <michael@walle.cc>
---
This is a revived patch from Andrew's tree.

Mark, could you Ack this instead of taking it through your tree,
because it future net-next changes will depend on it. There are
currently no in-tree users for this regmap. The Kconfig symbol is
never selected.

Andrew, I've changed some minor compilation errors and also
introduced the REGMAP_MDIO_C45_* macros. I think they are needed
by the users, who would otherwise use the MII_DEVADDR_C45_* macros.
---
 drivers/base/regmap/regmap-mdio.c | 41 +++++++++++++++++--------------
 include/linux/regmap.h            |  8 ++++++
 2 files changed, 31 insertions(+), 18 deletions(-)

Comments

Mark Brown Jan. 16, 2023, 12:50 p.m. UTC | #1
On Mon, Jan 16, 2023 at 12:15:09PM +0100, Michael Walle wrote:

> Mark, could you Ack this instead of taking it through your tree,
> because it future net-next changes will depend on it. There are
> currently no in-tree users for this regmap. The Kconfig symbol is
> never selected.

I can just as easily send a pull request for it?
Michael Walle Jan. 16, 2023, 12:54 p.m. UTC | #2
Am 2023-01-16 13:50, schrieb Mark Brown:
> On Mon, Jan 16, 2023 at 12:15:09PM +0100, Michael Walle wrote:
> 
>> Mark, could you Ack this instead of taking it through your tree,
>> because it future net-next changes will depend on it. There are
>> currently no in-tree users for this regmap. The Kconfig symbol is
>> never selected.
> 
> I can just as easily send a pull request for it?

Sure. Just thought the former was more convenient.

-michael
Mark Brown Jan. 16, 2023, 2:47 p.m. UTC | #3
On Mon, Jan 16, 2023 at 12:15:09PM +0100, Michael Walle wrote:
> From: Andrew Lunn <andrew@lunn.ch>
> 
> The MDIO subsystem is getting rid of MII_ADDR_C45 and thus also
> encoding associated encoding of the C45 device address and register
> address into one value. regmap-mdio also uses this encoding for the
> C45 bus.

The following changes since commit 1b929c02afd37871d5afb9d498426f83432e71c2:

  Linux 6.2-rc1 (2022-12-25 13:41:39 -0800)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/regmap-mdio-c45-rework

for you to fetch changes up to 7b3c4c370c09313e22b555e79167e73d233611d1:

  regmap: Rework regmap_mdio_c45_{read|write} for new C45 API. (2023-01-16 13:16:09 +0000)

----------------------------------------------------------------
regmap: Rework regmap_mdio_c45_{read|write} for new C45 API.

This reworks the regmap MDIO handling of C45 addresses in
preparation for some forthcoming updates to the networking code.

----------------------------------------------------------------
Andrew Lunn (1):
      regmap: Rework regmap_mdio_c45_{read|write} for new C45 API.

 drivers/base/regmap/regmap-mdio.c | 41 ++++++++++++++++++++++-----------------
 include/linux/regmap.h            |  8 ++++++++
 2 files changed, 31 insertions(+), 18 deletions(-)
Mark Brown Jan. 16, 2023, 2:49 p.m. UTC | #4
On Mon, 16 Jan 2023 12:15:09 +0100, Michael Walle wrote:
> The MDIO subsystem is getting rid of MII_ADDR_C45 and thus also
> encoding associated encoding of the C45 device address and register
> address into one value. regmap-mdio also uses this encoding for the
> C45 bus.
> 
> Move to the new C45 helpers for MDIO access and provide regmap-mdio
> helper macros.
> 
> [...]

Applied to

   broonie/regmap.git for-next

Thanks!

[1/1] regmap: Rework regmap_mdio_c45_{read|write} for new C45 API.
      commit: 7b3c4c370c09313e22b555e79167e73d233611d1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
Jakub Kicinski Jan. 18, 2023, 3:12 a.m. UTC | #5
On Mon, 16 Jan 2023 14:47:46 +0000 Mark Brown wrote:
> regmap: Rework regmap_mdio_c45_{read|write} for new C45 API.
> 
> This reworks the regmap MDIO handling of C45 addresses in
> preparation for some forthcoming updates to the networking code.

Pulled, thanks!
diff mbox series

Patch

diff --git a/drivers/base/regmap/regmap-mdio.c b/drivers/base/regmap/regmap-mdio.c
index f7293040a2b1..6aa6a2409478 100644
--- a/drivers/base/regmap/regmap-mdio.c
+++ b/drivers/base/regmap/regmap-mdio.c
@@ -10,31 +10,21 @@ 
 /* Clause-45 mask includes the device type (5 bit) and actual register number (16 bit) */
 #define REGNUM_C45_MASK		GENMASK(20, 0)
 
-static int regmap_mdio_read(struct mdio_device *mdio_dev, u32 reg, unsigned int *val)
+static int regmap_mdio_c22_read(void *context, unsigned int reg, unsigned int *val)
 {
+	struct mdio_device *mdio_dev = context;
 	int ret;
 
+	if (unlikely(reg & ~REGNUM_C22_MASK))
+		return -ENXIO;
+
 	ret = mdiodev_read(mdio_dev, reg);
 	if (ret < 0)
 		return ret;
 
 	*val = ret & REGVAL_MASK;
-	return 0;
-}
-
-static int regmap_mdio_write(struct mdio_device *mdio_dev, u32 reg, unsigned int val)
-{
-	return mdiodev_write(mdio_dev, reg, val);
-}
-
-static int regmap_mdio_c22_read(void *context, unsigned int reg, unsigned int *val)
-{
-	struct mdio_device *mdio_dev = context;
-
-	if (unlikely(reg & ~REGNUM_C22_MASK))
-		return -ENXIO;
 
-	return regmap_mdio_read(mdio_dev, reg, val);
+	return 0;
 }
 
 static int regmap_mdio_c22_write(void *context, unsigned int reg, unsigned int val)
@@ -55,21 +45,36 @@  static const struct regmap_bus regmap_mdio_c22_bus = {
 static int regmap_mdio_c45_read(void *context, unsigned int reg, unsigned int *val)
 {
 	struct mdio_device *mdio_dev = context;
+	unsigned int devad;
+	int ret;
 
 	if (unlikely(reg & ~REGNUM_C45_MASK))
 		return -ENXIO;
 
-	return regmap_mdio_read(mdio_dev, MII_ADDR_C45 | reg, val);
+	devad = reg >> REGMAP_MDIO_C45_DEVAD_SHIFT;
+	reg = reg & REGMAP_MDIO_C45_REGNUM_MASK;
+
+	ret = mdiodev_c45_read(mdio_dev, devad, reg);
+	if (ret < 0)
+		return ret;
+
+	*val = ret & REGVAL_MASK;
+
+	return 0;
 }
 
 static int regmap_mdio_c45_write(void *context, unsigned int reg, unsigned int val)
 {
 	struct mdio_device *mdio_dev = context;
+	unsigned int devad;
 
 	if (unlikely(reg & ~REGNUM_C45_MASK))
 		return -ENXIO;
 
-	return regmap_mdio_write(mdio_dev, MII_ADDR_C45 | reg, val);
+	devad = reg >> REGMAP_MDIO_C45_DEVAD_SHIFT;
+	reg = reg & REGMAP_MDIO_C45_REGNUM_MASK;
+
+	return mdiodev_c45_write(mdio_dev, devad, reg, val);
 }
 
 static const struct regmap_bus regmap_mdio_c45_bus = {
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index a3bc695bcca0..029b9e09d3ca 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -38,6 +38,14 @@  struct regmap_field;
 struct snd_ac97;
 struct sdw_slave;
 
+/*
+ * regmap_mdio address encoding. IEEE 802.3ae clause 45 addresses consist of a
+ * device address and a register address.
+ */
+#define REGMAP_MDIO_C45_DEVAD_SHIFT	16
+#define REGMAP_MDIO_C45_DEVAD_MASK	GENMASK(20, 16)
+#define REGMAP_MDIO_C45_REGNUM_MASK	GENMASK(15, 0)
+
 /* An enum of all the supported cache types */
 enum regcache_type {
 	REGCACHE_NONE,