1 From 2679834327b5b8db8a7b0c90b632b81c35f9e271 Mon Sep 17 00:00:00 2001
2 From: James Hughes <james.hughes@raspberrypi.org>
3 Date: Thu, 31 Oct 2019 14:39:44 +0000
4 Subject: [PATCH] net:phy:2711 Allow ethernet LED mode to be set via
7 Add device tree entries and code to allow the specification of
8 the lighting modes for the LED's on the ethernet connector.
10 Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
12 arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 3 +++
13 arch/arm/boot/dts/bcm2838.dtsi | 1 +
14 arch/arm/boot/dts/overlays/README | 28 +++++++++++++++++++--------
15 drivers/net/phy/broadcom.c | 9 +++++++--
16 4 files changed, 31 insertions(+), 10 deletions(-)
18 --- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
19 +++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
21 pwr_led_gpio = <&pwr_led>,"gpios:4";
22 pwr_led_activelow = <&pwr_led>,"gpios:8";
23 pwr_led_trigger = <&pwr_led>,"linux,default-trigger";
25 + eth_led0 = <&phy1>,"led-modes:0";
26 + eth_led1 = <&phy1>,"led-modes:4";
29 --- a/arch/arm/boot/dts/bcm2838.dtsi
30 +++ b/arch/arm/boot/dts/bcm2838.dtsi
32 /* No interrupts - use PHY_POLL */
35 + led-modes = <0x02 0x02>;
39 --- a/arch/arm/boot/dts/overlays/README
40 +++ b/arch/arm/boot/dts/overlays/README
41 @@ -102,26 +102,38 @@ Params:
43 eee Enable Energy Efficient Ethernet support for
44 compatible devices (default "on"). See also
46 + "tx_lpi_timer". Pi3B+ only.
48 eth_downshift_after Set the number of auto-negotiation failures
49 after which the 1000Mbps modes are disabled.
50 Legal values are 2, 3, 4, 5 and 0, where
51 - 0 means never downshift (default 2).
52 + 0 means never downshift (default 2). Pi3B+ only.
54 - eth_led0 Set mode of LED0 (usually orange) (default
55 - "1"). The legal values are:
56 - 0=link/activity 1=link1000/activity
57 + eth_led0 Set mode of LED0 (usually orange). The legal
62 + 0=link/activity 1=link1000/activity (default)
63 2=link100/activity 3=link10/activity
64 4=link100/1000/activity 5=link10/1000/activity
65 6=link10/100/activity 14=off 15=on
67 - eth_led1 Set mode of LED1 (usually green) (default
68 - "6"). See eth_led0 for legal values.
71 + 0=Speed/Activity (default) 1=Speed
72 + 2=Speed/Flash activity 3=FDX
77 + eth_led1 Set mode of LED1 (usually green) (Pi3B+ default
78 + "6", Pi4 default "0"). See eth_led0 for legal
81 eth_max_speed Set the maximum speed a link is allowed
82 to negotiate. Legal values are 10, 100 and
83 - 1000 (default 1000).
84 + 1000 (default 1000). Pi3B+ only.
86 i2c_arm Set to "on" to enable the ARM's i2c interface
88 --- a/drivers/net/phy/broadcom.c
89 +++ b/drivers/net/phy/broadcom.c
90 @@ -292,6 +292,9 @@ static void bcm54xx_adjust_rxrefclk(stru
91 static int bcm54xx_config_init(struct phy_device *phydev)
94 + u32 led_modes[] = {BCM_LED_MULTICOLOR_LINK_ACT,
95 + BCM_LED_MULTICOLOR_LINK_ACT};
96 + struct device_node *np = phydev->mdio.dev.of_node;
98 reg = phy_read(phydev, MII_BCM54XX_ECR);
100 @@ -345,6 +348,8 @@ static int bcm54xx_config_init(struct ph
102 bcm54xx_phydsp_config(phydev);
104 + of_property_read_u32_array(np, "led-modes", led_modes, 2);
106 /* Encode link speed into LED1 and LED3 pair (green/amber).
107 * Also flash these two LEDs on activity. This means configuring
108 * them for MULTICOLOR and encoding link/activity into them.
109 @@ -354,8 +359,8 @@ static int bcm54xx_config_init(struct ph
110 bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val);
112 val = BCM_LED_MULTICOLOR_IN_PHASE |
113 - BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) |
114 - BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT);
115 + BCM5482_SHD_LEDS1_LED1(led_modes[0]) |
116 + BCM5482_SHD_LEDS1_LED3(led_modes[1]);
117 bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val);