aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-5.10
diff options
context:
space:
mode:
authorDENG Qingfang <dqfext@gmail.com>2021-04-22 13:08:11 +0800
committerHauke Mehrtens <hauke@hauke-m.de>2021-04-30 23:48:37 +0200
commit20a924d2ae378fe35b74f81be3b7f58366472e80 (patch)
tree3cff52c9c86600ce9a7668b3723299ecaa7a363b /target/linux/generic/backport-5.10
parent0d6f20723047c02bd624f0384df9dc74ee075bc7 (diff)
downloadupstream-20a924d2ae378fe35b74f81be3b7f58366472e80.tar.gz
upstream-20a924d2ae378fe35b74f81be3b7f58366472e80.tar.bz2
upstream-20a924d2ae378fe35b74f81be3b7f58366472e80.zip
kernel: update mt7530 EEE patch from upstream
The new EEE patch is accepted upstream, so backport it and replace the current one. Cc: René van Dorst <opensource@vdorst.com> Signed-off-by: DENG Qingfang <dqfext@gmail.com>
Diffstat (limited to 'target/linux/generic/backport-5.10')
-rw-r--r--target/linux/generic/backport-5.10/781-v5.13-net-dsa-mt7530-Add-support-for-EEE-features.patch120
1 files changed, 120 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.10/781-v5.13-net-dsa-mt7530-Add-support-for-EEE-features.patch b/target/linux/generic/backport-5.10/781-v5.13-net-dsa-mt7530-Add-support-for-EEE-features.patch
new file mode 100644
index 0000000000..f85d5cdaad
--- /dev/null
+++ b/target/linux/generic/backport-5.10/781-v5.13-net-dsa-mt7530-Add-support-for-EEE-features.patch
@@ -0,0 +1,120 @@
+From 40b5d2f15c091fa9c854acde91ad2acb504027d7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ren=C3=A9=20van=20Dorst?= <opensource@vdorst.com>
+Date: Mon, 12 Apr 2021 08:50:31 +0200
+Subject: [PATCH] net: dsa: mt7530: Add support for EEE features
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This patch adds EEE support.
+
+Signed-off-by: René van Dorst <opensource@vdorst.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+---
+ drivers/net/dsa/mt7530.c | 43 ++++++++++++++++++++++++++++++++++++++++
+ drivers/net/dsa/mt7530.h | 14 ++++++++++++-
+ 2 files changed, 56 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/dsa/mt7530.c
++++ b/drivers/net/dsa/mt7530.c
+@@ -2277,6 +2277,17 @@ static void mt753x_phylink_mac_link_up(s
+ mcr |= PMCR_RX_FC_EN;
+ }
+
++ if (mode == MLO_AN_PHY && phydev && phy_init_eee(phydev, 0) >= 0) {
++ switch (speed) {
++ case SPEED_1000:
++ mcr |= PMCR_FORCE_EEE1G;
++ break;
++ case SPEED_100:
++ mcr |= PMCR_FORCE_EEE100;
++ break;
++ }
++ }
++
+ mt7530_set(priv, MT7530_PMCR_P(port), mcr);
+ }
+
+@@ -2507,6 +2518,36 @@ mt753x_phy_write(struct dsa_switch *ds,
+ return priv->info->phy_write(ds, port, regnum, val);
+ }
+
++static int mt753x_get_mac_eee(struct dsa_switch *ds, int port,
++ struct ethtool_eee *e)
++{
++ struct mt7530_priv *priv = ds->priv;
++ u32 eeecr = mt7530_read(priv, MT7530_PMEEECR_P(port));
++
++ e->tx_lpi_enabled = !(eeecr & LPI_MODE_EN);
++ e->tx_lpi_timer = GET_LPI_THRESH(eeecr);
++
++ return 0;
++}
++
++static int mt753x_set_mac_eee(struct dsa_switch *ds, int port,
++ struct ethtool_eee *e)
++{
++ struct mt7530_priv *priv = ds->priv;
++ u32 set, mask = LPI_THRESH_MASK | LPI_MODE_EN;
++
++ if (e->tx_lpi_timer > 0xFFF)
++ return -EINVAL;
++
++ set = SET_LPI_THRESH(e->tx_lpi_timer);
++ if (!e->tx_lpi_enabled)
++ /* Force LPI Mode without a delay */
++ set |= LPI_MODE_EN;
++ mt7530_rmw(priv, MT7530_PMEEECR_P(port), mask, set);
++
++ return 0;
++}
++
+ static const struct dsa_switch_ops mt7530_switch_ops = {
+ .get_tag_protocol = mtk_get_tag_protocol,
+ .setup = mt753x_setup,
+@@ -2535,6 +2576,8 @@ static const struct dsa_switch_ops mt753
+ .phylink_mac_an_restart = mt753x_phylink_mac_an_restart,
+ .phylink_mac_link_down = mt753x_phylink_mac_link_down,
+ .phylink_mac_link_up = mt753x_phylink_mac_link_up,
++ .get_mac_eee = mt753x_get_mac_eee,
++ .set_mac_eee = mt753x_set_mac_eee,
+ };
+
+ static const struct mt753x_info mt753x_table[] = {
+--- a/drivers/net/dsa/mt7530.h
++++ b/drivers/net/dsa/mt7530.h
+@@ -240,6 +240,8 @@ enum mt7530_vlan_port_attr {
+ #define PMCR_RX_EN BIT(13)
+ #define PMCR_BACKOFF_EN BIT(9)
+ #define PMCR_BACKPR_EN BIT(8)
++#define PMCR_FORCE_EEE1G BIT(7)
++#define PMCR_FORCE_EEE100 BIT(6)
+ #define PMCR_TX_FC_EN BIT(5)
+ #define PMCR_RX_FC_EN BIT(4)
+ #define PMCR_FORCE_SPEED_1000 BIT(3)
+@@ -264,7 +266,8 @@ enum mt7530_vlan_port_attr {
+ #define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
+ PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
+ PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
+- PMCR_FORCE_FDX | PMCR_FORCE_LNK)
++ PMCR_FORCE_FDX | PMCR_FORCE_LNK | \
++ PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100)
+ #define PMCR_CPU_PORT_SETTING(id) (PMCR_FORCE_MODE_ID((id)) | \
+ PMCR_IFG_XMIT(1) | PMCR_MAC_MODE | \
+ PMCR_BACKOFF_EN | PMCR_BACKPR_EN | \
+@@ -273,6 +276,15 @@ enum mt7530_vlan_port_attr {
+ PMCR_FORCE_SPEED_1000 | \
+ PMCR_FORCE_FDX | PMCR_FORCE_LNK)
+
++#define MT7530_PMEEECR_P(x) (0x3004 + (x) * 0x100)
++#define WAKEUP_TIME_1000(x) (((x) & 0xFF) << 24)
++#define WAKEUP_TIME_100(x) (((x) & 0xFF) << 16)
++#define LPI_THRESH_MASK GENMASK(15, 4)
++#define LPI_THRESH_SHT 4
++#define SET_LPI_THRESH(x) (((x) << LPI_THRESH_SHT) & LPI_THRESH_MASK)
++#define GET_LPI_THRESH(x) (((x) & LPI_THRESH_MASK) >> LPI_THRESH_SHT)
++#define LPI_MODE_EN BIT(0)
++
+ #define MT7530_PMSR_P(x) (0x3008 + (x) * 0x100)
+ #define PMSR_EEE1G BIT(7)
+ #define PMSR_EEE100M BIT(6)