From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next 7/7] net: phy: bcm7xxx: enable EEE at the PHY level
Date: Fri, 22 Aug 2014 18:55:45 -0700 [thread overview]
Message-ID: <1408758945-18908-8-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1408758945-18908-1-git-send-email-f.fainelli@gmail.com>
The 28nm Gigabit PHY on BCM7xxx chips comes out of reset with absolutely
no EEE capabilities, such that we would actually return that we do not
support EEE when accessing 3.20 (MDIO_PCS_EEE_ABLE) registers.
Poke through the vendor-specific C45 register to enable EEE globally at
the PHY level, and advertise supported EEE modes.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/bcm7xxx.c | 31 +++++++++++++++++++++++++++++++
include/linux/brcmphy.h | 3 +++
2 files changed, 34 insertions(+)
diff --git a/drivers/net/phy/bcm7xxx.c b/drivers/net/phy/bcm7xxx.c
index 9dcf241b62ef..1e8c611831bf 100644
--- a/drivers/net/phy/bcm7xxx.c
+++ b/drivers/net/phy/bcm7xxx.c
@@ -14,6 +14,7 @@
#include <linux/delay.h>
#include <linux/bitops.h>
#include <linux/brcmphy.h>
+#include <linux/mdio.h>
/* Broadcom BCM7xxx internal PHY registers */
#define MII_BCM7XXX_CHANNEL_WIDTH 0x2000
@@ -167,6 +168,32 @@ static int bcm7xxx_apd_enable(struct phy_device *phydev)
return bcm54xx_shadow_write(phydev, BCM54XX_SHD_APD, val);
}
+static int bcm7xxx_eee_enable(struct phy_device *phydev)
+{
+ int val;
+
+ val = phy_read_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL,
+ MDIO_MMD_AN, phydev->addr);
+ if (val < 0)
+ return val;
+
+ /* Enable general EEE feature at the PHY level */
+ val |= LPI_FEATURE_EN | LPI_FEATURE_EN_DIG1000X;
+
+ phy_write_mmd_indirect(phydev, BRCM_CL45VEN_EEE_CONTROL,
+ MDIO_MMD_AN, phydev->addr, val);
+
+ /* Advertise supported modes */
+ val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV,
+ MDIO_MMD_AN, phydev->addr);
+
+ val |= (MDIO_AN_EEE_ADV_100TX | MDIO_AN_EEE_ADV_1000T);
+ phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV,
+ MDIO_MMD_AN, phydev->addr, val);
+
+ return 0;
+}
+
static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
{
int ret;
@@ -179,6 +206,10 @@ static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
if (ret)
return ret;
+ ret = bcm7xxx_eee_enable(phydev);
+ if (ret)
+ return ret;
+
return bcm7xxx_apd_enable(phydev);
}
diff --git a/include/linux/brcmphy.h b/include/linux/brcmphy.h
index c221e6df2bc4..fcf7675d5d92 100644
--- a/include/linux/brcmphy.h
+++ b/include/linux/brcmphy.h
@@ -215,5 +215,8 @@ static inline int bcm54xx_shadow_write(struct phy_device *phydev, u16 shadow,
MII_BCM54XX_SHD_DATA(val));
}
+#define BRCM_CL45VEN_EEE_CONTROL 0x803d
+#define LPI_FEATURE_EN 0x8000
+#define LPI_FEATURE_EN_DIG1000X 0x4000
#endif /* _LINUX_BRCMPHY_H */
--
1.9.1
next prev parent reply other threads:[~2014-08-23 1:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-23 1:55 [PATCH net-next 0/7] net: phy: bcm7xxx: APD and EEE support Florian Fainelli
2014-08-23 1:55 ` [PATCH net-next 1/7] net: phy: broadcom: extract all registers to brcmphy.h Florian Fainelli
2014-08-23 1:55 ` [PATCH net-next 2/7] net: phy: broadcom: move shadow 0x1C register accessors " Florian Fainelli
2014-08-23 1:55 ` [PATCH net-next 3/7] net: phy: bcm7xxx: enable auto power down Florian Fainelli
2014-08-23 1:55 ` [PATCH net-next 4/7] net: phy: fixed: return an error for Clause 45 over 22 reads Florian Fainelli
2014-08-23 1:55 ` [PATCH net-next 5/7] net: phy: export phy_{read,write}_mmd_indirect Florian Fainelli
2014-08-23 1:55 ` [PATCH net-next 6/7] net: phy: allow phy_init_eee() to work with internal PHYs Florian Fainelli
2014-08-23 1:55 ` Florian Fainelli [this message]
2014-08-23 18:39 ` [PATCH net-next 0/7] net: phy: bcm7xxx: APD and EEE support David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408758945-18908-8-git-send-email-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).