84ad9387f6c6571fa66f917559aaaee603d4890a
[openwrt/staging/xback.git] /
1 From 3ab0c4b6aa76a4dedb51c4e800b5b4ba29187c46 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 drivers/net/phy/broadcom.c | 9 +++++++--
13 1 file changed, 7 insertions(+), 2 deletions(-)
14
15 --- a/drivers/net/phy/broadcom.c
16 +++ b/drivers/net/phy/broadcom.c
17 @@ -313,6 +313,9 @@ static void bcm54xx_adjust_rxrefclk(stru
18 static int bcm54xx_config_init(struct phy_device *phydev)
19 {
20 int reg, err, val;
21 + u32 led_modes[] = {BCM_LED_MULTICOLOR_LINK_ACT,
22 + BCM_LED_MULTICOLOR_LINK_ACT};
23 + struct device_node *np = phydev->mdio.dev.of_node;
24
25 reg = phy_read(phydev, MII_BCM54XX_ECR);
26 if (reg < 0)
27 @@ -368,6 +371,8 @@ static int bcm54xx_config_init(struct ph
28
29 bcm54xx_phydsp_config(phydev);
30
31 + of_property_read_u32_array(np, "led-modes", led_modes, 2);
32 +
33 /* Encode link speed into LED1 and LED3 pair (green/amber).
34 * Also flash these two LEDs on activity. This means configuring
35 * them for MULTICOLOR and encoding link/activity into them.
36 @@ -377,8 +382,8 @@ static int bcm54xx_config_init(struct ph
37 bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val);
38
39 val = BCM_LED_MULTICOLOR_IN_PHASE |
40 - BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) |
41 - BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT);
42 + BCM5482_SHD_LEDS1_LED1(led_modes[0]) |
43 + BCM5482_SHD_LEDS1_LED3(led_modes[1]);
44 bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val);
45
46 return 0;