kernel: bump 4.14 to 4.14.159
[oweals/openwrt.git] / target / linux / generic / backport-4.9 / 076-v4.11-0006-net-phy-broadcom-add-support-for-BCM54210E.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
2 Date: Fri, 27 Jan 2017 14:07:01 +0100
3 Subject: [PATCH] net: phy: broadcom: add support for BCM54210E
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 It's Broadcom PHY simply described as single-port
9 RGMII 10/100/1000BASE-T PHY. It requires disabling delay skew and GTXCLK
10 bits.
11
12 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15
16 --- a/drivers/net/phy/broadcom.c
17 +++ b/drivers/net/phy/broadcom.c
18 @@ -30,6 +30,22 @@ MODULE_DESCRIPTION("Broadcom PHY driver"
19  MODULE_AUTHOR("Maciej W. Rozycki");
20  MODULE_LICENSE("GPL");
21  
22 +static int bcm54210e_config_init(struct phy_device *phydev)
23 +{
24 +       int val;
25 +
26 +       val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
27 +       val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
28 +       val |= MII_BCM54XX_AUXCTL_MISC_WREN;
29 +       bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, val);
30 +
31 +       val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
32 +       val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
33 +       bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
34 +
35 +       return 0;
36 +}
37 +
38  static int bcm54810_config(struct phy_device *phydev)
39  {
40         int rc, val;
41 @@ -230,7 +246,11 @@ static int bcm54xx_config_init(struct ph
42             (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
43                 bcm54xx_adjust_rxrefclk(phydev);
44  
45 -       if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
46 +       if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E) {
47 +               err = bcm54210e_config_init(phydev);
48 +               if (err)
49 +                       return err;
50 +       } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) {
51                 err = bcm54810_config(phydev);
52                 if (err)
53                         return err;
54 @@ -544,6 +564,17 @@ static struct phy_driver broadcom_driver
55         .ack_interrupt  = bcm_phy_ack_intr,
56         .config_intr    = bcm_phy_config_intr,
57  }, {
58 +       .phy_id         = PHY_ID_BCM54210E,
59 +       .phy_id_mask    = 0xfffffff0,
60 +       .name           = "Broadcom BCM54210E",
61 +       .features       = PHY_GBIT_FEATURES,
62 +       .flags          = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
63 +       .config_init    = bcm54xx_config_init,
64 +       .config_aneg    = genphy_config_aneg,
65 +       .read_status    = genphy_read_status,
66 +       .ack_interrupt  = bcm_phy_ack_intr,
67 +       .config_intr    = bcm_phy_config_intr,
68 +}, {
69         .phy_id         = PHY_ID_BCM5461,
70         .phy_id_mask    = 0xfffffff0,
71         .name           = "Broadcom BCM5461",
72 @@ -694,6 +725,7 @@ module_phy_driver(broadcom_drivers);
73  static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
74         { PHY_ID_BCM5411, 0xfffffff0 },
75         { PHY_ID_BCM5421, 0xfffffff0 },
76 +       { PHY_ID_BCM54210E, 0xfffffff0 },
77         { PHY_ID_BCM5461, 0xfffffff0 },
78         { PHY_ID_BCM54612E, 0xfffffff0 },
79         { PHY_ID_BCM54616S, 0xfffffff0 },
80 --- a/include/linux/brcmphy.h
81 +++ b/include/linux/brcmphy.h
82 @@ -17,6 +17,7 @@
83  #define PHY_ID_BCM5482                 0x0143bcb0
84  #define PHY_ID_BCM5411                 0x00206070
85  #define PHY_ID_BCM5421                 0x002060e0
86 +#define PHY_ID_BCM54210E               0x600d84a0
87  #define PHY_ID_BCM5464                 0x002060b0
88  #define PHY_ID_BCM5461                 0x002060c0
89  #define PHY_ID_BCM54612E               0x03625e60