GPY211 phy default to using all four led pins.
Hardwares using only two leds where led0 is used as the high
network speed led and led1 the low network speed led will not
get the correct behaviour since 1Gbit and 2.5Gbit will not be
represented at all in the existing leds.
Marcus Carlberg (2):
dt-bindings: net: Add mxl,gpy
net: phy: mxl-gpy: Add mode for 2 leds
.../devicetree/bindings/net/mxl,gpy.yaml | 39 ++++++++++++++++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
MAINTAINERS | 1 +
drivers/net/phy/mxl-gpy.c | 45 +++++++++++++++++++
4 files changed, 87 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/mxl,gpy.yaml
--
2.20.1
Add dual-led-mode override property specific to mxl,gpy.
Signed-off-by: Marcus Carlberg <[email protected]>
---
.../devicetree/bindings/net/mxl,gpy.yaml | 39 +++++++++++++++++++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
MAINTAINERS | 1 +
3 files changed, 42 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/mxl,gpy.yaml
diff --git a/Documentation/devicetree/bindings/net/mxl,gpy.yaml b/Documentation/devicetree/bindings/net/mxl,gpy.yaml
new file mode 100644
index 000000000000..423d2a5e1ce9
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/mxl,gpy.yaml
@@ -0,0 +1,39 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/mxl,gpy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxlinear Phy
+
+maintainers:
+ - Xu Liang <[email protected]>
+
+allOf:
+ - $ref: ethernet-phy.yaml#
+
+properties:
+ mxl,dual-led-mode:
+ $ref: /schemas/types.yaml#/definitions/flag
+ description:
+ If set, indicates that the hardware only have connected pins led0 and
+ led1 where led0 is used for noting the highest network speed (2500) and
+ led1 for the rest (10, 100, 1000). The absence of this property
+ indicates that the PHY uses all four led pins to communicate link speed,
+ one pin for each speed.
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ ethernet {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ethernet-phy@0 {
+ compatible = "ethernet-phy-id67c9.de10", "ethernet-phy-ieee802.3-c45";
+ reg = <0>;
+ mxl,dual-led-mode;
+ };
+ };
+
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 2f0151e9f6be..3c833827a790 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -757,6 +757,8 @@ patternProperties:
description: MaxBotix Inc.
"^maxim,.*":
description: Maxim Integrated Products
+ "^mxl,.*":
+ description: Maxlinear Inc.
"^mbvl,.*":
description: Mobiveil Inc.
"^mcube,.*":
diff --git a/MAINTAINERS b/MAINTAINERS
index 9ae989b32ebb..accc4242c027 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12455,6 +12455,7 @@ MAXLINEAR ETHERNET PHY DRIVER
M: Xu Liang <[email protected]>
L: [email protected]
S: Supported
+F: Documentation/devicetree/bindings/net/phy/mxl,gpy.yaml
F: drivers/net/phy/mxl-gpy.c
MCBA MICROCHIP CAN BUS ANALYZER TOOL DRIVER
--
2.20.1
GPY211 phy default to using all four led pins.
Hardwares using only two leds where led0 is used as the high
network speed led and led1 the low network speed led will not
get the correct behaviour since 1Gbit and 2.5Gbit will not be
represented at all in the existing leds.
This patch adds a property for switching to a two led mode as specified
above.
Signed-off-by: Marcus Carlberg <[email protected]>
---
drivers/net/phy/mxl-gpy.c | 45 +++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c
index 24bae27eedef..0886fa21c4ff 100644
--- a/drivers/net/phy/mxl-gpy.c
+++ b/drivers/net/phy/mxl-gpy.c
@@ -12,6 +12,7 @@
#include <linux/phy.h>
#include <linux/polynomial.h>
#include <linux/netdevice.h>
+#include <linux/of_platform.h>
/* PHY ID */
#define PHY_ID_GPYx15B_MASK 0xFFFFFFFC
@@ -32,6 +33,7 @@
#define PHY_MIISTAT 0x18 /* MII state */
#define PHY_IMASK 0x19 /* interrupt mask */
#define PHY_ISTAT 0x1A /* interrupt status */
+#define PHY_LED 0x1B /* LED control */
#define PHY_FWV 0x1E /* firmware version */
#define PHY_MIISTAT_SPD_MASK GENMASK(2, 0)
@@ -59,6 +61,16 @@
#define PHY_FWV_MAJOR_MASK GENMASK(11, 8)
#define PHY_FWV_MINOR_MASK GENMASK(7, 0)
+/* LED */
+#define VSPEC1_LED0_CTRL 0x01
+#define VSPEC1_LED1_CTRL 0x02
+#define VSPEC1_LED2_CTRL 0x03
+#define VSPEC1_LED3_CTRL 0x04
+#define TWO_LED_CONFIG 0x0300
+#define LED_BLINK_2500MBIT 0x0380
+#define LED_BLINK_1000MBIT_100MBIT_10_MBIT 0x0370
+#define LED_DUAL_MODE 2
+
/* SGMII */
#define VSPEC1_SGMII_CTRL 0x08
#define VSPEC1_SGMII_CTRL_ANEN BIT(12) /* Aneg enable */
@@ -201,9 +213,34 @@ static int gpy_config_init(struct phy_device *phydev)
return ret < 0 ? ret : 0;
}
+static int gpy_override_led_mode(struct phy_device
+ *phydev, u32 led_mode)
+{
+ int ret;
+
+ if (led_mode == LED_DUAL_MODE) {
+ ret = phy_write(phydev, PHY_LED, TWO_LED_CONFIG);
+ if (ret < 0)
+ return ret;
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1,
+ VSPEC1_LED0_CTRL,
+ LED_BLINK_2500MBIT);
+ if (ret < 0)
+ return ret;
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND1,
+ VSPEC1_LED1_CTRL,
+ LED_BLINK_1000MBIT_100MBIT_10_MBIT);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
static int gpy_probe(struct phy_device *phydev)
{
struct device *dev = &phydev->mdio.dev;
+ struct device_node *np = dev->of_node;
struct gpy_priv *priv;
int fw_version;
int ret;
@@ -234,6 +271,14 @@ static int gpy_probe(struct phy_device *phydev)
priv->fw_major, priv->fw_minor, fw_version,
fw_version & PHY_FWV_REL_MASK ? "" : " test version");
+ /* Override led mode */
+ ret = of_property_read_bool(np, "mxl,dual-led-mode");
+ if (ret) {
+ ret = gpy_override_led_mode(phydev, LED_DUAL_MODE);
+ if (ret < 0)
+ return ret;
+ }
+
return 0;
}
--
2.20.1
Hi,
> GPY211 phy default to using all four led pins.
> Hardwares using only two leds where led0 is used as the high
> network speed led and led1 the low network speed led will not
> get the correct behaviour since 1Gbit and 2.5Gbit will not be
> represented at all in the existing leds.
I might be wrong, but PHY LED bindings should be integrated with/using
the LED subsystem. Although I didn't see any development regarding this
for a long time.
That being said, it seems you are adding a new (DT) property which
just matches your particular hardware design, no?
-michael
On Thu, Sep 22, 2022 at 10:05:29AM +0200, Michael Walle wrote:
> Hi,
>
> > GPY211 phy default to using all four led pins.
> > Hardwares using only two leds where led0 is used as the high
> > network speed led and led1 the low network speed led will not
> > get the correct behaviour since 1Gbit and 2.5Gbit will not be
> > represented at all in the existing leds.
>
> I might be wrong, but PHY LED bindings should be integrated with/using
> the LED subsystem. Although I didn't see any development regarding this
> for a long time.
>
> That being said, it seems you are adding a new (DT) property which
> just matches your particular hardware design, no?
Thanks Michael
Replying to this was on my TODO list. We have NACKed patches like this
for a few years now, wanting the Linux LED subsystem be used to
configure PHY LEDs. The patches to implement the core of that
sometimes makes some progress, then goes dormant for a while. The last
effort was getting close to being ready. Maybe the needs for this
driver can help get them finished?
Andrew
Hi Marcus,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Marcus-Carlberg/net-phy-mxl-gpy-Add-mode-for-2-leds/20220920-231459
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git b324c6e5e099229d5f715779be1492a5480be6df
reproduce:
# https://github.com/intel-lab-lkp/linux/commit/1684b6abd15a624ff2551a75d5688d383136babb
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Marcus-Carlberg/net-phy-mxl-gpy-Add-mode-for-2-leds/20220920-231459
git checkout 1684b6abd15a624ff2551a75d5688d383136babb
make menuconfig
# enable CONFIG_COMPILE_TEST, CONFIG_WARN_MISSING_DOCUMENTS, CONFIG_WARN_ABI_ERRORS
make htmldocs
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
All warnings (new ones prefixed by >>):
>> Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/net/phy/mxl,gpy.yaml
--
0-DAY CI Kernel Test Service
https://01.org/lkp