From: "Nithin Nayak Sujir" <nsujir@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, mchan@broadcom.com,
"Nithin Nayak Sujir" <nsujir@broadcom.com>
Subject: [PATCH net-next 06/11] tg3: Add SGMII phy support for 5719/5718 serdes
Date: Tue, 9 Apr 2013 11:48:06 -0700 [thread overview]
Message-ID: <1365533291-5672-7-git-send-email-nsujir@broadcom.com> (raw)
In-Reply-To: <1365533291-5672-1-git-send-email-nsujir@broadcom.com>
From: Michael Chan <mchan@broadcom.com>
Signed-off-by: Nithin Nayak Sujir <nsujir@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
drivers/net/ethernet/broadcom/tg3.c | 51 ++++++++++++++++++++++++++++++++-----
drivers/net/ethernet/broadcom/tg3.h | 7 +++++
2 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 568dd07..f53e309 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -5465,11 +5465,50 @@ static int tg3_setup_fiber_phy(struct tg3 *tp, int force_reset)
static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
{
- int current_link_up, err = 0;
+ int current_link_up = 0, err = 0;
u32 bmsr, bmcr;
- u16 current_speed;
- u8 current_duplex;
- u32 local_adv, remote_adv;
+ u16 current_speed = SPEED_UNKNOWN;
+ u8 current_duplex = DUPLEX_UNKNOWN;
+ u32 local_adv, remote_adv, sgsr;
+
+ if ((tg3_asic_rev(tp) == ASIC_REV_5719 ||
+ tg3_asic_rev(tp) == ASIC_REV_5720) &&
+ !tg3_readphy(tp, SERDES_TG3_1000X_STATUS, &sgsr) &&
+ (sgsr & SERDES_TG3_SGMII_MODE)) {
+
+ if (force_reset)
+ tg3_phy_reset(tp);
+
+ tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK;
+
+ if (!(sgsr & SERDES_TG3_LINK_UP)) {
+ tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
+ } else {
+ current_link_up = 1;
+ if (sgsr & SERDES_TG3_SPEED_1000) {
+ current_speed = SPEED_1000;
+ tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
+ } else if (sgsr & SERDES_TG3_SPEED_100) {
+ current_speed = SPEED_100;
+ tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
+ } else {
+ current_speed = SPEED_10;
+ tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
+ }
+
+ if (sgsr & SERDES_TG3_FULL_DUPLEX)
+ current_duplex = DUPLEX_FULL;
+ else
+ current_duplex = DUPLEX_HALF;
+ }
+
+ tw32_f(MAC_MODE, tp->mac_mode);
+ udelay(40);
+
+ tg3_clear_mac_status(tp);
+
+ goto fiber_setup_done;
+ }
tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
tw32_f(MAC_MODE, tp->mac_mode);
@@ -5480,9 +5519,6 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
if (force_reset)
tg3_phy_reset(tp);
- current_link_up = 0;
- current_speed = SPEED_UNKNOWN;
- current_duplex = DUPLEX_UNKNOWN;
tp->link_config.rmt_adv = 0;
err |= tg3_readphy(tp, MII_BMSR, &bmsr);
@@ -5600,6 +5636,7 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
}
}
+fiber_setup_done:
if (current_link_up == 1 && current_duplex == DUPLEX_FULL)
tg3_setup_flow_control(tp, local_adv, remote_adv);
diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
index 1cdc1b6..fd00a38 100644
--- a/drivers/net/ethernet/broadcom/tg3.h
+++ b/drivers/net/ethernet/broadcom/tg3.h
@@ -2371,6 +2371,13 @@
#define MII_TG3_FET_SHDW_AUXSTAT2 0x1b
#define MII_TG3_FET_SHDW_AUXSTAT2_APD 0x0020
+/* Serdes PHY Register Definitions */
+#define SERDES_TG3_1000X_STATUS 0x14
+#define SERDES_TG3_SGMII_MODE 0x0001
+#define SERDES_TG3_LINK_UP 0x0002
+#define SERDES_TG3_FULL_DUPLEX 0x0004
+#define SERDES_TG3_SPEED_100 0x0008
+#define SERDES_TG3_SPEED_1000 0x0010
/* APE registers. Accessible through BAR1 */
#define TG3_APE_GPIO_MSG 0x0008
--
1.8.1.4
next prev parent reply other threads:[~2013-04-09 18:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 18:48 [PATCH net-next 00/11] tg3: misc patches - minor fixes and enhancements Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 01/11] tg3: Fix flow control settings not propagated to hardware Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 02/11] tg3: Fix NVRAM size detection for the STM45PE20 pinstrap on 5762 devices Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 03/11] tg3: Remove unnecessary phy reset during ethtool commands Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 04/11] tg3: Add a warning during link settings change if mgmt enabled Nithin Nayak Sujir
2013-04-10 12:56 ` Ben Hutchings
2013-04-10 15:06 ` Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 05/11] tg3: Add tg3_clear_mac_status() common function Nithin Nayak Sujir
2013-04-09 18:48 ` Nithin Nayak Sujir [this message]
2013-04-09 18:48 ` [PATCH net-next 07/11] tg3: Add support for link flap avoidance Nithin Nayak Sujir
2013-04-09 19:15 ` David Miller
2013-04-09 20:59 ` Nithin Nayak Sujir
2013-04-09 21:07 ` David Miller
2013-04-09 18:48 ` [PATCH net-next 08/11] tg3: Pull the phy advertised speed and flow control settings on driver load Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 09/11] tg3: Reset the phy to allow modified EEE settings to take effect Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 10/11] tg3: Update version to 3.131 Nithin Nayak Sujir
2013-04-09 18:48 ` [PATCH net-next 11/11] MAINTAINERS: Update tg3 to reflect organizational changes Nithin Nayak Sujir
2013-04-09 20:18 ` [PATCH net-next] tg3: Use bool not int Joe Perches
2013-04-09 21:00 ` Michael Chan
2013-04-09 21:08 ` 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=1365533291-5672-7-git-send-email-nsujir@broadcom.com \
--to=nsujir@broadcom.com \
--cc=davem@davemloft.net \
--cc=mchan@broadcom.com \
--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).