net: phy: marvell: Add functions to read PHY's extended registers
Subsystems (2)
PATCH 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.
--- drivers/net/phy/marvell.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/net/phy/marvell.c +27 -0
@@ -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, };/*
Signature · 1 line
2.1.4
PATCH 1/1 net: phy: marvell: Add functions to read PHY's extended registers
Dear All,
Quoted 2 lines
[PATCH] net: phy: marvell: Add functions to read PHY's extended registers
Gentle ping about this patch.
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
PATCH 1/1 net: phy: marvell: Add functions to read PHY's extended registers
In reply to Lukasz MajewskiQuoted 53 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.100x1011The above code changes the way ETH connector LEDs blink.
Signed-off-by Lukasz Majewski <[email protected]>--- drivers/net/phy/marvell.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/net/phy/marvell.c +25
-0@@ -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 M88E1510_driver = { · line 701
Quoted 8 lines
drivers/net/phy/marvell.c +2
-0@@ -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, };/*
I guess this feature is usable. You only enable it for M88E1510. Can the same be applied to other Marvell PHYs?
York
PATCH 1/1 net: phy: marvell: Add functions to read PHY's extended registers
Quoted 65 lines · On Thu, 26 Oct 2017 15:05:18 +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.100x1011The above code changes the way ETH connector LEDs blink.
Signed-off-by Lukasz Majewski <[email protected]>--- drivers/net/phy/marvell.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/net/phy/marvell.c +9
-0@@ -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, intaddr,
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 +5
-0+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, };
Quoted 6 lines
drivers/net/phy/marvell.c static struct phy_driver M88E1510_driver = { · line 701
Quoted 2 lines
drivers/net/phy/marvell.c +0
-0/* I guess this feature is usable. You only enable it for M88E1510. Can the same be applied to other Marvell PHYs?
It should work...
However, in this patch I've only enabled one - which I could test.....
I can enable more if you can help me with debugging.
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
PATCH 1/1 net: phy: marvell: Add functions to read PHY's extended registers
Quoted 75 lines · On Thu, 26 Oct 2017 17:15:19 +0200 Lukasz Majewski <[email protected]> wrote:
Quoted 65 lines · On Thu, 26 Oct 2017 15:05:18 +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.100x1011The above code changes the way ETH connector LEDs blink.
Signed-off-by Lukasz Majewski <[email protected]>--- drivers/net/phy/marvell.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/net/phy/marvell.c +9
-0@@ -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, intaddr,
drivers/net/phy/marvell.c +1
-0+ int devaddr, int regnum, u16val) +{
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 +5
-0+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, };Quoted 6 lines
drivers/net/phy/marvell.c static struct phy_driver M88E1510_driver = { · line 701
Quoted 2 lines
drivers/net/phy/marvell.c +0
-0/* I guess this feature is usable. You only enable it for M88E1510. Can the same be applied to other Marvell PHYs?
Quoted 5 lines
It should work...
However, in this patch I've only enabled one - which I could test.....
I can enable more if you can help me with debugging.
s/debugging/testing
Quoted 9 lines
Quoted 3 lines
York
Best regards,
Quoted 7 lines
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
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
PATCH 1/1 net: phy: marvell: Add functions to read PHY's extended registers
Quoted 78 lines · Lukasz Majewski
Quoted 75 lines · On Thu, 26 Oct 2017 17:15:19 +0200 Lukasz Majewski <[email protected]> wrote:
Quoted 71 lines · On Thu, 26 Oct 2017 15:05:18 +0000 York Sun <[email protected]> wrote:
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.100x1011The above code changes the way ETH connector LEDs blink.
Signed-off-by Lukasz Majewski <[email protected]>--- drivers/net/phy/marvell.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/net/phy/marvell.c +9
-0@@ -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, intaddr,
drivers/net/phy/marvell.c +1
-0+ int devaddr, int regnum, u16val) +{
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 M88E1510_driver = { · line 701
Quoted 8 lines
drivers/net/phy/marvell.c +2
-0@@ -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, };/* I guess this feature is usable. You only enable it for M88E1510. Can the same be applied to other Marvell PHYs?
Quoted 8 lines
Quoted 5 lines
It should work...
However, in this patch I've only enabled one - which I could test.....
I can enable more if you can help me with debugging.
s/debugging/testing
I can try to find some old boards with Marvell PHYs, but it is not easy. Our recent boards don't use their PHYs (don't ask me why). Maybe we can take another approach. If you have access to the PHY manual, maybe you can confirm the extended page is available. This actually prompts another thought. What would happen if you access to a non-exist page? I hope it doesn't lock the system. Please try it.
York
PATCH 1/1 net: phy: marvell: Add functions to read PHY's extended registers
Hi York,
Quoted 89 lines · Lukasz Majewski
Quoted 78 lines
Quoted 75 lines · On Thu, 26 Oct 2017 17:15:19 +0200 Lukasz Majewski <[email protected]> wrote:
Quoted 71 lines · On Thu, 26 Oct 2017 15:05:18 +0000 York Sun <[email protected]> wrote:
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.100x1011The above code changes the way ETH connector LEDs blink.
Signed-off-by Lukasz Majewski <[email protected]>--- drivers/net/phy/marvell.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)(quoted diff) +0
-0
b/drivers/net/phy/marvell.cindex b7f300e..a167c34 100644drivers/net/phy/marvell.c +9
-0@@ -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, intaddr,
drivers/net/phy/marvell.c +1
-0+ int devaddr, int regnum, u16val) +{
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 M88E1510_driver = { · line 701
Quoted 8 lines
drivers/net/phy/marvell.c +2
-0@@ -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, };/* I guess this feature is usable. You only enable it for M88E1510. Can the same be applied to other Marvell PHYs?
Quoted 9 lines
Quoted 6 lines
It should work...
However, in this patch I've only enabled one - which I could test.....
I can enable more if you can help me with debugging.
s/debugging/testing
Quoted 6 lines
I can try to find some old boards with Marvell PHYs, but it is not easy. Our recent boards don't use their PHYs (don't ask me why). Maybe we can take another approach. If you have access to the PHY manual, maybe you can confirm the extended page is available. This actually prompts another thought. What would happen if you access to a non-exist page? I hope it doesn't lock the system. Please try it.
It should not harm the devices. I would add the code to devices which we can test.
Support for others would be added on demand if somebody can test the code.
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