9a5e29c208290b2e370c6bf0007b4fa492735bb9
[openwrt/staging/linusw.git] /
1 From b1e290ec968186530ec59479adfba89d2cfe21c8 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <olteanv@gmail.com>
3 Date: Sun, 24 Mar 2019 00:18:46 +0200
4 Subject: [PATCH] net: phy: bcm54xx: Encode link speed and activity
5 into LEDs
6
7 Previously the green and amber LEDs on this quad PHY were solid, to
8 indicate an encoding of the link speed (10/100/1000).
9
10 This keeps the LEDs always on just as before, but now they flash on
11 Rx/Tx activity.
12
13 Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
14 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
16 ---
17 drivers/net/phy/broadcom.c | 13 +++++++++++++
18 include/linux/brcmphy.h | 16 ++++++++++++++++
19 2 files changed, 29 insertions(+)
20
21 --- a/drivers/net/phy/broadcom.c
22 +++ b/drivers/net/phy/broadcom.c
23 @@ -345,6 +345,19 @@ static int bcm54xx_config_init(struct ph
24
25 bcm54xx_phydsp_config(phydev);
26
27 + /* Encode link speed into LED1 and LED3 pair (green/amber).
28 + * Also flash these two LEDs on activity. This means configuring
29 + * them for MULTICOLOR and encoding link/activity into them.
30 + */
31 + val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) |
32 + BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1);
33 + bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val);
34 +
35 + val = BCM_LED_MULTICOLOR_IN_PHASE |
36 + BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) |
37 + BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT);
38 + bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val);
39 +
40 return 0;
41 }
42
43 --- a/include/linux/brcmphy.h
44 +++ b/include/linux/brcmphy.h
45 @@ -148,6 +148,22 @@
46 #define BCM_LED_SRC_OFF 0xe /* Tied high */
47 #define BCM_LED_SRC_ON 0xf /* Tied low */
48
49 +/*
50 + * Broadcom Multicolor LED configurations (expansion register 4)
51 + */
52 +#define BCM_EXP_MULTICOLOR (MII_BCM54XX_EXP_SEL_ER + 0x04)
53 +#define BCM_LED_MULTICOLOR_IN_PHASE BIT(8)
54 +#define BCM_LED_MULTICOLOR_LINK_ACT 0x0
55 +#define BCM_LED_MULTICOLOR_SPEED 0x1
56 +#define BCM_LED_MULTICOLOR_ACT_FLASH 0x2
57 +#define BCM_LED_MULTICOLOR_FDX 0x3
58 +#define BCM_LED_MULTICOLOR_OFF 0x4
59 +#define BCM_LED_MULTICOLOR_ON 0x5
60 +#define BCM_LED_MULTICOLOR_ALT 0x6
61 +#define BCM_LED_MULTICOLOR_FLASH 0x7
62 +#define BCM_LED_MULTICOLOR_LINK 0x8
63 +#define BCM_LED_MULTICOLOR_ACT 0x9
64 +#define BCM_LED_MULTICOLOR_PROGRAM 0xa
65
66 /*
67 * BCM5482: Shadow registers