[PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.

Subsystems: ethernet phy library, networking drivers, the rest

STALE3651d

4 messages, 2 authors, 2016-09-08 · open the first message on its own page

[PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.

From: Raju Lakkaraju <hidden>
Date: 2016-08-24 12:43:32

From: Nagaraju Lakkaraju <redacted>

PHY Read support will be added for VSC 85xx Microsemi PHYs.

Signed-off-by: Nagaraju Lakkaraju <redacted>
---
 drivers/net/phy/mscc.c | 25 +++++++++++++++++++++++++
 include/linux/mscc.h   |  8 ++++++++
 2 files changed, 33 insertions(+)
diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
index 60d9d5f..5a74f81 100644
--- a/drivers/net/phy/mscc.c
+++ b/drivers/net/phy/mscc.c
@@ -194,6 +194,28 @@ static int vsc85xx_mac_if_get(struct phy_device *phydev,
        return rc;
 }

+static int vsc85xx_phy_read_reg(struct phy_device *phydev,
+                               struct phy_reg_op *data)
+{
+       int rc = 0;
+       u16 reg_addr = data->reg;
+       u8  page = data->pg;
+       u16 reg_val;
+
+       if (page != 0) {
+               mutex_lock(&phydev->lock);
+               rc = vsc85xx_phy_page_set(phydev, page);
+               reg_val = phy_read(phydev, reg_addr);
+               rc = vsc85xx_phy_page_set(phydev, 0);
+               mutex_unlock(&phydev->lock);
+       } else {
+               reg_val = phy_read(phydev, reg_addr);
+       }
+       data->val = reg_val;
+
+       return rc;
+}
+
 static int vsc85xx_features_set(struct phy_device *phydev)
 {
        int rc = 0;
@@ -225,6 +247,9 @@ static int vsc85xx_features_get(struct phy_device *phydev)
        case PHY_MAC_IF:
                rc = vsc85xx_mac_if_get(phydev, &ftrs->mac_if);
                break;
+       case PHY_READ_REG:
+               rc = vsc85xx_phy_read_reg(phydev, ftrs->data);
+               break;
        default:
                break;
        }
diff --git a/include/linux/mscc.h b/include/linux/mscc.h
index dcfd0ae..4265da7 100644
--- a/include/linux/mscc.h
+++ b/include/linux/mscc.h
@@ -12,6 +12,7 @@
 enum phy_features {
        PHY_EDGE_RATE_CONTROL = 0,
        PHY_MAC_IF            = 1,
+       PHY_READ_REG          = 2,
        PHY_SUPPORTED_FEATURES_MAX
 };
@@ -26,10 +27,17 @@ enum rgmii_rx_clock_delay {
        RGMII_RX_CLK_DELAY_3_4_NS = 7
 };

+struct phy_reg_op {
+       u16 reg;
+       u16 val;
+       u8  pg;
+};
+
 struct phy_features_t {
        enum phy_features cmd;           /* PHY Supported Features */
        u8   rate;                       /* Edge rate control */
        phy_interface_t mac_if;          /* MAC interface config */
+       struct phy_reg_op *data;         /* Read/Write register operatioins */
 };

 #endif /*  __LINUX_MSCC_H */
-- 
2.7.4

Re: [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.

From: Andrew Lunn <andrew@lunn.ch>
Date: 2016-08-24 13:13:54

On Wed, Aug 24, 2016 at 12:27:07PM +0000, Raju Lakkaraju wrote:
From: Nagaraju Lakkaraju <redacted>

PHY Read support will be added for VSC 85xx Microsemi PHYs.
Why do i need this, when we have SIOCGMIIREG? 

    Andrew

Re: [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.

From: Raju Lakkaraju <hidden>
Date: 2016-09-08 09:58:05

Hi Andrew,

Thank you for review the code and valuable comments.

On Wed, Aug 24, 2016 at 03:13:47PM +0200, Andrew Lunn wrote:
EXTERNAL EMAIL


On Wed, Aug 24, 2016 at 12:27:07PM +0000, Raju Lakkaraju wrote:
quoted
From: Nagaraju Lakkaraju <redacted>

PHY Read support will be added for VSC 85xx Microsemi PHYs.
Why do i need this, when we have SIOCGMIIREG?
Microsemi PHY have different pages i.e. Std IEEE, Extended, Extended_2, Extended_3 and
GPIO pages.
When I want to use SIOCGMIIREG, I can read Std IEEE only with SIOCGMIIREG and not other 
pages.
phy_read_reg function is debug function where I can read entair PHY registers.
In this function, I set the page number and register address then read register value
as atomic operation.

Do you have any suggestions to implement this function in different ways?

Thanks,
Raju.

Re: [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.

From: Andrew Lunn <andrew@lunn.ch>
Date: 2016-09-08 13:40:28

Microsemi PHY have different pages i.e. Std IEEE, Extended,
Extended_2, Extended_3 and GPIO pages.
Yes, nothing special there. Marvell does the same, and probably
others.
When I want to use SIOCGMIIREG, I can read Std IEEE only with
SIOCGMIIREG and not other pages.
So this is purely for your own debug. So you can hack in anything you
want. Just don't submit it for mainline.

Or you can do it properly. Take a look at the sources for
mii-tool. Figure out a way to do it cleanly which will work for all
phys which support multiple pages. Then submit patches which does this
for both your own PHY and one other manufacture. I can help with
Marvell PHYS, if that is what you want.

What will never get accepted is something which is not generic. What
you submit must work for multiple vendors, and you need to submit it
all, from the userspace/kernel space API all the way down to the PHY,
and ideally patches to mii-tool as well.

    Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help