lkml.org 
[lkml]   [2021]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH net-next 1/2] net: phy: at803x: add pages support to AR8031/33
Date
The AR8031 has two register sets: Copper and Fiber. The fiber page is
used in case of 100Base-FX and 1000Base-X. But more importantly it is
also used for the SGMII link. Add support to switch between these two.

Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/net/phy/at803x.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index d67bddc111e3..a3aa10f14638 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -144,6 +144,9 @@
#define ATH8035_PHY_ID 0x004dd072
#define AT8030_PHY_ID_MASK 0xffffffef

+#define AT803X_FIBER_PAGE 0
+#define AT803X_COPPER_PAGE 1
+
MODULE_DESCRIPTION("Qualcomm Atheros AR803x PHY driver");
MODULE_AUTHOR("Matus Ujhelyi");
MODULE_LICENSE("GPL");
@@ -1143,6 +1146,36 @@ static int at803x_cable_test_start(struct phy_device *phydev)
return 0;
}

+static int at803x_read_page(struct phy_device *phydev)
+{
+ int val;
+
+ val = __phy_read(phydev, AT803X_REG_CHIP_CONFIG);
+ if (val < 0)
+ return val;
+
+ return (val & AT803X_BT_BX_REG_SEL) ? AT803X_COPPER_PAGE : AT803X_FIBER_PAGE;
+}
+
+static int at803x_write_page(struct phy_device *phydev, int page)
+{
+ u16 sel;
+
+ switch (page) {
+ case AT803X_FIBER_PAGE:
+ sel = 0;
+ break;
+ case AT803X_COPPER_PAGE:
+ sel = AT803X_BT_BX_REG_SEL;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return __phy_modify(phydev, AT803X_REG_CHIP_CONFIG,
+ AT803X_BT_BX_REG_SEL, sel);
+}
+
static struct phy_driver at803x_driver[] = {
{
/* Qualcomm Atheros AR8035 */
@@ -1189,6 +1222,8 @@ static struct phy_driver at803x_driver[] = {
.flags = PHY_POLL_CABLE_TEST,
.probe = at803x_probe,
.remove = at803x_remove,
+ .read_page = at803x_read_page,
+ .write_page = at803x_write_page,
.config_init = at803x_config_init,
.soft_reset = genphy_soft_reset,
.set_wol = at803x_set_wol,
--
2.20.1
\
 
 \ /
  Last update: 2021-02-14 02:06    [W:0.036 / U:15.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site