mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
rockchip: 5.15: backport yt8521 driver from upstream kernel v6.2
This commit is contained in:
parent
b1a02a7a64
commit
a9671e8543
@ -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_fdx(u16 lcladv, u16 rmtadv)
|
||||||
|
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
@ -15,15 +15,15 @@ Signed-off-by: Furkan Kardame <f.kardame@manjaro.org>
|
|||||||
|
|
||||||
--- a/drivers/net/phy/motorcomm.c
|
--- a/drivers/net/phy/motorcomm.c
|
||||||
+++ b/drivers/net/phy/motorcomm.c
|
+++ b/drivers/net/phy/motorcomm.c
|
||||||
@@ -10,6 +10,7 @@
|
@@ -13,6 +13,7 @@
|
||||||
#include <linux/phy.h>
|
|
||||||
|
|
||||||
#define PHY_ID_YT8511 0x0000010a
|
#define PHY_ID_YT8511 0x0000010a
|
||||||
|
#define PHY_ID_YT8521 0x0000011A
|
||||||
+#define PHY_ID_YT8531 0x4f51e91b
|
+#define PHY_ID_YT8531 0x4f51e91b
|
||||||
|
|
||||||
#define YT8511_PAGE_SELECT 0x1e
|
/* YT8521 Register Overview
|
||||||
#define YT8511_PAGE 0x1f
|
* UTP Register space | FIBER Register space
|
||||||
@@ -38,6 +39,38 @@
|
@@ -129,6 +130,38 @@
|
||||||
#define YT8511_DELAY_FE_TX_EN (0xf << 12)
|
#define YT8511_DELAY_FE_TX_EN (0xf << 12)
|
||||||
#define YT8511_DELAY_FE_TX_DIS (0x2 << 12)
|
#define YT8511_DELAY_FE_TX_DIS (0x2 << 12)
|
||||||
|
|
||||||
@ -59,11 +59,11 @@ Signed-off-by: Furkan Kardame <f.kardame@manjaro.org>
|
|||||||
+ */
|
+ */
|
||||||
+#define YT8531_CLKCFG_125M (BIT(6) | BIT(4) | (0x0 < 1))
|
+#define YT8531_CLKCFG_125M (BIT(6) | BIT(4) | (0x0 < 1))
|
||||||
+
|
+
|
||||||
static int yt8511_read_page(struct phy_device *phydev)
|
/* Extended register is different from MMD Register and MII Register.
|
||||||
{
|
* We can use ytphy_read_ext/ytphy_write_ext/ytphy_modify_ext function to
|
||||||
return __phy_read(phydev, YT8511_PAGE_SELECT);
|
* operate extended register.
|
||||||
@@ -111,6 +144,51 @@ err_restore_page:
|
@@ -1723,6 +1756,51 @@ err_restore_page:
|
||||||
return phy_restore_page(phydev, oldpage, ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
+static int yt8531_config_init(struct phy_device *phydev)
|
+static int yt8531_config_init(struct phy_device *phydev)
|
||||||
@ -114,10 +114,10 @@ Signed-off-by: Furkan Kardame <f.kardame@manjaro.org>
|
|||||||
static struct phy_driver motorcomm_phy_drvs[] = {
|
static struct phy_driver motorcomm_phy_drvs[] = {
|
||||||
{
|
{
|
||||||
PHY_ID_MATCH_EXACT(PHY_ID_YT8511),
|
PHY_ID_MATCH_EXACT(PHY_ID_YT8511),
|
||||||
@@ -120,7 +198,16 @@ static struct phy_driver motorcomm_phy_d
|
@@ -1749,7 +1827,16 @@ static struct phy_driver motorcomm_phy_d
|
||||||
.resume = genphy_resume,
|
.soft_reset = yt8521_soft_reset,
|
||||||
.read_page = yt8511_read_page,
|
.suspend = yt8521_suspend,
|
||||||
.write_page = yt8511_write_page,
|
.resume = yt8521_resume,
|
||||||
+ }, {
|
+ }, {
|
||||||
+ PHY_ID_MATCH_EXACT(PHY_ID_YT8531),
|
+ PHY_ID_MATCH_EXACT(PHY_ID_YT8531),
|
||||||
+ .name = "YT8531 Gigabit Ethernet",
|
+ .name = "YT8531 Gigabit Ethernet",
|
||||||
@ -131,10 +131,10 @@ Signed-off-by: Furkan Kardame <f.kardame@manjaro.org>
|
|||||||
};
|
};
|
||||||
|
|
||||||
module_phy_driver(motorcomm_phy_drvs);
|
module_phy_driver(motorcomm_phy_drvs);
|
||||||
@@ -131,6 +218,7 @@ MODULE_LICENSE("GPL");
|
@@ -1762,6 +1849,7 @@ MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
|
static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = {
|
||||||
{ PHY_ID_MATCH_EXACT(PHY_ID_YT8511) },
|
{ 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_YT8531) },
|
||||||
{ /* sentinal */ }
|
{ /* sentinal */ }
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user