All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.
@ 2016-08-24 12:27 Raju Lakkaraju
  2016-08-24 13:13 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Raju Lakkaraju @ 2016-08-24 12:27 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli, Andrew Lunn (andrew@lunn.ch), Allan Nielsen

From: Nagaraju Lakkaraju <Raju.Lakkaraju@microsemi.com>

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

Signed-off-by: Nagaraju Lakkaraju <Raju.Lakkaraju@microsemi.com>
---
 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

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

* Re: [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.
  2016-08-24 12:27 [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs Raju Lakkaraju
@ 2016-08-24 13:13 ` Andrew Lunn
  2016-09-08  9:42   ` Raju Lakkaraju
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2016-08-24 13:13 UTC (permalink / raw)
  To: Raju Lakkaraju; +Cc: netdev, f.fainelli, Allan Nielsen

On Wed, Aug 24, 2016 at 12:27:07PM +0000, Raju Lakkaraju wrote:
> From: Nagaraju Lakkaraju <Raju.Lakkaraju@microsemi.com>
> 
> PHY Read support will be added for VSC 85xx Microsemi PHYs.

Why do i need this, when we have SIOCGMIIREG? 

    Andrew

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

* Re: [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.
  2016-08-24 13:13 ` Andrew Lunn
@ 2016-09-08  9:42   ` Raju Lakkaraju
  2016-09-08 13:40     ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Raju Lakkaraju @ 2016-09-08  9:42 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, f.fainelli, Allan Nielsen

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:
> > From: Nagaraju Lakkaraju <Raju.Lakkaraju@microsemi.com>
> >
> > 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.

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

* Re: [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs.
  2016-09-08  9:42   ` Raju Lakkaraju
@ 2016-09-08 13:40     ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2016-09-08 13:40 UTC (permalink / raw)
  To: Raju Lakkaraju; +Cc: netdev, f.fainelli, Allan Nielsen

> 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

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

end of thread, other threads:[~2016-09-08 13:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24 12:27 [PATCH 3/4] net: phy: Add read driver for Microsemi PHYs Raju Lakkaraju
2016-08-24 13:13 ` Andrew Lunn
2016-09-08  9:42   ` Raju Lakkaraju
2016-09-08 13:40     ` Andrew Lunn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.