* [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
@ 2017-02-07 13:40 Raju Lakkaraju
2017-02-08 18:29 ` David Miller
[not found] ` <1486474826-29426-1-git-send-email-Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
0 siblings, 2 replies; 7+ messages in thread
From: Raju Lakkaraju @ 2017-02-07 13:40 UTC (permalink / raw)
To: netdev, devicetree; +Cc: f.fainelli, Allan.Nielsen, andrew, Raju Lakkaraju
From: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
LED Mode:
Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different
status information that can be selected by setting LED mode.
LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get
from Device Tree.
Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
---
Change set:
v0:
- Initial version of LED driver for Microsemi PHYs.
v1:
- Update all review comments given by Andrew.
- Add new header file "mscc-phy-vsc8531.h" to define DT macros.
- Add error/range check for DT LED mode input
v2:
- Fixed x86_64 build error.
v3:
- Update all review comments.
- Fix the error check condition.
.../devicetree/bindings/net/mscc-phy-vsc8531.txt | 10 +++
drivers/net/phy/mscc.c | 85 +++++++++++++++++++++-
include/dt-bindings/net/mscc-phy-vsc8531.h | 29 ++++++++
3 files changed, 123 insertions(+), 1 deletion(-)
create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
diff --git a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
index bdefefc6..0eedabe 100644
--- a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
+++ b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
@@ -27,6 +27,14 @@ Optional properties:
'vddmac'.
Default value is 0%.
Ref: Table:1 - Edge rate change (below).
+- vsc8531,led-0-mode : LED mode. Specify how the LED[0] should behave.
+ Allowed values are define in
+ "include/dt-bindings/net/mscc-phy-vsc8531.h".
+ Default value is VSC8531_LINK_1000_ACTIVITY (1).
+- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.
+ Allowed values are define in
+ "include/dt-bindings/net/mscc-phy-vsc8531.h".
+ Default value is VSC8531_LINK_100_ACTIVITY (2).
Table: 1 - Edge rate change
----------------------------------------------------------------|
@@ -60,4 +68,6 @@ Example:
compatible = "ethernet-phy-id0007.0570";
vsc8531,vddmac = <3300>;
vsc8531,edge-slowdown = <7>;
+ vsc8531,led-0-mode = <LINK_1000_ACTIVITY>;
+ vsc8531,led-1-mode = <LINK_100_ACTIVITY>;
};
diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c
index e03ead8..650c266 100644
--- a/drivers/net/phy/mscc.c
+++ b/drivers/net/phy/mscc.c
@@ -13,6 +13,7 @@
#include <linux/phy.h>
#include <linux/of.h>
#include <linux/netdevice.h>
+#include <dt-bindings/net/mscc-phy-vsc8531.h>
enum rgmii_rx_clock_delay {
RGMII_RX_CLK_DELAY_0_2_NS = 0,
@@ -52,6 +53,11 @@ enum rgmii_rx_clock_delay {
#define MSCC_PHY_DEV_AUX_CNTL 28
#define HP_AUTO_MDIX_X_OVER_IND_MASK 0x2000
+#define MSCC_PHY_LED_MODE_SEL 29
+#define LED_1_MODE_SEL_MASK 0x00F0
+#define LED_0_MODE_SEL_MASK 0x000F
+#define LED_1_MODE_SEL_POS 4
+
#define MSCC_EXT_PAGE_ACCESS 31
#define MSCC_PHY_PAGE_STANDARD 0x0000 /* Standard registers */
#define MSCC_PHY_PAGE_EXTENDED 0x0001 /* Extended registers */
@@ -99,6 +105,8 @@ enum rgmii_rx_clock_delay {
struct vsc8531_private {
int rate_magic;
+ u8 led_0_mode;
+ u8 led_1_mode;
};
#ifdef CONFIG_OF_MDIO
@@ -123,6 +131,29 @@ static int vsc85xx_phy_page_set(struct phy_device *phydev, u8 page)
return rc;
}
+static int vsc85xx_led_cntl_set(struct phy_device *phydev,
+ u8 led_num,
+ u8 mode)
+{
+ int rc;
+ u16 reg_val;
+
+ mutex_lock(&phydev->lock);
+ reg_val = phy_read(phydev, MSCC_PHY_LED_MODE_SEL);
+ if (led_num) {
+ reg_val &= ~LED_1_MODE_SEL_MASK;
+ reg_val |= (((u16)mode << LED_1_MODE_SEL_POS) &
+ LED_1_MODE_SEL_MASK);
+ } else {
+ reg_val &= ~LED_0_MODE_SEL_MASK;
+ reg_val |= ((u16)mode & LED_0_MODE_SEL_MASK);
+ }
+ rc = phy_write(phydev, MSCC_PHY_LED_MODE_SEL, reg_val);
+ mutex_unlock(&phydev->lock);
+
+ return rc;
+}
+
static int vsc85xx_mdix_get(struct phy_device *phydev, u8 *mdix)
{
u16 reg_val;
@@ -370,11 +401,41 @@ static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
return -EINVAL;
}
+
+static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
+ char *led,
+ u8 default_mode)
+{
+ struct device *dev = &phydev->mdio.dev;
+ struct device_node *of_node = dev->of_node;
+ u8 led_mode;
+ int err;
+
+ if (!of_node)
+ return -ENODEV;
+
+ led_mode = default_mode;
+ err = of_property_read_u8(of_node, led, &led_mode);
+ if (!err && (led_mode > 15 || led_mode == 7 || led_mode == 11)) {
+ phydev_err(phydev, "DT %s invalid\n", led);
+ return -EINVAL;
+ }
+
+ return led_mode;
+}
+
#else
static int vsc85xx_edge_rate_magic_get(struct phy_device *phydev)
{
return 0;
}
+
+static int vsc85xx_dt_led_mode_get(struct phy_device *phydev,
+ char *led,
+ u8 default_mode)
+{
+ return default_mode;
+}
#endif /* CONFIG_OF_MDIO */
static int vsc85xx_edge_rate_cntl_set(struct phy_device *phydev, u8 edge_rate)
@@ -499,6 +560,14 @@ static int vsc85xx_config_init(struct phy_device *phydev)
if (rc)
return rc;
+ rc = vsc85xx_led_cntl_set(phydev, 1, vsc8531->led_1_mode);
+ if (rc)
+ return rc;
+
+ rc = vsc85xx_led_cntl_set(phydev, 0, vsc8531->led_0_mode);
+ if (rc)
+ return rc;
+
rc = genphy_config_init(phydev);
return rc;
@@ -555,8 +624,9 @@ static int vsc85xx_read_status(struct phy_device *phydev)
static int vsc85xx_probe(struct phy_device *phydev)
{
- int rate_magic;
struct vsc8531_private *vsc8531;
+ int rate_magic;
+ int led_mode;
rate_magic = vsc85xx_edge_rate_magic_get(phydev);
if (rate_magic < 0)
@@ -570,6 +640,19 @@ static int vsc85xx_probe(struct phy_device *phydev)
vsc8531->rate_magic = rate_magic;
+ /* LED[0] and LED[1] mode */
+ led_mode = vsc85xx_dt_led_mode_get(phydev, "vsc8531,led-0-mode",
+ VSC8531_LINK_1000_ACTIVITY);
+ if (led_mode < 0)
+ return led_mode;
+ vsc8531->led_0_mode = led_mode;
+
+ led_mode = vsc85xx_dt_led_mode_get(phydev, "vsc8531,led-1-mode",
+ VSC8531_LINK_100_ACTIVITY);
+ if (led_mode < 0)
+ return led_mode;
+ vsc8531->led_1_mode = led_mode;
+
return 0;
}
diff --git a/include/dt-bindings/net/mscc-phy-vsc8531.h b/include/dt-bindings/net/mscc-phy-vsc8531.h
new file mode 100644
index 0000000..697161f
--- /dev/null
+++ b/include/dt-bindings/net/mscc-phy-vsc8531.h
@@ -0,0 +1,29 @@
+/*
+ * Device Tree constants for Microsemi VSC8531 PHY
+ *
+ * Author: Nagaraju Lakkaraju
+ *
+ * License: Dual MIT/GPL
+ * Copyright (c) 2017 Microsemi Corporation
+ */
+
+#ifndef _DT_BINDINGS_MSCC_VSC8531_H
+#define _DT_BINDINGS_MSCC_VSC8531_H
+
+/* PHY LED Modes */
+#define VSC8531_LINK_ACTIVITY 0
+#define VSC8531_LINK_1000_ACTIVITY 1
+#define VSC8531_LINK_100_ACTIVITY 2
+#define VSC8531_LINK_10_ACTIVITY 3
+#define VSC8531_LINK_100_1000_ACTIVITY 4
+#define VSC8531_LINK_10_1000_ACTIVITY 5
+#define VSC8531_LINK_10_100_ACTIVITY 6
+#define VSC8531_DUPLEX_COLLISION 8
+#define VSC8531_COLLISION 9
+#define VSC8531_ACTIVITY 10
+#define VSC8531_AUTONEG_FAULT 12
+#define VSC8531_SERIAL_MODE 13
+#define VSC8531_FORCE_LED_OFF 14
+#define VSC8531_FORCE_LED_ON 15
+
+#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
2017-02-07 13:40 [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs Raju Lakkaraju
@ 2017-02-08 18:29 ` David Miller
[not found] ` <1486474826-29426-1-git-send-email-Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2017-02-08 18:29 UTC (permalink / raw)
To: Raju.Lakkaraju; +Cc: netdev, devicetree, f.fainelli, Allan.Nielsen, andrew
From: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Date: Tue, 7 Feb 2017 19:10:26 +0530
> From: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
>
> LED Mode:
> Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different
> status information that can be selected by setting LED mode.
>
> LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get
> from Device Tree.
>
> Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
[not found] ` <1486474826-29426-1-git-send-email-Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
@ 2017-02-15 16:45 ` Rob Herring
2017-02-16 9:06 ` Raju Lakkaraju
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2017-02-15 16:45 UTC (permalink / raw)
To: Raju Lakkaraju
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
f.fainelli-Re5JQEeQqe8AvxtiuMwx3w,
Allan.Nielsen-dzo6w/eZyo2tG0bUXCXiUA, andrew-g2DYL2Zd6BY
On Tue, Feb 07, 2017 at 07:10:26PM +0530, Raju Lakkaraju wrote:
> From: Raju Lakkaraju <Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
>
> LED Mode:
> Microsemi PHY support 2 LEDs (LED[0] and LED[1]) to display different
> status information that can be selected by setting LED mode.
>
> LED Mode parameter (vsc8531, led-0-mode) and (vsc8531, led-1-mode) get
> from Device Tree.
>
> Signed-off-by: Raju Lakkaraju <Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
> ---
> Change set:
> v0:
> - Initial version of LED driver for Microsemi PHYs.
> v1:
> - Update all review comments given by Andrew.
> - Add new header file "mscc-phy-vsc8531.h" to define DT macros.
> - Add error/range check for DT LED mode input
> v2:
> - Fixed x86_64 build error.
> v3:
> - Update all review comments.
> - Fix the error check condition.
>
> .../devicetree/bindings/net/mscc-phy-vsc8531.txt | 10 +++
> drivers/net/phy/mscc.c | 85 +++++++++++++++++++++-
> include/dt-bindings/net/mscc-phy-vsc8531.h | 29 ++++++++
> 3 files changed, 123 insertions(+), 1 deletion(-)
> create mode 100644 include/dt-bindings/net/mscc-phy-vsc8531.h
>
> diff --git a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
> index bdefefc6..0eedabe 100644
> --- a/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
> +++ b/Documentation/devicetree/bindings/net/mscc-phy-vsc8531.txt
> @@ -27,6 +27,14 @@ Optional properties:
> 'vddmac'.
> Default value is 0%.
> Ref: Table:1 - Edge rate change (below).
> +- vsc8531,led-0-mode : LED mode. Specify how the LED[0] should behave.
> + Allowed values are define in
> + "include/dt-bindings/net/mscc-phy-vsc8531.h".
> + Default value is VSC8531_LINK_1000_ACTIVITY (1).
> +- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.
You failed to address my comment on v2. vsc8531 is not a vendor prefix.
Please fix in a new patch since David already applied it.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
2017-02-15 16:45 ` Rob Herring
@ 2017-02-16 9:06 ` Raju Lakkaraju
2017-02-16 14:19 ` Andrew Lunn
[not found] ` <20170216090646.GA29082-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
0 siblings, 2 replies; 7+ messages in thread
From: Raju Lakkaraju @ 2017-02-16 9:06 UTC (permalink / raw)
To: Rob Herring
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA,
f.fainelli-Re5JQEeQqe8AvxtiuMwx3w,
Allan.Nielsen-dzo6w/eZyo2tG0bUXCXiUA, andrew-g2DYL2Zd6BY
Hi Rob,
On Wed, Feb 15, 2017 at 10:45:40AM -0600, Rob Herring wrote:
> EXTERNAL EMAIL
>
>
> On Tue, Feb 07, 2017 at 07:10:26PM +0530, Raju Lakkaraju wrote:
> > From: Raju Lakkaraju <Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
> >
> > + Default value is VSC8531_LINK_1000_ACTIVITY (1).
> > +- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.
>
> You failed to address my comment on v2. vsc8531 is not a vendor prefix.
> Please fix in a new patch since David already applied it.
>
Accpeted my fault. i missed your comment.
Do i need to change from "vsc8531, led-0-mode" to "mscc, led-0-mode"
Is this your suggestion?
> Rob
---
Thanks,
Raju.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
2017-02-16 9:06 ` Raju Lakkaraju
@ 2017-02-16 14:19 ` Andrew Lunn
[not found] ` <20170216090646.GA29082-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
1 sibling, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2017-02-16 14:19 UTC (permalink / raw)
To: Raju Lakkaraju; +Cc: Rob Herring, netdev, devicetree, f.fainelli, Allan.Nielsen
On Thu, Feb 16, 2017 at 02:36:48PM +0530, Raju Lakkaraju wrote:
> Hi Rob,
>
> On Wed, Feb 15, 2017 at 10:45:40AM -0600, Rob Herring wrote:
> > EXTERNAL EMAIL
> >
> >
> > On Tue, Feb 07, 2017 at 07:10:26PM +0530, Raju Lakkaraju wrote:
> > > From: Raju Lakkaraju <Raju.Lakkaraju@microsemi.com>
> > >
> > > + Default value is VSC8531_LINK_1000_ACTIVITY (1).
> > > +- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.
> >
> > You failed to address my comment on v2. vsc8531 is not a vendor prefix.
> > Please fix in a new patch since David already applied it.
> >
>
> Accpeted my fault. i missed your comment.
> Do i need to change from "vsc8531, led-0-mode" to "mscc, led-0-mode"
> Is this your suggestion?
Hi Raju
Are there any in kernel users of this binding? I don't think there
are. I know Microsemi has a modified beagle bone black available as a
development board, but i don't think mainline support for this board
has been added yet?
Since there is nothing to remain backwards compatible with, you could
change all the property names?
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
[not found] ` <20170216090646.GA29082-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
@ 2017-02-21 16:42 ` Rob Herring
[not found] ` <CAL_JsqJLCe1O7Bv526zAY-s-R1DcnA2O0bpx48dTFGSgeu-Edw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2017-02-21 16:42 UTC (permalink / raw)
To: Raju Lakkaraju
Cc: netdev, devicetree-u79uwXL29TY76Z2rM5mHXA, Florian Fainelli,
Allan.Nielsen-dzo6w/eZyo2tG0bUXCXiUA, Andrew Lunn
On Thu, Feb 16, 2017 at 3:06 AM, Raju Lakkaraju
<Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org> wrote:
> Hi Rob,
>
> On Wed, Feb 15, 2017 at 10:45:40AM -0600, Rob Herring wrote:
>> EXTERNAL EMAIL
>>
>>
>> On Tue, Feb 07, 2017 at 07:10:26PM +0530, Raju Lakkaraju wrote:
>> > From: Raju Lakkaraju <Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
>> >
>> > + Default value is VSC8531_LINK_1000_ACTIVITY (1).
>> > +- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.
>>
>> You failed to address my comment on v2. vsc8531 is not a vendor prefix.
>> Please fix in a new patch since David already applied it.
>>
>
> Accpeted my fault. i missed your comment.
> Do i need to change from "vsc8531, led-0-mode" to "mscc, led-0-mode"
> Is this your suggestion?
Well, there shouldn't be a space there, but yess, mscc is the prefix.
Read my original comments. I also suggested combining this to a single property.
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
[not found] ` <CAL_JsqJLCe1O7Bv526zAY-s-R1DcnA2O0bpx48dTFGSgeu-Edw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-02-24 6:05 ` Raju Lakkaraju
0 siblings, 0 replies; 7+ messages in thread
From: Raju Lakkaraju @ 2017-02-24 6:05 UTC (permalink / raw)
To: Rob Herring
Cc: netdev, devicetree-u79uwXL29TY76Z2rM5mHXA, Florian Fainelli,
Allan.Nielsen-dzo6w/eZyo2tG0bUXCXiUA, Andrew Lunn
Hi Rob,
Thank you for code review comments.
On Tue, Feb 21, 2017 at 10:42:38AM -0600, Rob Herring wrote:
> EXTERNAL EMAIL
>
>
> > Do i need to change from "vsc8531, led-0-mode" to "mscc, led-0-mode"
> > Is this your suggestion?
>
> Well, there shouldn't be a space there, but yess, mscc is the prefix.
>
> Read my original comments. I also suggested combining this to a single property.
>
Accepted your comment.
Fix the combining into single property and change prefix to mscc.
I sent the latest code for review. Please review and send your comments.
> Rob
---
Thanks,
Raju
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-02-24 6:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 13:40 [PATCH v3 net-next] net: phy: Add LED mode driver for Microsemi PHYs Raju Lakkaraju
2017-02-08 18:29 ` David Miller
[not found] ` <1486474826-29426-1-git-send-email-Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
2017-02-15 16:45 ` Rob Herring
2017-02-16 9:06 ` Raju Lakkaraju
2017-02-16 14:19 ` Andrew Lunn
[not found] ` <20170216090646.GA29082-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
2017-02-21 16:42 ` Rob Herring
[not found] ` <CAL_JsqJLCe1O7Bv526zAY-s-R1DcnA2O0bpx48dTFGSgeu-Edw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-24 6:05 ` Raju Lakkaraju
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).