net:phy:2711 Allow ethernet LED mode to be set via device tree
authorJames Hughes <james.hughes@raspberrypi.org>
Thu, 31 Oct 2019 14:39:44 +0000 (14:39 +0000)
committerpopcornmix <popcornmix@gmail.com>
Wed, 1 Jul 2020 15:33:09 +0000 (16:33 +0100)
Add device tree entries and code to allow the specification of
the lighting modes for the LED's on the ethernet connector.

Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
arch/arm/boot/dts/bcm2711-rpi-4-b.dts
arch/arm/boot/dts/bcm2838.dtsi
arch/arm/boot/dts/overlays/README
drivers/net/phy/broadcom.c

index ccdc274..6ce9a58 100644 (file)
                pwr_led_gpio = <&pwr_led>,"gpios:4";
                pwr_led_activelow = <&pwr_led>,"gpios:8";
                pwr_led_trigger = <&pwr_led>,"linux,default-trigger";
+
+               eth_led0 = <&phy1>,"led-modes:0";
+               eth_led1 = <&phy1>,"led-modes:4";
        };
 };
index a8614cc..88615a5 100644 (file)
                                        /* No interrupts - use PHY_POLL */
                                        max-speed = <1000>;
                                        reg = <0x1>;
+                                       led-modes = <0x02 0x02>;
                                };
                        };
                };
index 8ce8cf0..00a70a4 100644 (file)
@@ -102,26 +102,38 @@ Params:
 
         eee                     Enable Energy Efficient Ethernet support for
                                 compatible devices (default "on"). See also
-                                "tx_lpi_timer".
+                                "tx_lpi_timer". Pi3B+ only.
 
         eth_downshift_after     Set the number of auto-negotiation failures
                                 after which the 1000Mbps modes are disabled.
                                 Legal values are 2, 3, 4, 5 and 0, where
-                                0 means never downshift (default 2).
+                                0 means never downshift (default 2). Pi3B+ only.
 
-        eth_led0                Set mode of LED0 (usually orange) (default
-                                "1"). The legal values are:
-                                0=link/activity          1=link1000/activity
+        eth_led0                Set mode of LED0 (usually orange). The legal
+                                values are:
+
+                                Pi3B+
+
+                                0=link/activity    1=link1000/activity (default)
                                 2=link100/activity       3=link10/activity
                                 4=link100/1000/activity  5=link10/1000/activity
                                 6=link10/100/activity    14=off    15=on
 
-        eth_led1                Set mode of LED1 (usually green) (default
-                                "6"). See eth_led0 for legal values.
+                                Pi4
+
+                                0=Speed/Activity (default)       1=Speed
+                                2=Speed/Flash activity   3=FDX
+                                4=Off                    5=On
+                                6=Alt                    7=Speed/Flash
+                                8=Link                   9=Activity
+
+        eth_led1                Set mode of LED1 (usually green) (Pi3B+ default
+                                "6", Pi4 default "0"). See eth_led0 for legal
+                                values.
 
         eth_max_speed           Set the maximum speed a link is allowed
                                 to negotiate. Legal values are 10, 100 and
-                                1000 (default 1000).
+                                1000 (default 1000). Pi3B+ only.
 
         i2c_arm                 Set to "on" to enable the ARM's i2c interface
                                 (default "off")
index f5881fb..8f26eaf 100644 (file)
@@ -283,6 +283,9 @@ static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
 static int bcm54xx_config_init(struct phy_device *phydev)
 {
        int reg, err, val;
+       u32 led_modes[] = {BCM_LED_MULTICOLOR_LINK_ACT,
+                          BCM_LED_MULTICOLOR_LINK_ACT};
+       struct device_node *np = phydev->mdio.dev.of_node;
 
        reg = phy_read(phydev, MII_BCM54XX_ECR);
        if (reg < 0)
@@ -336,6 +339,8 @@ static int bcm54xx_config_init(struct phy_device *phydev)
 
        bcm54xx_phydsp_config(phydev);
 
+       of_property_read_u32_array(np, "led-modes", led_modes, 2);
+
        /* Encode link speed into LED1 and LED3 pair (green/amber).
         * Also flash these two LEDs on activity. This means configuring
         * them for MULTICOLOR and encoding link/activity into them.
@@ -345,8 +350,8 @@ static int bcm54xx_config_init(struct phy_device *phydev)
        bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val);
 
        val = BCM_LED_MULTICOLOR_IN_PHASE |
-               BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) |
-               BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT);
+               BCM5482_SHD_LEDS1_LED1(led_modes[0]) |
+               BCM5482_SHD_LEDS1_LED3(led_modes[1]);
        bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val);
 
        return 0;