1 From 33396408776385f3d2f6069646169a6b5b28e3b3 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 3 Apr 2023 02:17:40 +0100
4 Subject: [PATCH 03/13] net: dsa: mt7530: use unlocked regmap accessors
6 Instead of wrapping the locked register accessor functions, use the
7 unlocked variants and add locking wrapper functions to let regmap
10 This is a preparation towards being able to always use regmap to
11 access switch registers instead of open-coded accessor functions.
13 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
14 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
17 drivers/net/dsa/mt7530.c | 23 ++++++++++++++---------
18 1 file changed, 14 insertions(+), 9 deletions(-)
20 --- a/drivers/net/dsa/mt7530.c
21 +++ b/drivers/net/dsa/mt7530.c
22 @@ -2941,7 +2941,7 @@ static int mt7530_regmap_read(void *cont
24 struct mt7530_priv *priv = context;
26 - *val = mt7530_read(priv, reg);
27 + *val = mt7530_mii_read(priv, reg);
31 @@ -2949,23 +2949,25 @@ static int mt7530_regmap_write(void *con
33 struct mt7530_priv *priv = context;
35 - mt7530_write(priv, reg, val);
36 + mt7530_mii_write(priv, reg, val);
40 -static int mt7530_regmap_update_bits(void *context, unsigned int reg,
41 - unsigned int mask, unsigned int val)
43 +mt7530_mdio_regmap_lock(void *mdio_lock)
45 - struct mt7530_priv *priv = context;
46 + mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED);
49 - mt7530_rmw(priv, reg, mask, val);
53 +mt7530_mdio_regmap_unlock(void *mdio_lock)
55 + mutex_unlock(mdio_lock);
58 static const struct regmap_bus mt7531_regmap_bus = {
59 .reg_write = mt7530_regmap_write,
60 .reg_read = mt7530_regmap_read,
61 - .reg_update_bits = mt7530_regmap_update_bits,
65 @@ -2991,6 +2993,9 @@ mt7531_create_sgmii(struct mt7530_priv *
66 mt7531_pcs_config[i]->reg_stride = 4;
67 mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
68 mt7531_pcs_config[i]->max_register = 0x17c;
69 + mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock;
70 + mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
71 + mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
73 regmap = devm_regmap_init(priv->dev,
74 &mt7531_regmap_bus, priv,