mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-18 16:40:29 +00:00
kernel: backport Motorcomm YT8521/YT8531 support
It will be used on NanoPi R2C and OrangePi R1 Plus LTS board. Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
parent
afff2feb28
commit
64afcbad3d
@ -25,7 +25,7 @@ Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17537,6 +17537,14 @@ T: git git://linuxtv.org/media_tree.git
|
||||
@@ -17538,6 +17538,14 @@ T: git git://linuxtv.org/media_tree.git
|
||||
F: Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml
|
||||
F: drivers/media/i2c/imx412.c
|
||||
|
||||
|
@ -132,7 +132,7 @@ Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
|
||||
+...
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17551,6 +17551,7 @@ M: Raspberry Pi Kernel Maintenance <kern
|
||||
@@ -17552,6 +17552,7 @@ M: Raspberry Pi Kernel Maintenance <kern
|
||||
L: linux-media@vger.kernel.org
|
||||
S: Maintained
|
||||
T: git git://linuxtv.org/media_tree.git
|
||||
|
@ -132,7 +132,7 @@ Signed-off-by: Lee Jackson <info@arducam.com>
|
||||
+...
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17555,6 +17555,14 @@ F: Documentation/devicetree/bindings/med
|
||||
@@ -17556,6 +17556,14 @@ F: Documentation/devicetree/bindings/med
|
||||
F: Documentation/devicetree/bindings/media/i2c/imx477.yaml
|
||||
F: drivers/media/i2c/imx477.c
|
||||
|
||||
|
@ -0,0 +1,55 @@
|
||||
From bdb6cfe7512f7a214815a3092f0be50963dcacbc Mon Sep 17 00:00:00 2001
|
||||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
||||
Date: Sat, 18 Jun 2022 11:28:32 +0100
|
||||
Subject: [PATCH] net: mii: add mii_bmcr_encode_fixed()
|
||||
|
||||
Add a function to encode a fixed speed/duplex to a BMCR value.
|
||||
|
||||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
include/linux/mii.h | 35 +++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 35 insertions(+)
|
||||
|
||||
--- a/include/linux/mii.h
|
||||
+++ b/include/linux/mii.h
|
||||
@@ -595,4 +595,39 @@ static inline u8 mii_resolve_flowctrl_fd
|
||||
return cap;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * mii_bmcr_encode_fixed - encode fixed speed/duplex settings to a BMCR value
|
||||
+ * @speed: a SPEED_* value
|
||||
+ * @duplex: a DUPLEX_* value
|
||||
+ *
|
||||
+ * Encode the speed and duplex to a BMCR value. 2500, 1000, 100 and 10 Mbps are
|
||||
+ * supported. 2500Mbps is encoded to 1000Mbps. Other speeds are encoded as 10
|
||||
+ * Mbps. Unknown duplex values are encoded to half-duplex.
|
||||
+ */
|
||||
+static inline u16 mii_bmcr_encode_fixed(int speed, int duplex)
|
||||
+{
|
||||
+ u16 bmcr;
|
||||
+
|
||||
+ switch (speed) {
|
||||
+ case SPEED_2500:
|
||||
+ case SPEED_1000:
|
||||
+ bmcr = BMCR_SPEED1000;
|
||||
+ break;
|
||||
+
|
||||
+ case SPEED_100:
|
||||
+ bmcr = BMCR_SPEED100;
|
||||
+ break;
|
||||
+
|
||||
+ case SPEED_10:
|
||||
+ default:
|
||||
+ bmcr = BMCR_SPEED10;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (duplex == DUPLEX_FULL)
|
||||
+ bmcr |= BMCR_FULLDPLX;
|
||||
+
|
||||
+ return bmcr;
|
||||
+}
|
||||
+
|
||||
#endif /* __LINUX_MII_H__ */
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,49 @@
|
||||
From 4e0243e7128c9b25ea2739136076a95d6adaba5e Mon Sep 17 00:00:00 2001
|
||||
From: Frank <Frank.Sae@motor-comm.com>
|
||||
Date: Fri, 4 Nov 2022 16:44:41 +0800
|
||||
Subject: [PATCH] net: phy: fix yt8521 duplicated argument to & or |
|
||||
|
||||
cocci warnings: (new ones prefixed by >>)
|
||||
>> drivers/net/phy/motorcomm.c:1122:8-35: duplicated argument to & or |
|
||||
drivers/net/phy/motorcomm.c:1126:8-35: duplicated argument to & or |
|
||||
drivers/net/phy/motorcomm.c:1130:8-34: duplicated argument to & or |
|
||||
drivers/net/phy/motorcomm.c:1134:8-34: duplicated argument to & or |
|
||||
|
||||
The second YT8521_RC1R_GE_TX_DELAY_xx should be YT8521_RC1R_FE_TX_DELAY_xx.
|
||||
|
||||
Fixes: 70479a40954c ("net: phy: Add driver for Motorcomm yt8521 gigabit ethernet phy")
|
||||
Reported-by: kernel test robot <lkp@intel.com>
|
||||
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
|
||||
Signed-off-by: Frank <Frank.Sae@motor-comm.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/phy/motorcomm.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -1119,19 +1119,19 @@ static int yt8521_config_init(struct phy
|
||||
|
||||
switch (phydev->interface) {
|
||||
case PHY_INTERFACE_MODE_RGMII:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_DIS | YT8521_RC1R_GE_TX_DELAY_DIS;
|
||||
+ val = YT8521_RC1R_GE_TX_DELAY_DIS | YT8521_RC1R_FE_TX_DELAY_DIS;
|
||||
val |= YT8521_RC1R_RX_DELAY_DIS;
|
||||
break;
|
||||
case PHY_INTERFACE_MODE_RGMII_RXID:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_DIS | YT8521_RC1R_GE_TX_DELAY_DIS;
|
||||
+ val = YT8521_RC1R_GE_TX_DELAY_DIS | YT8521_RC1R_FE_TX_DELAY_DIS;
|
||||
val |= YT8521_RC1R_RX_DELAY_EN;
|
||||
break;
|
||||
case PHY_INTERFACE_MODE_RGMII_TXID:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_EN | YT8521_RC1R_GE_TX_DELAY_EN;
|
||||
+ val = YT8521_RC1R_GE_TX_DELAY_EN | YT8521_RC1R_FE_TX_DELAY_EN;
|
||||
val |= YT8521_RC1R_RX_DELAY_DIS;
|
||||
break;
|
||||
case PHY_INTERFACE_MODE_RGMII_ID:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_EN | YT8521_RC1R_GE_TX_DELAY_EN;
|
||||
+ val = YT8521_RC1R_GE_TX_DELAY_EN | YT8521_RC1R_FE_TX_DELAY_EN;
|
||||
val |= YT8521_RC1R_RX_DELAY_EN;
|
||||
break;
|
||||
case PHY_INTERFACE_MODE_SGMII:
|
@ -0,0 +1,140 @@
|
||||
From 813abcd98fb1b2cccf850cdfa092a4bfc50b2363 Mon Sep 17 00:00:00 2001
|
||||
From: Frank <Frank.Sae@motor-comm.com>
|
||||
Date: Tue, 22 Nov 2022 16:42:32 +0800
|
||||
Subject: [PATCH] net: phy: add Motorcomm YT8531S phy id.
|
||||
|
||||
We added patch for motorcomm.c to support YT8531S. This patch has
|
||||
been tested on AM335x platform which has one YT8531S interface
|
||||
card and passed all test cases.
|
||||
The tested cases indluding: YT8531S UTP function with support of
|
||||
10M/100M/1000M; YT8531S Fiber function with support of 100M/1000M;
|
||||
and YT8531S Combo function that supports auto detection of media type.
|
||||
|
||||
Since most functions of YT8531S are similar to YT8521 and we reuse some
|
||||
codes for YT8521 in the patch file.
|
||||
|
||||
Signed-off-by: Frank <Frank.Sae@motor-comm.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/phy/Kconfig | 2 +-
|
||||
drivers/net/phy/motorcomm.c | 52 +++++++++++++++++++++++++++++++++----
|
||||
2 files changed, 48 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/Kconfig
|
||||
+++ b/drivers/net/phy/Kconfig
|
||||
@@ -245,7 +245,7 @@ config MOTORCOMM_PHY
|
||||
tristate "Motorcomm PHYs"
|
||||
help
|
||||
Enables support for Motorcomm network PHYs.
|
||||
- Currently supports the YT8511, YT8521 Gigabit Ethernet PHYs.
|
||||
+ Currently supports the YT8511, YT8521, YT8531S Gigabit Ethernet PHYs.
|
||||
|
||||
config NATIONAL_PHY
|
||||
tristate "National Semiconductor PHYs"
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
- * Motorcomm 8511/8521 PHY driver.
|
||||
+ * Motorcomm 8511/8521/8531S PHY driver.
|
||||
*
|
||||
* Author: Peter Geis <pgwipeout@gmail.com>
|
||||
* Author: Frank <Frank.Sae@motor-comm.com>
|
||||
@@ -12,9 +12,10 @@
|
||||
#include <linux/phy.h>
|
||||
|
||||
#define PHY_ID_YT8511 0x0000010a
|
||||
-#define PHY_ID_YT8521 0x0000011A
|
||||
+#define PHY_ID_YT8521 0x0000011A
|
||||
+#define PHY_ID_YT8531S 0x4F51E91A
|
||||
|
||||
-/* YT8521 Register Overview
|
||||
+/* YT8521/YT8531S Register Overview
|
||||
* UTP Register space | FIBER Register space
|
||||
* ------------------------------------------------------------
|
||||
* | UTP MII | FIBER MII |
|
||||
@@ -147,7 +148,7 @@
|
||||
#define YT8521_LINK_TIMER_CFG2_REG 0xA5
|
||||
#define YT8521_LTCR_EN_AUTOSEN BIT(15)
|
||||
|
||||
-/* 0xA000, 0xA001, 0xA003 ,and 0xA006 ~ 0xA00A are common ext registers
|
||||
+/* 0xA000, 0xA001, 0xA003, 0xA006 ~ 0xA00A and 0xA012 are common ext registers
|
||||
* of yt8521 phy. There is no need to switch reg space when operating these
|
||||
* registers.
|
||||
*/
|
||||
@@ -221,6 +222,9 @@
|
||||
*/
|
||||
#define YTPHY_WCR_TYPE_PULSE BIT(0)
|
||||
|
||||
+#define YT8531S_SYNCE_CFG_REG 0xA012
|
||||
+#define YT8531S_SCR_SYNCE_ENABLE BIT(6)
|
||||
+
|
||||
/* Extended Register end */
|
||||
|
||||
struct yt8521_priv {
|
||||
@@ -648,6 +652,26 @@ static int yt8521_probe(struct phy_devic
|
||||
}
|
||||
|
||||
/**
|
||||
+ * yt8531s_probe() - read chip config then set suitable polling_mode
|
||||
+ * @phydev: a pointer to a &struct phy_device
|
||||
+ *
|
||||
+ * returns 0 or negative errno code
|
||||
+ */
|
||||
+static int yt8531s_probe(struct phy_device *phydev)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ /* Disable SyncE clock output by default */
|
||||
+ ret = ytphy_modify_ext_with_lock(phydev, YT8531S_SYNCE_CFG_REG,
|
||||
+ YT8531S_SCR_SYNCE_ENABLE, 0);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* same as yt8521_probe */
|
||||
+ return yt8521_probe(phydev);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* ytphy_utp_read_lpa() - read LPA then setup lp_advertising for utp
|
||||
* @phydev: a pointer to a &struct phy_device
|
||||
*
|
||||
@@ -1750,11 +1774,28 @@ static struct phy_driver motorcomm_phy_d
|
||||
.suspend = yt8521_suspend,
|
||||
.resume = yt8521_resume,
|
||||
},
|
||||
+ {
|
||||
+ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S),
|
||||
+ .name = "YT8531S Gigabit Ethernet",
|
||||
+ .get_features = yt8521_get_features,
|
||||
+ .probe = yt8531s_probe,
|
||||
+ .read_page = yt8521_read_page,
|
||||
+ .write_page = yt8521_write_page,
|
||||
+ .get_wol = ytphy_get_wol,
|
||||
+ .set_wol = ytphy_set_wol,
|
||||
+ .config_aneg = yt8521_config_aneg,
|
||||
+ .aneg_done = yt8521_aneg_done,
|
||||
+ .config_init = yt8521_config_init,
|
||||
+ .read_status = yt8521_read_status,
|
||||
+ .soft_reset = yt8521_soft_reset,
|
||||
+ .suspend = yt8521_suspend,
|
||||
+ .resume = yt8521_resume,
|
||||
+ },
|
||||
};
|
||||
|
||||
module_phy_driver(motorcomm_phy_drvs);
|
||||
|
||||
-MODULE_DESCRIPTION("Motorcomm 8511/8521 PHY driver");
|
||||
+MODULE_DESCRIPTION("Motorcomm 8511/8521/8531S PHY driver");
|
||||
MODULE_AUTHOR("Peter Geis");
|
||||
MODULE_AUTHOR("Frank");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -1762,6 +1803,7 @@ MODULE_LICENSE("GPL");
|
||||
static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8511) },
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8521) },
|
||||
+ { PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },
|
||||
{ /* sentinal */ }
|
||||
};
|
||||
|
@ -0,0 +1,26 @@
|
||||
From 4104a713204d62aca482eebb0c6226d82a0721eb Mon Sep 17 00:00:00 2001
|
||||
From: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Date: Sat, 28 Jan 2023 14:35:57 +0800
|
||||
Subject: [PATCH] net: phy: fix the spelling problem of Sentinel
|
||||
|
||||
CHECK: 'sentinal' may be misspelled - perhaps 'sentinel'?
|
||||
|
||||
Signed-off-by: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Link: https://lore.kernel.org/r/20230128063558.5850-1-Frank.Sae@motor-comm.com
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/phy/motorcomm.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -1804,7 +1804,7 @@ static const struct mdio_device_id __may
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8511) },
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8521) },
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },
|
||||
- { /* sentinal */ }
|
||||
+ { /* sentinel */ }
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(mdio, motorcomm_tbl);
|
@ -0,0 +1,29 @@
|
||||
From 3c1dc22162d673d595855d24f95200ed2643f88f Mon Sep 17 00:00:00 2001
|
||||
From: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Date: Sat, 28 Jan 2023 14:35:58 +0800
|
||||
Subject: [PATCH] net: phy: motorcomm: change the phy id of yt8521 and yt8531s
|
||||
to lowercase
|
||||
|
||||
The phy id is usually defined in lower case.
|
||||
|
||||
Signed-off-by: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Link: https://lore.kernel.org/r/20230128063558.5850-2-Frank.Sae@motor-comm.com
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/phy/motorcomm.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -12,8 +12,8 @@
|
||||
#include <linux/phy.h>
|
||||
|
||||
#define PHY_ID_YT8511 0x0000010a
|
||||
-#define PHY_ID_YT8521 0x0000011A
|
||||
-#define PHY_ID_YT8531S 0x4F51E91A
|
||||
+#define PHY_ID_YT8521 0x0000011a
|
||||
+#define PHY_ID_YT8531S 0x4f51e91a
|
||||
|
||||
/* YT8521/YT8531S Register Overview
|
||||
* UTP Register space | FIBER Register space
|
@ -0,0 +1,107 @@
|
||||
From 4869a146cd60fc8115230f0a45e15e534c531922 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Date: Thu, 2 Feb 2023 11:00:34 +0800
|
||||
Subject: [PATCH] net: phy: Add BIT macro for Motorcomm yt8521/yt8531 gigabit
|
||||
ethernet phy
|
||||
|
||||
Add BIT macro for Motorcomm yt8521/yt8531 gigabit ethernet phy.
|
||||
This is a preparatory patch. Add BIT macro for 0xA012 reg, and
|
||||
supplement for 0xA001 and 0xA003 reg. These will be used to support dts.
|
||||
|
||||
Signed-off-by: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/phy/motorcomm.c | 55 ++++++++++++++++++++++++++++++++++---
|
||||
1 file changed, 51 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -161,6 +161,11 @@
|
||||
|
||||
#define YT8521_CHIP_CONFIG_REG 0xA001
|
||||
#define YT8521_CCR_SW_RST BIT(15)
|
||||
+/* 1b0 disable 1.9ns rxc clock delay *default*
|
||||
+ * 1b1 enable 1.9ns rxc clock delay
|
||||
+ */
|
||||
+#define YT8521_CCR_RXC_DLY_EN BIT(8)
|
||||
+#define YT8521_CCR_RXC_DLY_1_900_NS 1900
|
||||
|
||||
#define YT8521_CCR_MODE_SEL_MASK (BIT(2) | BIT(1) | BIT(0))
|
||||
#define YT8521_CCR_MODE_UTP_TO_RGMII 0
|
||||
@@ -178,22 +183,41 @@
|
||||
#define YT8521_MODE_POLL 0x3
|
||||
|
||||
#define YT8521_RGMII_CONFIG1_REG 0xA003
|
||||
-
|
||||
+/* 1b0 use original tx_clk_rgmii *default*
|
||||
+ * 1b1 use inverted tx_clk_rgmii.
|
||||
+ */
|
||||
+#define YT8521_RC1R_TX_CLK_SEL_INVERTED BIT(14)
|
||||
/* TX Gig-E Delay is bits 3:0, default 0x1
|
||||
* TX Fast-E Delay is bits 7:4, default 0xf
|
||||
* RX Delay is bits 13:10, default 0x0
|
||||
* Delay = 150ps * N
|
||||
* On = 2250ps, off = 0ps
|
||||
*/
|
||||
-#define YT8521_RC1R_RX_DELAY_MASK (0xF << 10)
|
||||
+#define YT8521_RC1R_RX_DELAY_MASK GENMASK(13, 10)
|
||||
#define YT8521_RC1R_RX_DELAY_EN (0xF << 10)
|
||||
#define YT8521_RC1R_RX_DELAY_DIS (0x0 << 10)
|
||||
-#define YT8521_RC1R_FE_TX_DELAY_MASK (0xF << 4)
|
||||
+#define YT8521_RC1R_FE_TX_DELAY_MASK GENMASK(7, 4)
|
||||
#define YT8521_RC1R_FE_TX_DELAY_EN (0xF << 4)
|
||||
#define YT8521_RC1R_FE_TX_DELAY_DIS (0x0 << 4)
|
||||
-#define YT8521_RC1R_GE_TX_DELAY_MASK (0xF << 0)
|
||||
+#define YT8521_RC1R_GE_TX_DELAY_MASK GENMASK(3, 0)
|
||||
#define YT8521_RC1R_GE_TX_DELAY_EN (0xF << 0)
|
||||
#define YT8521_RC1R_GE_TX_DELAY_DIS (0x0 << 0)
|
||||
+#define YT8521_RC1R_RGMII_0_000_NS 0
|
||||
+#define YT8521_RC1R_RGMII_0_150_NS 1
|
||||
+#define YT8521_RC1R_RGMII_0_300_NS 2
|
||||
+#define YT8521_RC1R_RGMII_0_450_NS 3
|
||||
+#define YT8521_RC1R_RGMII_0_600_NS 4
|
||||
+#define YT8521_RC1R_RGMII_0_750_NS 5
|
||||
+#define YT8521_RC1R_RGMII_0_900_NS 6
|
||||
+#define YT8521_RC1R_RGMII_1_050_NS 7
|
||||
+#define YT8521_RC1R_RGMII_1_200_NS 8
|
||||
+#define YT8521_RC1R_RGMII_1_350_NS 9
|
||||
+#define YT8521_RC1R_RGMII_1_500_NS 10
|
||||
+#define YT8521_RC1R_RGMII_1_650_NS 11
|
||||
+#define YT8521_RC1R_RGMII_1_800_NS 12
|
||||
+#define YT8521_RC1R_RGMII_1_950_NS 13
|
||||
+#define YT8521_RC1R_RGMII_2_100_NS 14
|
||||
+#define YT8521_RC1R_RGMII_2_250_NS 15
|
||||
|
||||
#define YTPHY_MISC_CONFIG_REG 0xA006
|
||||
#define YTPHY_MCR_FIBER_SPEED_MASK BIT(0)
|
||||
@@ -222,6 +246,29 @@
|
||||
*/
|
||||
#define YTPHY_WCR_TYPE_PULSE BIT(0)
|
||||
|
||||
+#define YTPHY_SYNCE_CFG_REG 0xA012
|
||||
+#define YT8521_SCR_SYNCE_ENABLE BIT(5)
|
||||
+/* 1b0 output 25m clock
|
||||
+ * 1b1 output 125m clock *default*
|
||||
+ */
|
||||
+#define YT8521_SCR_CLK_FRE_SEL_125M BIT(3)
|
||||
+#define YT8521_SCR_CLK_SRC_MASK GENMASK(2, 1)
|
||||
+#define YT8521_SCR_CLK_SRC_PLL_125M 0
|
||||
+#define YT8521_SCR_CLK_SRC_UTP_RX 1
|
||||
+#define YT8521_SCR_CLK_SRC_SDS_RX 2
|
||||
+#define YT8521_SCR_CLK_SRC_REF_25M 3
|
||||
+#define YT8531_SCR_SYNCE_ENABLE BIT(6)
|
||||
+/* 1b0 output 25m clock *default*
|
||||
+ * 1b1 output 125m clock
|
||||
+ */
|
||||
+#define YT8531_SCR_CLK_FRE_SEL_125M BIT(4)
|
||||
+#define YT8531_SCR_CLK_SRC_MASK GENMASK(3, 1)
|
||||
+#define YT8531_SCR_CLK_SRC_PLL_125M 0
|
||||
+#define YT8531_SCR_CLK_SRC_UTP_RX 1
|
||||
+#define YT8531_SCR_CLK_SRC_SDS_RX 2
|
||||
+#define YT8531_SCR_CLK_SRC_CLOCK_FROM_DIGITAL 3
|
||||
+#define YT8531_SCR_CLK_SRC_REF_25M 4
|
||||
+#define YT8531_SCR_CLK_SRC_SSC_25M 5
|
||||
#define YT8531S_SYNCE_CFG_REG 0xA012
|
||||
#define YT8531S_SCR_SYNCE_ENABLE BIT(6)
|
||||
|
@ -0,0 +1,343 @@
|
||||
From a6e68f0f8769f79c67cdcfb6302feecd36197dec Mon Sep 17 00:00:00 2001
|
||||
From: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Date: Thu, 2 Feb 2023 11:00:35 +0800
|
||||
Subject: [PATCH] net: phy: Add dts support for Motorcomm yt8521 gigabit
|
||||
ethernet phy
|
||||
|
||||
Add dts support for Motorcomm yt8521 gigabit ethernet phy.
|
||||
Add ytphy_rgmii_clk_delay_config function to support dst config for
|
||||
the delay of rgmii clk. This funciont is common for yt8521, yt8531s
|
||||
and yt8531.
|
||||
This patch has been verified on AM335x platform.
|
||||
|
||||
Signed-off-by: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/phy/motorcomm.c | 253 ++++++++++++++++++++++++++++--------
|
||||
1 file changed, 199 insertions(+), 54 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/phy.h>
|
||||
+#include <linux/of.h>
|
||||
|
||||
#define PHY_ID_YT8511 0x0000010a
|
||||
#define PHY_ID_YT8521 0x0000011a
|
||||
@@ -187,21 +188,9 @@
|
||||
* 1b1 use inverted tx_clk_rgmii.
|
||||
*/
|
||||
#define YT8521_RC1R_TX_CLK_SEL_INVERTED BIT(14)
|
||||
-/* TX Gig-E Delay is bits 3:0, default 0x1
|
||||
- * TX Fast-E Delay is bits 7:4, default 0xf
|
||||
- * RX Delay is bits 13:10, default 0x0
|
||||
- * Delay = 150ps * N
|
||||
- * On = 2250ps, off = 0ps
|
||||
- */
|
||||
#define YT8521_RC1R_RX_DELAY_MASK GENMASK(13, 10)
|
||||
-#define YT8521_RC1R_RX_DELAY_EN (0xF << 10)
|
||||
-#define YT8521_RC1R_RX_DELAY_DIS (0x0 << 10)
|
||||
#define YT8521_RC1R_FE_TX_DELAY_MASK GENMASK(7, 4)
|
||||
-#define YT8521_RC1R_FE_TX_DELAY_EN (0xF << 4)
|
||||
-#define YT8521_RC1R_FE_TX_DELAY_DIS (0x0 << 4)
|
||||
#define YT8521_RC1R_GE_TX_DELAY_MASK GENMASK(3, 0)
|
||||
-#define YT8521_RC1R_GE_TX_DELAY_EN (0xF << 0)
|
||||
-#define YT8521_RC1R_GE_TX_DELAY_DIS (0x0 << 0)
|
||||
#define YT8521_RC1R_RGMII_0_000_NS 0
|
||||
#define YT8521_RC1R_RGMII_0_150_NS 1
|
||||
#define YT8521_RC1R_RGMII_0_300_NS 2
|
||||
@@ -274,6 +263,10 @@
|
||||
|
||||
/* Extended Register end */
|
||||
|
||||
+#define YTPHY_DTS_OUTPUT_CLK_DIS 0
|
||||
+#define YTPHY_DTS_OUTPUT_CLK_25M 25000000
|
||||
+#define YTPHY_DTS_OUTPUT_CLK_125M 125000000
|
||||
+
|
||||
struct yt8521_priv {
|
||||
/* combo_advertising is used for case of YT8521 in combo mode,
|
||||
* this means that yt8521 may work in utp or fiber mode which depends
|
||||
@@ -641,6 +634,142 @@ static int yt8521_write_page(struct phy_
|
||||
};
|
||||
|
||||
/**
|
||||
+ * struct ytphy_cfg_reg_map - map a config value to a register value
|
||||
+ * @cfg: value in device configuration
|
||||
+ * @reg: value in the register
|
||||
+ */
|
||||
+struct ytphy_cfg_reg_map {
|
||||
+ u32 cfg;
|
||||
+ u32 reg;
|
||||
+};
|
||||
+
|
||||
+static const struct ytphy_cfg_reg_map ytphy_rgmii_delays[] = {
|
||||
+ /* for tx delay / rx delay with YT8521_CCR_RXC_DLY_EN is not set. */
|
||||
+ { 0, YT8521_RC1R_RGMII_0_000_NS },
|
||||
+ { 150, YT8521_RC1R_RGMII_0_150_NS },
|
||||
+ { 300, YT8521_RC1R_RGMII_0_300_NS },
|
||||
+ { 450, YT8521_RC1R_RGMII_0_450_NS },
|
||||
+ { 600, YT8521_RC1R_RGMII_0_600_NS },
|
||||
+ { 750, YT8521_RC1R_RGMII_0_750_NS },
|
||||
+ { 900, YT8521_RC1R_RGMII_0_900_NS },
|
||||
+ { 1050, YT8521_RC1R_RGMII_1_050_NS },
|
||||
+ { 1200, YT8521_RC1R_RGMII_1_200_NS },
|
||||
+ { 1350, YT8521_RC1R_RGMII_1_350_NS },
|
||||
+ { 1500, YT8521_RC1R_RGMII_1_500_NS },
|
||||
+ { 1650, YT8521_RC1R_RGMII_1_650_NS },
|
||||
+ { 1800, YT8521_RC1R_RGMII_1_800_NS },
|
||||
+ { 1950, YT8521_RC1R_RGMII_1_950_NS }, /* default tx/rx delay */
|
||||
+ { 2100, YT8521_RC1R_RGMII_2_100_NS },
|
||||
+ { 2250, YT8521_RC1R_RGMII_2_250_NS },
|
||||
+
|
||||
+ /* only for rx delay with YT8521_CCR_RXC_DLY_EN is set. */
|
||||
+ { 0 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_0_000_NS },
|
||||
+ { 150 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_0_150_NS },
|
||||
+ { 300 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_0_300_NS },
|
||||
+ { 450 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_0_450_NS },
|
||||
+ { 600 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_0_600_NS },
|
||||
+ { 750 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_0_750_NS },
|
||||
+ { 900 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_0_900_NS },
|
||||
+ { 1050 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_1_050_NS },
|
||||
+ { 1200 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_1_200_NS },
|
||||
+ { 1350 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_1_350_NS },
|
||||
+ { 1500 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_1_500_NS },
|
||||
+ { 1650 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_1_650_NS },
|
||||
+ { 1800 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_1_800_NS },
|
||||
+ { 1950 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_1_950_NS },
|
||||
+ { 2100 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_2_100_NS },
|
||||
+ { 2250 + YT8521_CCR_RXC_DLY_1_900_NS, YT8521_RC1R_RGMII_2_250_NS }
|
||||
+};
|
||||
+
|
||||
+static u32 ytphy_get_delay_reg_value(struct phy_device *phydev,
|
||||
+ const char *prop_name,
|
||||
+ const struct ytphy_cfg_reg_map *tbl,
|
||||
+ int tb_size,
|
||||
+ u16 *rxc_dly_en,
|
||||
+ u32 dflt)
|
||||
+{
|
||||
+ struct device_node *node = phydev->mdio.dev.of_node;
|
||||
+ int tb_size_half = tb_size / 2;
|
||||
+ u32 val;
|
||||
+ int i;
|
||||
+
|
||||
+ if (of_property_read_u32(node, prop_name, &val))
|
||||
+ goto err_dts_val;
|
||||
+
|
||||
+ /* when rxc_dly_en is NULL, it is get the delay for tx, only half of
|
||||
+ * tb_size is valid.
|
||||
+ */
|
||||
+ if (!rxc_dly_en)
|
||||
+ tb_size = tb_size_half;
|
||||
+
|
||||
+ for (i = 0; i < tb_size; i++) {
|
||||
+ if (tbl[i].cfg == val) {
|
||||
+ if (rxc_dly_en && i < tb_size_half)
|
||||
+ *rxc_dly_en = 0;
|
||||
+ return tbl[i].reg;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ phydev_warn(phydev, "Unsupported value %d for %s using default (%u)\n",
|
||||
+ val, prop_name, dflt);
|
||||
+
|
||||
+err_dts_val:
|
||||
+ /* when rxc_dly_en is not NULL, it is get the delay for rx.
|
||||
+ * The rx default in dts and ytphy_rgmii_clk_delay_config is 1950 ps,
|
||||
+ * so YT8521_CCR_RXC_DLY_EN should not be set.
|
||||
+ */
|
||||
+ if (rxc_dly_en)
|
||||
+ *rxc_dly_en = 0;
|
||||
+
|
||||
+ return dflt;
|
||||
+}
|
||||
+
|
||||
+static int ytphy_rgmii_clk_delay_config(struct phy_device *phydev)
|
||||
+{
|
||||
+ int tb_size = ARRAY_SIZE(ytphy_rgmii_delays);
|
||||
+ u16 rxc_dly_en = YT8521_CCR_RXC_DLY_EN;
|
||||
+ u32 rx_reg, tx_reg;
|
||||
+ u16 mask, val = 0;
|
||||
+ int ret;
|
||||
+
|
||||
+ rx_reg = ytphy_get_delay_reg_value(phydev, "rx-internal-delay-ps",
|
||||
+ ytphy_rgmii_delays, tb_size,
|
||||
+ &rxc_dly_en,
|
||||
+ YT8521_RC1R_RGMII_1_950_NS);
|
||||
+ tx_reg = ytphy_get_delay_reg_value(phydev, "tx-internal-delay-ps",
|
||||
+ ytphy_rgmii_delays, tb_size, NULL,
|
||||
+ YT8521_RC1R_RGMII_1_950_NS);
|
||||
+
|
||||
+ switch (phydev->interface) {
|
||||
+ case PHY_INTERFACE_MODE_RGMII:
|
||||
+ rxc_dly_en = 0;
|
||||
+ break;
|
||||
+ case PHY_INTERFACE_MODE_RGMII_RXID:
|
||||
+ val |= FIELD_PREP(YT8521_RC1R_RX_DELAY_MASK, rx_reg);
|
||||
+ break;
|
||||
+ case PHY_INTERFACE_MODE_RGMII_TXID:
|
||||
+ rxc_dly_en = 0;
|
||||
+ val |= FIELD_PREP(YT8521_RC1R_GE_TX_DELAY_MASK, tx_reg);
|
||||
+ break;
|
||||
+ case PHY_INTERFACE_MODE_RGMII_ID:
|
||||
+ val |= FIELD_PREP(YT8521_RC1R_RX_DELAY_MASK, rx_reg) |
|
||||
+ FIELD_PREP(YT8521_RC1R_GE_TX_DELAY_MASK, tx_reg);
|
||||
+ break;
|
||||
+ default: /* do not support other modes */
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ ret = ytphy_modify_ext(phydev, YT8521_CHIP_CONFIG_REG,
|
||||
+ YT8521_CCR_RXC_DLY_EN, rxc_dly_en);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Generally, it is not necessary to adjust YT8521_RC1R_FE_TX_DELAY */
|
||||
+ mask = YT8521_RC1R_RX_DELAY_MASK | YT8521_RC1R_GE_TX_DELAY_MASK;
|
||||
+ return ytphy_modify_ext(phydev, YT8521_RGMII_CONFIG1_REG, mask, val);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* yt8521_probe() - read chip config then set suitable polling_mode
|
||||
* @phydev: a pointer to a &struct phy_device
|
||||
*
|
||||
@@ -648,9 +777,12 @@ static int yt8521_write_page(struct phy_
|
||||
*/
|
||||
static int yt8521_probe(struct phy_device *phydev)
|
||||
{
|
||||
+ struct device_node *node = phydev->mdio.dev.of_node;
|
||||
struct device *dev = &phydev->mdio.dev;
|
||||
struct yt8521_priv *priv;
|
||||
int chip_config;
|
||||
+ u16 mask, val;
|
||||
+ u32 freq;
|
||||
int ret;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
@@ -695,7 +827,45 @@ static int yt8521_probe(struct phy_devic
|
||||
return ret;
|
||||
}
|
||||
|
||||
- return 0;
|
||||
+ if (of_property_read_u32(node, "motorcomm,clk-out-frequency-hz", &freq))
|
||||
+ freq = YTPHY_DTS_OUTPUT_CLK_DIS;
|
||||
+
|
||||
+ if (phydev->drv->phy_id == PHY_ID_YT8521) {
|
||||
+ switch (freq) {
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_DIS:
|
||||
+ mask = YT8521_SCR_SYNCE_ENABLE;
|
||||
+ val = 0;
|
||||
+ break;
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_25M:
|
||||
+ mask = YT8521_SCR_SYNCE_ENABLE |
|
||||
+ YT8521_SCR_CLK_SRC_MASK |
|
||||
+ YT8521_SCR_CLK_FRE_SEL_125M;
|
||||
+ val = YT8521_SCR_SYNCE_ENABLE |
|
||||
+ FIELD_PREP(YT8521_SCR_CLK_SRC_MASK,
|
||||
+ YT8521_SCR_CLK_SRC_REF_25M);
|
||||
+ break;
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_125M:
|
||||
+ mask = YT8521_SCR_SYNCE_ENABLE |
|
||||
+ YT8521_SCR_CLK_SRC_MASK |
|
||||
+ YT8521_SCR_CLK_FRE_SEL_125M;
|
||||
+ val = YT8521_SCR_SYNCE_ENABLE |
|
||||
+ YT8521_SCR_CLK_FRE_SEL_125M |
|
||||
+ FIELD_PREP(YT8521_SCR_CLK_SRC_MASK,
|
||||
+ YT8521_SCR_CLK_SRC_PLL_125M);
|
||||
+ break;
|
||||
+ default:
|
||||
+ phydev_warn(phydev, "Freq err:%u\n", freq);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ } else if (phydev->drv->phy_id == PHY_ID_YT8531S) {
|
||||
+ return 0;
|
||||
+ } else {
|
||||
+ phydev_warn(phydev, "PHY id err\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ return ytphy_modify_ext_with_lock(phydev, YTPHY_SYNCE_CFG_REG, mask,
|
||||
+ val);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1180,61 +1350,36 @@ static int yt8521_resume(struct phy_devi
|
||||
*/
|
||||
static int yt8521_config_init(struct phy_device *phydev)
|
||||
{
|
||||
+ struct device_node *node = phydev->mdio.dev.of_node;
|
||||
int old_page;
|
||||
int ret = 0;
|
||||
- u16 val;
|
||||
|
||||
old_page = phy_select_page(phydev, YT8521_RSSR_UTP_SPACE);
|
||||
if (old_page < 0)
|
||||
goto err_restore_page;
|
||||
|
||||
- switch (phydev->interface) {
|
||||
- case PHY_INTERFACE_MODE_RGMII:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_DIS | YT8521_RC1R_FE_TX_DELAY_DIS;
|
||||
- val |= YT8521_RC1R_RX_DELAY_DIS;
|
||||
- break;
|
||||
- case PHY_INTERFACE_MODE_RGMII_RXID:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_DIS | YT8521_RC1R_FE_TX_DELAY_DIS;
|
||||
- val |= YT8521_RC1R_RX_DELAY_EN;
|
||||
- break;
|
||||
- case PHY_INTERFACE_MODE_RGMII_TXID:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_EN | YT8521_RC1R_FE_TX_DELAY_EN;
|
||||
- val |= YT8521_RC1R_RX_DELAY_DIS;
|
||||
- break;
|
||||
- case PHY_INTERFACE_MODE_RGMII_ID:
|
||||
- val = YT8521_RC1R_GE_TX_DELAY_EN | YT8521_RC1R_FE_TX_DELAY_EN;
|
||||
- val |= YT8521_RC1R_RX_DELAY_EN;
|
||||
- break;
|
||||
- case PHY_INTERFACE_MODE_SGMII:
|
||||
- break;
|
||||
- default: /* do not support other modes */
|
||||
- ret = -EOPNOTSUPP;
|
||||
- goto err_restore_page;
|
||||
- }
|
||||
-
|
||||
/* set rgmii delay mode */
|
||||
if (phydev->interface != PHY_INTERFACE_MODE_SGMII) {
|
||||
- ret = ytphy_modify_ext(phydev, YT8521_RGMII_CONFIG1_REG,
|
||||
- (YT8521_RC1R_RX_DELAY_MASK |
|
||||
- YT8521_RC1R_FE_TX_DELAY_MASK |
|
||||
- YT8521_RC1R_GE_TX_DELAY_MASK),
|
||||
- val);
|
||||
+ ret = ytphy_rgmii_clk_delay_config(phydev);
|
||||
if (ret < 0)
|
||||
goto err_restore_page;
|
||||
}
|
||||
|
||||
- /* disable auto sleep */
|
||||
- ret = ytphy_modify_ext(phydev, YT8521_EXTREG_SLEEP_CONTROL1_REG,
|
||||
- YT8521_ESC1R_SLEEP_SW, 0);
|
||||
- if (ret < 0)
|
||||
- goto err_restore_page;
|
||||
-
|
||||
- /* enable RXC clock when no wire plug */
|
||||
- ret = ytphy_modify_ext(phydev, YT8521_CLOCK_GATING_REG,
|
||||
- YT8521_CGR_RX_CLK_EN, 0);
|
||||
- if (ret < 0)
|
||||
- goto err_restore_page;
|
||||
+ if (of_property_read_bool(node, "motorcomm,auto-sleep-disabled")) {
|
||||
+ /* disable auto sleep */
|
||||
+ ret = ytphy_modify_ext(phydev, YT8521_EXTREG_SLEEP_CONTROL1_REG,
|
||||
+ YT8521_ESC1R_SLEEP_SW, 0);
|
||||
+ if (ret < 0)
|
||||
+ goto err_restore_page;
|
||||
+ }
|
||||
|
||||
+ if (of_property_read_bool(node, "motorcomm,keep-pll-enabled")) {
|
||||
+ /* enable RXC clock when no wire plug */
|
||||
+ ret = ytphy_modify_ext(phydev, YT8521_CLOCK_GATING_REG,
|
||||
+ YT8521_CGR_RX_CLK_EN, 0);
|
||||
+ if (ret < 0)
|
||||
+ goto err_restore_page;
|
||||
+ }
|
||||
err_restore_page:
|
||||
return phy_restore_page(phydev, old_page, ret);
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
From 36152f87dda4af221b16258751451d9cd3d0fb0b Mon Sep 17 00:00:00 2001
|
||||
From: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Date: Thu, 2 Feb 2023 11:00:36 +0800
|
||||
Subject: [PATCH] net: phy: Add dts support for Motorcomm yt8531s gigabit
|
||||
ethernet phy
|
||||
|
||||
Add dts support for Motorcomm yt8531s gigabit ethernet phy.
|
||||
Change yt8521_probe to support clk config of yt8531s. Becase
|
||||
yt8521_probe does the things which yt8531s is needed, so
|
||||
removed yt8531s function.
|
||||
This patch has been verified on AM335x platform with yt8531s board.
|
||||
|
||||
Signed-off-by: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/phy/motorcomm.c | 51 ++++++++++++++++++++-----------------
|
||||
1 file changed, 27 insertions(+), 24 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -258,8 +258,6 @@
|
||||
#define YT8531_SCR_CLK_SRC_CLOCK_FROM_DIGITAL 3
|
||||
#define YT8531_SCR_CLK_SRC_REF_25M 4
|
||||
#define YT8531_SCR_CLK_SRC_SSC_25M 5
|
||||
-#define YT8531S_SYNCE_CFG_REG 0xA012
|
||||
-#define YT8531S_SCR_SYNCE_ENABLE BIT(6)
|
||||
|
||||
/* Extended Register end */
|
||||
|
||||
@@ -858,7 +856,32 @@ static int yt8521_probe(struct phy_devic
|
||||
return -EINVAL;
|
||||
}
|
||||
} else if (phydev->drv->phy_id == PHY_ID_YT8531S) {
|
||||
- return 0;
|
||||
+ switch (freq) {
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_DIS:
|
||||
+ mask = YT8531_SCR_SYNCE_ENABLE;
|
||||
+ val = 0;
|
||||
+ break;
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_25M:
|
||||
+ mask = YT8531_SCR_SYNCE_ENABLE |
|
||||
+ YT8531_SCR_CLK_SRC_MASK |
|
||||
+ YT8531_SCR_CLK_FRE_SEL_125M;
|
||||
+ val = YT8531_SCR_SYNCE_ENABLE |
|
||||
+ FIELD_PREP(YT8531_SCR_CLK_SRC_MASK,
|
||||
+ YT8531_SCR_CLK_SRC_REF_25M);
|
||||
+ break;
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_125M:
|
||||
+ mask = YT8531_SCR_SYNCE_ENABLE |
|
||||
+ YT8531_SCR_CLK_SRC_MASK |
|
||||
+ YT8531_SCR_CLK_FRE_SEL_125M;
|
||||
+ val = YT8531_SCR_SYNCE_ENABLE |
|
||||
+ YT8531_SCR_CLK_FRE_SEL_125M |
|
||||
+ FIELD_PREP(YT8531_SCR_CLK_SRC_MASK,
|
||||
+ YT8531_SCR_CLK_SRC_PLL_125M);
|
||||
+ break;
|
||||
+ default:
|
||||
+ phydev_warn(phydev, "Freq err:%u\n", freq);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
} else {
|
||||
phydev_warn(phydev, "PHY id err\n");
|
||||
return -EINVAL;
|
||||
@@ -869,26 +892,6 @@ static int yt8521_probe(struct phy_devic
|
||||
}
|
||||
|
||||
/**
|
||||
- * yt8531s_probe() - read chip config then set suitable polling_mode
|
||||
- * @phydev: a pointer to a &struct phy_device
|
||||
- *
|
||||
- * returns 0 or negative errno code
|
||||
- */
|
||||
-static int yt8531s_probe(struct phy_device *phydev)
|
||||
-{
|
||||
- int ret;
|
||||
-
|
||||
- /* Disable SyncE clock output by default */
|
||||
- ret = ytphy_modify_ext_with_lock(phydev, YT8531S_SYNCE_CFG_REG,
|
||||
- YT8531S_SCR_SYNCE_ENABLE, 0);
|
||||
- if (ret < 0)
|
||||
- return ret;
|
||||
-
|
||||
- /* same as yt8521_probe */
|
||||
- return yt8521_probe(phydev);
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
* ytphy_utp_read_lpa() - read LPA then setup lp_advertising for utp
|
||||
* @phydev: a pointer to a &struct phy_device
|
||||
*
|
||||
@@ -1970,7 +1973,7 @@ static struct phy_driver motorcomm_phy_d
|
||||
PHY_ID_MATCH_EXACT(PHY_ID_YT8531S),
|
||||
.name = "YT8531S Gigabit Ethernet",
|
||||
.get_features = yt8521_get_features,
|
||||
- .probe = yt8531s_probe,
|
||||
+ .probe = yt8521_probe,
|
||||
.read_page = yt8521_read_page,
|
||||
.write_page = yt8521_write_page,
|
||||
.get_wol = ytphy_get_wol,
|
@ -0,0 +1,302 @@
|
||||
From 4ac94f728a588e7096dd5010cd7141a309ea7805 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Date: Thu, 2 Feb 2023 11:00:37 +0800
|
||||
Subject: [PATCH] net: phy: Add driver for Motorcomm yt8531 gigabit ethernet
|
||||
phy
|
||||
|
||||
Add a driver for the motorcomm yt8531 gigabit ethernet phy. We have
|
||||
verified the driver on AM335x platform with yt8531 board. On the
|
||||
board, yt8531 gigabit ethernet phy works in utp mode, RGMII
|
||||
interface, supports 1000M/100M/10M speeds, and wol(magic package).
|
||||
|
||||
Signed-off-by: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/phy/Kconfig | 2 +-
|
||||
drivers/net/phy/motorcomm.c | 208 +++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 207 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/Kconfig
|
||||
+++ b/drivers/net/phy/Kconfig
|
||||
@@ -245,7 +245,7 @@ config MOTORCOMM_PHY
|
||||
tristate "Motorcomm PHYs"
|
||||
help
|
||||
Enables support for Motorcomm network PHYs.
|
||||
- Currently supports the YT8511, YT8521, YT8531S Gigabit Ethernet PHYs.
|
||||
+ Currently supports YT85xx Gigabit Ethernet PHYs.
|
||||
|
||||
config NATIONAL_PHY
|
||||
tristate "National Semiconductor PHYs"
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
- * Motorcomm 8511/8521/8531S PHY driver.
|
||||
+ * Motorcomm 8511/8521/8531/8531S PHY driver.
|
||||
*
|
||||
* Author: Peter Geis <pgwipeout@gmail.com>
|
||||
* Author: Frank <Frank.Sae@motor-comm.com>
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#define PHY_ID_YT8511 0x0000010a
|
||||
#define PHY_ID_YT8521 0x0000011a
|
||||
+#define PHY_ID_YT8531 0x4f51e91b
|
||||
#define PHY_ID_YT8531S 0x4f51e91a
|
||||
|
||||
/* YT8521/YT8531S Register Overview
|
||||
@@ -517,6 +518,61 @@ err_restore_page:
|
||||
return phy_restore_page(phydev, old_page, ret);
|
||||
}
|
||||
|
||||
+static int yt8531_set_wol(struct phy_device *phydev,
|
||||
+ struct ethtool_wolinfo *wol)
|
||||
+{
|
||||
+ const u16 mac_addr_reg[] = {
|
||||
+ YTPHY_WOL_MACADDR2_REG,
|
||||
+ YTPHY_WOL_MACADDR1_REG,
|
||||
+ YTPHY_WOL_MACADDR0_REG,
|
||||
+ };
|
||||
+ const u8 *mac_addr;
|
||||
+ u16 mask, val;
|
||||
+ int ret;
|
||||
+ u8 i;
|
||||
+
|
||||
+ if (wol->wolopts & WAKE_MAGIC) {
|
||||
+ mac_addr = phydev->attached_dev->dev_addr;
|
||||
+
|
||||
+ /* Store the device address for the magic packet */
|
||||
+ for (i = 0; i < 3; i++) {
|
||||
+ ret = ytphy_write_ext_with_lock(phydev, mac_addr_reg[i],
|
||||
+ ((mac_addr[i * 2] << 8)) |
|
||||
+ (mac_addr[i * 2 + 1]));
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* Enable WOL feature */
|
||||
+ mask = YTPHY_WCR_PULSE_WIDTH_MASK | YTPHY_WCR_INTR_SEL;
|
||||
+ val = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;
|
||||
+ val |= YTPHY_WCR_TYPE_PULSE | YTPHY_WCR_PULSE_WIDTH_672MS;
|
||||
+ ret = ytphy_modify_ext_with_lock(phydev, YTPHY_WOL_CONFIG_REG,
|
||||
+ mask, val);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Enable WOL interrupt */
|
||||
+ ret = phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG, 0,
|
||||
+ YTPHY_IER_WOL);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ } else {
|
||||
+ /* Disable WOL feature */
|
||||
+ mask = YTPHY_WCR_ENABLE | YTPHY_WCR_INTR_SEL;
|
||||
+ ret = ytphy_modify_ext_with_lock(phydev, YTPHY_WOL_CONFIG_REG,
|
||||
+ mask, 0);
|
||||
+
|
||||
+ /* Disable WOL interrupt */
|
||||
+ ret = phy_modify(phydev, YTPHY_INTERRUPT_ENABLE_REG,
|
||||
+ YTPHY_IER_WOL, 0);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int yt8511_read_page(struct phy_device *phydev)
|
||||
{
|
||||
return __phy_read(phydev, YT8511_PAGE_SELECT);
|
||||
@@ -767,6 +823,17 @@ static int ytphy_rgmii_clk_delay_config(
|
||||
return ytphy_modify_ext(phydev, YT8521_RGMII_CONFIG1_REG, mask, val);
|
||||
}
|
||||
|
||||
+static int ytphy_rgmii_clk_delay_config_with_lock(struct phy_device *phydev)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ phy_lock_mdio_bus(phydev);
|
||||
+ ret = ytphy_rgmii_clk_delay_config(phydev);
|
||||
+ phy_unlock_mdio_bus(phydev);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* yt8521_probe() - read chip config then set suitable polling_mode
|
||||
* @phydev: a pointer to a &struct phy_device
|
||||
@@ -891,6 +958,43 @@ static int yt8521_probe(struct phy_devic
|
||||
val);
|
||||
}
|
||||
|
||||
+static int yt8531_probe(struct phy_device *phydev)
|
||||
+{
|
||||
+ struct device_node *node = phydev->mdio.dev.of_node;
|
||||
+ u16 mask, val;
|
||||
+ u32 freq;
|
||||
+
|
||||
+ if (of_property_read_u32(node, "motorcomm,clk-out-frequency-hz", &freq))
|
||||
+ freq = YTPHY_DTS_OUTPUT_CLK_DIS;
|
||||
+
|
||||
+ switch (freq) {
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_DIS:
|
||||
+ mask = YT8531_SCR_SYNCE_ENABLE;
|
||||
+ val = 0;
|
||||
+ break;
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_25M:
|
||||
+ mask = YT8531_SCR_SYNCE_ENABLE | YT8531_SCR_CLK_SRC_MASK |
|
||||
+ YT8531_SCR_CLK_FRE_SEL_125M;
|
||||
+ val = YT8531_SCR_SYNCE_ENABLE |
|
||||
+ FIELD_PREP(YT8531_SCR_CLK_SRC_MASK,
|
||||
+ YT8531_SCR_CLK_SRC_REF_25M);
|
||||
+ break;
|
||||
+ case YTPHY_DTS_OUTPUT_CLK_125M:
|
||||
+ mask = YT8531_SCR_SYNCE_ENABLE | YT8531_SCR_CLK_SRC_MASK |
|
||||
+ YT8531_SCR_CLK_FRE_SEL_125M;
|
||||
+ val = YT8531_SCR_SYNCE_ENABLE | YT8531_SCR_CLK_FRE_SEL_125M |
|
||||
+ FIELD_PREP(YT8531_SCR_CLK_SRC_MASK,
|
||||
+ YT8531_SCR_CLK_SRC_PLL_125M);
|
||||
+ break;
|
||||
+ default:
|
||||
+ phydev_warn(phydev, "Freq err:%u\n", freq);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ return ytphy_modify_ext_with_lock(phydev, YTPHY_SYNCE_CFG_REG, mask,
|
||||
+ val);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* ytphy_utp_read_lpa() - read LPA then setup lp_advertising for utp
|
||||
* @phydev: a pointer to a &struct phy_device
|
||||
@@ -1387,6 +1491,94 @@ err_restore_page:
|
||||
return phy_restore_page(phydev, old_page, ret);
|
||||
}
|
||||
|
||||
+static int yt8531_config_init(struct phy_device *phydev)
|
||||
+{
|
||||
+ struct device_node *node = phydev->mdio.dev.of_node;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = ytphy_rgmii_clk_delay_config_with_lock(phydev);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (of_property_read_bool(node, "motorcomm,auto-sleep-disabled")) {
|
||||
+ /* disable auto sleep */
|
||||
+ ret = ytphy_modify_ext_with_lock(phydev,
|
||||
+ YT8521_EXTREG_SLEEP_CONTROL1_REG,
|
||||
+ YT8521_ESC1R_SLEEP_SW, 0);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ if (of_property_read_bool(node, "motorcomm,keep-pll-enabled")) {
|
||||
+ /* enable RXC clock when no wire plug */
|
||||
+ ret = ytphy_modify_ext_with_lock(phydev,
|
||||
+ YT8521_CLOCK_GATING_REG,
|
||||
+ YT8521_CGR_RX_CLK_EN, 0);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * yt8531_link_change_notify() - Adjust the tx clock direction according to
|
||||
+ * the current speed and dts config.
|
||||
+ * @phydev: a pointer to a &struct phy_device
|
||||
+ *
|
||||
+ * NOTE: This function is only used to adapt to VF2 with JH7110 SoC. Please
|
||||
+ * keep "motorcomm,tx-clk-adj-enabled" not exist in dts when the soc is not
|
||||
+ * JH7110.
|
||||
+ */
|
||||
+static void yt8531_link_change_notify(struct phy_device *phydev)
|
||||
+{
|
||||
+ struct device_node *node = phydev->mdio.dev.of_node;
|
||||
+ bool tx_clk_adj_enabled = false;
|
||||
+ bool tx_clk_1000_inverted;
|
||||
+ bool tx_clk_100_inverted;
|
||||
+ bool tx_clk_10_inverted;
|
||||
+ u16 val = 0;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (of_property_read_bool(node, "motorcomm,tx-clk-adj-enabled"))
|
||||
+ tx_clk_adj_enabled = true;
|
||||
+
|
||||
+ if (!tx_clk_adj_enabled)
|
||||
+ return;
|
||||
+
|
||||
+ if (of_property_read_bool(node, "motorcomm,tx-clk-10-inverted"))
|
||||
+ tx_clk_10_inverted = true;
|
||||
+ if (of_property_read_bool(node, "motorcomm,tx-clk-100-inverted"))
|
||||
+ tx_clk_100_inverted = true;
|
||||
+ if (of_property_read_bool(node, "motorcomm,tx-clk-1000-inverted"))
|
||||
+ tx_clk_1000_inverted = true;
|
||||
+
|
||||
+ if (phydev->speed < 0)
|
||||
+ return;
|
||||
+
|
||||
+ switch (phydev->speed) {
|
||||
+ case SPEED_1000:
|
||||
+ if (tx_clk_1000_inverted)
|
||||
+ val = YT8521_RC1R_TX_CLK_SEL_INVERTED;
|
||||
+ break;
|
||||
+ case SPEED_100:
|
||||
+ if (tx_clk_100_inverted)
|
||||
+ val = YT8521_RC1R_TX_CLK_SEL_INVERTED;
|
||||
+ break;
|
||||
+ case SPEED_10:
|
||||
+ if (tx_clk_10_inverted)
|
||||
+ val = YT8521_RC1R_TX_CLK_SEL_INVERTED;
|
||||
+ break;
|
||||
+ default:
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ret = ytphy_modify_ext_with_lock(phydev, YT8521_RGMII_CONFIG1_REG,
|
||||
+ YT8521_RC1R_TX_CLK_SEL_INVERTED, val);
|
||||
+ if (ret < 0)
|
||||
+ phydev_warn(phydev, "Modify TX_CLK_SEL err:%d\n", ret);
|
||||
+}
|
||||
+
|
||||
/**
|
||||
* yt8521_prepare_fiber_features() - A small helper function that setup
|
||||
* fiber's features.
|
||||
@@ -1970,6 +2162,17 @@ static struct phy_driver motorcomm_phy_d
|
||||
.resume = yt8521_resume,
|
||||
},
|
||||
{
|
||||
+ PHY_ID_MATCH_EXACT(PHY_ID_YT8531),
|
||||
+ .name = "YT8531 Gigabit Ethernet",
|
||||
+ .probe = yt8531_probe,
|
||||
+ .config_init = yt8531_config_init,
|
||||
+ .suspend = genphy_suspend,
|
||||
+ .resume = genphy_resume,
|
||||
+ .get_wol = ytphy_get_wol,
|
||||
+ .set_wol = yt8531_set_wol,
|
||||
+ .link_change_notify = yt8531_link_change_notify,
|
||||
+ },
|
||||
+ {
|
||||
PHY_ID_MATCH_EXACT(PHY_ID_YT8531S),
|
||||
.name = "YT8531S Gigabit Ethernet",
|
||||
.get_features = yt8521_get_features,
|
||||
@@ -1990,7 +2193,7 @@ static struct phy_driver motorcomm_phy_d
|
||||
|
||||
module_phy_driver(motorcomm_phy_drvs);
|
||||
|
||||
-MODULE_DESCRIPTION("Motorcomm 8511/8521/8531S PHY driver");
|
||||
+MODULE_DESCRIPTION("Motorcomm 8511/8521/8531/8531S PHY driver");
|
||||
MODULE_AUTHOR("Peter Geis");
|
||||
MODULE_AUTHOR("Frank");
|
||||
MODULE_LICENSE("GPL");
|
||||
@@ -1998,6 +2201,7 @@ MODULE_LICENSE("GPL");
|
||||
static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8511) },
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8521) },
|
||||
+ { PHY_ID_MATCH_EXACT(PHY_ID_YT8531) },
|
||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) },
|
||||
{ /* sentinel */ }
|
||||
};
|
@ -0,0 +1,34 @@
|
||||
From 9753613f7399601f9bae6ee81e9d4274246c98ab Mon Sep 17 00:00:00 2001
|
||||
From: Dan Carpenter <error27@gmail.com>
|
||||
Date: Wed, 15 Feb 2023 07:21:47 +0300
|
||||
Subject: [PATCH] net: phy: motorcomm: uninitialized variables in
|
||||
yt8531_link_change_notify()
|
||||
|
||||
These booleans are never set to false, but are just used without being
|
||||
initialized.
|
||||
|
||||
Fixes: 4ac94f728a58 ("net: phy: Add driver for Motorcomm yt8531 gigabit ethernet phy")
|
||||
Signed-off-by: Dan Carpenter <error27@gmail.com>
|
||||
Reviewed-by: Frank Sae <Frank.Sae@motor-comm.com>
|
||||
Link: https://lore.kernel.org/r/Y+xd2yJet2ImHLoQ@kili
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/phy/motorcomm.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/phy/motorcomm.c
|
||||
+++ b/drivers/net/phy/motorcomm.c
|
||||
@@ -1533,10 +1533,10 @@ static int yt8531_config_init(struct phy
|
||||
static void yt8531_link_change_notify(struct phy_device *phydev)
|
||||
{
|
||||
struct device_node *node = phydev->mdio.dev.of_node;
|
||||
+ bool tx_clk_1000_inverted = false;
|
||||
+ bool tx_clk_100_inverted = false;
|
||||
+ bool tx_clk_10_inverted = false;
|
||||
bool tx_clk_adj_enabled = false;
|
||||
- bool tx_clk_1000_inverted;
|
||||
- bool tx_clk_100_inverted;
|
||||
- bool tx_clk_10_inverted;
|
||||
u16 val = 0;
|
||||
int ret;
|
||||
|
@ -19,7 +19,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -17961,6 +17961,11 @@ L: netdev@vger.kernel.org
|
||||
@@ -17962,6 +17962,11 @@ L: netdev@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/net/ethernet/dlink/sundance.c
|
||||
|
||||
|
@ -32,7 +32,7 @@ Signed-off-by: Guenter Roeck <linux@roeck-us.net>
|
||||
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -15898,6 +15898,13 @@ S: Maintained
|
||||
@@ -15899,6 +15899,13 @@ S: Maintained
|
||||
F: include/sound/rt*.h
|
||||
F: sound/soc/codecs/rt*
|
||||
|
||||
|
@ -350,6 +350,7 @@ CONFIG_MMC_SDHCI_OF_DWCMSHC=y
|
||||
# CONFIG_MMC_SDHCI_PCI is not set
|
||||
CONFIG_MMC_SDHCI_PLTFM=y
|
||||
CONFIG_MODULES_USE_ELF_RELA=y
|
||||
CONFIG_MOTORCOMM_PHY=y
|
||||
CONFIG_MQ_IOSCHED_DEADLINE=y
|
||||
# CONFIG_MTD_CFI is not set
|
||||
CONFIG_MTD_CMDLINE_PARTS=y
|
||||
|
Loading…
x
Reference in New Issue
Block a user