Skip to contentSkip to conversation

net: phy: marvell: Add functions to read PHY's extended registers

PATCH Superseded Lukasz Majewski 3 participants 12 messages Oct 27, 2017 – Jan 22, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: phy: marvell: Add functions to read PHY's extended registers

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
drivers/net/phy/marvell.c +47 -0
index b7f300e..19f451d 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, devaddr);
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, oldpage);
+
+	return val;
+}
+
+static int m88e1xxx_phy_extwrite(struct phy_device *phydev, int addr,
+				 int devaddr, int regnum, u16 val)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE);
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, devaddr);
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, oldpage);
+
+	return 0;
+}
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {
@@ -599,6 +624,8 @@ static struct phy_driver M88E1011S_driver = {
 	.config = &m88e1011s_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1111S_driver = {
@@ -609,6 +636,8 @@ static struct phy_driver M88E1111S_driver = {
 	.config = &m88e1111s_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1118_driver = {
@@ -619,6 +648,8 @@ static struct phy_driver M88E1118_driver = {
 	.config = &m88e1118_config,
 	.startup = &m88e1118_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1118R_driver = {
@@ -629,6 +660,8 @@ static struct phy_driver M88E1118R_driver = {
 	.config = &m88e1118_config,
 	.startup = &m88e1118_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1121R_driver = {
@@ -639,6 +672,8 @@ static struct phy_driver M88E1121R_driver = {
 	.config = &m88e1121_config,
 	.startup = &genphy_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1145_driver = {
@@ -649,6 +684,8 @@ static struct phy_driver M88E1145_driver = {
 	.config = &m88e1145_config,
 	.startup = &m88e1145_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1149S_driver = {
@@ -659,6 +696,8 @@ static struct phy_driver M88E1149S_driver = {
 	.config = &m88e1149_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1510_driver = {
@@ -669,6 +708,8 @@ static struct phy_driver M88E1510_driver = {
 	.config = &m88e1510_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 /*
@@ -684,6 +725,8 @@ static struct phy_driver M88E1518_driver = {
 	.config = &m88e1518_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1310_driver = {
@@ -694,6 +737,8 @@ static struct phy_driver M88E1310_driver = {
 	.config = &m88e1310_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1680_driver = {
@@ -704,6 +749,8 @@ static struct phy_driver M88E1680_driver = {
 	.config = &m88e1680_config,
 	.startup = &genphy_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 int phy_marvell_init(void)
Signature · 1 line
2.1.4
#1 lore raw

PATCH v2 1/1 net: phy: marvell: Add functions to read PHY's extended registers

Quoted 58 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
drivers/net/phy/marvell.c +25 -0
index b7f300e..19f451d 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, devaddr);
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, oldpage);
+
+	return val;
+}
+
+static int m88e1xxx_phy_extwrite(struct phy_device *phydev, int addr,
+				 int devaddr, int regnum, u16 val)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE);
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, devaddr);
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, oldpage);
+
+	return 0;
+}
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {

drivers/net/phy/marvell.c static struct phy_driver M88E1011S_driver = { · line 630

Quoted 7 lines
drivers/net/phy/marvell.c +2 -0
@@ -599,6 +624,8 @@ static struct phy_driver M88E1011S_driver = {
 	.config = &m88e1011s_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 

Lukasz,

This seems wrong. 88E1011S doesn't have the page register. I can only confirm 88E1111 and 88E1145 have pages. I don't have other part's datasheet to check.

York

#2 lore raw

PATCH v2 1/1 net: phy: marvell: Add functions to read PHY's extended registers

Quoted 75 lines · On Fri, 27 Oct 2017 15:06:37 +0000 York Sun <[email protected]> wrote:
Quoted 64 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 47

+++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)

drivers/net/phy/marvell.c +9 -0
index b7f300e..19f451d 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int
 addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,
 MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,
 devaddr);
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +4 -0
+	return val;
+}
+
+static int m88e1xxx_phy_extwrite(struct phy_device *phydev, int

addr,

drivers/net/phy/marvell.c +3 -0
+				 int devaddr, int regnum, u16 val)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,

MII_MARVELL_PHY_PAGE); +

drivers/net/phy/marvell.c +1 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

devaddr);

drivers/net/phy/marvell.c +2 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +3 -0
+	return 0;
+}
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {

drivers/net/phy/marvell.c static struct phy_driver M88E1011S_driver = { · line 630

Quoted 7 lines
drivers/net/phy/marvell.c +2 -0
@@ -599,6 +624,8 @@ static struct phy_driver M88E1011S_driver = {
 	.config = &m88e1011s_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 

Lukasz,

Quoted 1 line

This seems wrong. 88E1011S doesn't have the page register.

Ok. I will remove this one from v3.

Quoted 2 lines

I can only
confirm 88E1111 and 88E1145 have pages.

I do know that it works on 88E151x

The 88E1318 and 88E1618 seems to be unknown.

Quoted 5 lines

I don't have other part's
datasheet to check.

York

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de

#3 lore raw

PATCH v2 1/1 net: phy: marvell: Add functions to read PHY's extended registers

Quoted 34 lines · Lukasz Majewski
Quoted 31 lines · On Fri, 27 Oct 2017 15:06:37 +0000 York Sun <[email protected]> wrote:
Quoted 30 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 47

+++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)

drivers/net/phy/marvell.c +0 -0
index b7f300e..19f451d 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
Quoted 10 lines
Quoted 10 lines

drivers/net/phy/marvell.c line 116

Quoted 10 lines
drivers/net/phy/marvell.c +7 -0
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int
 addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,
 MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,
 devaddr);

For register 30 and 31, the page register is 29, not 22.

Quoted 36 lines
Quoted 34 lines
Quoted 24 lines
drivers/net/phy/marvell.c +2 -0
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +4 -0
+	return val;
+}
+
+static int m88e1xxx_phy_extwrite(struct phy_device *phydev, int

addr,

drivers/net/phy/marvell.c +3 -0
+				 int devaddr, int regnum, u16 val)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,

MII_MARVELL_PHY_PAGE); +

drivers/net/phy/marvell.c +1 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

devaddr);

drivers/net/phy/marvell.c +2 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +3 -0
+	return 0;
+}
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {

drivers/net/phy/marvell.c static struct phy_driver M88E1011S_driver = { · line 630

Quoted 7 lines
drivers/net/phy/marvell.c +2 -0
@@ -599,6 +624,8 @@ static struct phy_driver M88E1011S_driver = {
 	.config = &m88e1011s_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 

Lukasz,

Quoted 1 line

This seems wrong. 88E1011S doesn't have the page register.

Quoted 12 lines

Ok. I will remove this one from v3.

Quoted 2 lines

I can only
confirm 88E1111 and 88E1145 have pages.

I do know that it works on 88E151x

The 88E1318 and 88E1618 seems to be unknown.

Quoted 2 lines

I don't have other part's
datasheet to check.

I suggest only to enable the parts you can confirm on hardware, datasheet, or from the source code (where the page register is used).

York

#4 lore raw

PATCH v2 1/1 net: phy: marvell: Add functions to read PHY's extended registers

Hi York,

Quoted 35 lines · Lukasz Majewski
Quoted 34 lines
Quoted 31 lines · On Fri, 27 Oct 2017 15:06:37 +0000 York Sun <[email protected]> wrote:
Quoted 30 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 47

+++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)

drivers/net/phy/marvell.c +0 -0
index b7f300e..19f451d 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
Quoted 60 lines
Quoted 10 lines
Quoted 10 lines

drivers/net/phy/marvell.c line 116

Quoted 10 lines
drivers/net/phy/marvell.c +7 -0
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int
 addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,
 MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,
 devaddr);

For register 30 and 31, the page register is 29, not 22.

Quoted 47 lines
Quoted 34 lines
Quoted 24 lines
drivers/net/phy/marvell.c +2 -0
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +4 -0
+	return val;
+}
+
+static int m88e1xxx_phy_extwrite(struct phy_device *phydev, int

addr,

drivers/net/phy/marvell.c +1 -0
+				 int devaddr, int regnum, u16

val) +{

drivers/net/phy/marvell.c +1 -0
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,

MII_MARVELL_PHY_PAGE); +

drivers/net/phy/marvell.c +1 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

devaddr);

drivers/net/phy/marvell.c +2 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +3 -0
+	return 0;
+}
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {

drivers/net/phy/marvell.c static struct phy_driver M88E1011S_driver = { · line 630

Quoted 7 lines
drivers/net/phy/marvell.c +2 -0
@@ -599,6 +624,8 @@ static struct phy_driver M88E1011S_driver = {
 	.config = &m88e1011s_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 

Lukasz,

Quoted 1 line

This seems wrong. 88E1011S doesn't have the page register.

Ok. I will remove this one from v3.

Quoted 2 lines

I can only
confirm 88E1111 and 88E1145 have pages.

I do know that it works on 88E151x

The 88E1318 and 88E1618 seems to be unknown.

Quoted 2 lines

I don't have other part's
datasheet to check.

Datasheet is not so easily accessible.

Quoted 4 lines
Quoted 1 line

I suggest only to enable the parts you can confirm on hardware, datasheet, or from the source code (where the page register is used).

Then this code will be enabled at:

88E1111, 88E1145, and 88E151x (which I can test).

Quoted 2 lines

York

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de

#5 lore raw

PATCH v2 1/1 net: phy: marvell: Add functions to read PHY's extended registers

In reply to York Sun

Hi York,

Quoted 35 lines · Lukasz Majewski
Quoted 34 lines
Quoted 31 lines · On Fri, 27 Oct 2017 15:06:37 +0000 York Sun <[email protected]> wrote:
Quoted 30 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 47

+++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)

drivers/net/phy/marvell.c +0 -0
index b7f300e..19f451d 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
Quoted 12 lines
Quoted 10 lines
Quoted 10 lines

drivers/net/phy/marvell.c line 116

Quoted 10 lines
drivers/net/phy/marvell.c +7 -0
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int
 addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,
 MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,
 devaddr);  

For register 30 and 31, the page register is 29, not 22.

Yes, for 88E1145 and 88E1149 the page register is 29, not 22 (as it is in majority of devices from marvell.c file in u-boot).

It seems like the most practical approach would be as presented in patch v1 - just enable this code on PHY which I can test.

If you find other devices (boards) and test the code, then we can add it as well.

Quoted 45 lines
Quoted 45 lines
Quoted 34 lines
Quoted 24 lines
drivers/net/phy/marvell.c +2 -0
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +4 -0
+	return val;
+}
+
+static int m88e1xxx_phy_extwrite(struct phy_device *phydev, int

addr,

drivers/net/phy/marvell.c +1 -0
+				 int devaddr, int regnum, u16

val) +{

drivers/net/phy/marvell.c +1 -0
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,

MII_MARVELL_PHY_PAGE); +

drivers/net/phy/marvell.c +1 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

devaddr);

drivers/net/phy/marvell.c +2 -0
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,

oldpage); +

drivers/net/phy/marvell.c +3 -0
+	return 0;
+}
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {

drivers/net/phy/marvell.c static struct phy_driver M88E1011S_driver = { · line 630

Quoted 7 lines
drivers/net/phy/marvell.c +2 -0
@@ -599,6 +624,8 @@ static struct phy_driver M88E1011S_driver = {
 	.config = &m88e1011s_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 

Lukasz,

Quoted 1 line

This seems wrong. 88E1011S doesn't have the page register.

Ok. I will remove this one from v3.

Quoted 2 lines

I can only
confirm 88E1111 and 88E1145 have pages.

I do know that it works on 88E151x

The 88E1318 and 88E1618 seems to be unknown.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

I don't have other part's
datasheet to check.

I suggest only to enable the parts you can confirm on hardware, datasheet, or from the source code (where the page register is used).

York

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171030/edd7b7fe/attachment.sig>

#6 lore raw

PATCH v2 1/1 net: phy: marvell: Add functions to read PHY's extended registers

Quoted 50 lines · Lukasz Majewski

Hi York,

Quoted 35 lines · Lukasz Majewski
Quoted 34 lines
Quoted 31 lines · On Fri, 27 Oct 2017 15:06:37 +0000 York Sun <[email protected]> wrote:
Quoted 30 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 47

+++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)

drivers/net/phy/marvell.c +0 -0
index b7f300e..19f451d 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
Quoted 12 lines
Quoted 10 lines
Quoted 10 lines

drivers/net/phy/marvell.c line 116

Quoted 10 lines
drivers/net/phy/marvell.c +7 -0
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int
 addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,
 MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE,
 devaddr);  

For register 30 and 31, the page register is 29, not 22.

Quoted 9 lines

Yes, for 88E1145 and 88E1149 the page register is 29, not 22 (as it is in majority of devices from marvell.c file in u-boot).

It seems like the most practical approach would be as presented in patch v1 - just enable this code on PHY which I can test.

If you find other devices (boards) and test the code, then we can add it as well.

OK. Thanks for trying.

York

#7 lore raw

PATCH v3 1/1 net: phy: marvell: Add functions to read PHY's extended registers

In reply to Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v3:
- Enable extended registers access only for 88E151x family of PHYs

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

 drivers/net/phy/marvell.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/net/phy/marvell.c +29 -0
index b7f300e40f..0b9a9fce8a 100644
@@ -104,6 +104,31 @@
 #define MIIM_88E151x_MODE_SGMII		1
 #define MIIM_88E151x_RESET_OFFS		15
 
+static int m88e1xxx_phy_extread(struct phy_device *phydev, int addr,
+				int devaddr, int regnum)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE);
+	int val;
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, devaddr);
+	val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, oldpage);
+
+	return val;
+}
+
+static int m88e1xxx_phy_extwrite(struct phy_device *phydev, int addr,
+				 int devaddr, int regnum, u16 val)
+{
+	int oldpage = phy_read(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE);
+
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, devaddr);
+	phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
+	phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, oldpage);
+
+	return 0;
+}
+
 /* Marvell 88E1011S */
 static int m88e1011s_config(struct phy_device *phydev)
 {
@@ -669,6 +694,8 @@ static struct phy_driver M88E1510_driver = {
 	.config = &m88e1510_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 /*
@@ -684,6 +711,8 @@ static struct phy_driver M88E1518_driver = {
 	.config = &m88e1518_config,
 	.startup = &m88e1011s_startup,
 	.shutdown = &genphy_shutdown,
+	.readext = &m88e1xxx_phy_extread,
+	.writeext = &m88e1xxx_phy_extwrite,
 };
 
 static struct phy_driver M88E1310_driver = {
Signature · 1 line
2.11.0
#8 lore raw

PATCH v3 1/1 net: phy: marvell: Add functions to read PHY's extended registers

Quoted 12 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

Quoted 9 lines

---

Changes in v3:
- Enable extended registers access only for 88E151x family of PHYs

Changes in v2:
- Provide the readext and writeext callbacks to other marvell ETH PHY devices

#9 lore raw

PATCH v3 1/1 net: phy: marvell: Add functions to read PHY's extended registers

Hi Joe,

Quoted 19 lines · Lukasz Majewski
Quoted 18 lines

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.

---

Changes in v3:
- Enable extended registers access only for 88E151x family of
PHYs

Quoted 6 lines
Quoted 4 lines

Changes in v2:
- Provide the readext and writeext callbacks to other marvell
ETH PHY devices

Would it be possible to add this patch to your next u-boot-net PR?

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/9dcc3797/attachment.sig>

#10 lore raw

PATCH v3 1/1 net: phy: marvell: Add functions to read PHY's extended registers

In reply to Lukasz Majewski
Quoted 11 lines · Lukasz Majewski

This commit allows extended Marvell registers to be read with:

foo > mdio rx FEC 3.10
Reading from bus FEC
PHY at address 0:
3.16 - 0x1063
foo > mdio wx FEC 3.10 0x1011

The above code changes the way ETH connector LEDs blink.