1b922420c052b65dea09707a9941039166d9acc9
[openwrt/staging/linusw.git] /
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
5 device tree
6
7 Add device tree entries and code to allow the specification of
8 the lighting modes for the LED's on the ethernet connector.
9
10 Signed-off-by: James Hughes <james.hughes@raspberrypi.org>
11 ---
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(-)
17
18 --- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
19 +++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
20 @@ -334,5 +334,8 @@
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";
24 +
25 + eth_led0 = <&phy1>,"led-modes:0";
26 + eth_led1 = <&phy1>,"led-modes:4";
27 };
28 };
29 --- a/arch/arm/boot/dts/bcm2838.dtsi
30 +++ b/arch/arm/boot/dts/bcm2838.dtsi
31 @@ -380,6 +380,7 @@
32 /* No interrupts - use PHY_POLL */
33 max-speed = <1000>;
34 reg = <0x1>;
35 + led-modes = <0x02 0x02>;
36 };
37 };
38 };
39 --- a/arch/arm/boot/dts/overlays/README
40 +++ b/arch/arm/boot/dts/overlays/README
41 @@ -102,26 +102,38 @@ Params:
42
43 eee Enable Energy Efficient Ethernet support for
44 compatible devices (default "on"). See also
45 - "tx_lpi_timer".
46 + "tx_lpi_timer". Pi3B+ only.
47
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.
53
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
58 + values are:
59 +
60 + Pi3B+
61 +
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
66
67 - eth_led1 Set mode of LED1 (usually green) (default
68 - "6"). See eth_led0 for legal values.
69 + Pi4
70 +
71 + 0=Speed/Activity (default) 1=Speed
72 + 2=Speed/Flash activity 3=FDX
73 + 4=Off 5=On
74 + 6=Alt 7=Speed/Flash
75 + 8=Link 9=Activity
76 +
77 + eth_led1 Set mode of LED1 (usually green) (Pi3B+ default
78 + "6", Pi4 default "0"). See eth_led0 for legal
79 + values.
80
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.
85
86 i2c_arm Set to "on" to enable the ARM's i2c interface
87 (default "off")
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)
92 {
93 int reg, err, val;
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;
97
98 reg = phy_read(phydev, MII_BCM54XX_ECR);
99 if (reg < 0)
100 @@ -345,6 +348,8 @@ static int bcm54xx_config_init(struct ph
101
102 bcm54xx_phydsp_config(phydev);
103
104 + of_property_read_u32_array(np, "led-modes", led_modes, 2);
105 +
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);
111
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);
118
119 return 0;