15af5a7ca49e506a36ee53269f24665e74d79ba9
[openwrt/staging/ynezz.git] /
1 From dc2550fdfd0a46c3ec67e5003b3d69c29141406b Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.org>
3 Date: Fri, 17 May 2019 13:31:21 +0100
4 Subject: [PATCH] phy: bcm54213pe: configure the LED outputs to be more
5 user-friendly
6
7 The default state was both LEDs indicating link speed.
8
9 Change the default configuration to
10 - Amber: 1000/100 link speed indication
11 - Green: link present + activity indication
12
13 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
14 ---
15 drivers/net/phy/broadcom.c | 17 +++++++++++++++++
16 include/linux/brcmphy.h | 4 ++++
17 2 files changed, 21 insertions(+)
18
19 --- a/drivers/net/phy/broadcom.c
20 +++ b/drivers/net/phy/broadcom.c
21 @@ -52,6 +52,21 @@ static int bcm54210e_config_init(struct
22 return 0;
23 }
24
25 +static void bcm54213pe_config_init(struct phy_device *phydev)
26 +{
27 + u16 val;
28 +
29 + /* Enable ACT+LINK indication on ACTIVITY trigger */
30 + val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_LEDCTL);
31 + val |= BCM54XX_SHD_LEDCTL_ACTLINK_EN;
32 + bcm_phy_write_shadow(phydev, BCM54XX_SHD_LEDCTL, val);
33 +
34 + /* Set ACTIVITY on LED "1" output, LINKSPD[1] on LED "3" output */
35 + val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_ACTIVITYLED) |
36 + BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_LINKSPD1);
37 + bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val);
38 +}
39 +
40 static int bcm54612e_config_init(struct phy_device *phydev)
41 {
42 int reg;
43 @@ -310,6 +325,8 @@ static int bcm54xx_config_init(struct ph
44 err = bcm54210e_config_init(phydev);
45 if (err)
46 return err;
47 + } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54213PE) {
48 + bcm54213pe_config_init(phydev);
49 } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54612E) {
50 err = bcm54612e_config_init(phydev);
51 if (err)
52 --- a/include/linux/brcmphy.h
53 +++ b/include/linux/brcmphy.h
54 @@ -168,6 +168,10 @@
55 #define BCM54XX_SHD_SCR3_DLLAPD_DIS 0x0002
56 #define BCM54XX_SHD_SCR3_TRDDAPD 0x0004
57
58 +/* 01001: Additional LED trigger options */
59 +#define BCM54XX_SHD_LEDCTL 0x09
60 +#define BCM54XX_SHD_LEDCTL_ACTLINK_EN 0x0010
61 +
62 /* 01010: Auto Power-Down */
63 #define BCM54XX_SHD_APD 0x0a
64 #define BCM_APD_CLR_MASK 0xFE9F /* clear bits 5, 6 & 8 */