From: Michael Walle <michael@walle.cc>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Michael Walle <michael@walle.cc>
Subject: [PATCH net-next 1/2] net: phy: at803x: add pages support to AR8031/33
Date: Sun, 14 Feb 2021 02:04:04 +0100 [thread overview]
Message-ID: <20210214010405.32019-2-michael@walle.cc> (raw)
In-Reply-To: <20210214010405.32019-1-michael@walle.cc>
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
next prev parent reply other threads:[~2021-02-14 1:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-14 1:04 [PATCH net-next 0/2] net: phy: at803x: paging support Michael Walle
2021-02-14 1:04 ` Michael Walle [this message]
2021-02-14 1:04 ` [PATCH net-next 2/2] net: phy: at803x: use proper locking in at803x_aneg_done() Michael Walle
2021-02-14 1:57 ` Vladimir Oltean
2021-02-14 2:18 ` Michael Walle
2021-02-14 2:24 ` Vladimir Oltean
2021-02-14 20:48 ` Michael Walle
2021-02-15 21:32 ` Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210214010405.32019-2-michael@walle.cc \
--to=michael@walle.cc \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox