forked from coolsnowwolf/lede
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bot] AutoMerging: merge all upstream's changes:
* https://github.com/coolsnowwolf/lede: generic: mt7530: backport support for the MT7988 built-in switch generic: add support for MediaTek NETSYS v3
- Loading branch information
Showing
26 changed files
with
5,559 additions
and
6 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ic/backport-5.15/790-v6.4-0001-net-dsa-mt7530-make-some-noise-if-register-read-fail.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From b6f56cddb5f57a0b8da0ce582232a2f1933558c6 Mon Sep 17 00:00:00 2001 | ||
From: Daniel Golle <[email protected]> | ||
Date: Mon, 3 Apr 2023 02:17:19 +0100 | ||
Subject: [PATCH 04/16] net: dsa: mt7530: make some noise if register read | ||
fails | ||
|
||
Simply returning the negative error value instead of the read value | ||
doesn't seem like a good idea. Return 0 instead and add WARN_ON_ONCE(1) | ||
so this kind of error will not go unnoticed. | ||
|
||
Suggested-by: Andrew Lunn <[email protected]> | ||
Signed-off-by: Daniel Golle <[email protected]> | ||
Reviewed-by: Andrew Lunn <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
drivers/net/dsa/mt7530.c | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
--- a/drivers/net/dsa/mt7530.c | ||
+++ b/drivers/net/dsa/mt7530.c | ||
@@ -224,9 +224,10 @@ mt7530_mii_read(struct mt7530_priv *priv | ||
/* MT7530 uses 31 as the pseudo port */ | ||
ret = bus->write(bus, 0x1f, 0x1f, page); | ||
if (ret < 0) { | ||
+ WARN_ON_ONCE(1); | ||
dev_err(&bus->dev, | ||
"failed to read mt7530 register\n"); | ||
- return ret; | ||
+ return 0; | ||
} | ||
|
||
lo = bus->read(bus, 0x1f, r); |
111 changes: 111 additions & 0 deletions
111
...inux/generic/backport-5.15/790-v6.4-0002-net-dsa-mt7530-refactor-SGMII-PCS-creation.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
From 9ecc00164dc2300dfcd40afe549a8ee951dfea9f Mon Sep 17 00:00:00 2001 | ||
From: Daniel Golle <[email protected]> | ||
Date: Mon, 3 Apr 2023 02:17:30 +0100 | ||
Subject: [PATCH 05/16] net: dsa: mt7530: refactor SGMII PCS creation | ||
|
||
Instead of macro templates use a dedidated function and allocated | ||
regmap_config when creating the regmaps for the pcs-mtk-lynxi | ||
instances. | ||
This is in preparation to switching to use unlocked regmap accessors | ||
and have regmap's locking API handle locking for us. | ||
|
||
Signed-off-by: Daniel Golle <[email protected]> | ||
Reviewed-by: Andrew Lunn <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
drivers/net/dsa/mt7530.c | 74 +++++++++++++++++++++++++++------------- | ||
1 file changed, 50 insertions(+), 24 deletions(-) | ||
|
||
--- a/drivers/net/dsa/mt7530.c | ||
+++ b/drivers/net/dsa/mt7530.c | ||
@@ -2926,26 +2926,56 @@ static const struct regmap_bus mt7531_re | ||
.reg_update_bits = mt7530_regmap_update_bits, | ||
}; | ||
|
||
-#define MT7531_PCS_REGMAP_CONFIG(_name, _reg_base) \ | ||
- { \ | ||
- .name = _name, \ | ||
- .reg_bits = 16, \ | ||
- .val_bits = 32, \ | ||
- .reg_stride = 4, \ | ||
- .reg_base = _reg_base, \ | ||
- .max_register = 0x17c, \ | ||
+static int | ||
+mt7531_create_sgmii(struct mt7530_priv *priv) | ||
+{ | ||
+ struct regmap_config *mt7531_pcs_config[2]; | ||
+ struct phylink_pcs *pcs; | ||
+ struct regmap *regmap; | ||
+ int i, ret = 0; | ||
+ | ||
+ for (i = 0; i < 2; i++) { | ||
+ mt7531_pcs_config[i] = devm_kzalloc(priv->dev, | ||
+ sizeof(struct regmap_config), | ||
+ GFP_KERNEL); | ||
+ if (!mt7531_pcs_config[i]) { | ||
+ ret = -ENOMEM; | ||
+ break; | ||
+ } | ||
+ | ||
+ mt7531_pcs_config[i]->name = i ? "port6" : "port5"; | ||
+ mt7531_pcs_config[i]->reg_bits = 16; | ||
+ mt7531_pcs_config[i]->val_bits = 32; | ||
+ mt7531_pcs_config[i]->reg_stride = 4; | ||
+ mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i); | ||
+ mt7531_pcs_config[i]->max_register = 0x17c; | ||
+ | ||
+ regmap = devm_regmap_init(priv->dev, | ||
+ &mt7531_regmap_bus, priv, | ||
+ mt7531_pcs_config[i]); | ||
+ if (IS_ERR(regmap)) { | ||
+ ret = PTR_ERR(regmap); | ||
+ break; | ||
+ } | ||
+ pcs = mtk_pcs_lynxi_create(priv->dev, regmap, | ||
+ MT7531_PHYA_CTRL_SIGNAL3, 0); | ||
+ if (!pcs) { | ||
+ ret = -ENXIO; | ||
+ break; | ||
+ } | ||
+ priv->ports[5 + i].sgmii_pcs = pcs; | ||
} | ||
|
||
-static const struct regmap_config mt7531_pcs_config[] = { | ||
- MT7531_PCS_REGMAP_CONFIG("port5", MT7531_SGMII_REG_BASE(5)), | ||
- MT7531_PCS_REGMAP_CONFIG("port6", MT7531_SGMII_REG_BASE(6)), | ||
-}; | ||
+ if (ret && i) | ||
+ mtk_pcs_lynxi_destroy(priv->ports[5].sgmii_pcs); | ||
+ | ||
+ return ret; | ||
+} | ||
|
||
static int | ||
mt753x_setup(struct dsa_switch *ds) | ||
{ | ||
struct mt7530_priv *priv = ds->priv; | ||
- struct regmap *regmap; | ||
int i, ret; | ||
|
||
/* Initialise the PCS devices */ | ||
@@ -2967,15 +2997,11 @@ mt753x_setup(struct dsa_switch *ds) | ||
if (ret && priv->irq) | ||
mt7530_free_irq_common(priv); | ||
|
||
- if (priv->id == ID_MT7531) | ||
- for (i = 0; i < 2; i++) { | ||
- regmap = devm_regmap_init(ds->dev, | ||
- &mt7531_regmap_bus, priv, | ||
- &mt7531_pcs_config[i]); | ||
- priv->ports[5 + i].sgmii_pcs = | ||
- mtk_pcs_lynxi_create(ds->dev, regmap, | ||
- MT7531_PHYA_CTRL_SIGNAL3, 0); | ||
- } | ||
+ if (priv->id == ID_MT7531) { | ||
+ ret = mt7531_create_sgmii(priv); | ||
+ if (ret && priv->irq) | ||
+ mt7530_free_irq_common(priv); | ||
+ } | ||
|
||
return ret; | ||
} |
74 changes: 74 additions & 0 deletions
74
...ux/generic/backport-5.15/790-v6.4-0003-net-dsa-mt7530-use-unlocked-regmap-accessors.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
From 1bd099c49f65ed923b9f19b8c4b3cd1ff0024091 Mon Sep 17 00:00:00 2001 | ||
From: Daniel Golle <[email protected]> | ||
Date: Mon, 3 Apr 2023 02:17:40 +0100 | ||
Subject: [PATCH 06/16] net: dsa: mt7530: use unlocked regmap accessors | ||
|
||
Instead of wrapping the locked register accessor functions, use the | ||
unlocked variants and add locking wrapper functions to let regmap | ||
handle the locking. | ||
|
||
This is a preparation towards being able to always use regmap to | ||
access switch registers instead of open-coded accessor functions. | ||
|
||
Signed-off-by: Daniel Golle <[email protected]> | ||
Reviewed-by: Andrew Lunn <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
drivers/net/dsa/mt7530.c | 23 ++++++++++++++--------- | ||
1 file changed, 14 insertions(+), 9 deletions(-) | ||
|
||
--- a/drivers/net/dsa/mt7530.c | ||
+++ b/drivers/net/dsa/mt7530.c | ||
@@ -2899,7 +2899,7 @@ static int mt7530_regmap_read(void *cont | ||
{ | ||
struct mt7530_priv *priv = context; | ||
|
||
- *val = mt7530_read(priv, reg); | ||
+ *val = mt7530_mii_read(priv, reg); | ||
return 0; | ||
}; | ||
|
||
@@ -2907,23 +2907,25 @@ static int mt7530_regmap_write(void *con | ||
{ | ||
struct mt7530_priv *priv = context; | ||
|
||
- mt7530_write(priv, reg, val); | ||
+ mt7530_mii_write(priv, reg, val); | ||
return 0; | ||
}; | ||
|
||
-static int mt7530_regmap_update_bits(void *context, unsigned int reg, | ||
- unsigned int mask, unsigned int val) | ||
+static void | ||
+mt7530_mdio_regmap_lock(void *mdio_lock) | ||
{ | ||
- struct mt7530_priv *priv = context; | ||
+ mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED); | ||
+} | ||
|
||
- mt7530_rmw(priv, reg, mask, val); | ||
- return 0; | ||
-}; | ||
+static void | ||
+mt7530_mdio_regmap_unlock(void *mdio_lock) | ||
+{ | ||
+ mutex_unlock(mdio_lock); | ||
+} | ||
|
||
static const struct regmap_bus mt7531_regmap_bus = { | ||
.reg_write = mt7530_regmap_write, | ||
.reg_read = mt7530_regmap_read, | ||
- .reg_update_bits = mt7530_regmap_update_bits, | ||
}; | ||
|
||
static int | ||
@@ -2949,6 +2951,9 @@ mt7531_create_sgmii(struct mt7530_priv * | ||
mt7531_pcs_config[i]->reg_stride = 4; | ||
mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i); | ||
mt7531_pcs_config[i]->max_register = 0x17c; | ||
+ mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock; | ||
+ mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock; | ||
+ mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock; | ||
|
||
regmap = devm_regmap_init(priv->dev, | ||
&mt7531_regmap_bus, priv, |
Oops, something went wrong.