linux-amlogic.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH u-boot] net: phy: realtek: Add functions to read PHY's extended registers
@ 2019-01-16 11:34 Carlo Caione
  2019-01-22 22:17 ` [U-Boot] " Joe Hershberger
  0 siblings, 1 reply; 2+ messages in thread
From: Carlo Caione @ 2019-01-16 11:34 UTC (permalink / raw)
  To: joe.hershberger, u-boot, linux-amlogic; +Cc: Carlo Caione

According to the datasheet to access the extended registers we have to:

1. Write Register 31 Data = 0x0XYZ (Page 0xXYZ)
2. Read/Write the target Register Data
3. Write Register 31 Data = 0x0000 or 0xa42 (switch back to IEEE
   Standard Registers)

Hook the missing functions so that we can use the `mdio rx/wx` command to
easily access the extended registers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
 drivers/net/phy/realtek.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index b3e6578df9..3bea1fa9d0 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -57,6 +57,31 @@
 #define MIIM_RTL8211F_TX_DELAY		0x100
 #define MIIM_RTL8211F_LCR		0x10
 
+static int rtl8211f_phy_extread(struct phy_device *phydev, int addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, devaddr);
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, oldpage);
+
+	return val;
+}
+
+static int rtl8211f_phy_extwrite(struct phy_device *phydev, int addr,
+				 int devaddr, int regnum, u16 val)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT);
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, devaddr);
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, oldpage);
+
+	return 0;
+}
+
 static int rtl8211b_probe(struct phy_device *phydev)
 {
 #ifdef CONFIG_RTL8211X_PHY_FORCE_MASTER
@@ -336,6 +361,8 @@ static struct phy_driver RTL8211F_driver = {
 	.config = &rtl8211f_config,
 	.startup = &rtl8211f_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &rtl8211f_phy_extread,
+	.writeext = &rtl8211f_phy_extwrite,
 };
 
 int phy_realtek_init(void)
-- 
2.19.1


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [U-Boot] [PATCH u-boot] net: phy: realtek: Add functions to read PHY's extended registers
  2019-01-16 11:34 [PATCH u-boot] net: phy: realtek: Add functions to read PHY's extended registers Carlo Caione
@ 2019-01-22 22:17 ` Joe Hershberger
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Hershberger @ 2019-01-22 22:17 UTC (permalink / raw)
  To: Carlo Caione; +Cc: u-boot, linux-amlogic, Joseph Hershberger

On Wed, Jan 16, 2019 at 8:07 AM Carlo Caione <ccaione@baylibre.com> wrote:
>
> According to the datasheet to access the extended registers we have to:
>
> 1. Write Register 31 Data = 0x0XYZ (Page 0xXYZ)
> 2. Read/Write the target Register Data
> 3. Write Register 31 Data = 0x0000 or 0xa42 (switch back to IEEE
>    Standard Registers)
>
> Hook the missing functions so that we can use the `mdio rx/wx` command to
> easily access the extended registers.
>
> Signed-off-by: Carlo Caione <ccaione@baylibre.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-22 22:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 11:34 [PATCH u-boot] net: phy: realtek: Add functions to read PHY's extended registers Carlo Caione
2019-01-22 22:17 ` [U-Boot] " Joe Hershberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).