iPXE
Data Structures | Macros | Functions | Variables
tg3_phy.c File Reference
#include <mii.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <byteswap.h>
#include <ipxe/pci.h>
#include "tg3.h"

Go to the source code of this file.

Data Structures

struct  subsys_tbl_ent
 
struct  tg3_fiber_aneginfo
 

Macros

#define PHY_BUSY_LOOPS   5000
 
#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)
 
#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp)
 
#define ADVERTISED_Autoneg   (1 << 6)
 
#define ADVERTISED_Pause   (1 << 13)
 
#define ADVERTISED_TP   (1 << 7)
 
#define ADVERTISED_FIBRE   (1 << 10)
 
#define AUTONEG_ENABLE   0x01
 
#define ANEG_STATE_UNKNOWN   0
 
#define ANEG_STATE_AN_ENABLE   1
 
#define ANEG_STATE_RESTART_INIT   2
 
#define ANEG_STATE_RESTART   3
 
#define ANEG_STATE_DISABLE_LINK_OK   4
 
#define ANEG_STATE_ABILITY_DETECT_INIT   5
 
#define ANEG_STATE_ABILITY_DETECT   6
 
#define ANEG_STATE_ACK_DETECT_INIT   7
 
#define ANEG_STATE_ACK_DETECT   8
 
#define ANEG_STATE_COMPLETE_ACK_INIT   9
 
#define ANEG_STATE_COMPLETE_ACK   10
 
#define ANEG_STATE_IDLE_DETECT_INIT   11
 
#define ANEG_STATE_IDLE_DETECT   12
 
#define ANEG_STATE_LINK_OK   13
 
#define ANEG_STATE_NEXT_PAGE_WAIT_INIT   14
 
#define ANEG_STATE_NEXT_PAGE_WAIT   15
 
#define MR_AN_ENABLE   0x00000001
 
#define MR_RESTART_AN   0x00000002
 
#define MR_AN_COMPLETE   0x00000004
 
#define MR_PAGE_RX   0x00000008
 
#define MR_NP_LOADED   0x00000010
 
#define MR_TOGGLE_TX   0x00000020
 
#define MR_LP_ADV_FULL_DUPLEX   0x00000040
 
#define MR_LP_ADV_HALF_DUPLEX   0x00000080
 
#define MR_LP_ADV_SYM_PAUSE   0x00000100
 
#define MR_LP_ADV_ASYM_PAUSE   0x00000200
 
#define MR_LP_ADV_REMOTE_FAULT1   0x00000400
 
#define MR_LP_ADV_REMOTE_FAULT2   0x00000800
 
#define MR_LP_ADV_NEXT_PAGE   0x00001000
 
#define MR_TOGGLE_RX   0x00002000
 
#define MR_NP_RX   0x00004000
 
#define MR_LINK_OK   0x80000000
 
#define ANEG_CFG_NP   0x00000080
 
#define ANEG_CFG_ACK   0x00000040
 
#define ANEG_CFG_RF2   0x00000020
 
#define ANEG_CFG_RF1   0x00000010
 
#define ANEG_CFG_PS2   0x00000001
 
#define ANEG_CFG_PS1   0x00008000
 
#define ANEG_CFG_HD   0x00004000
 
#define ANEG_CFG_FD   0x00002000
 
#define ANEG_CFG_INVAL   0x00001f06
 
#define ANEG_OK   0
 
#define ANEG_DONE   1
 
#define ANEG_TIMER_ENAB   2
 
#define ANEG_FAILED   -1
 
#define ANEG_STATE_SETTLE_TIME   10000
 

Functions

static void tg3_link_report (struct tg3 *tp)
 
void tg3_mdio_init (struct tg3 *tp)
 
static int tg3_issue_otp_command (struct tg3 *tp, u32 cmd)
 
u32 tg3_read_otp_phycfg (struct tg3 *tp)
 int tg3_rx_prodring_init(struct tg3 *tp, struct tg3_rx_prodring_set *tpr); More...
 
int tg3_readphy (struct tg3 *tp, int reg, u32 *val)
 
static struct subsys_tbl_enttg3_lookup_by_subsys (struct tg3 *tp)
 
int tg3_writephy (struct tg3 *tp, int reg, u32 val)
 
static int tg3_bmcr_reset (struct tg3 *tp)
 
static int tg3_wait_macro_done (struct tg3 *tp)
 
static int tg3_phy_write_and_check_testpat (struct tg3 *tp, int *resetp)
 
static int tg3_phy_reset_chanpat (struct tg3 *tp)
 
static int tg3_phydsp_write (struct tg3 *tp, u32 reg, u32 val)
 
static int tg3_phy_auxctl_write (struct tg3 *tp, int reg, u32 set)
 
static int tg3_phy_reset_5703_4_5 (struct tg3 *tp)
 
static void tg3_phy_apply_otp (struct tg3 *tp)
 
static int tg3_phy_auxctl_read (struct tg3 *tp, int reg, u32 *val)
 
static void tg3_phy_toggle_automdix (struct tg3 *tp, int enable)
 
static void tg3_phy_set_wirespeed (struct tg3 *tp)
 
int tg3_phy_reset (struct tg3 *tp)
 
static int tg3_copper_is_advertising_all (struct tg3 *tp, u32 mask)
 
static u16 tg3_advert_flowctrl_1000T (u8 flow_ctrl)
 
static int tg3_phy_autoneg_cfg (struct tg3 *tp, u32 advertise, u32 flowctrl)
 
static int tg3_init_5401phy_dsp (struct tg3 *tp)
 
static void tg3_phy_init_link_config (struct tg3 *tp)
 
int tg3_phy_probe (struct tg3 *tp)
 
void tg3_poll_link (struct tg3 *tp)
 
static void tg3_aux_stat_to_speed_duplex (struct tg3 *tp, u32 val, u16 *speed, u8 *duplex)
 
static int tg3_adv_1000T_flowctrl_ok (struct tg3 *tp, u32 *lcladv, u32 *rmtadv)
 
static u8 tg3_resolve_flowctrl_1000X (u16 lcladv, u16 rmtadv)
 
static void tg3_setup_flow_control (struct tg3 *tp, u32 lcladv, u32 rmtadv)
 
static void tg3_phy_copper_begin (struct tg3 *tp)
 
static int tg3_5700_link_polarity (struct tg3 *tp, u32 speed)
 
static void tg3_ump_link_report (struct tg3 *tp)
 
static u16 tg3_advert_flowctrl_1000X (u8 flow_ctrl)
 
static void tg3_init_bcm8002 (struct tg3 *tp)
 
static int tg3_setup_fiber_hw_autoneg (struct tg3 *tp, u32 mac_status)
 
static int tg3_fiber_aneg_smachine (struct tg3 *tp, struct tg3_fiber_aneginfo *ap)
 
static int fiber_autoneg (struct tg3 *tp, u32 *txflags, u32 *rxflags)
 
static int tg3_setup_fiber_by_hand (struct tg3 *tp, u32 mac_status)
 
static int tg3_test_and_report_link_chg (struct tg3 *tp, int curr_link_up)
 
static void tg3_clear_mac_status (struct tg3 *tp)
 
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)
 
static int tg3_setup_copper_phy (struct tg3 *tp, int force_reset)
 
int tg3_setup_phy (struct tg3 *tp, int force_reset)
 

Variables

static struct subsys_tbl_ent subsys_id_to_phy_id []
 

Macro Definition Documentation

◆ PHY_BUSY_LOOPS

#define PHY_BUSY_LOOPS   5000

Definition at line 84 of file tg3_phy.c.

◆ TG3_PHY_AUXCTL_SMDSP_ENABLE

#define TG3_PHY_AUXCTL_SMDSP_ENABLE (   tp)
Value:
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:423
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_TG3_AUXCTL_ACTL_TX_6DB
Definition: tg3.h:2358
#define MII_TG3_AUXCTL_ACTL_SMDSP_ENA
Definition: tg3.h:2359
#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL
Definition: tg3.h:2357

Definition at line 432 of file tg3_phy.c.

◆ TG3_PHY_AUXCTL_SMDSP_DISABLE

#define TG3_PHY_AUXCTL_SMDSP_DISABLE (   tp)
Value:
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:423
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_TG3_AUXCTL_ACTL_TX_6DB
Definition: tg3.h:2358
#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL
Definition: tg3.h:2357

Definition at line 437 of file tg3_phy.c.

◆ ADVERTISED_Autoneg

#define ADVERTISED_Autoneg   (1 << 6)

Definition at line 859 of file tg3_phy.c.

◆ ADVERTISED_Pause

#define ADVERTISED_Pause   (1 << 13)

Definition at line 860 of file tg3_phy.c.

◆ ADVERTISED_TP

#define ADVERTISED_TP   (1 << 7)

Definition at line 861 of file tg3_phy.c.

◆ ADVERTISED_FIBRE

#define ADVERTISED_FIBRE   (1 << 10)

Definition at line 862 of file tg3_phy.c.

◆ AUTONEG_ENABLE

#define AUTONEG_ENABLE   0x01

Definition at line 864 of file tg3_phy.c.

◆ ANEG_STATE_UNKNOWN

#define ANEG_STATE_UNKNOWN   0

Definition at line 1293 of file tg3_phy.c.

◆ ANEG_STATE_AN_ENABLE

#define ANEG_STATE_AN_ENABLE   1

Definition at line 1294 of file tg3_phy.c.

◆ ANEG_STATE_RESTART_INIT

#define ANEG_STATE_RESTART_INIT   2

Definition at line 1295 of file tg3_phy.c.

◆ ANEG_STATE_RESTART

#define ANEG_STATE_RESTART   3

Definition at line 1296 of file tg3_phy.c.

◆ ANEG_STATE_DISABLE_LINK_OK

#define ANEG_STATE_DISABLE_LINK_OK   4

Definition at line 1297 of file tg3_phy.c.

◆ ANEG_STATE_ABILITY_DETECT_INIT

#define ANEG_STATE_ABILITY_DETECT_INIT   5

Definition at line 1298 of file tg3_phy.c.

◆ ANEG_STATE_ABILITY_DETECT

#define ANEG_STATE_ABILITY_DETECT   6

Definition at line 1299 of file tg3_phy.c.

◆ ANEG_STATE_ACK_DETECT_INIT

#define ANEG_STATE_ACK_DETECT_INIT   7

Definition at line 1300 of file tg3_phy.c.

◆ ANEG_STATE_ACK_DETECT

#define ANEG_STATE_ACK_DETECT   8

Definition at line 1301 of file tg3_phy.c.

◆ ANEG_STATE_COMPLETE_ACK_INIT

#define ANEG_STATE_COMPLETE_ACK_INIT   9

Definition at line 1302 of file tg3_phy.c.

◆ ANEG_STATE_COMPLETE_ACK

#define ANEG_STATE_COMPLETE_ACK   10

Definition at line 1303 of file tg3_phy.c.

◆ ANEG_STATE_IDLE_DETECT_INIT

#define ANEG_STATE_IDLE_DETECT_INIT   11

Definition at line 1304 of file tg3_phy.c.

◆ ANEG_STATE_IDLE_DETECT

#define ANEG_STATE_IDLE_DETECT   12

Definition at line 1305 of file tg3_phy.c.

◆ ANEG_STATE_LINK_OK

#define ANEG_STATE_LINK_OK   13

Definition at line 1306 of file tg3_phy.c.

◆ ANEG_STATE_NEXT_PAGE_WAIT_INIT

#define ANEG_STATE_NEXT_PAGE_WAIT_INIT   14

Definition at line 1307 of file tg3_phy.c.

◆ ANEG_STATE_NEXT_PAGE_WAIT

#define ANEG_STATE_NEXT_PAGE_WAIT   15

Definition at line 1308 of file tg3_phy.c.

◆ MR_AN_ENABLE

#define MR_AN_ENABLE   0x00000001

Definition at line 1311 of file tg3_phy.c.

◆ MR_RESTART_AN

#define MR_RESTART_AN   0x00000002

Definition at line 1312 of file tg3_phy.c.

◆ MR_AN_COMPLETE

#define MR_AN_COMPLETE   0x00000004

Definition at line 1313 of file tg3_phy.c.

◆ MR_PAGE_RX

#define MR_PAGE_RX   0x00000008

Definition at line 1314 of file tg3_phy.c.

◆ MR_NP_LOADED

#define MR_NP_LOADED   0x00000010

Definition at line 1315 of file tg3_phy.c.

◆ MR_TOGGLE_TX

#define MR_TOGGLE_TX   0x00000020

Definition at line 1316 of file tg3_phy.c.

◆ MR_LP_ADV_FULL_DUPLEX

#define MR_LP_ADV_FULL_DUPLEX   0x00000040

Definition at line 1317 of file tg3_phy.c.

◆ MR_LP_ADV_HALF_DUPLEX

#define MR_LP_ADV_HALF_DUPLEX   0x00000080

Definition at line 1318 of file tg3_phy.c.

◆ MR_LP_ADV_SYM_PAUSE

#define MR_LP_ADV_SYM_PAUSE   0x00000100

Definition at line 1319 of file tg3_phy.c.

◆ MR_LP_ADV_ASYM_PAUSE

#define MR_LP_ADV_ASYM_PAUSE   0x00000200

Definition at line 1320 of file tg3_phy.c.

◆ MR_LP_ADV_REMOTE_FAULT1

#define MR_LP_ADV_REMOTE_FAULT1   0x00000400

Definition at line 1321 of file tg3_phy.c.

◆ MR_LP_ADV_REMOTE_FAULT2

#define MR_LP_ADV_REMOTE_FAULT2   0x00000800

Definition at line 1322 of file tg3_phy.c.

◆ MR_LP_ADV_NEXT_PAGE

#define MR_LP_ADV_NEXT_PAGE   0x00001000

Definition at line 1323 of file tg3_phy.c.

◆ MR_TOGGLE_RX

#define MR_TOGGLE_RX   0x00002000

Definition at line 1324 of file tg3_phy.c.

◆ MR_NP_RX

#define MR_NP_RX   0x00004000

Definition at line 1325 of file tg3_phy.c.

◆ MR_LINK_OK

#define MR_LINK_OK   0x80000000

Definition at line 1327 of file tg3_phy.c.

◆ ANEG_CFG_NP

#define ANEG_CFG_NP   0x00000080

Definition at line 1337 of file tg3_phy.c.

◆ ANEG_CFG_ACK

#define ANEG_CFG_ACK   0x00000040

Definition at line 1338 of file tg3_phy.c.

◆ ANEG_CFG_RF2

#define ANEG_CFG_RF2   0x00000020

Definition at line 1339 of file tg3_phy.c.

◆ ANEG_CFG_RF1

#define ANEG_CFG_RF1   0x00000010

Definition at line 1340 of file tg3_phy.c.

◆ ANEG_CFG_PS2

#define ANEG_CFG_PS2   0x00000001

Definition at line 1341 of file tg3_phy.c.

◆ ANEG_CFG_PS1

#define ANEG_CFG_PS1   0x00008000

Definition at line 1342 of file tg3_phy.c.

◆ ANEG_CFG_HD

#define ANEG_CFG_HD   0x00004000

Definition at line 1343 of file tg3_phy.c.

◆ ANEG_CFG_FD

#define ANEG_CFG_FD   0x00002000

Definition at line 1344 of file tg3_phy.c.

◆ ANEG_CFG_INVAL

#define ANEG_CFG_INVAL   0x00001f06

Definition at line 1345 of file tg3_phy.c.

◆ ANEG_OK

#define ANEG_OK   0

Definition at line 1348 of file tg3_phy.c.

◆ ANEG_DONE

#define ANEG_DONE   1

Definition at line 1349 of file tg3_phy.c.

◆ ANEG_TIMER_ENAB

#define ANEG_TIMER_ENAB   2

Definition at line 1350 of file tg3_phy.c.

◆ ANEG_FAILED

#define ANEG_FAILED   -1

Definition at line 1351 of file tg3_phy.c.

◆ ANEG_STATE_SETTLE_TIME

#define ANEG_STATE_SETTLE_TIME   10000

Definition at line 1353 of file tg3_phy.c.

Function Documentation

◆ tg3_link_report()

static void tg3_link_report ( struct tg3 tp)
static

Definition at line 1261 of file tg3_phy.c.

1262 { DBGP("%s\n", __func__);
1263 
1264  if (!netdev_link_ok(tp->dev)) {
1265  DBGC(tp->dev, "Link is down\n");
1267  } else {
1268  DBGC(tp->dev, "Link is up at %d Mbps, %s duplex\n",
1269  (tp->link_config.active_speed == SPEED_1000 ?
1270  1000 :
1271  (tp->link_config.active_speed == SPEED_100 ?
1272  100 : 10)),
1273  (tp->link_config.active_duplex == DUPLEX_FULL ?
1274  "full" : "half"));
1275 
1276  DBGC(tp->dev, "Flow control is %s for TX and %s for RX\n",
1277  (tp->link_config.active_flowctrl & FLOW_CTRL_TX) ?
1278  "on" : "off",
1279  (tp->link_config.active_flowctrl & FLOW_CTRL_RX) ?
1280  "on" : "off");
1281 
1282  if (tp->phy_flags & TG3_PHYFLG_EEE_CAP)
1283  DBGC(tp->dev, "EEE is %s\n",
1284  tp->setlpicnt ? "enabled" : "disabled");
1285 
1287  }
1288 }
#define SPEED_1000
Definition: atl1e.h:52
static void tg3_ump_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1213
#define DBGC(...)
Definition: compiler.h:505
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define SPEED_100
Definition: atl1e.h:51
#define DBGP(...)
Definition: compiler.h:532
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:639
#define DUPLEX_FULL
Definition: bnx2.h:111
static struct tulip_private * tp
Definition: tulip.c:442
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
#define TG3_PHYFLG_EEE_CAP
Definition: tg3.h:3253

References DBGC, DBGP, DUPLEX_FULL, FLOW_CTRL_RX, FLOW_CTRL_TX, netdev_link_ok(), SPEED_100, SPEED_1000, TG3_PHYFLG_EEE_CAP, tg3_ump_link_report(), and tp.

Referenced by tg3_phy_reset(), tg3_setup_copper_phy(), tg3_setup_fiber_phy(), and tg3_test_and_report_link_chg().

◆ tg3_mdio_init()

void tg3_mdio_init ( struct tg3 tp)

Definition at line 14 of file tg3_phy.c.

15 { DBGP("%s\n", __func__);
16 
17  if (tg3_flag(tp, 5717_PLUS)) {
18  u32 is_serdes;
19 
20  tp->phy_addr = PCI_FUNC(tp->pdev->busdevfn) + 1;
21 
22  if (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0)
23  is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES;
24  else
25  is_serdes = tr32(TG3_CPMU_PHY_STRAP) &
27  if (is_serdes)
28  tp->phy_addr += 7;
29  } else
30  tp->phy_addr = TG3_PHY_MII_ADDR;
31 }
#define PCI_FUNC(busdevfn)
Definition: pci.h:285
#define tr32(reg)
Definition: tg3.h:3339
#define TG3_CPMU_PHY_STRAP
Definition: tg3.h:1262
#define TG3_CPMU_PHY_STRAP_IS_SERDES
Definition: tg3.h:1263
#define SG_DIG_STATUS
Definition: tg3.h:897
#define TG3_PHY_MII_ADDR
Definition: tg3.h:2306
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define SG_DIG_IS_SERDES
Definition: tg3.h:906
#define CHIPREV_ID_5717_A0
Definition: tg3.h:294
uint32_t u32
Definition: stdint.h:23

References CHIPREV_ID_5717_A0, DBGP, PCI_FUNC, SG_DIG_IS_SERDES, SG_DIG_STATUS, TG3_CPMU_PHY_STRAP, TG3_CPMU_PHY_STRAP_IS_SERDES, tg3_flag, TG3_PHY_MII_ADDR, tp, and tr32.

Referenced by tg3_get_invariants().

◆ tg3_issue_otp_command()

static int tg3_issue_otp_command ( struct tg3 tp,
u32  cmd 
)
static

Definition at line 33 of file tg3_phy.c.

34 { DBGP("%s\n", __func__);
35 
36  int i;
37  u32 val;
38 
40  tw32(OTP_CTRL, cmd);
41 
42  /* Wait for up to 1 ms for command to execute. */
43  for (i = 0; i < 100; i++) {
44  val = tr32(OTP_STATUS);
46  break;
47  udelay(10);
48  }
49 
50  return (val & OTP_STATUS_CMD_DONE) ? 0 : -EBUSY;
51 }
#define tr32(reg)
Definition: tg3.h:3339
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define OTP_STATUS
Definition: tg3.h:2072
void __asmcall int val
Definition: setjmp.h:12
#define OTP_CTRL
Definition: tg3.h:2067
#define DBGP(...)
Definition: compiler.h:532
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define OTP_CTRL_OTP_CMD_START
Definition: tg3.h:2071
#define tw32(reg, val)
Definition: tg3.h:3329
struct golan_eqe_cmd cmd
Definition: CIB_PRM.h:29
uint32_t u32
Definition: stdint.h:23
#define OTP_STATUS_CMD_DONE
Definition: tg3.h:2073

References cmd, DBGP, EBUSY, OTP_CTRL, OTP_CTRL_OTP_CMD_START, OTP_STATUS, OTP_STATUS_CMD_DONE, tr32, tw32, udelay(), and val.

Referenced by tg3_read_otp_phycfg().

◆ tg3_read_otp_phycfg()

u32 tg3_read_otp_phycfg ( struct tg3 tp)

int tg3_rx_prodring_init(struct tg3 *tp, struct tg3_rx_prodring_set *tpr);

Definition at line 57 of file tg3_phy.c.

58 { DBGP("%s\n", __func__);
59 
60  u32 bhalf_otp, thalf_otp;
61 
63 
65  return 0;
66 
68 
70  return 0;
71 
72  thalf_otp = tr32(OTP_READ_DATA);
73 
75 
77  return 0;
78 
79  bhalf_otp = tr32(OTP_READ_DATA);
80 
81  return ((thalf_otp & 0x0000ffff) << 16) | (bhalf_otp >> 16);
82 }
#define OTP_ADDRESS
Definition: tg3.h:2074
#define tr32(reg)
Definition: tg3.h:3339
#define OTP_CTRL_OTP_CMD_READ
Definition: tg3.h:2069
static int tg3_issue_otp_command(struct tg3 *tp, u32 cmd)
Definition: tg3_phy.c:33
#define OTP_MODE
Definition: tg3.h:2065
#define OTP_CTRL_OTP_CMD_INIT
Definition: tg3.h:2070
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
#define OTP_ADDRESS_MAGIC1
Definition: tg3.h:2075
#define OTP_MODE_OTP_THRU_GRC
Definition: tg3.h:2066
#define OTP_ADDRESS_MAGIC2
Definition: tg3.h:2076
#define OTP_READ_DATA
Definition: tg3.h:2079
#define tw32(reg, val)
Definition: tg3.h:3329
uint32_t u32
Definition: stdint.h:23

References DBGP, OTP_ADDRESS, OTP_ADDRESS_MAGIC1, OTP_ADDRESS_MAGIC2, OTP_CTRL_OTP_CMD_INIT, OTP_CTRL_OTP_CMD_READ, OTP_MODE, OTP_MODE_OTP_THRU_GRC, OTP_READ_DATA, tg3_issue_otp_command(), tp, tr32, and tw32.

Referenced by tg3_get_invariants().

◆ tg3_readphy()

int tg3_readphy ( struct tg3 tp,
int  reg,
u32 val 
)

Definition at line 86 of file tg3_phy.c.

87 { DBGP("%s\n", __func__);
88 
89  u32 frame_val;
90  unsigned int loops;
91  int ret;
92 
93  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
95  (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL));
96  udelay(80);
97  }
98 
99  *val = 0x0;
100 
101  frame_val = ((tp->phy_addr << MI_COM_PHY_ADDR_SHIFT) &
103  frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
105  frame_val |= (MI_COM_CMD_READ | MI_COM_START);
106 
107  tw32_f(MAC_MI_COM, frame_val);
108 
109  loops = PHY_BUSY_LOOPS;
110  while (loops != 0) {
111  udelay(10);
112  frame_val = tr32(MAC_MI_COM);
113 
114  if ((frame_val & MI_COM_BUSY) == 0) {
115  udelay(5);
116  frame_val = tr32(MAC_MI_COM);
117  break;
118  }
119  loops -= 1;
120  }
121 
122  ret = -EBUSY;
123  if (loops != 0) {
124  *val = frame_val & MI_COM_DATA_MASK;
125  ret = 0;
126  }
127 
128  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
129  tw32_f(MAC_MI_MODE, tp->mi_mode);
130  udelay(80);
131  }
132 
133  return ret;
134 }
#define tr32(reg)
Definition: tg3.h:3339
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static unsigned int unsigned int reg
Definition: myson.h:162
void __asmcall int val
Definition: setjmp.h:12
#define MAC_MI_COM
Definition: tg3.h:603
#define MI_COM_REG_ADDR_MASK
Definition: tg3.h:612
#define PHY_BUSY_LOOPS
Definition: tg3_phy.c:84
#define MI_COM_PHY_ADDR_SHIFT
Definition: tg3.h:611
#define DBGP(...)
Definition: compiler.h:532
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:442
#define MI_COM_CMD_READ
Definition: tg3.h:606
#define MI_COM_REG_ADDR_SHIFT
Definition: tg3.h:613
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MAC_MI_MODE_AUTO_POLL
Definition: tg3.h:621
#define MI_COM_PHY_ADDR_MASK
Definition: tg3.h:610
#define MI_COM_START
Definition: tg3.h:608
#define MI_COM_DATA_MASK
Definition: tg3.h:614
#define MAC_MI_MODE
Definition: tg3.h:618
#define MI_COM_BUSY
Definition: tg3.h:609
uint32_t u32
Definition: stdint.h:23

References DBGP, EBUSY, MAC_MI_COM, MAC_MI_MODE, MAC_MI_MODE_AUTO_POLL, MI_COM_BUSY, MI_COM_CMD_READ, MI_COM_DATA_MASK, MI_COM_PHY_ADDR_MASK, MI_COM_PHY_ADDR_SHIFT, MI_COM_REG_ADDR_MASK, MI_COM_REG_ADDR_SHIFT, MI_COM_START, PHY_BUSY_LOOPS, reg, tp, tr32, tw32_f, udelay(), and val.

Referenced by tg3_adv_1000T_flowctrl_ok(), tg3_bmcr_reset(), tg3_copper_is_advertising_all(), tg3_phy_auxctl_read(), tg3_phy_probe(), tg3_phy_reset(), tg3_phy_reset_5703_4_5(), tg3_phy_toggle_automdix(), tg3_phy_write_and_check_testpat(), tg3_reset_hw(), tg3_setup_copper_phy(), tg3_setup_fiber_mii_phy(), tg3_ump_link_report(), and tg3_wait_macro_done().

◆ tg3_lookup_by_subsys()

static struct subsys_tbl_ent* tg3_lookup_by_subsys ( struct tg3 tp)
static

Definition at line 205 of file tg3_phy.c.

206 { DBGP("%s\n", __func__);
207 
208  int i;
209 
210  DBGC(tp->dev, "Matching with: %x:%x\n", tp->subsystem_vendor, tp->subsystem_device);
211 
212  for (i = 0; i < (int) ARRAY_SIZE(subsys_id_to_phy_id); i++) {
213  if ((subsys_id_to_phy_id[i].subsys_vendor ==
214  tp->subsystem_vendor) &&
216  tp->subsystem_device))
217  return &subsys_id_to_phy_id[i];
218  }
219  return NULL;
220 }
static struct subsys_tbl_ent subsys_id_to_phy_id[]
Definition: tg3_phy.c:141
#define DBGC(...)
Definition: compiler.h:505
u16 subsys_devid
Definition: tg3_phy.c:137
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References ARRAY_SIZE, DBGC, DBGP, NULL, subsys_tbl_ent::subsys_devid, subsys_id_to_phy_id, subsys_tbl_ent::subsys_vendor, and tp.

Referenced by tg3_phy_probe().

◆ tg3_writephy()

int tg3_writephy ( struct tg3 tp,
int  reg,
u32  val 
)

Definition at line 222 of file tg3_phy.c.

223 { DBGP("%s\n", __func__);
224 
225  u32 frame_val;
226  unsigned int loops;
227  int ret;
228 
229  if ((tp->phy_flags & TG3_PHYFLG_IS_FET) &&
231  return 0;
232 
233  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
235  (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL));
236  udelay(80);
237  }
238 
239  frame_val = ((tp->phy_addr << MI_COM_PHY_ADDR_SHIFT) &
241  frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
243  frame_val |= (val & MI_COM_DATA_MASK);
244  frame_val |= (MI_COM_CMD_WRITE | MI_COM_START);
245 
246  tw32_f(MAC_MI_COM, frame_val);
247 
248  loops = PHY_BUSY_LOOPS;
249  while (loops != 0) {
250  udelay(10);
251  frame_val = tr32(MAC_MI_COM);
252  if ((frame_val & MI_COM_BUSY) == 0) {
253  udelay(5);
254  frame_val = tr32(MAC_MI_COM);
255  break;
256  }
257  loops -= 1;
258  }
259 
260  ret = -EBUSY;
261  if (loops != 0)
262  ret = 0;
263 
264  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
265  tw32_f(MAC_MI_MODE, tp->mi_mode);
266  udelay(80);
267  }
268 
269  return ret;
270 }
#define MII_TG3_AUX_CTRL
Definition: tg3.h:2355
#define tr32(reg)
Definition: tg3.h:3339
#define MI_COM_CMD_WRITE
Definition: tg3.h:605
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static unsigned int unsigned int reg
Definition: myson.h:162
void __asmcall int val
Definition: setjmp.h:12
#define MAC_MI_COM
Definition: tg3.h:603
#define MI_COM_REG_ADDR_MASK
Definition: tg3.h:612
#define PHY_BUSY_LOOPS
Definition: tg3_phy.c:84
#define MI_COM_PHY_ADDR_SHIFT
Definition: tg3.h:611
#define TG3_PHYFLG_IS_FET
Definition: tg3.h:3241
#define DBGP(...)
Definition: compiler.h:532
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:442
#define MI_COM_REG_ADDR_SHIFT
Definition: tg3.h:613
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MAC_MI_MODE_AUTO_POLL
Definition: tg3.h:621
#define MI_COM_PHY_ADDR_MASK
Definition: tg3.h:610
#define MI_COM_START
Definition: tg3.h:608
#define MI_COM_DATA_MASK
Definition: tg3.h:614
#define MAC_MI_MODE
Definition: tg3.h:618
#define MI_COM_BUSY
Definition: tg3.h:609
#define MII_TG3_CTRL
Definition: tg3.h:2312
uint32_t u32
Definition: stdint.h:23

References DBGP, EBUSY, MAC_MI_COM, MAC_MI_MODE, MAC_MI_MODE_AUTO_POLL, MI_COM_BUSY, MI_COM_CMD_WRITE, MI_COM_DATA_MASK, MI_COM_PHY_ADDR_MASK, MI_COM_PHY_ADDR_SHIFT, MI_COM_REG_ADDR_MASK, MI_COM_REG_ADDR_SHIFT, MI_COM_START, MII_TG3_AUX_CTRL, MII_TG3_CTRL, PHY_BUSY_LOOPS, reg, TG3_PHYFLG_IS_FET, tp, tr32, tw32_f, udelay(), and val.

Referenced by tg3_adv_1000T_flowctrl_ok(), tg3_bmcr_reset(), tg3_init_bcm8002(), tg3_phy_autoneg_cfg(), tg3_phy_auxctl_read(), tg3_phy_auxctl_write(), tg3_phy_copper_begin(), tg3_phy_probe(), tg3_phy_reset(), tg3_phy_reset_5703_4_5(), tg3_phy_reset_chanpat(), tg3_phy_toggle_automdix(), tg3_phy_write_and_check_testpat(), tg3_phydsp_write(), tg3_reset_hw(), tg3_setup_copper_phy(), and tg3_setup_fiber_mii_phy().

◆ tg3_bmcr_reset()

static int tg3_bmcr_reset ( struct tg3 tp)
static

Definition at line 272 of file tg3_phy.c.

273 { DBGP("%s\n", __func__);
274 
275  u32 phy_control;
276  int limit, err;
277 
278  /* OK, reset it, and poll the BMCR_RESET bit until it
279  * clears or we time out.
280  */
281  phy_control = BMCR_RESET;
282  err = tg3_writephy(tp, MII_BMCR, phy_control);
283  if (err != 0)
284  return -EBUSY;
285 
286  limit = 5000;
287  while (limit--) {
288  err = tg3_readphy(tp, MII_BMCR, &phy_control);
289  if (err != 0)
290  return -EBUSY;
291 
292  if ((phy_control & BMCR_RESET) == 0) {
293  udelay(40);
294  break;
295  }
296  udelay(10);
297  }
298  if (limit < 0)
299  return -EBUSY;
300 
301  return 0;
302 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define DBGP(...)
Definition: compiler.h:532
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:442
uint16_t limit
Limit.
Definition: librm.h:136
#define MII_BMCR
Definition: atl1e.h:871
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define BMCR_RESET
Definition: mii.h:52
uint32_t u32
Definition: stdint.h:23

References BMCR_RESET, DBGP, EBUSY, limit, MII_BMCR, tg3_readphy(), tg3_writephy(), tp, and udelay().

Referenced by tg3_phy_reset(), and tg3_phy_reset_5703_4_5().

◆ tg3_wait_macro_done()

static int tg3_wait_macro_done ( struct tg3 tp)
static

Definition at line 304 of file tg3_phy.c.

305 { DBGP("%s\n", __func__);
306 
307  int limit = 100;
308 
309  while (limit--) {
310  u32 tmp32;
311 
312  if (!tg3_readphy(tp, MII_TG3_DSP_CONTROL, &tmp32)) {
313  if ((tmp32 & 0x1000) == 0)
314  break;
315  }
316  }
317  if (limit < 0)
318  return -EBUSY;
319 
320  return 0;
321 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
uint16_t limit
Limit.
Definition: librm.h:136
#define MII_TG3_DSP_CONTROL
Definition: tg3.h:2333
uint32_t u32
Definition: stdint.h:23

References DBGP, EBUSY, limit, MII_TG3_DSP_CONTROL, tg3_readphy(), and tp.

Referenced by tg3_phy_reset_chanpat(), and tg3_phy_write_and_check_testpat().

◆ tg3_phy_write_and_check_testpat()

static int tg3_phy_write_and_check_testpat ( struct tg3 tp,
int *  resetp 
)
static

Definition at line 323 of file tg3_phy.c.

324 { DBGP("%s\n", __func__);
325 
326  static const u32 test_pat[4][6] = {
327  { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
328  { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
329  { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
330  { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
331  };
332  int chan;
333 
334  for (chan = 0; chan < 4; chan++) {
335  int i;
336 
338  (chan * 0x2000) | 0x0200);
340 
341  for (i = 0; i < 6; i++)
343  test_pat[chan][i]);
344 
346  if (tg3_wait_macro_done(tp)) {
347  *resetp = 1;
348  return -EBUSY;
349  }
350 
352  (chan * 0x2000) | 0x0200);
354  if (tg3_wait_macro_done(tp)) {
355  *resetp = 1;
356  return -EBUSY;
357  }
358 
360  if (tg3_wait_macro_done(tp)) {
361  *resetp = 1;
362  return -EBUSY;
363  }
364 
365  for (i = 0; i < 6; i += 2) {
366  u32 low, high;
367 
371  *resetp = 1;
372  return -EBUSY;
373  }
374  low &= 0x7fff;
375  high &= 0x000f;
376  if (low != test_pat[chan][i] ||
377  high != test_pat[chan][i+1]) {
381 
382  return -EBUSY;
383  }
384  }
385  }
386 
387  return 0;
388 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
uint32_t low
Low 16 bits of address.
Definition: myson.h:19
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define MII_TG3_DSP_RW_PORT
Definition: tg3.h:2332
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
uint32_t high
High 32 bits of address.
Definition: myson.h:20
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define MII_TG3_DSP_ADDRESS
Definition: tg3.h:2334
#define MII_TG3_DSP_CONTROL
Definition: tg3.h:2333
static int tg3_wait_macro_done(struct tg3 *tp)
Definition: tg3_phy.c:304
uint32_t u32
Definition: stdint.h:23

References DBGP, EBUSY, high, low, MII_TG3_DSP_ADDRESS, MII_TG3_DSP_CONTROL, MII_TG3_DSP_RW_PORT, tg3_readphy(), tg3_wait_macro_done(), tg3_writephy(), and tp.

Referenced by tg3_phy_reset_5703_4_5().

◆ tg3_phy_reset_chanpat()

static int tg3_phy_reset_chanpat ( struct tg3 tp)
static

Definition at line 390 of file tg3_phy.c.

391 { DBGP("%s\n", __func__);
392 
393  int chan;
394 
395  for (chan = 0; chan < 4; chan++) {
396  int i;
397 
399  (chan * 0x2000) | 0x0200);
401  for (i = 0; i < 6; i++)
404  if (tg3_wait_macro_done(tp))
405  return -EBUSY;
406  }
407 
408  return 0;
409 }
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define MII_TG3_DSP_RW_PORT
Definition: tg3.h:2332
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define MII_TG3_DSP_ADDRESS
Definition: tg3.h:2334
#define MII_TG3_DSP_CONTROL
Definition: tg3.h:2333
static int tg3_wait_macro_done(struct tg3 *tp)
Definition: tg3_phy.c:304

References DBGP, EBUSY, MII_TG3_DSP_ADDRESS, MII_TG3_DSP_CONTROL, MII_TG3_DSP_RW_PORT, tg3_wait_macro_done(), tg3_writephy(), and tp.

Referenced by tg3_phy_reset_5703_4_5().

◆ tg3_phydsp_write()

static int tg3_phydsp_write ( struct tg3 tp,
u32  reg,
u32  val 
)
static

Definition at line 411 of file tg3_phy.c.

412 { DBGP("%s\n", __func__);
413 
414  int err;
415 
417  if (!err)
419 
420  return err;
421 }
static unsigned int unsigned int reg
Definition: myson.h:162
void __asmcall int val
Definition: setjmp.h:12
#define MII_TG3_DSP_RW_PORT
Definition: tg3.h:2332
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define MII_TG3_DSP_ADDRESS
Definition: tg3.h:2334

References DBGP, MII_TG3_DSP_ADDRESS, MII_TG3_DSP_RW_PORT, reg, tg3_writephy(), tp, and val.

Referenced by tg3_init_5401phy_dsp(), tg3_phy_apply_otp(), tg3_phy_reset(), and tg3_phy_reset_5703_4_5().

◆ tg3_phy_auxctl_write()

static int tg3_phy_auxctl_write ( struct tg3 tp,
int  reg,
u32  set 
)
static

Definition at line 423 of file tg3_phy.c.

424 { DBGP("%s\n", __func__);
425 
428 
429  return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg);
430 }
#define MII_TG3_AUX_CTRL
Definition: tg3.h:2355
#define MII_TG3_AUXCTL_MISC_WREN
Definition: tg3.h:2375
static unsigned int unsigned int reg
Definition: myson.h:162
struct option_descriptor set[0]
Definition: nvo_cmd.c:111
#define MII_TG3_AUXCTL_SHDWSEL_MISC
Definition: tg3.h:2371
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222

References DBGP, MII_TG3_AUX_CTRL, MII_TG3_AUXCTL_MISC_WREN, MII_TG3_AUXCTL_SHDWSEL_MISC, reg, set, tg3_writephy(), and tp.

Referenced by tg3_init_5401phy_dsp(), tg3_phy_reset(), tg3_phy_set_wirespeed(), tg3_phy_toggle_automdix(), and tg3_setup_copper_phy().

◆ tg3_phy_reset_5703_4_5()

static int tg3_phy_reset_5703_4_5 ( struct tg3 tp)
static

Definition at line 441 of file tg3_phy.c.

442 { DBGP("%s\n", __func__);
443 
444  u32 reg32, phy9_orig;
445  int retries, do_phy_reset, err;
446 
447  retries = 10;
448  do_phy_reset = 1;
449  do {
450  if (do_phy_reset) {
451  err = tg3_bmcr_reset(tp);
452  if (err)
453  return err;
454  do_phy_reset = 0;
455  }
456 
457  /* Disable transmitter and interrupt. */
458  if (tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32))
459  continue;
460 
461  reg32 |= 0x3000;
463 
464  /* Set full-duplex, 1000 mbps. */
467 
468  /* Set to master mode. */
469  if (tg3_readphy(tp, MII_TG3_CTRL, &phy9_orig))
470  continue;
471 
475 
477  if (err)
478  return err;
479 
480  /* Block the PHY control access. */
481  tg3_phydsp_write(tp, 0x8005, 0x0800);
482 
483  err = tg3_phy_write_and_check_testpat(tp, &do_phy_reset);
484  if (!err)
485  break;
486  } while (--retries);
487 
488  err = tg3_phy_reset_chanpat(tp);
489  if (err)
490  return err;
491 
492  tg3_phydsp_write(tp, 0x8005, 0x0000);
493 
496 
498 
499  tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
500 
501  if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32)) {
502  reg32 &= ~0x3000;
504  } else if (!err)
505  err = -EBUSY;
506 
507  return err;
508 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static int tg3_phy_reset_chanpat(struct tg3 *tp)
Definition: tg3_phy.c:390
static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
Definition: tg3_phy.c:411
#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)
Definition: tg3_phy.c:432
#define DBGP(...)
Definition: compiler.h:532
#define MII_TG3_CTRL_ENABLE_AS_MASTER
Definition: tg3.h:2316
static struct tulip_private * tp
Definition: tulip.c:442
static int tg3_bmcr_reset(struct tg3 *tp)
Definition: tg3_phy.c:272
#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp)
Definition: tg3_phy.c:437
#define MII_BMCR
Definition: atl1e.h:871
#define MII_TG3_EXT_CTRL
Definition: tg3.h:2322
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define MII_TG3_DSP_ADDRESS
Definition: tg3.h:2334
static int tg3_phy_write_and_check_testpat(struct tg3 *tp, int *resetp)
Definition: tg3_phy.c:323
#define MII_TG3_DSP_CONTROL
Definition: tg3.h:2333
#define TG3_BMCR_SPEED1000
Definition: tg3.h:2310
#define MII_TG3_CTRL
Definition: tg3.h:2312
#define MII_TG3_CTRL_AS_MASTER
Definition: tg3.h:2315
uint32_t u32
Definition: stdint.h:23
#define BMCR_FULLDPLX
Definition: mii.h:45

References BMCR_FULLDPLX, DBGP, EBUSY, MII_BMCR, MII_TG3_CTRL, MII_TG3_CTRL_AS_MASTER, MII_TG3_CTRL_ENABLE_AS_MASTER, MII_TG3_DSP_ADDRESS, MII_TG3_DSP_CONTROL, MII_TG3_EXT_CTRL, tg3_bmcr_reset(), TG3_BMCR_SPEED1000, TG3_PHY_AUXCTL_SMDSP_DISABLE, TG3_PHY_AUXCTL_SMDSP_ENABLE, tg3_phy_reset_chanpat(), tg3_phy_write_and_check_testpat(), tg3_phydsp_write(), tg3_readphy(), tg3_writephy(), and tp.

Referenced by tg3_phy_reset().

◆ tg3_phy_apply_otp()

static void tg3_phy_apply_otp ( struct tg3 tp)
static

Definition at line 510 of file tg3_phy.c.

511 { DBGP("%s\n", __func__);
512 
513  u32 otp, phy;
514 
515  if (!tp->phy_otp)
516  return;
517 
518  otp = tp->phy_otp;
519 
521  return;
522 
523  phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT);
526 
527  phy = ((otp & TG3_OTP_HPFFLTR_MASK) >> TG3_OTP_HPFFLTR_SHIFT) |
530 
531  phy = ((otp & TG3_OTP_LPFDIS_MASK) >> TG3_OTP_LPFDIS_SHIFT);
534 
535  phy = ((otp & TG3_OTP_VDAC_MASK) >> TG3_OTP_VDAC_SHIFT);
537 
538  phy = ((otp & TG3_OTP_10BTAMP_MASK) >> TG3_OTP_10BTAMP_SHIFT);
540 
541  phy = ((otp & TG3_OTP_ROFF_MASK) >> TG3_OTP_ROFF_SHIFT) |
544 
546 }
#define TG3_OTP_LPFDIS_MASK
Definition: tg3.h:2127
#define MII_TG3_DSP_TAP1
Definition: tg3.h:2336
#define MII_TG3_DSP_EXP97
Definition: tg3.h:2353
#define TG3_OTP_10BTAMP_SHIFT
Definition: tg3.h:2132
#define TG3_OTP_HPFFLTR_SHIFT
Definition: tg3.h:2124
#define TG3_OTP_RCOFF_SHIFT
Definition: tg3.h:2136
#define TG3_OTP_HPFFLTR_MASK
Definition: tg3.h:2123
#define TG3_OTP_ROFF_MASK
Definition: tg3.h:2133
#define MII_TG3_DSP_EXP75
Definition: tg3.h:2351
static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
Definition: tg3_phy.c:411
#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)
Definition: tg3_phy.c:432
#define TG3_OTP_LPFDIS_SHIFT
Definition: tg3.h:2128
#define TG3_OTP_VDAC_MASK
Definition: tg3.h:2129
#define DBGP(...)
Definition: compiler.h:532
#define TG3_OTP_VDAC_SHIFT
Definition: tg3.h:2130
#define TG3_OTP_HPFOVER_SHIFT
Definition: tg3.h:2126
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_TG3_DSP_AADJ1CH0
Definition: tg3.h:2342
#define TG3_OTP_HPFOVER_MASK
Definition: tg3.h:2125
#define MII_TG3_DSP_EXP96
Definition: tg3.h:2352
#define TG3_OTP_AGCTGT_MASK
Definition: tg3.h:2121
#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp)
Definition: tg3_phy.c:437
#define MII_TG3_DSP_AADJ1CH3
Definition: tg3.h:2345
#define MII_TG3_DSP_TAP1_AGCTGT_DFLT
Definition: tg3.h:2337
#define TG3_OTP_10BTAMP_MASK
Definition: tg3.h:2131
#define TG3_OTP_RCOFF_MASK
Definition: tg3.h:2135
#define TG3_OTP_AGCTGT_SHIFT
Definition: tg3.h:2122
#define TG3_OTP_ROFF_SHIFT
Definition: tg3.h:2134
#define MII_TG3_DSP_AADJ1CH3_ADCCKADJ
Definition: tg3.h:2346
uint32_t u32
Definition: stdint.h:23

References DBGP, MII_TG3_DSP_AADJ1CH0, MII_TG3_DSP_AADJ1CH3, MII_TG3_DSP_AADJ1CH3_ADCCKADJ, MII_TG3_DSP_EXP75, MII_TG3_DSP_EXP96, MII_TG3_DSP_EXP97, MII_TG3_DSP_TAP1, MII_TG3_DSP_TAP1_AGCTGT_DFLT, TG3_OTP_10BTAMP_MASK, TG3_OTP_10BTAMP_SHIFT, TG3_OTP_AGCTGT_MASK, TG3_OTP_AGCTGT_SHIFT, TG3_OTP_HPFFLTR_MASK, TG3_OTP_HPFFLTR_SHIFT, TG3_OTP_HPFOVER_MASK, TG3_OTP_HPFOVER_SHIFT, TG3_OTP_LPFDIS_MASK, TG3_OTP_LPFDIS_SHIFT, TG3_OTP_RCOFF_MASK, TG3_OTP_RCOFF_SHIFT, TG3_OTP_ROFF_MASK, TG3_OTP_ROFF_SHIFT, TG3_OTP_VDAC_MASK, TG3_OTP_VDAC_SHIFT, TG3_PHY_AUXCTL_SMDSP_DISABLE, TG3_PHY_AUXCTL_SMDSP_ENABLE, tg3_phydsp_write(), and tp.

Referenced by tg3_phy_reset().

◆ tg3_phy_auxctl_read()

static int tg3_phy_auxctl_read ( struct tg3 tp,
int  reg,
u32 val 
)
static

Definition at line 548 of file tg3_phy.c.

549 { DBGP("%s\n", __func__);
550 
551  int err;
552 
556  if (!err)
558 
559  return err;
560 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define MII_TG3_AUX_CTRL
Definition: tg3.h:2355
static unsigned int unsigned int reg
Definition: myson.h:162
void __asmcall int val
Definition: setjmp.h:12
#define MII_TG3_AUXCTL_SHDWSEL_MISC
Definition: tg3.h:2371
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_TG3_AUXCTL_MISC_RDSEL_SHIFT
Definition: tg3.h:2374
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222

References DBGP, MII_TG3_AUX_CTRL, MII_TG3_AUXCTL_MISC_RDSEL_SHIFT, MII_TG3_AUXCTL_SHDWSEL_MISC, reg, tg3_readphy(), tg3_writephy(), tp, and val.

Referenced by tg3_phy_set_wirespeed(), tg3_phy_toggle_automdix(), and tg3_setup_copper_phy().

◆ tg3_phy_toggle_automdix()

static void tg3_phy_toggle_automdix ( struct tg3 tp,
int  enable 
)
static

Definition at line 562 of file tg3_phy.c.

563 { DBGP("%s\n", __func__);
564 
565  u32 phy;
566 
567  if (!tg3_flag(tp, 5705_PLUS) ||
568  (tp->phy_flags & TG3_PHYFLG_ANY_SERDES))
569  return;
570 
571  if (tp->phy_flags & TG3_PHYFLG_IS_FET) {
572  u32 ephy;
573 
574  if (!tg3_readphy(tp, MII_TG3_FET_TEST, &ephy)) {
576 
578  ephy | MII_TG3_FET_SHADOW_EN);
579  if (!tg3_readphy(tp, reg, &phy)) {
580  if (enable)
582  else
584  tg3_writephy(tp, reg, phy);
585  }
587  }
588  } else {
589  int ret;
590 
591  ret = tg3_phy_auxctl_read(tp,
593  if (!ret) {
594  if (enable)
596  else
600  }
601  }
602 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define MII_TG3_FET_SHDW_MISCCTRL
Definition: tg3.h:2432
static unsigned int unsigned int reg
Definition: myson.h:162
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:423
#define MII_TG3_AUXCTL_SHDWSEL_MISC
Definition: tg3.h:2371
#define MII_TG3_AUXCTL_MISC_FORCE_AMDIX
Definition: tg3.h:2373
#define MII_TG3_FET_SHADOW_EN
Definition: tg3.h:2430
#define MII_TG3_FET_SHDW_MISCCTRL_MDIX
Definition: tg3.h:2433
#define TG3_PHYFLG_ANY_SERDES
Definition: tg3.h:3239
#define TG3_PHYFLG_IS_FET
Definition: tg3.h:3241
#define DBGP(...)
Definition: compiler.h:532
#define MII_TG3_FET_TEST
Definition: tg3.h:2429
static struct tulip_private * tp
Definition: tulip.c:442
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
static int tg3_phy_auxctl_read(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:548
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
uint32_t u32
Definition: stdint.h:23

References DBGP, MII_TG3_AUXCTL_MISC_FORCE_AMDIX, MII_TG3_AUXCTL_SHDWSEL_MISC, MII_TG3_FET_SHADOW_EN, MII_TG3_FET_SHDW_MISCCTRL, MII_TG3_FET_SHDW_MISCCTRL_MDIX, MII_TG3_FET_TEST, reg, tg3_flag, tg3_phy_auxctl_read(), tg3_phy_auxctl_write(), TG3_PHYFLG_ANY_SERDES, TG3_PHYFLG_IS_FET, tg3_readphy(), tg3_writephy(), and tp.

Referenced by tg3_phy_reset().

◆ tg3_phy_set_wirespeed()

static void tg3_phy_set_wirespeed ( struct tg3 tp)
static

Definition at line 604 of file tg3_phy.c.

605 { DBGP("%s\n", __func__);
606 
607  int ret;
608  u32 val;
609 
610  if (tp->phy_flags & TG3_PHYFLG_NO_ETH_WIRE_SPEED)
611  return;
612 
614  if (!ret)
617 }
void __asmcall int val
Definition: setjmp.h:12
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:423
#define MII_TG3_AUXCTL_MISC_WIRESPD_EN
Definition: tg3.h:2372
#define MII_TG3_AUXCTL_SHDWSEL_MISC
Definition: tg3.h:2371
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
static int tg3_phy_auxctl_read(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:548
uint32_t u32
Definition: stdint.h:23
#define TG3_PHYFLG_NO_ETH_WIRE_SPEED
Definition: tg3.h:3245

References DBGP, MII_TG3_AUXCTL_MISC_WIRESPD_EN, MII_TG3_AUXCTL_SHDWSEL_MISC, tg3_phy_auxctl_read(), tg3_phy_auxctl_write(), TG3_PHYFLG_NO_ETH_WIRE_SPEED, tp, and val.

Referenced by tg3_phy_probe(), and tg3_phy_reset().

◆ tg3_phy_reset()

int tg3_phy_reset ( struct tg3 tp)

Definition at line 622 of file tg3_phy.c.

623 { DBGP("%s\n", __func__);
624 
625  u32 val, cpmuctrl;
626  int err;
627 
628  DBGCP(&tp->pdev->dev, "%s\n", __func__);
629 
630  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
631  val = tr32(GRC_MISC_CFG);
633  udelay(40);
634  }
635  err = tg3_readphy(tp, MII_BMSR, &val);
636  err |= tg3_readphy(tp, MII_BMSR, &val);
637  if (err != 0)
638  return -EBUSY;
639 
640  netdev_link_down(tp->dev);
642 
643  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
644  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
645  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
646  err = tg3_phy_reset_5703_4_5(tp);
647  if (err)
648  return err;
649  goto out;
650  }
651 
652  cpmuctrl = 0;
653  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 &&
654  GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5784_AX) {
655  cpmuctrl = tr32(TG3_CPMU_CTRL);
656  if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY)
658  cpmuctrl & ~CPMU_CTRL_GPHY_10MB_RXONLY);
659  }
660 
661  err = tg3_bmcr_reset(tp);
662  if (err)
663  return err;
664 
665  if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY) {
668 
669  tw32(TG3_CPMU_CTRL, cpmuctrl);
670  }
671 
672  if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX ||
673  GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX) {
678  udelay(40);
680  }
681  }
682 
683  if (tg3_flag(tp, 5717_PLUS) &&
684  (tp->phy_flags & TG3_PHYFLG_MII_SERDES))
685  return 0;
686 
688 
689 out:
690  if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) &&
692  tg3_phydsp_write(tp, 0x201f, 0x2aaa);
693  tg3_phydsp_write(tp, 0x000a, 0x0323);
695  }
696 
697  if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) {
700  }
701 
702  if (tp->phy_flags & TG3_PHYFLG_BER_BUG) {
704  tg3_phydsp_write(tp, 0x000a, 0x310b);
705  tg3_phydsp_write(tp, 0x201f, 0x9506);
706  tg3_phydsp_write(tp, 0x401f, 0x14e2);
708  }
709  } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) {
712  if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) {
715  MII_TG3_TEST1_TRIM_EN | 0x4);
716  } else
718 
720  }
721  }
722 
723  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) {
724  /* Cannot do read-modify-write on 5401 */
726  }
727 
728  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
729  /* adjust output voltage */
731  }
732 
735  return 0;
736 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define TG3_PHYFLG_5704_A0_BUG
Definition: tg3.h:3249
#define ASIC_REV_5784
Definition: tg3.h:312
#define CHIPREV_5784_AX
Definition: tg3.h:331
#define tr32(reg)
Definition: tg3.h:3339
#define TG3_PHYFLG_BER_BUG
Definition: tg3.h:3250
#define EBUSY
Device or resource busy.
Definition: errno.h:338
void __asmcall int val
Definition: setjmp.h:12
static void tg3_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1261
static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
Definition: tg3_phy.c:441
#define CPMU_LSPD_1000MB_MACCLK_12_5
Definition: tg3.h:1231
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:423
#define ASIC_REV_5906
Definition: tg3.h:310
#define MII_TG3_DSP_RW_PORT
Definition: tg3.h:2332
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
__be32 out[4]
Definition: CIB_PRM.h:36
#define GET_ASIC_REV(CHIP_REV_ID)
Definition: tg3.h:298
static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
Definition: tg3_phy.c:411
#define CPMU_CTRL_GPHY_10MB_RXONLY
Definition: tg3.h:1223
#define TG3_PHYFLG_MII_SERDES
Definition: tg3.h:3238
#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)
Definition: tg3_phy.c:432
#define MII_TG3_TEST1_TRIM_EN
Definition: tg3.h:2415
#define DBGP(...)
Definition: compiler.h:532
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define TG3_PHYFLG_ADC_BUG
Definition: tg3.h:3248
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_TG3_DSP_EXP8_REJ2MHz
Definition: tg3.h:2349
#define ASIC_REV_5704
Definition: tg3.h:302
static int tg3_bmcr_reset(struct tg3 *tp)
Definition: tg3_phy.c:272
#define MII_TG3_DSP_EXP8_AEDW
Definition: tg3.h:2350
#define ASIC_REV_5705
Definition: tg3.h:303
#define TG3_PHYFLG_ADJUST_TRIM
Definition: tg3.h:3247
#define ASIC_REV_5703
Definition: tg3.h:301
#define MII_TG3_MISC_SHDW
Definition: tg3.h:2400
#define MII_TG3_DSP_EXP8
Definition: tg3.h:2348
#define TG3_CPMU_CTRL
Definition: tg3.h:1219
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define GRC_MISC_CFG_EPHY_IDDQ
Definition: tg3.h:1835
#define MII_TG3_FET_PTEST
Definition: tg3.h:2425
#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp)
Definition: tg3_phy.c:437
#define CHIPREV_5761_AX
Definition: tg3.h:332
#define tw32_f(reg, val)
Definition: tg3.h:3333
static void tg3_phy_apply_otp(struct tg3 *tp)
Definition: tg3_phy.c:510
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define CPMU_LSPD_1000MB_MACCLK_MASK
Definition: tg3.h:1232
#define MII_TG3_DSP_ADDRESS
Definition: tg3.h:2334
#define TG3_CPMU_LSPD_1000MB_CLK
Definition: tg3.h:1229
static void tg3_phy_set_wirespeed(struct tg3 *tp)
Definition: tg3_phy.c:604
#define TG3_PHYFLG_JITTER_BUG
Definition: tg3.h:3246
#define tw32(reg, val)
Definition: tg3.h:3329
#define DBGCP(...)
Definition: compiler.h:539
#define GRC_MISC_CFG
Definition: tg3.h:1819
#define GET_CHIP_REV(CHIP_REV_ID)
Definition: tg3.h:321
static void tg3_phy_toggle_automdix(struct tg3 *tp, int enable)
Definition: tg3_phy.c:562
#define MII_BMSR
Definition: atl1e.h:872
#define MII_TG3_TEST1
Definition: tg3.h:2414
uint32_t u32
Definition: stdint.h:23
#define TG3_PHY_ID_MASK
Definition: tg3.h:3185
#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL
Definition: tg3.h:2357
#define TG3_PHY_ID_BCM5401
Definition: tg3.h:3187

References ASIC_REV_5703, ASIC_REV_5704, ASIC_REV_5705, ASIC_REV_5784, ASIC_REV_5906, CHIPREV_5761_AX, CHIPREV_5784_AX, CPMU_CTRL_GPHY_10MB_RXONLY, CPMU_LSPD_1000MB_MACCLK_12_5, CPMU_LSPD_1000MB_MACCLK_MASK, DBGCP, DBGP, EBUSY, GET_ASIC_REV, GET_CHIP_REV, GRC_MISC_CFG, GRC_MISC_CFG_EPHY_IDDQ, MII_BMSR, MII_TG3_AUXCTL_SHDWSEL_AUXCTL, MII_TG3_DSP_ADDRESS, MII_TG3_DSP_EXP8, MII_TG3_DSP_EXP8_AEDW, MII_TG3_DSP_EXP8_REJ2MHz, MII_TG3_DSP_RW_PORT, MII_TG3_FET_PTEST, MII_TG3_MISC_SHDW, MII_TG3_TEST1, MII_TG3_TEST1_TRIM_EN, netdev_link_down(), out, tg3_bmcr_reset(), TG3_CPMU_CTRL, TG3_CPMU_LSPD_1000MB_CLK, tg3_flag, tg3_link_report(), tg3_phy_apply_otp(), TG3_PHY_AUXCTL_SMDSP_DISABLE, TG3_PHY_AUXCTL_SMDSP_ENABLE, tg3_phy_auxctl_write(), TG3_PHY_ID_BCM5401, TG3_PHY_ID_MASK, tg3_phy_reset_5703_4_5(), tg3_phy_set_wirespeed(), tg3_phy_toggle_automdix(), tg3_phydsp_write(), TG3_PHYFLG_5704_A0_BUG, TG3_PHYFLG_ADC_BUG, TG3_PHYFLG_ADJUST_TRIM, TG3_PHYFLG_BER_BUG, TG3_PHYFLG_JITTER_BUG, TG3_PHYFLG_MII_SERDES, tg3_readphy(), tg3_writephy(), tp, tr32, tw32, tw32_f, udelay(), and val.

Referenced by tg3_phy_probe(), tg3_reset_hw(), tg3_setup_copper_phy(), and tg3_setup_fiber_mii_phy().

◆ tg3_copper_is_advertising_all()

static int tg3_copper_is_advertising_all ( struct tg3 tp,
u32  mask 
)
static

Definition at line 738 of file tg3_phy.c.

739 { DBGP("%s\n", __func__);
740 
741  u32 adv_reg, all_mask = 0;
742 
743  if (mask & ADVERTISED_10baseT_Half)
744  all_mask |= ADVERTISE_10HALF;
745  if (mask & ADVERTISED_10baseT_Full)
746  all_mask |= ADVERTISE_10FULL;
747  if (mask & ADVERTISED_100baseT_Half)
748  all_mask |= ADVERTISE_100HALF;
749  if (mask & ADVERTISED_100baseT_Full)
750  all_mask |= ADVERTISE_100FULL;
751 
752  if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg))
753  return 0;
754 
755  if ((adv_reg & all_mask) != all_mask)
756  return 0;
757  if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) {
758  u32 tg3_ctrl;
759 
760  all_mask = 0;
761  if (mask & ADVERTISED_1000baseT_Half)
762  all_mask |= ADVERTISE_1000HALF;
763  if (mask & ADVERTISED_1000baseT_Full)
764  all_mask |= ADVERTISE_1000FULL;
765 
766  if (tg3_readphy(tp, MII_TG3_CTRL, &tg3_ctrl))
767  return 0;
768 
769  if ((tg3_ctrl & all_mask) != all_mask)
770  return 0;
771  }
772  return 1;
773 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define MII_ADVERTISE
Definition: atl1e.h:875
#define ADVERTISE_1000FULL
Definition: mii.h:133
#define ADVERTISE_10FULL
Definition: mii.h:76
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
#define TG3_PHYFLG_10_100_ONLY
Definition: tg3.h:3242
#define ADVERTISE_100FULL
Definition: mii.h:80
#define ADVERTISED_1000baseT_Half
Definition: bnx2.h:46
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
#define ADVERTISE_1000HALF
Definition: mii.h:134
#define ADVERTISE_10HALF
Definition: mii.h:74
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define ADVERTISE_100HALF
Definition: mii.h:78
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
#define MII_TG3_CTRL
Definition: tg3.h:2312
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
uint32_t u32
Definition: stdint.h:23

References ADVERTISE_1000FULL, ADVERTISE_1000HALF, ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, ADVERTISED_1000baseT_Full, ADVERTISED_1000baseT_Half, ADVERTISED_100baseT_Full, ADVERTISED_100baseT_Half, ADVERTISED_10baseT_Full, ADVERTISED_10baseT_Half, DBGP, MII_ADVERTISE, MII_TG3_CTRL, TG3_PHYFLG_10_100_ONLY, tg3_readphy(), and tp.

Referenced by tg3_phy_probe(), and tg3_setup_copper_phy().

◆ tg3_advert_flowctrl_1000T()

static u16 tg3_advert_flowctrl_1000T ( u8  flow_ctrl)
static

Definition at line 775 of file tg3_phy.c.

776 { DBGP("%s\n", __func__);
777 
778  u16 miireg;
779 
780  if ((flow_ctrl & FLOW_CTRL_TX) && (flow_ctrl & FLOW_CTRL_RX))
781  miireg = ADVERTISE_PAUSE_CAP;
782  else if (flow_ctrl & FLOW_CTRL_TX)
783  miireg = ADVERTISE_PAUSE_ASYM;
784  else if (flow_ctrl & FLOW_CTRL_RX)
786  else
787  miireg = 0;
788 
789  return miireg;
790 }
uint16_t u16
Definition: stdint.h:21
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define DBGP(...)
Definition: compiler.h:532
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83

References ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, DBGP, FLOW_CTRL_RX, and FLOW_CTRL_TX.

Referenced by tg3_adv_1000T_flowctrl_ok(), and tg3_phy_autoneg_cfg().

◆ tg3_phy_autoneg_cfg()

static int tg3_phy_autoneg_cfg ( struct tg3 tp,
u32  advertise,
u32  flowctrl 
)
static

Definition at line 792 of file tg3_phy.c.

793 { DBGP("%s\n", __func__);
794 
795  int err = 0;
796  u32 val __unused, new_adv;
797 
798  new_adv = ADVERTISE_CSMA;
799  if (advertise & ADVERTISED_10baseT_Half)
800  new_adv |= ADVERTISE_10HALF;
801  if (advertise & ADVERTISED_10baseT_Full)
802  new_adv |= ADVERTISE_10FULL;
803  if (advertise & ADVERTISED_100baseT_Half)
804  new_adv |= ADVERTISE_100HALF;
805  if (advertise & ADVERTISED_100baseT_Full)
806  new_adv |= ADVERTISE_100FULL;
807 
809 
810  err = tg3_writephy(tp, MII_ADVERTISE, new_adv);
811  if (err)
812  goto done;
813 
814  if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)
815  goto done;
816 
817  new_adv = 0;
818  if (advertise & ADVERTISED_1000baseT_Half)
819  new_adv |= MII_TG3_CTRL_ADV_1000_HALF;
820  if (advertise & ADVERTISED_1000baseT_Full)
821  new_adv |= MII_TG3_CTRL_ADV_1000_FULL;
822 
823  if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
824  tp->pci_chip_rev_id == CHIPREV_ID_5701_B0)
825  new_adv |= (MII_TG3_CTRL_AS_MASTER |
827 
828  err = tg3_writephy(tp, MII_TG3_CTRL, new_adv);
829  if (err)
830  goto done;
831 
832  if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP))
833  goto done;
834 
835 done:
836  return err;
837 }
#define MII_ADVERTISE
Definition: atl1e.h:875
void __asmcall int val
Definition: setjmp.h:12
#define ADVERTISE_10FULL
Definition: mii.h:76
#define MII_TG3_CTRL_ADV_1000_FULL
Definition: tg3.h:2314
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
#define TG3_PHYFLG_10_100_ONLY
Definition: tg3.h:3242
#define CHIPREV_ID_5701_B0
Definition: tg3.h:268
#define ADVERTISE_100FULL
Definition: mii.h:80
static int flowctrl
Definition: sundance.c:75
#define ADVERTISED_1000baseT_Half
Definition: bnx2.h:46
#define DBGP(...)
Definition: compiler.h:532
#define MII_TG3_CTRL_ENABLE_AS_MASTER
Definition: tg3.h:2316
static u16 tg3_advert_flowctrl_1000T(u8 flow_ctrl)
Definition: tg3_phy.c:775
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
static struct tulip_private * tp
Definition: tulip.c:442
#define ADVERTISE_CSMA
Definition: mii.h:73
#define MII_TG3_CTRL_ADV_1000_HALF
Definition: tg3.h:2313
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define CHIPREV_ID_5701_A0
Definition: tg3.h:267
#define TG3_PHYFLG_EEE_CAP
Definition: tg3.h:3253
#define ADVERTISE_10HALF
Definition: mii.h:74
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define ADVERTISE_100HALF
Definition: mii.h:78
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
#define MII_TG3_CTRL
Definition: tg3.h:2312
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
#define MII_TG3_CTRL_AS_MASTER
Definition: tg3.h:2315
struct bofm_section_header done
Definition: bofm_test.c:46
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
uint32_t u32
Definition: stdint.h:23

References __unused, ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_10FULL, ADVERTISE_10HALF, ADVERTISE_CSMA, ADVERTISED_1000baseT_Full, ADVERTISED_1000baseT_Half, ADVERTISED_100baseT_Full, ADVERTISED_100baseT_Half, ADVERTISED_10baseT_Full, ADVERTISED_10baseT_Half, CHIPREV_ID_5701_A0, CHIPREV_ID_5701_B0, DBGP, done, flowctrl, MII_ADVERTISE, MII_TG3_CTRL, MII_TG3_CTRL_ADV_1000_FULL, MII_TG3_CTRL_ADV_1000_HALF, MII_TG3_CTRL_AS_MASTER, MII_TG3_CTRL_ENABLE_AS_MASTER, tg3_advert_flowctrl_1000T(), TG3_PHYFLG_10_100_ONLY, TG3_PHYFLG_EEE_CAP, tg3_writephy(), tp, and val.

Referenced by tg3_phy_copper_begin(), and tg3_phy_probe().

◆ tg3_init_5401phy_dsp()

static int tg3_init_5401phy_dsp ( struct tg3 tp)
static

Definition at line 839 of file tg3_phy.c.

840 { DBGP("%s\n", __func__);
841 
842  int err;
843 
844  /* Turn off tap power management. */
845  /* Set Extended packet length bit */
847 
848  err |= tg3_phydsp_write(tp, 0x0012, 0x1804);
849  err |= tg3_phydsp_write(tp, 0x0013, 0x1204);
850  err |= tg3_phydsp_write(tp, 0x8006, 0x0132);
851  err |= tg3_phydsp_write(tp, 0x8006, 0x0232);
852  err |= tg3_phydsp_write(tp, 0x201f, 0x0a20);
853 
854  udelay(40);
855 
856  return err;
857 }
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:423
static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
Definition: tg3_phy.c:411
#define DBGP(...)
Definition: compiler.h:532
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL
Definition: tg3.h:2357

References DBGP, MII_TG3_AUXCTL_SHDWSEL_AUXCTL, tg3_phy_auxctl_write(), tg3_phydsp_write(), tp, and udelay().

Referenced by tg3_phy_probe(), and tg3_setup_copper_phy().

◆ tg3_phy_init_link_config()

static void tg3_phy_init_link_config ( struct tg3 tp)
static

Definition at line 866 of file tg3_phy.c.

867 { DBGP("%s\n", __func__);
868 
869  u32 adv = ADVERTISED_Autoneg |
871 
872 
873  if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY))
876  if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES))
877  adv |= ADVERTISED_100baseT_Half |
882  else
883  adv |= ADVERTISED_FIBRE;
884 
885  tp->link_config.advertising = adv;
886  tp->link_config.speed = SPEED_INVALID;
887  tp->link_config.duplex = DUPLEX_INVALID;
888  tp->link_config.autoneg = AUTONEG_ENABLE;
889  tp->link_config.active_speed = SPEED_INVALID;
890  tp->link_config.active_duplex = DUPLEX_INVALID;
891  tp->link_config.orig_speed = SPEED_INVALID;
892  tp->link_config.orig_duplex = DUPLEX_INVALID;
893  tp->link_config.orig_autoneg = AUTONEG_INVALID;
894 }
#define ADVERTISED_Autoneg
Definition: tg3_phy.c:859
#define AUTONEG_INVALID
Definition: tg3.h:2837
#define ADVERTISED_Pause
Definition: tg3_phy.c:860
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
#define TG3_PHYFLG_10_100_ONLY
Definition: tg3.h:3242
#define SPEED_INVALID
Definition: bnx2.h:106
u16 advertising[4]
Definition: tulip.c:418
#define ADVERTISED_FIBRE
Definition: tg3_phy.c:862
#define ADVERTISED_TP
Definition: tg3_phy.c:861
#define ADVERTISED_1000baseT_Half
Definition: bnx2.h:46
#define TG3_PHYFLG_ANY_SERDES
Definition: tg3.h:3239
#define DBGP(...)
Definition: compiler.h:532
#define DUPLEX_INVALID
Definition: bnx2.h:112
static struct tulip_private * tp
Definition: tulip.c:442
#define AUTONEG_ENABLE
Definition: tg3_phy.c:864
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
uint32_t u32
Definition: stdint.h:23

References ADVERTISED_1000baseT_Full, ADVERTISED_1000baseT_Half, ADVERTISED_100baseT_Full, ADVERTISED_100baseT_Half, ADVERTISED_10baseT_Full, ADVERTISED_10baseT_Half, ADVERTISED_Autoneg, ADVERTISED_FIBRE, ADVERTISED_Pause, ADVERTISED_TP, tulip_private::advertising, AUTONEG_ENABLE, AUTONEG_INVALID, DBGP, DUPLEX_INVALID, SPEED_INVALID, TG3_PHYFLG_10_100_ONLY, TG3_PHYFLG_ANY_SERDES, and tp.

Referenced by tg3_phy_probe().

◆ tg3_phy_probe()

int tg3_phy_probe ( struct tg3 tp)

Definition at line 896 of file tg3_phy.c.

897 { DBGP("%s\n", __func__);
898 
899  u32 hw_phy_id_1, hw_phy_id_2;
900  u32 hw_phy_id, hw_phy_id_masked;
901  int err;
902 
903  /* flow control autonegotiation is default behavior */
904  tg3_flag_set(tp, PAUSE_AUTONEG);
905  tp->link_config.flowctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
906 
907  /* Reading the PHY ID register can conflict with ASF
908  * firmware access to the PHY hardware.
909  */
910  err = 0;
911  if (tg3_flag(tp, ENABLE_ASF) || tg3_flag(tp, ENABLE_APE)) {
912  hw_phy_id = hw_phy_id_masked = TG3_PHY_ID_INVALID;
913  } else {
914  /* Now read the physical PHY_ID from the chip and verify
915  * that it is sane. If it doesn't look good, we fall back
916  * to either the hard-coded table based PHY_ID and failing
917  * that the value found in the eeprom area.
918  */
919  err |= tg3_readphy(tp, MII_PHYSID1, &hw_phy_id_1);
920  err |= tg3_readphy(tp, MII_PHYSID2, &hw_phy_id_2);
921 
922  hw_phy_id = (hw_phy_id_1 & 0xffff) << 10;
923  hw_phy_id |= (hw_phy_id_2 & 0xfc00) << 16;
924  hw_phy_id |= (hw_phy_id_2 & 0x03ff) << 0;
925 
926  hw_phy_id_masked = hw_phy_id & TG3_PHY_ID_MASK;
927  }
928 
929  if (!err && TG3_KNOWN_PHY_ID(hw_phy_id_masked)) {
930  tp->phy_id = hw_phy_id;
931  if (hw_phy_id_masked == TG3_PHY_ID_BCM8002)
932  tp->phy_flags |= TG3_PHYFLG_PHY_SERDES;
933  else
934  tp->phy_flags &= ~TG3_PHYFLG_PHY_SERDES;
935  } else {
936  if (tp->phy_id != TG3_PHY_ID_INVALID) {
937  /* Do nothing, phy ID already set up in
938  * tg3_get_eeprom_hw_cfg().
939  */
940  } else {
941  struct subsys_tbl_ent *p;
942 
943  /* No eeprom signature? Try the hardcoded
944  * subsys device table.
945  */
947  if (!p) {
948  DBGC(&tp->pdev->dev, "lookup by subsys failed\n");
949  return -ENODEV;
950  }
951 
952  tp->phy_id = p->phy_id;
953  if (!tp->phy_id ||
954  tp->phy_id == TG3_PHY_ID_BCM8002)
955  tp->phy_flags |= TG3_PHYFLG_PHY_SERDES;
956  }
957  }
958 
959  if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) &&
960  ((tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 &&
961  tp->pci_chip_rev_id != CHIPREV_ID_5717_A0) ||
962  (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 &&
963  tp->pci_chip_rev_id != CHIPREV_ID_57765_A0)))
964  tp->phy_flags |= TG3_PHYFLG_EEE_CAP;
965 
967 
968  if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) &&
969  !tg3_flag(tp, ENABLE_APE) &&
970  !tg3_flag(tp, ENABLE_ASF)) {
971  u32 bmsr;
972  u32 mask;
973 
974  tg3_readphy(tp, MII_BMSR, &bmsr);
975  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
976  (bmsr & BMSR_LSTATUS))
977  goto skip_phy_reset;
978 
979  err = tg3_phy_reset(tp);
980  if (err)
981  return err;
982 
984 
988  if (!tg3_copper_is_advertising_all(tp, mask)) {
989  tg3_phy_autoneg_cfg(tp, tp->link_config.advertising,
990  tp->link_config.flowctrl);
991 
994  }
995  }
996 
997 skip_phy_reset:
998  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) {
999  err = tg3_init_5401phy_dsp(tp);
1000  if (err)
1001  return err;
1002 
1003  err = tg3_init_5401phy_dsp(tp);
1004  }
1005 
1006  return err;
1007 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
static struct subsys_tbl_ent * tg3_lookup_by_subsys(struct tg3 *tp)
Definition: tg3_phy.c:205
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
#define DBGC(...)
Definition: compiler.h:505
#define BMCR_ANRESTART
Definition: mii.h:46
u16 advertising[4]
Definition: tulip.c:418
#define TG3PCI_DEVICE_TIGON3_5718
Definition: tg3.h:198
#define GET_ASIC_REV(CHIP_REV_ID)
Definition: tg3.h:298
#define CHIPREV_ID_57765_A0
Definition: tg3.h:295
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define TG3_PHYFLG_PHY_SERDES
Definition: tg3.h:3237
#define ADVERTISED_1000baseT_Half
Definition: bnx2.h:46
#define TG3_PHYFLG_ANY_SERDES
Definition: tg3.h:3239
int tg3_phy_reset(struct tg3 *tp)
Definition: tg3_phy.c:622
static void tg3_phy_init_link_config(struct tg3 *tp)
Definition: tg3_phy.c:866
#define TG3_PHY_ID_BCM8002
Definition: tg3.h:3208
#define DBGP(...)
Definition: compiler.h:532
#define tg3_flag_set(tp, flag)
Definition: tg3.h:3367
static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
Definition: tg3_phy.c:792
static int tg3_init_5401phy_dsp(struct tg3 *tp)
Definition: tg3_phy.c:839
static struct tulip_private * tp
Definition: tulip.c:442
#define BMSR_LSTATUS
Definition: mii.h:57
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define TG3_PHY_ID_INVALID
Definition: tg3.h:3209
#define ENODEV
No such device.
Definition: errno.h:509
#define MII_BMCR
Definition: atl1e.h:871
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
static void tg3_phy_set_wirespeed(struct tg3 *tp)
Definition: tg3_phy.c:604
#define MII_PHYSID2
Definition: atl1e.h:874
#define TG3_PHYFLG_EEE_CAP
Definition: tg3.h:3253
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define CHIPREV_ID_5717_A0
Definition: tg3.h:294
#define BMCR_ANENABLE
Definition: mii.h:49
static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
Definition: tg3_phy.c:738
#define MII_BMSR
Definition: atl1e.h:872
#define MII_PHYSID1
Definition: atl1e.h:873
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
uint32_t u32
Definition: stdint.h:23
#define TG3_PHY_ID_MASK
Definition: tg3.h:3185
#define TG3_PHY_ID_BCM5401
Definition: tg3.h:3187
#define TG3_KNOWN_PHY_ID(X)
Definition: tg3.h:3220
#define ASIC_REV_57765
Definition: tg3.h:317

References ADVERTISED_1000baseT_Full, ADVERTISED_1000baseT_Half, ADVERTISED_100baseT_Full, ADVERTISED_100baseT_Half, ADVERTISED_10baseT_Full, ADVERTISED_10baseT_Half, tulip_private::advertising, ASIC_REV_57765, BMCR_ANENABLE, BMCR_ANRESTART, BMSR_LSTATUS, CHIPREV_ID_5717_A0, CHIPREV_ID_57765_A0, DBGC, DBGP, ENODEV, FLOW_CTRL_RX, FLOW_CTRL_TX, GET_ASIC_REV, MII_BMCR, MII_BMSR, MII_PHYSID1, MII_PHYSID2, subsys_tbl_ent::phy_id, tg3_copper_is_advertising_all(), tg3_flag, tg3_flag_set, tg3_init_5401phy_dsp(), TG3_KNOWN_PHY_ID, tg3_lookup_by_subsys(), tg3_phy_autoneg_cfg(), TG3_PHY_ID_BCM5401, TG3_PHY_ID_BCM8002, TG3_PHY_ID_INVALID, TG3_PHY_ID_MASK, tg3_phy_init_link_config(), tg3_phy_reset(), tg3_phy_set_wirespeed(), TG3_PHYFLG_ANY_SERDES, TG3_PHYFLG_EEE_CAP, TG3_PHYFLG_PHY_SERDES, tg3_readphy(), tg3_writephy(), TG3PCI_DEVICE_TIGON3_5718, and tp.

Referenced by tg3_get_invariants().

◆ tg3_poll_link()

void tg3_poll_link ( struct tg3 tp)

Definition at line 1009 of file tg3_phy.c.

1010 { DBGP("%s\n", __func__);
1011 
1012  if (tp->hw_status->status & SD_STATUS_LINK_CHG) {
1013  DBGC(tp->dev,"link_changed\n");
1014  tp->hw_status->status &= ~SD_STATUS_LINK_CHG;
1015  tg3_setup_phy(tp, 0);
1016  }
1017 }
#define DBGC(...)
Definition: compiler.h:505
int tg3_setup_phy(struct tg3 *tp, int force_reset)
Definition: tg3_phy.c:2521
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
#define SD_STATUS_LINK_CHG
Definition: tg3.h:2673

References DBGC, DBGP, SD_STATUS_LINK_CHG, tg3_setup_phy(), and tp.

Referenced by tg3_poll().

◆ tg3_aux_stat_to_speed_duplex()

static void tg3_aux_stat_to_speed_duplex ( struct tg3 tp,
u32  val,
u16 speed,
u8 duplex 
)
static

Definition at line 1019 of file tg3_phy.c.

1020 { DBGP("%s\n", __func__);
1021 
1022  switch (val & MII_TG3_AUX_STAT_SPDMASK) {
1024  *speed = SPEED_10;
1025  *duplex = DUPLEX_HALF;
1026  break;
1027 
1029  *speed = SPEED_10;
1030  *duplex = DUPLEX_FULL;
1031  break;
1032 
1034  *speed = SPEED_100;
1035  *duplex = DUPLEX_HALF;
1036  break;
1037 
1039  *speed = SPEED_100;
1040  *duplex = DUPLEX_FULL;
1041  break;
1042 
1044  *speed = SPEED_1000;
1045  *duplex = DUPLEX_HALF;
1046  break;
1047 
1049  *speed = SPEED_1000;
1050  *duplex = DUPLEX_FULL;
1051  break;
1052 
1053  default:
1054  if (tp->phy_flags & TG3_PHYFLG_IS_FET) {
1055  *speed = (val & MII_TG3_AUX_STAT_100) ? SPEED_100 :
1056  SPEED_10;
1058  DUPLEX_HALF;
1059  break;
1060  }
1061  *speed = SPEED_INVALID;
1063  break;
1064  }
1065 }
#define SPEED_1000
Definition: atl1e.h:52
#define MII_TG3_AUX_STAT_100FULL
Definition: tg3.h:2385
void __asmcall int val
Definition: setjmp.h:12
#define SPEED_INVALID
Definition: bnx2.h:106
#define MII_TG3_AUX_STAT_10FULL
Definition: tg3.h:2382
#define SPEED_10
Definition: atl1e.h:50
#define MII_TG3_AUX_STAT_SPDMASK
Definition: tg3.h:2380
#define SPEED_100
Definition: atl1e.h:51
#define MII_TG3_AUX_STAT_100HALF
Definition: tg3.h:2383
#define TG3_PHYFLG_IS_FET
Definition: tg3.h:3241
#define DBGP(...)
Definition: compiler.h:532
#define DUPLEX_INVALID
Definition: bnx2.h:112
#define DUPLEX_FULL
Definition: bnx2.h:111
#define MII_TG3_AUX_STAT_1000HALF
Definition: tg3.h:2386
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_TG3_AUX_STAT_FULL
Definition: tg3.h:2389
#define MII_TG3_AUX_STAT_10HALF
Definition: tg3.h:2381
duplex
Definition: nic.h:40
#define MII_TG3_AUX_STAT_1000FULL
Definition: tg3.h:2387
#define MII_TG3_AUX_STAT_100
Definition: tg3.h:2388
#define DUPLEX_HALF
Definition: bnx2.h:110

References DBGP, DUPLEX_FULL, DUPLEX_HALF, DUPLEX_INVALID, MII_TG3_AUX_STAT_100, MII_TG3_AUX_STAT_1000FULL, MII_TG3_AUX_STAT_1000HALF, MII_TG3_AUX_STAT_100FULL, MII_TG3_AUX_STAT_100HALF, MII_TG3_AUX_STAT_10FULL, MII_TG3_AUX_STAT_10HALF, MII_TG3_AUX_STAT_FULL, MII_TG3_AUX_STAT_SPDMASK, SPEED_10, SPEED_100, SPEED_1000, SPEED_INVALID, TG3_PHYFLG_IS_FET, tp, and val.

Referenced by tg3_setup_copper_phy().

◆ tg3_adv_1000T_flowctrl_ok()

static int tg3_adv_1000T_flowctrl_ok ( struct tg3 tp,
u32 lcladv,
u32 rmtadv 
)
static

Definition at line 1067 of file tg3_phy.c.

1068 { DBGP("%s\n", __func__);
1069 
1070  u32 curadv, reqadv;
1071 
1072  if (tg3_readphy(tp, MII_ADVERTISE, lcladv))
1073  return 1;
1074 
1075  curadv = *lcladv & (ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
1076  reqadv = tg3_advert_flowctrl_1000T(tp->link_config.flowctrl);
1077 
1078  if (tp->link_config.active_duplex == DUPLEX_FULL) {
1079  if (curadv != reqadv)
1080  return 0;
1081 
1082  if (tg3_flag(tp, PAUSE_AUTONEG))
1083  tg3_readphy(tp, MII_LPA, rmtadv);
1084  } else {
1085  /* Reprogram the advertisement register, even if it
1086  * does not affect the current link. If the link
1087  * gets renegotiated in the future, we can save an
1088  * additional renegotiation cycle by advertising
1089  * it correctly in the first place.
1090  */
1091  if (curadv != reqadv) {
1092  *lcladv &= ~(ADVERTISE_PAUSE_CAP |
1094  tg3_writephy(tp, MII_ADVERTISE, *lcladv | reqadv);
1095  }
1096  }
1097 
1098  return 1;
1099 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define MII_ADVERTISE
Definition: atl1e.h:875
#define MII_LPA
Definition: atl1e.h:876
#define DBGP(...)
Definition: compiler.h:532
static u16 tg3_advert_flowctrl_1000T(u8 flow_ctrl)
Definition: tg3_phy.c:775
#define DUPLEX_FULL
Definition: bnx2.h:111
static struct tulip_private * tp
Definition: tulip.c:442
#define ADVERTISE_PAUSE_ASYM
Definition: mii.h:84
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define ADVERTISE_PAUSE_CAP
Definition: mii.h:83
uint32_t u32
Definition: stdint.h:23

References ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP, DBGP, DUPLEX_FULL, MII_ADVERTISE, MII_LPA, tg3_advert_flowctrl_1000T(), tg3_flag, tg3_readphy(), tg3_writephy(), and tp.

Referenced by tg3_setup_copper_phy().

◆ tg3_resolve_flowctrl_1000X()

static u8 tg3_resolve_flowctrl_1000X ( u16  lcladv,
u16  rmtadv 
)
static

Definition at line 1101 of file tg3_phy.c.

1102 { DBGP("%s\n", __func__);
1103 
1104  u8 cap = 0;
1105 
1106  if (lcladv & ADVERTISE_1000XPAUSE) {
1107  if (lcladv & ADVERTISE_1000XPSE_ASYM) {
1108  if (rmtadv & LPA_1000XPAUSE)
1109  cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
1110  else if (rmtadv & LPA_1000XPAUSE_ASYM)
1111  cap = FLOW_CTRL_RX;
1112  } else {
1113  if (rmtadv & LPA_1000XPAUSE)
1114  cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
1115  }
1116  } else if (lcladv & ADVERTISE_1000XPSE_ASYM) {
1117  if ((rmtadv & LPA_1000XPAUSE) && (rmtadv & LPA_1000XPAUSE_ASYM))
1118  cap = FLOW_CTRL_TX;
1119  }
1120 
1121  return cap;
1122 }
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
#define LPA_1000XPAUSE
Definition: mii.h:102
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define LPA_1000XPAUSE_ASYM
Definition: mii.h:104
#define DBGP(...)
Definition: compiler.h:532
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
uint8_t u8
Definition: stdint.h:19

References ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, DBGP, FLOW_CTRL_RX, FLOW_CTRL_TX, LPA_1000XPAUSE, and LPA_1000XPAUSE_ASYM.

Referenced by tg3_setup_flow_control().

◆ tg3_setup_flow_control()

static void tg3_setup_flow_control ( struct tg3 tp,
u32  lcladv,
u32  rmtadv 
)
static

Definition at line 1124 of file tg3_phy.c.

1125 { DBGP("%s\n", __func__);
1126 
1127  u8 flowctrl = 0;
1128  u32 old_rx_mode = tp->rx_mode;
1129  u32 old_tx_mode = tp->tx_mode;
1130 
1131  if (tg3_flag(tp, PAUSE_AUTONEG)) {
1132  if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES)
1133  flowctrl = tg3_resolve_flowctrl_1000X(lcladv, rmtadv);
1134  else
1135  flowctrl = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
1136  } else
1137  flowctrl = tp->link_config.flowctrl;
1138 
1139  tp->link_config.active_flowctrl = flowctrl;
1140 
1141  if (flowctrl & FLOW_CTRL_RX)
1142  tp->rx_mode |= RX_MODE_FLOW_CTRL_ENABLE;
1143  else
1144  tp->rx_mode &= ~RX_MODE_FLOW_CTRL_ENABLE;
1145 
1146  if (old_rx_mode != tp->rx_mode)
1147  tw32_f(MAC_RX_MODE, tp->rx_mode);
1148 
1149  if (flowctrl & FLOW_CTRL_TX)
1150  tp->tx_mode |= TX_MODE_FLOW_CTRL_ENABLE;
1151  else
1152  tp->tx_mode &= ~TX_MODE_FLOW_CTRL_ENABLE;
1153 
1154  if (old_tx_mode != tp->tx_mode)
1155  tw32_f(MAC_TX_MODE, tp->tx_mode);
1156 }
static u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv)
mii_resolve_flowctrl_fdx @lcladv: value of MII ADVERTISE register @rmtadv: value of MII LPA register
Definition: tg3.h:3420
static u8 tg3_resolve_flowctrl_1000X(u16 lcladv, u16 rmtadv)
Definition: tg3_phy.c:1101
#define MAC_TX_MODE
Definition: tg3.h:626
static int flowctrl
Definition: sundance.c:75
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define TX_MODE_FLOW_CTRL_ENABLE
Definition: tg3.h:629
#define TG3_PHYFLG_ANY_SERDES
Definition: tg3.h:3239
#define DBGP(...)
Definition: compiler.h:532
#define RX_MODE_FLOW_CTRL_ENABLE
Definition: tg3.h:654
static struct tulip_private * tp
Definition: tulip.c:442
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define FLOW_CTRL_RX
Definition: bnx2.h:4153
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
#define MAC_RX_MODE
Definition: tg3.h:651

References DBGP, FLOW_CTRL_RX, FLOW_CTRL_TX, flowctrl, MAC_RX_MODE, MAC_TX_MODE, mii_resolve_flowctrl_fdx(), RX_MODE_FLOW_CTRL_ENABLE, tg3_flag, TG3_PHYFLG_ANY_SERDES, tg3_resolve_flowctrl_1000X(), tp, tw32_f, and TX_MODE_FLOW_CTRL_ENABLE.

Referenced by tg3_setup_copper_phy(), tg3_setup_fiber_by_hand(), tg3_setup_fiber_hw_autoneg(), and tg3_setup_fiber_mii_phy().

◆ tg3_phy_copper_begin()

static void tg3_phy_copper_begin ( struct tg3 tp)
static

Definition at line 1158 of file tg3_phy.c.

1159 { DBGP("%s\n", __func__);
1160 
1161  u32 new_adv;
1162 
1163  if (tp->link_config.speed == SPEED_INVALID) {
1164  if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)
1165  tp->link_config.advertising &=
1168 
1169  tg3_phy_autoneg_cfg(tp, tp->link_config.advertising,
1170  tp->link_config.flowctrl);
1171  } else {
1172  /* Asking for a specific link mode. */
1173  if (tp->link_config.speed == SPEED_1000) {
1174  if (tp->link_config.duplex == DUPLEX_FULL)
1175  new_adv = ADVERTISED_1000baseT_Full;
1176  else
1177  new_adv = ADVERTISED_1000baseT_Half;
1178  } else if (tp->link_config.speed == SPEED_100) {
1179  if (tp->link_config.duplex == DUPLEX_FULL)
1180  new_adv = ADVERTISED_100baseT_Full;
1181  else
1182  new_adv = ADVERTISED_100baseT_Half;
1183  } else {
1184  if (tp->link_config.duplex == DUPLEX_FULL)
1185  new_adv = ADVERTISED_10baseT_Full;
1186  else
1187  new_adv = ADVERTISED_10baseT_Half;
1188  }
1189 
1190  tg3_phy_autoneg_cfg(tp, new_adv,
1191  tp->link_config.flowctrl);
1192  }
1193 
1195 }
#define SPEED_1000
Definition: atl1e.h:52
#define ADVERTISED_100baseT_Half
Definition: bnx2.h:44
#define TG3_PHYFLG_10_100_ONLY
Definition: tg3.h:3242
#define SPEED_INVALID
Definition: bnx2.h:106
#define BMCR_ANRESTART
Definition: mii.h:46
u16 advertising[4]
Definition: tulip.c:418
#define ADVERTISED_1000baseT_Half
Definition: bnx2.h:46
#define SPEED_100
Definition: atl1e.h:51
#define DBGP(...)
Definition: compiler.h:532
static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
Definition: tg3_phy.c:792
#define DUPLEX_FULL
Definition: bnx2.h:111
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_BMCR
Definition: atl1e.h:871
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define ADVERTISED_10baseT_Full
Definition: bnx2.h:43
#define BMCR_ANENABLE
Definition: mii.h:49
#define ADVERTISED_1000baseT_Full
Definition: bnx2.h:47
#define ADVERTISED_100baseT_Full
Definition: bnx2.h:45
#define ADVERTISED_10baseT_Half
Definition: bnx2.h:42
uint32_t u32
Definition: stdint.h:23

References ADVERTISED_1000baseT_Full, ADVERTISED_1000baseT_Half, ADVERTISED_100baseT_Full, ADVERTISED_100baseT_Half, ADVERTISED_10baseT_Full, ADVERTISED_10baseT_Half, tulip_private::advertising, BMCR_ANENABLE, BMCR_ANRESTART, DBGP, DUPLEX_FULL, MII_BMCR, SPEED_100, SPEED_1000, SPEED_INVALID, tg3_phy_autoneg_cfg(), TG3_PHYFLG_10_100_ONLY, tg3_writephy(), and tp.

Referenced by tg3_setup_copper_phy().

◆ tg3_5700_link_polarity()

static int tg3_5700_link_polarity ( struct tg3 tp,
u32  speed 
)
static

Definition at line 1197 of file tg3_phy.c.

1198 { DBGP("%s\n", __func__);
1199 
1200  if (tp->led_ctrl == LED_CTRL_MODE_PHY_2)
1201  return 1;
1202  else if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5411) {
1203  if (speed != SPEED_10)
1204  return 1;
1205  } else if (speed == SPEED_10)
1206  return 1;
1207 
1208  return 0;
1209 }
#define TG3_PHY_ID_BCM5411
Definition: tg3.h:3188
#define SPEED_10
Definition: atl1e.h:50
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:442
#define LED_CTRL_MODE_PHY_2
Definition: tg3.h:567
#define TG3_PHY_ID_MASK
Definition: tg3.h:3185

References DBGP, LED_CTRL_MODE_PHY_2, SPEED_10, TG3_PHY_ID_BCM5411, TG3_PHY_ID_MASK, and tp.

Referenced by tg3_setup_copper_phy().

◆ tg3_ump_link_report()

static void tg3_ump_link_report ( struct tg3 tp)
static

Definition at line 1213 of file tg3_phy.c.

1214 { DBGP("%s\n", __func__);
1215 
1216  u32 reg;
1217  u32 val;
1218 
1219  if (!tg3_flag(tp, 5780_CLASS) || !tg3_flag(tp, ENABLE_ASF))
1220  return;
1221 
1223 
1225 
1227 
1228  val = 0;
1229  if (!tg3_readphy(tp, MII_BMCR, &reg))
1230  val = reg << 16;
1231  if (!tg3_readphy(tp, MII_BMSR, &reg))
1232  val |= (reg & 0xffff);
1234 
1235  val = 0;
1236  if (!tg3_readphy(tp, MII_ADVERTISE, &reg))
1237  val = reg << 16;
1238  if (!tg3_readphy(tp, MII_LPA, &reg))
1239  val |= (reg & 0xffff);
1241 
1242  val = 0;
1243  if (!(tp->phy_flags & TG3_PHYFLG_MII_SERDES)) {
1244  if (!tg3_readphy(tp, MII_CTRL1000, &reg))
1245  val = reg << 16;
1246  if (!tg3_readphy(tp, MII_STAT1000, &reg))
1247  val |= (reg & 0xffff);
1248  }
1250 
1251  if (!tg3_readphy(tp, MII_PHYADDR, &reg))
1252  val = reg << 16;
1253  else
1254  val = 0;
1256 
1258 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define MII_ADVERTISE
Definition: atl1e.h:875
#define MII_PHYADDR
Definition: atl1e.h:890
static void tg3_generate_fw_event(struct tg3 *tp)
Definition: tg3.h:3403
#define MII_LPA
Definition: atl1e.h:876
static unsigned int unsigned int reg
Definition: myson.h:162
void __asmcall int val
Definition: setjmp.h:12
#define NIC_SRAM_FW_CMD_MBOX
Definition: tg3.h:2234
#define TG3_PHYFLG_MII_SERDES
Definition: tg3.h:3238
#define DBGP(...)
Definition: compiler.h:532
#define NIC_SRAM_FW_CMD_DATA_MBOX
Definition: tg3.h:2245
#define NIC_SRAM_FW_CMD_LEN_MBOX
Definition: tg3.h:2244
static struct tulip_private * tp
Definition: tulip.c:442
#define MII_CTRL1000
Definition: mii.h:24
#define FWCMD_NICDRV_LINK_UPDATE
Definition: tg3.h:2241
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define MII_BMCR
Definition: atl1e.h:871
void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
Definition: tg3_hw.c:922
#define MII_BMSR
Definition: atl1e.h:872
uint32_t u32
Definition: stdint.h:23
#define MII_STAT1000
Definition: mii.h:25
void tg3_wait_for_event_ack(struct tg3 *tp)
Definition: tg3_hw.c:909

References DBGP, FWCMD_NICDRV_LINK_UPDATE, MII_ADVERTISE, MII_BMCR, MII_BMSR, MII_CTRL1000, MII_LPA, MII_PHYADDR, MII_STAT1000, NIC_SRAM_FW_CMD_DATA_MBOX, NIC_SRAM_FW_CMD_LEN_MBOX, NIC_SRAM_FW_CMD_MBOX, reg, tg3_flag, tg3_generate_fw_event(), TG3_PHYFLG_MII_SERDES, tg3_readphy(), tg3_wait_for_event_ack(), tg3_write_mem(), tp, and val.

Referenced by tg3_link_report().

◆ tg3_advert_flowctrl_1000X()

static u16 tg3_advert_flowctrl_1000X ( u8  flow_ctrl)
static

Definition at line 1355 of file tg3_phy.c.

1356 {
1357  u16 miireg;
1358 
1359  if ((flow_ctrl & FLOW_CTRL_TX) && (flow_ctrl & FLOW_CTRL_RX))
1360  miireg = ADVERTISE_1000XPAUSE;
1361  else if (flow_ctrl & FLOW_CTRL_TX)
1362  miireg = ADVERTISE_1000XPSE_ASYM;
1363  else if (flow_ctrl & FLOW_CTRL_RX)
1365  else
1366  miireg = 0;
1367 
1368  return miireg;
1369 }
uint16_t u16
Definition: stdint.h:21
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
#define FLOW_CTRL_TX
Definition: bnx2.h:4152
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define FLOW_CTRL_RX
Definition: bnx2.h:4153

References ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, FLOW_CTRL_RX, and FLOW_CTRL_TX.

Referenced by tg3_fiber_aneg_smachine(), tg3_setup_fiber_hw_autoneg(), and tg3_setup_fiber_mii_phy().

◆ tg3_init_bcm8002()

static void tg3_init_bcm8002 ( struct tg3 tp)
static

Definition at line 1371 of file tg3_phy.c.

1372 {
1373  u32 mac_status = tr32(MAC_STATUS);
1374  int i;
1375 
1376  /* Reset when initting first time or we have a link. */
1377  if (tg3_flag(tp, INIT_COMPLETE) &&
1378  !(mac_status & MAC_STATUS_PCS_SYNCED))
1379  return;
1380 
1381  /* Set PLL lock range. */
1382  tg3_writephy(tp, 0x16, 0x8007);
1383 
1384  /* SW reset */
1386 
1387  /* Wait for reset to complete. */
1388  /* XXX schedule_timeout() ... */
1389  for (i = 0; i < 500; i++)
1390  udelay(10);
1391 
1392  /* Config mode; select PMA/Ch 1 regs. */
1393  tg3_writephy(tp, 0x10, 0x8411);
1394 
1395  /* Enable auto-lock and comdet, select txclk for tx. */
1396  tg3_writephy(tp, 0x11, 0x0a10);
1397 
1398  tg3_writephy(tp, 0x18, 0x00a0);
1399  tg3_writephy(tp, 0x16, 0x41ff);
1400 
1401  /* Assert and deassert POR. */
1402  tg3_writephy(tp, 0x13, 0x0400);
1403  udelay(40);
1404  tg3_writephy(tp, 0x13, 0x0000);
1405 
1406  tg3_writephy(tp, 0x11, 0x0a50);
1407  udelay(40);
1408  tg3_writephy(tp, 0x11, 0x0a10);
1409 
1410  /* Wait for signal to stabilize */
1411  /* XXX schedule_timeout() ... */
1412  for (i = 0; i < 15000; i++)
1413  udelay(10);
1414 
1415  /* Deselect the channel register so we can read the PHYID
1416  * later.
1417  */
1418  tg3_writephy(tp, 0x10, 0x8011);
1419 }
#define tr32(reg)
Definition: tg3.h:3339
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:442
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define MII_BMCR
Definition: atl1e.h:871
#define MAC_STATUS_PCS_SYNCED
Definition: tg3.h:531
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define MAC_STATUS
Definition: tg3.h:530
#define BMCR_RESET
Definition: mii.h:52
uint32_t u32
Definition: stdint.h:23

References BMCR_RESET, MAC_STATUS, MAC_STATUS_PCS_SYNCED, MII_BMCR, tg3_flag, tg3_writephy(), tp, tr32, and udelay().

Referenced by tg3_setup_fiber_phy().

◆ tg3_setup_fiber_hw_autoneg()

static int tg3_setup_fiber_hw_autoneg ( struct tg3 tp,
u32  mac_status 
)
static

Definition at line 1421 of file tg3_phy.c.

1422 {
1423  u16 flowctrl;
1424  int current_link_up;
1425  u32 sg_dig_ctrl, sg_dig_status;
1426  u32 serdes_cfg, expected_sg_dig_ctrl;
1427  int workaround, port_a;
1428 
1429  serdes_cfg = 0;
1430  expected_sg_dig_ctrl = 0;
1431  workaround = 0;
1432  port_a = 1;
1433  current_link_up = 0;
1434 
1435  if (tp->pci_chip_rev_id != CHIPREV_ID_5704_A0 &&
1436  tp->pci_chip_rev_id != CHIPREV_ID_5704_A1) {
1437  workaround = 1;
1439  port_a = 0;
1440 
1441  /* preserve bits 0-11,13,14 for signal pre-emphasis */
1442  /* preserve bits 20-23 for voltage regulator */
1443  serdes_cfg = tr32(MAC_SERDES_CFG) & 0x00f06fff;
1444  }
1445 
1446  sg_dig_ctrl = tr32(SG_DIG_CTRL);
1447 
1448  if (tp->link_config.autoneg != AUTONEG_ENABLE) {
1449  if (sg_dig_ctrl & SG_DIG_USING_HW_AUTONEG) {
1450  if (workaround) {
1451  u32 val = serdes_cfg;
1452 
1453  if (port_a)
1454  val |= 0xc010000;
1455  else
1456  val |= 0x4010000;
1458  }
1459 
1461  }
1462  if (mac_status & MAC_STATUS_PCS_SYNCED) {
1463  tg3_setup_flow_control(tp, 0, 0);
1464  current_link_up = 1;
1465  }
1466  goto out;
1467  }
1468 
1469  /* Want auto-negotiation. */
1470  expected_sg_dig_ctrl = SG_DIG_USING_HW_AUTONEG | SG_DIG_COMMON_SETUP;
1471 
1472  flowctrl = tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
1474  expected_sg_dig_ctrl |= SG_DIG_PAUSE_CAP;
1476  expected_sg_dig_ctrl |= SG_DIG_ASYM_PAUSE;
1477 
1478  if (sg_dig_ctrl != expected_sg_dig_ctrl) {
1479  if ((tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT) &&
1480  tp->serdes_counter &&
1481  ((mac_status & (MAC_STATUS_PCS_SYNCED |
1482  MAC_STATUS_RCVD_CFG)) ==
1484  tp->serdes_counter--;
1485  current_link_up = 1;
1486  goto out;
1487  }
1488 restart_autoneg:
1489  if (workaround)
1490  tw32_f(MAC_SERDES_CFG, serdes_cfg | 0xc011000);
1491  tw32_f(SG_DIG_CTRL, expected_sg_dig_ctrl | SG_DIG_SOFT_RESET);
1492  udelay(5);
1493  tw32_f(SG_DIG_CTRL, expected_sg_dig_ctrl);
1494 
1495  tp->serdes_counter = SERDES_AN_TIMEOUT_5704S;
1496  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1497  } else if (mac_status & (MAC_STATUS_PCS_SYNCED |
1499  sg_dig_status = tr32(SG_DIG_STATUS);
1500  mac_status = tr32(MAC_STATUS);
1501 
1502  if ((sg_dig_status & SG_DIG_AUTONEG_COMPLETE) &&
1503  (mac_status & MAC_STATUS_PCS_SYNCED)) {
1504  u32 local_adv = 0, remote_adv = 0;
1505 
1506  if (sg_dig_ctrl & SG_DIG_PAUSE_CAP)
1507  local_adv |= ADVERTISE_1000XPAUSE;
1508  if (sg_dig_ctrl & SG_DIG_ASYM_PAUSE)
1509  local_adv |= ADVERTISE_1000XPSE_ASYM;
1510 
1511  if (sg_dig_status & SG_DIG_PARTNER_PAUSE_CAPABLE)
1512  remote_adv |= LPA_1000XPAUSE;
1513  if (sg_dig_status & SG_DIG_PARTNER_ASYM_PAUSE)
1514  remote_adv |= LPA_1000XPAUSE_ASYM;
1515 
1516  tp->link_config.rmt_adv =
1517  mii_adv_to_ethtool_adv_x(remote_adv);
1518 
1519  tg3_setup_flow_control(tp, local_adv, remote_adv);
1520  current_link_up = 1;
1521  tp->serdes_counter = 0;
1522  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1523  } else if (!(sg_dig_status & SG_DIG_AUTONEG_COMPLETE)) {
1524  if (tp->serdes_counter)
1525  tp->serdes_counter--;
1526  else {
1527  if (workaround) {
1528  u32 val = serdes_cfg;
1529 
1530  if (port_a)
1531  val |= 0xc010000;
1532  else
1533  val |= 0x4010000;
1534 
1536  }
1537 
1539  udelay(40);
1540 
1541  /* Link parallel detection - link is up */
1542  /* only if we have PCS_SYNC and not */
1543  /* receiving config code words */
1544  mac_status = tr32(MAC_STATUS);
1545  if ((mac_status & MAC_STATUS_PCS_SYNCED) &&
1546  !(mac_status & MAC_STATUS_RCVD_CFG)) {
1547  tg3_setup_flow_control(tp, 0, 0);
1548  current_link_up = 1;
1549  tp->phy_flags |=
1551  tp->serdes_counter =
1553  } else
1554  goto restart_autoneg;
1555  }
1556  }
1557  } else {
1558  tp->serdes_counter = SERDES_AN_TIMEOUT_5704S;
1559  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1560  }
1561 
1562 out:
1563  return current_link_up;
1564 }
uint16_t u16
Definition: stdint.h:21
#define tr32(reg)
Definition: tg3.h:3339
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
void __asmcall int val
Definition: setjmp.h:12
#define MAC_STATUS_RCVD_CFG
Definition: tg3.h:533
#define LPA_1000XPAUSE
Definition: mii.h:102
#define SG_DIG_AUTONEG_COMPLETE
Definition: tg3.h:909
static u16 tg3_advert_flowctrl_1000X(u8 flow_ctrl)
Definition: tg3_phy.c:1355
#define SG_DIG_STATUS
Definition: tg3.h:897
static int flowctrl
Definition: sundance.c:75
#define SG_DIG_SOFT_RESET
Definition: tg3.h:865
#define TG3PCI_DUAL_MAC_CTRL
Definition: tg3.h:415
#define SG_DIG_PARTNER_PAUSE_CAPABLE
Definition: tg3.h:901
#define CHIPREV_ID_5704_A1
Definition: tg3.h:276
__be32 out[4]
Definition: CIB_PRM.h:36
#define MAC_STATUS_SIGNAL_DET
Definition: tg3.h:532
static void tg3_setup_flow_control(struct tg3 *tp, u32 lcladv, u32 rmtadv)
Definition: tg3_phy.c:1124
#define DUAL_MAC_CTRL_ID
Definition: tg3.h:417
static u32 mii_adv_to_ethtool_adv_x(u32 adv)
Definition: tg3.h:3436
#define LPA_1000XPAUSE_ASYM
Definition: mii.h:104
#define SERDES_AN_TIMEOUT_5704S
Definition: tg3.h:3150
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:442
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define SG_DIG_ASYM_PAUSE
Definition: tg3.h:880
#define AUTONEG_ENABLE
Definition: tg3_phy.c:864
#define SG_DIG_CTRL
Definition: tg3.h:863
#define SERDES_PARALLEL_DET_TIMEOUT
Definition: tg3.h:3151
#define SG_DIG_USING_HW_AUTONEG
Definition: tg3.h:864
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define SG_DIG_PAUSE_CAP
Definition: tg3.h:879
#define MAC_STATUS_PCS_SYNCED
Definition: tg3.h:531
#define MAC_STATUS
Definition: tg3.h:530
#define SG_DIG_PARTNER_ASYM_PAUSE
Definition: tg3.h:900
#define SG_DIG_COMMON_SETUP
Definition: tg3.h:892
#define CHIPREV_ID_5704_A0
Definition: tg3.h:275
#define TG3_PHYFLG_PARALLEL_DETECT
Definition: tg3.h:3252
uint32_t u32
Definition: stdint.h:23
#define MAC_SERDES_CFG
Definition: tg3.h:743

References ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, AUTONEG_ENABLE, CHIPREV_ID_5704_A0, CHIPREV_ID_5704_A1, DUAL_MAC_CTRL_ID, flowctrl, LPA_1000XPAUSE, LPA_1000XPAUSE_ASYM, MAC_SERDES_CFG, MAC_STATUS, MAC_STATUS_PCS_SYNCED, MAC_STATUS_RCVD_CFG, MAC_STATUS_SIGNAL_DET, mii_adv_to_ethtool_adv_x(), out, SERDES_AN_TIMEOUT_5704S, SERDES_PARALLEL_DET_TIMEOUT, SG_DIG_ASYM_PAUSE, SG_DIG_AUTONEG_COMPLETE, SG_DIG_COMMON_SETUP, SG_DIG_CTRL, SG_DIG_PARTNER_ASYM_PAUSE, SG_DIG_PARTNER_PAUSE_CAPABLE, SG_DIG_PAUSE_CAP, SG_DIG_SOFT_RESET, SG_DIG_STATUS, SG_DIG_USING_HW_AUTONEG, tg3_advert_flowctrl_1000X(), TG3_PHYFLG_PARALLEL_DETECT, tg3_setup_flow_control(), TG3PCI_DUAL_MAC_CTRL, tp, tr32, tw32_f, udelay(), and val.

Referenced by tg3_setup_fiber_phy().

◆ tg3_fiber_aneg_smachine()

static int tg3_fiber_aneg_smachine ( struct tg3 tp,
struct tg3_fiber_aneginfo ap 
)
static

Definition at line 1566 of file tg3_phy.c.

1568 {
1569  u16 flowctrl;
1570  unsigned long delta;
1571  u32 rx_cfg_reg;
1572  int ret;
1573 
1574  if (ap->state == ANEG_STATE_UNKNOWN) {
1575  ap->rxconfig = 0;
1576  ap->link_time = 0;
1577  ap->cur_time = 0;
1578  ap->ability_match_cfg = 0;
1579  ap->ability_match_count = 0;
1580  ap->ability_match = 0;
1581  ap->idle_match = 0;
1582  ap->ack_match = 0;
1583  }
1584  ap->cur_time++;
1585 
1587  rx_cfg_reg = tr32(MAC_RX_AUTO_NEG);
1588 
1589  if (rx_cfg_reg != ap->ability_match_cfg) {
1590  ap->ability_match_cfg = rx_cfg_reg;
1591  ap->ability_match = 0;
1592  ap->ability_match_count = 0;
1593  } else {
1594  if (++ap->ability_match_count > 1) {
1595  ap->ability_match = 1;
1596  ap->ability_match_cfg = rx_cfg_reg;
1597  }
1598  }
1599  if (rx_cfg_reg & ANEG_CFG_ACK)
1600  ap->ack_match = 1;
1601  else
1602  ap->ack_match = 0;
1603 
1604  ap->idle_match = 0;
1605  } else {
1606  ap->idle_match = 1;
1607  ap->ability_match_cfg = 0;
1608  ap->ability_match_count = 0;
1609  ap->ability_match = 0;
1610  ap->ack_match = 0;
1611 
1612  rx_cfg_reg = 0;
1613  }
1614 
1615  ap->rxconfig = rx_cfg_reg;
1616  ret = ANEG_OK;
1617 
1618  switch (ap->state) {
1619  case ANEG_STATE_UNKNOWN:
1620  if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN))
1622 
1623  /* fallthru */
1624  case ANEG_STATE_AN_ENABLE:
1625  ap->flags &= ~(MR_AN_COMPLETE | MR_PAGE_RX);
1626  if (ap->flags & MR_AN_ENABLE) {
1627  ap->link_time = 0;
1628  ap->cur_time = 0;
1629  ap->ability_match_cfg = 0;
1630  ap->ability_match_count = 0;
1631  ap->ability_match = 0;
1632  ap->idle_match = 0;
1633  ap->ack_match = 0;
1634 
1636  } else {
1638  }
1639  break;
1640 
1642  ap->link_time = ap->cur_time;
1643  ap->flags &= ~(MR_NP_LOADED);
1644  ap->txconfig = 0;
1645  tw32(MAC_TX_AUTO_NEG, 0);
1646  tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
1647  tw32_f(MAC_MODE, tp->mac_mode);
1648  udelay(40);
1649 
1650  ret = ANEG_TIMER_ENAB;
1651  ap->state = ANEG_STATE_RESTART;
1652 
1653  /* fallthru */
1654  case ANEG_STATE_RESTART:
1655  delta = ap->cur_time - ap->link_time;
1656  if (delta > ANEG_STATE_SETTLE_TIME)
1658  else
1659  ret = ANEG_TIMER_ENAB;
1660  break;
1661 
1663  ret = ANEG_DONE;
1664  break;
1665 
1667  ap->flags &= ~(MR_TOGGLE_TX);
1668  ap->txconfig = ANEG_CFG_FD;
1669  flowctrl = tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
1671  ap->txconfig |= ANEG_CFG_PS1;
1673  ap->txconfig |= ANEG_CFG_PS2;
1675  tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
1676  tw32_f(MAC_MODE, tp->mac_mode);
1677  udelay(40);
1678 
1680  break;
1681 
1683  if (ap->ability_match != 0 && ap->rxconfig != 0)
1685  break;
1686 
1688  ap->txconfig |= ANEG_CFG_ACK;
1690  tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
1691  tw32_f(MAC_MODE, tp->mac_mode);
1692  udelay(40);
1693 
1695 
1696  /* fallthru */
1697  case ANEG_STATE_ACK_DETECT:
1698  if (ap->ack_match != 0) {
1699  if ((ap->rxconfig & ~ANEG_CFG_ACK) ==
1700  (ap->ability_match_cfg & ~ANEG_CFG_ACK)) {
1702  } else {
1704  }
1705  } else if (ap->ability_match != 0 &&
1706  ap->rxconfig == 0) {
1708  }
1709  break;
1710 
1712  if (ap->rxconfig & ANEG_CFG_INVAL) {
1713  ret = ANEG_FAILED;
1714  break;
1715  }
1716  ap->flags &= ~(MR_LP_ADV_FULL_DUPLEX |
1723  MR_TOGGLE_RX |
1724  MR_NP_RX);
1725  if (ap->rxconfig & ANEG_CFG_FD)
1727  if (ap->rxconfig & ANEG_CFG_HD)
1729  if (ap->rxconfig & ANEG_CFG_PS1)
1730  ap->flags |= MR_LP_ADV_SYM_PAUSE;
1731  if (ap->rxconfig & ANEG_CFG_PS2)
1732  ap->flags |= MR_LP_ADV_ASYM_PAUSE;
1733  if (ap->rxconfig & ANEG_CFG_RF1)
1735  if (ap->rxconfig & ANEG_CFG_RF2)
1737  if (ap->rxconfig & ANEG_CFG_NP)
1738  ap->flags |= MR_LP_ADV_NEXT_PAGE;
1739 
1740  ap->link_time = ap->cur_time;
1741 
1742  ap->flags ^= (MR_TOGGLE_TX);
1743  if (ap->rxconfig & 0x0008)
1744  ap->flags |= MR_TOGGLE_RX;
1745  if (ap->rxconfig & ANEG_CFG_NP)
1746  ap->flags |= MR_NP_RX;
1747  ap->flags |= MR_PAGE_RX;
1748 
1750  ret = ANEG_TIMER_ENAB;
1751  break;
1752 
1754  if (ap->ability_match != 0 &&
1755  ap->rxconfig == 0) {
1757  break;
1758  }
1759  delta = ap->cur_time - ap->link_time;
1760  if (delta > ANEG_STATE_SETTLE_TIME) {
1761  if (!(ap->flags & (MR_LP_ADV_NEXT_PAGE))) {
1763  } else {
1764  if ((ap->txconfig & ANEG_CFG_NP) == 0 &&
1765  !(ap->flags & MR_NP_RX)) {
1767  } else {
1768  ret = ANEG_FAILED;
1769  }
1770  }
1771  }
1772  break;
1773 
1775  ap->link_time = ap->cur_time;
1776  tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
1777  tw32_f(MAC_MODE, tp->mac_mode);
1778  udelay(40);
1779 
1781  ret = ANEG_TIMER_ENAB;
1782  break;
1783 
1785  if (ap->ability_match != 0 &&
1786  ap->rxconfig == 0) {
1788  break;
1789  }
1790  delta = ap->cur_time - ap->link_time;
1791  if (delta > ANEG_STATE_SETTLE_TIME) {
1792  /* XXX another gem from the Broadcom driver :( */
1793  ap->state = ANEG_STATE_LINK_OK;
1794  }
1795  break;
1796 
1797  case ANEG_STATE_LINK_OK:
1798  ap->flags |= (MR_AN_COMPLETE | MR_LINK_OK);
1799  ret = ANEG_DONE;
1800  break;
1801 
1803  /* ??? unimplemented */
1804  break;
1805 
1807  /* ??? unimplemented */
1808  break;
1809 
1810  default:
1811  ret = ANEG_FAILED;
1812  break;
1813  }
1814 
1815  return ret;
1816 }
uint16_t u16
Definition: stdint.h:21
#define MAC_MODE_SEND_CONFIGS
Definition: tg3.h:520
#define ANEG_STATE_AN_ENABLE
Definition: tg3_phy.c:1294
#define tr32(reg)
Definition: tg3.h:3339
#define ANEG_STATE_UNKNOWN
Definition: tg3_phy.c:1293
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
#define ANEG_CFG_HD
Definition: tg3_phy.c:1343
#define ANEG_CFG_NP
Definition: tg3_phy.c:1337
#define MR_NP_LOADED
Definition: tg3_phy.c:1315
#define MR_LP_ADV_SYM_PAUSE
Definition: tg3_phy.c:1319
#define MAC_TX_AUTO_NEG
Definition: tg3.h:597
#define MAC_STATUS_RCVD_CFG
Definition: tg3.h:533
#define ANEG_CFG_INVAL
Definition: tg3_phy.c:1345
#define ANEG_DONE
Definition: tg3_phy.c:1349
#define ANEG_CFG_PS1
Definition: tg3_phy.c:1342
#define MR_AN_ENABLE
Definition: tg3_phy.c:1311
static u16 tg3_advert_flowctrl_1000X(u8 flow_ctrl)
Definition: tg3_phy.c:1355
static int flowctrl
Definition: sundance.c:75
#define MR_RESTART_AN
Definition: tg3_phy.c:1312
#define MR_NP_RX
Definition: tg3_phy.c:1325
#define ANEG_CFG_RF2
Definition: tg3_phy.c:1339
#define ANEG_STATE_NEXT_PAGE_WAIT
Definition: tg3_phy.c:1308
#define ANEG_STATE_IDLE_DETECT_INIT
Definition: tg3_phy.c:1304
#define MR_AN_COMPLETE
Definition: tg3_phy.c:1313
unsigned long link_time
Definition: tg3_phy.c:1329
#define ANEG_FAILED
Definition: tg3_phy.c:1351
#define ANEG_CFG_RF1
Definition: tg3_phy.c:1340
#define MR_LP_ADV_REMOTE_FAULT1
Definition: tg3_phy.c:1321
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define ANEG_CFG_PS2
Definition: tg3_phy.c:1341
static struct tulip_private * tp
Definition: tulip.c:442
#define MR_LINK_OK
Definition: tg3_phy.c:1327
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define ANEG_STATE_ABILITY_DETECT_INIT
Definition: tg3_phy.c:1298
#define MR_TOGGLE_RX
Definition: tg3_phy.c:1324
#define ANEG_STATE_IDLE_DETECT
Definition: tg3_phy.c:1305
#define ANEG_OK
Definition: tg3_phy.c:1348
#define tw32_f(reg, val)
Definition: tg3.h:3333
unsigned long cur_time
Definition: tg3_phy.c:1329
#define MR_LP_ADV_ASYM_PAUSE
Definition: tg3_phy.c:1320
#define ANEG_STATE_SETTLE_TIME
Definition: tg3_phy.c:1353
#define MAC_RX_AUTO_NEG
Definition: tg3.h:600
#define ANEG_STATE_NEXT_PAGE_WAIT_INIT
Definition: tg3_phy.c:1307
#define MAC_STATUS
Definition: tg3.h:530
#define MR_LP_ADV_HALF_DUPLEX
Definition: tg3_phy.c:1318
#define MR_PAGE_RX
Definition: tg3_phy.c:1314
#define ANEG_STATE_COMPLETE_ACK
Definition: tg3_phy.c:1303
#define ANEG_STATE_RESTART_INIT
Definition: tg3_phy.c:1295
#define ANEG_STATE_RESTART
Definition: tg3_phy.c:1296
#define tw32(reg, val)
Definition: tg3.h:3329
#define MR_TOGGLE_TX
Definition: tg3_phy.c:1316
#define ANEG_STATE_COMPLETE_ACK_INIT
Definition: tg3_phy.c:1302
#define ANEG_STATE_ACK_DETECT
Definition: tg3_phy.c:1301
#define ANEG_TIMER_ENAB
Definition: tg3_phy.c:1350
#define MR_LP_ADV_NEXT_PAGE
Definition: tg3_phy.c:1323
#define ANEG_CFG_FD
Definition: tg3_phy.c:1344
#define ANEG_STATE_DISABLE_LINK_OK
Definition: tg3_phy.c:1297
#define ANEG_CFG_ACK
Definition: tg3_phy.c:1338
#define MR_LP_ADV_FULL_DUPLEX
Definition: tg3_phy.c:1317
#define MAC_MODE
Definition: tg3.h:501
#define ANEG_STATE_ACK_DETECT_INIT
Definition: tg3_phy.c:1300
#define ANEG_STATE_ABILITY_DETECT
Definition: tg3_phy.c:1299
uint32_t u32
Definition: stdint.h:23
#define MR_LP_ADV_REMOTE_FAULT2
Definition: tg3_phy.c:1322
#define ANEG_STATE_LINK_OK
Definition: tg3_phy.c:1306

References tg3_fiber_aneginfo::ability_match, tg3_fiber_aneginfo::ability_match_cfg, tg3_fiber_aneginfo::ability_match_count, tg3_fiber_aneginfo::ack_match, ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, ANEG_CFG_ACK, ANEG_CFG_FD, ANEG_CFG_HD, ANEG_CFG_INVAL, ANEG_CFG_NP, ANEG_CFG_PS1, ANEG_CFG_PS2, ANEG_CFG_RF1, ANEG_CFG_RF2, ANEG_DONE, ANEG_FAILED, ANEG_OK, ANEG_STATE_ABILITY_DETECT, ANEG_STATE_ABILITY_DETECT_INIT, ANEG_STATE_ACK_DETECT, ANEG_STATE_ACK_DETECT_INIT, ANEG_STATE_AN_ENABLE, ANEG_STATE_COMPLETE_ACK, ANEG_STATE_COMPLETE_ACK_INIT, ANEG_STATE_DISABLE_LINK_OK, ANEG_STATE_IDLE_DETECT, ANEG_STATE_IDLE_DETECT_INIT, ANEG_STATE_LINK_OK, ANEG_STATE_NEXT_PAGE_WAIT, ANEG_STATE_NEXT_PAGE_WAIT_INIT, ANEG_STATE_RESTART, ANEG_STATE_RESTART_INIT, ANEG_STATE_SETTLE_TIME, ANEG_STATE_UNKNOWN, ANEG_TIMER_ENAB, tg3_fiber_aneginfo::cur_time, tg3_fiber_aneginfo::flags, flowctrl, tg3_fiber_aneginfo::idle_match, tg3_fiber_aneginfo::link_time, MAC_MODE, MAC_MODE_SEND_CONFIGS, MAC_RX_AUTO_NEG, MAC_STATUS, MAC_STATUS_RCVD_CFG, MAC_TX_AUTO_NEG, MR_AN_COMPLETE, MR_AN_ENABLE, MR_LINK_OK, MR_LP_ADV_ASYM_PAUSE, MR_LP_ADV_FULL_DUPLEX, MR_LP_ADV_HALF_DUPLEX, MR_LP_ADV_NEXT_PAGE, MR_LP_ADV_REMOTE_FAULT1, MR_LP_ADV_REMOTE_FAULT2, MR_LP_ADV_SYM_PAUSE, MR_NP_LOADED, MR_NP_RX, MR_PAGE_RX, MR_RESTART_AN, MR_TOGGLE_RX, MR_TOGGLE_TX, tg3_fiber_aneginfo::rxconfig, tg3_fiber_aneginfo::state, tg3_advert_flowctrl_1000X(), tp, tr32, tw32, tw32_f, tg3_fiber_aneginfo::txconfig, and udelay().

Referenced by fiber_autoneg().

◆ fiber_autoneg()

static int fiber_autoneg ( struct tg3 tp,
u32 txflags,
u32 rxflags 
)
static

Definition at line 1818 of file tg3_phy.c.

1819 {
1820  int res = 0;
1821  struct tg3_fiber_aneginfo aninfo;
1822  int status = ANEG_FAILED;
1823  unsigned int tick;
1824  u32 tmp;
1825 
1826  tw32_f(MAC_TX_AUTO_NEG, 0);
1827 
1828  tmp = tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK;
1830  udelay(40);
1831 
1832  tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_SEND_CONFIGS);
1833  udelay(40);
1834 
1835  memset(&aninfo, 0, sizeof(aninfo));
1836  aninfo.flags |= MR_AN_ENABLE;
1837  aninfo.state = ANEG_STATE_UNKNOWN;
1838  aninfo.cur_time = 0;
1839  tick = 0;
1840  while (++tick < 195000) {
1841  status = tg3_fiber_aneg_smachine(tp, &aninfo);
1842  if (status == ANEG_DONE || status == ANEG_FAILED)
1843  break;
1844 
1845  udelay(1);
1846  }
1847 
1848  tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
1849  tw32_f(MAC_MODE, tp->mac_mode);
1850  udelay(40);
1851 
1852  *txflags = aninfo.txconfig;
1853  *rxflags = aninfo.flags;
1854 
1855  if (status == ANEG_DONE &&
1856  (aninfo.flags & (MR_AN_COMPLETE | MR_LINK_OK |
1858  res = 1;
1859 
1860  return res;
1861 }
#define MAC_MODE_SEND_CONFIGS
Definition: tg3.h:520
#define ANEG_STATE_UNKNOWN
Definition: tg3_phy.c:1293
static EFI_EVENT tick
Event used to wait for timer tick.
Definition: efi_entropy.c:50
#define MAC_TX_AUTO_NEG
Definition: tg3.h:597
#define ANEG_DONE
Definition: tg3_phy.c:1349
#define MAC_MODE_PORT_MODE_MASK
Definition: tg3.h:504
#define MR_AN_ENABLE
Definition: tg3_phy.c:1311
static int tg3_fiber_aneg_smachine(struct tg3 *tp, struct tg3_fiber_aneginfo *ap)
Definition: tg3_phy.c:1566
unsigned long tmp
Definition: linux_pci.h:64
#define MR_AN_COMPLETE
Definition: tg3_phy.c:1313
#define ANEG_FAILED
Definition: tg3_phy.c:1351
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:442
#define MR_LINK_OK
Definition: tg3_phy.c:1327
#define MAC_MODE_PORT_MODE_GMII
Definition: tg3.h:506
#define tw32_f(reg, val)
Definition: tg3.h:3333
uint8_t status
Status.
Definition: ena.h:16
#define MR_LP_ADV_FULL_DUPLEX
Definition: tg3_phy.c:1317
#define MAC_MODE
Definition: tg3.h:501
uint32_t u32
Definition: stdint.h:23
void * memset(void *dest, int character, size_t len) __nonnull

References ANEG_DONE, ANEG_FAILED, ANEG_STATE_UNKNOWN, tg3_fiber_aneginfo::cur_time, tg3_fiber_aneginfo::flags, MAC_MODE, MAC_MODE_PORT_MODE_GMII, MAC_MODE_PORT_MODE_MASK, MAC_MODE_SEND_CONFIGS, MAC_TX_AUTO_NEG, memset(), MR_AN_COMPLETE, MR_AN_ENABLE, MR_LINK_OK, MR_LP_ADV_FULL_DUPLEX, tg3_fiber_aneginfo::state, status, tg3_fiber_aneg_smachine(), tick, tmp, tp, tw32_f, tg3_fiber_aneginfo::txconfig, and udelay().

Referenced by tg3_setup_fiber_by_hand().

◆ tg3_setup_fiber_by_hand()

static int tg3_setup_fiber_by_hand ( struct tg3 tp,
u32  mac_status 
)
static

Definition at line 1863 of file tg3_phy.c.

1864 {
1865  int current_link_up = 0;
1866 
1867  if (!(mac_status & MAC_STATUS_PCS_SYNCED))
1868  goto out;
1869 
1870  if (tp->link_config.autoneg == AUTONEG_ENABLE) {
1871  u32 txflags, rxflags;
1872  int i;
1873 
1874  if (fiber_autoneg(tp, &txflags, &rxflags)) {
1875  u32 local_adv = 0, remote_adv = 0;
1876 
1877  if (txflags & ANEG_CFG_PS1)
1878  local_adv |= ADVERTISE_1000XPAUSE;
1879  if (txflags & ANEG_CFG_PS2)
1880  local_adv |= ADVERTISE_1000XPSE_ASYM;
1881 
1882  if (rxflags & MR_LP_ADV_SYM_PAUSE)
1883  remote_adv |= LPA_1000XPAUSE;
1884  if (rxflags & MR_LP_ADV_ASYM_PAUSE)
1885  remote_adv |= LPA_1000XPAUSE_ASYM;
1886 
1887  tp->link_config.rmt_adv =
1888  mii_adv_to_ethtool_adv_x(remote_adv);
1889 
1890  tg3_setup_flow_control(tp, local_adv, remote_adv);
1891 
1892  current_link_up = 1;
1893  }
1894  for (i = 0; i < 30; i++) {
1895  udelay(20);
1899  udelay(40);
1900  if ((tr32(MAC_STATUS) &
1902  MAC_STATUS_CFG_CHANGED)) == 0)
1903  break;
1904  }
1905 
1906  mac_status = tr32(MAC_STATUS);
1907  if (!current_link_up &&
1908  (mac_status & MAC_STATUS_PCS_SYNCED) &&
1909  !(mac_status & MAC_STATUS_RCVD_CFG))
1910  current_link_up = 1;
1911  } else {
1912  tg3_setup_flow_control(tp, 0, 0);
1913 
1914  /* Forcing 1000FD link up. */
1915  current_link_up = 1;
1916 
1917  tw32_f(MAC_MODE, (tp->mac_mode | MAC_MODE_SEND_CONFIGS));
1918  udelay(40);
1919 
1920  tw32_f(MAC_MODE, tp->mac_mode);
1921  udelay(40);
1922  }
1923 
1924 out:
1925  return current_link_up;
1926 }
#define MAC_MODE_SEND_CONFIGS
Definition: tg3.h:520
#define tr32(reg)
Definition: tg3.h:3339
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
#define MR_LP_ADV_SYM_PAUSE
Definition: tg3_phy.c:1319
#define MAC_STATUS_RCVD_CFG
Definition: tg3.h:533
#define ANEG_CFG_PS1
Definition: tg3_phy.c:1342
#define LPA_1000XPAUSE
Definition: mii.h:102
#define MAC_STATUS_CFG_CHANGED
Definition: tg3.h:534
__be32 out[4]
Definition: CIB_PRM.h:36
static void tg3_setup_flow_control(struct tg3 *tp, u32 lcladv, u32 rmtadv)
Definition: tg3_phy.c:1124
static int fiber_autoneg(struct tg3 *tp, u32 *txflags, u32 *rxflags)
Definition: tg3_phy.c:1818
static u32 mii_adv_to_ethtool_adv_x(u32 adv)
Definition: tg3.h:3436
#define LPA_1000XPAUSE_ASYM
Definition: mii.h:104
#define MAC_STATUS_SYNC_CHANGED
Definition: tg3.h:535
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define ANEG_CFG_PS2
Definition: tg3_phy.c:1341
static struct tulip_private * tp
Definition: tulip.c:442
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define AUTONEG_ENABLE
Definition: tg3_phy.c:864
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MR_LP_ADV_ASYM_PAUSE
Definition: tg3_phy.c:1320
#define MAC_STATUS_PCS_SYNCED
Definition: tg3.h:531
#define MAC_STATUS
Definition: tg3.h:530
#define MAC_MODE
Definition: tg3.h:501
uint32_t u32
Definition: stdint.h:23

References ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, ANEG_CFG_PS1, ANEG_CFG_PS2, AUTONEG_ENABLE, fiber_autoneg(), LPA_1000XPAUSE, LPA_1000XPAUSE_ASYM, MAC_MODE, MAC_MODE_SEND_CONFIGS, MAC_STATUS, MAC_STATUS_CFG_CHANGED, MAC_STATUS_PCS_SYNCED, MAC_STATUS_RCVD_CFG, MAC_STATUS_SYNC_CHANGED, mii_adv_to_ethtool_adv_x(), MR_LP_ADV_ASYM_PAUSE, MR_LP_ADV_SYM_PAUSE, out, tg3_setup_flow_control(), tp, tr32, tw32_f, and udelay().

Referenced by tg3_setup_fiber_phy().

◆ tg3_test_and_report_link_chg()

static int tg3_test_and_report_link_chg ( struct tg3 tp,
int  curr_link_up 
)
static

Definition at line 1928 of file tg3_phy.c.

1929 {
1930  if (curr_link_up != tp->link_up) {
1931  if (curr_link_up) {
1932  netdev_link_up(tp->dev);
1933  } else {
1934  netdev_link_down(tp->dev);
1935  if (tp->phy_flags & TG3_PHYFLG_MII_SERDES)
1936  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1937  }
1938 
1940  return 1;
1941  }
1942 
1943  return 0;
1944 }
static void tg3_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1261
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
#define TG3_PHYFLG_MII_SERDES
Definition: tg3.h:3238
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:788
static struct tulip_private * tp
Definition: tulip.c:442
#define TG3_PHYFLG_PARALLEL_DETECT
Definition: tg3.h:3252

References netdev_link_down(), netdev_link_up(), tg3_link_report(), TG3_PHYFLG_MII_SERDES, TG3_PHYFLG_PARALLEL_DETECT, and tp.

Referenced by tg3_setup_fiber_mii_phy(), and tg3_setup_fiber_phy().

◆ tg3_clear_mac_status()

static void tg3_clear_mac_status ( struct tg3 tp)
static

Definition at line 1946 of file tg3_phy.c.

1947 {
1948  tw32(MAC_EVENT, 0);
1949 
1955  udelay(40);
1956 }
#define MAC_STATUS_MI_COMPLETION
Definition: tg3.h:538
#define MAC_STATUS_CFG_CHANGED
Definition: tg3.h:534
#define MAC_STATUS_SYNC_CHANGED
Definition: tg3.h:535
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define MAC_EVENT
Definition: tg3.h:544
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MAC_STATUS
Definition: tg3.h:530
#define tw32(reg, val)
Definition: tg3.h:3329
#define MAC_STATUS_LNKSTATE_CHANGED
Definition: tg3.h:537

References MAC_EVENT, MAC_STATUS, MAC_STATUS_CFG_CHANGED, MAC_STATUS_LNKSTATE_CHANGED, MAC_STATUS_MI_COMPLETION, MAC_STATUS_SYNC_CHANGED, tw32, tw32_f, and udelay().

Referenced by tg3_setup_fiber_mii_phy().

◆ tg3_setup_fiber_phy()

static int tg3_setup_fiber_phy ( struct tg3 tp,
int  force_reset 
)
static

Definition at line 1958 of file tg3_phy.c.

1959 {
1960  u32 orig_pause_cfg;
1961  u16 orig_active_speed;
1962  u8 orig_active_duplex;
1963  u32 mac_status;
1964  int current_link_up = force_reset;
1965  int i;
1966 
1967  orig_pause_cfg = tp->link_config.active_flowctrl;
1968  orig_active_speed = tp->link_config.active_speed;
1969  orig_active_duplex = tp->link_config.active_duplex;
1970 
1971  if (!tg3_flag(tp, HW_AUTONEG) &&
1972  tp->link_up &&
1973  tg3_flag(tp, INIT_COMPLETE)) {
1974  mac_status = tr32(MAC_STATUS);
1975  mac_status &= (MAC_STATUS_PCS_SYNCED |
1979  if (mac_status == (MAC_STATUS_PCS_SYNCED |
1983  return 0;
1984  }
1985  }
1986 
1987  tw32_f(MAC_TX_AUTO_NEG, 0);
1988 
1990  tp->mac_mode |= MAC_MODE_PORT_MODE_TBI;
1991  tw32_f(MAC_MODE, tp->mac_mode);
1992  udelay(40);
1993 
1994  if (tp->phy_id == TG3_PHY_ID_BCM8002)
1996 
1997  /* Enable link change event even when serdes polling. */
1999  udelay(40);
2000 
2001  current_link_up = 0;
2002  tp->link_config.rmt_adv = 0;
2003  mac_status = tr32(MAC_STATUS);
2004 
2005  if (tg3_flag(tp, HW_AUTONEG))
2006  current_link_up = tg3_setup_fiber_hw_autoneg(tp, mac_status);
2007  else
2008  current_link_up = tg3_setup_fiber_by_hand(tp, mac_status);
2009 
2010  tp->hw_status->status =
2012  (tp->hw_status->status & ~SD_STATUS_LINK_CHG));
2013 
2014  for (i = 0; i < 100; i++) {
2017  udelay(5);
2021  break;
2022  }
2023 
2024  mac_status = tr32(MAC_STATUS);
2025  if ((mac_status & MAC_STATUS_PCS_SYNCED) == 0) {
2026  current_link_up = 0;
2027  if (tp->link_config.autoneg == AUTONEG_ENABLE &&
2028  tp->serdes_counter == 0) {
2029  tw32_f(MAC_MODE, (tp->mac_mode |
2031  udelay(1);
2032  tw32_f(MAC_MODE, tp->mac_mode);
2033  }
2034  }
2035 
2036  if (current_link_up) {
2037  tp->link_config.active_speed = SPEED_1000;
2038  tp->link_config.active_duplex = DUPLEX_FULL;
2039  tw32(MAC_LED_CTRL, (tp->led_ctrl |
2042  } else {
2043  tp->link_config.active_speed = SPEED_UNKNOWN;
2044  tp->link_config.active_duplex = DUPLEX_UNKNOWN;
2045  tw32(MAC_LED_CTRL, (tp->led_ctrl |
2048  }
2049 
2050  if (!tg3_test_and_report_link_chg(tp, current_link_up)) {
2051  u32 now_pause_cfg = tp->link_config.active_flowctrl;
2052  if (orig_pause_cfg != now_pause_cfg ||
2053  orig_active_speed != tp->link_config.active_speed ||
2054  orig_active_duplex != tp->link_config.active_duplex)
2056  }
2057 
2058  return 0;
2059 }
#define SPEED_1000
Definition: atl1e.h:52
uint16_t u16
Definition: stdint.h:21
#define MAC_MODE_SEND_CONFIGS
Definition: tg3.h:520
#define tr32(reg)
Definition: tg3.h:3339
static void tg3_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1261
#define MAC_TX_AUTO_NEG
Definition: tg3.h:597
#define MAC_STATUS_RCVD_CFG
Definition: tg3.h:533
#define MAC_MODE_PORT_MODE_MASK
Definition: tg3.h:504
#define MAC_STATUS_CFG_CHANGED
Definition: tg3.h:534
#define LED_CTRL_TRAFFIC_OVERRIDE
Definition: tg3.h:558
#define MAC_MODE_PORT_MODE_TBI
Definition: tg3.h:505
#define MAC_STATUS_SIGNAL_DET
Definition: tg3.h:532
#define TG3_PHY_ID_BCM8002
Definition: tg3.h:3208
#define MAC_STATUS_SYNC_CHANGED
Definition: tg3.h:535
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define DUPLEX_FULL
Definition: bnx2.h:111
#define DUPLEX_UNKNOWN
Definition: tg3.h:156
static struct tulip_private * tp
Definition: tulip.c:442
#define SPEED_UNKNOWN
Definition: tg3.h:150
#define SD_STATUS_LINK_CHG
Definition: tg3.h:2673
static int tg3_setup_fiber_hw_autoneg(struct tg3 *tp, u32 mac_status)
Definition: tg3_phy.c:1421
static void tg3_init_bcm8002(struct tg3 *tp)
Definition: tg3_phy.c:1371
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define LED_CTRL_LNKLED_OVERRIDE
Definition: tg3.h:554
#define AUTONEG_ENABLE
Definition: tg3_phy.c:864
static int tg3_test_and_report_link_chg(struct tg3 *tp, int curr_link_up)
Definition: tg3_phy.c:1928
#define LED_CTRL_1000MBPS_ON
Definition: tg3.h:555
#define MAC_EVENT_LNKSTATE_CHANGED
Definition: tg3.h:546
#define MAC_MODE_HALF_DUPLEX
Definition: tg3.h:503
#define MAC_EVENT
Definition: tg3.h:544
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MAC_LED_CTRL
Definition: tg3.h:553
#define MAC_STATUS_PCS_SYNCED
Definition: tg3.h:531
#define MAC_STATUS
Definition: tg3.h:530
#define SD_STATUS_UPDATED
Definition: tg3.h:2672
#define tw32(reg, val)
Definition: tg3.h:3329
#define MAC_MODE
Definition: tg3.h:501
#define MAC_STATUS_LNKSTATE_CHANGED
Definition: tg3.h:537
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
static int tg3_setup_fiber_by_hand(struct tg3 *tp, u32 mac_status)
Definition: tg3_phy.c:1863

References AUTONEG_ENABLE, DUPLEX_FULL, DUPLEX_UNKNOWN, LED_CTRL_1000MBPS_ON, LED_CTRL_LNKLED_OVERRIDE, LED_CTRL_TRAFFIC_OVERRIDE, MAC_EVENT, MAC_EVENT_LNKSTATE_CHANGED, MAC_LED_CTRL, MAC_MODE, MAC_MODE_HALF_DUPLEX, MAC_MODE_PORT_MODE_MASK, MAC_MODE_PORT_MODE_TBI, MAC_MODE_SEND_CONFIGS, MAC_STATUS, MAC_STATUS_CFG_CHANGED, MAC_STATUS_LNKSTATE_CHANGED, MAC_STATUS_PCS_SYNCED, MAC_STATUS_RCVD_CFG, MAC_STATUS_SIGNAL_DET, MAC_STATUS_SYNC_CHANGED, MAC_TX_AUTO_NEG, SD_STATUS_LINK_CHG, SD_STATUS_UPDATED, SPEED_1000, SPEED_UNKNOWN, tg3_flag, tg3_init_bcm8002(), tg3_link_report(), TG3_PHY_ID_BCM8002, tg3_setup_fiber_by_hand(), tg3_setup_fiber_hw_autoneg(), tg3_test_and_report_link_chg(), tp, tr32, tw32, tw32_f, and udelay().

Referenced by tg3_setup_phy().

◆ tg3_setup_fiber_mii_phy()

static int tg3_setup_fiber_mii_phy ( struct tg3 tp,
int  force_reset 
)
static

Definition at line 2061 of file tg3_phy.c.

2062 {
2063  int err = 0;
2064  u32 bmsr, bmcr;
2065  u16 current_speed = SPEED_UNKNOWN;
2066  u8 current_duplex = DUPLEX_UNKNOWN;
2067  int current_link_up = 0;
2068  u32 local_adv, remote_adv, sgsr;
2069 
2070  if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 ||
2071  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) &&
2073  (sgsr & SERDES_TG3_SGMII_MODE)) {
2074 
2075  if (force_reset)
2076  tg3_phy_reset(tp);
2077 
2078  tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK;
2079 
2080  if (!(sgsr & SERDES_TG3_LINK_UP)) {
2081  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2082  } else {
2083  current_link_up = 1;
2084  if (sgsr & SERDES_TG3_SPEED_1000) {
2085  current_speed = SPEED_1000;
2086  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2087  } else if (sgsr & SERDES_TG3_SPEED_100) {
2088  current_speed = SPEED_100;
2089  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2090  } else {
2091  current_speed = SPEED_10;
2092  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2093  }
2094 
2095  if (sgsr & SERDES_TG3_FULL_DUPLEX)
2096  current_duplex = DUPLEX_FULL;
2097  else
2098  current_duplex = DUPLEX_HALF;
2099  }
2100 
2101  tw32_f(MAC_MODE, tp->mac_mode);
2102  udelay(40);
2103 
2105 
2106  goto fiber_setup_done;
2107  }
2108 
2109  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2110  tw32_f(MAC_MODE, tp->mac_mode);
2111  udelay(40);
2112 
2114 
2115  if (force_reset)
2116  tg3_phy_reset(tp);
2117 
2118  tp->link_config.rmt_adv = 0;
2119 
2120  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2121  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2122  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) {
2124  bmsr |= BMSR_LSTATUS;
2125  else
2126  bmsr &= ~BMSR_LSTATUS;
2127  }
2128 
2129  err |= tg3_readphy(tp, MII_BMCR, &bmcr);
2130 
2131  if ((tp->link_config.autoneg == AUTONEG_ENABLE) && !force_reset &&
2132  (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) {
2133  /* do nothing, just check for link up at the end */
2134  } else if (tp->link_config.autoneg == AUTONEG_ENABLE) {
2135  u32 adv, newadv;
2136 
2137  err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
2138  newadv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
2141  ADVERTISE_SLCT);
2142 
2143  newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
2144  newadv |= ethtool_adv_to_mii_adv_x(tp->link_config.advertising);
2145 
2146  if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) {
2147  tg3_writephy(tp, MII_ADVERTISE, newadv);
2148  bmcr |= BMCR_ANENABLE | BMCR_ANRESTART;
2149  tg3_writephy(tp, MII_BMCR, bmcr);
2150 
2152  tp->serdes_counter = SERDES_AN_TIMEOUT_5714S;
2153  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
2154 
2155  return err;
2156  }
2157  } else {
2158  u32 new_bmcr;
2159 
2160  bmcr &= ~BMCR_SPEED1000;
2161  new_bmcr = bmcr & ~(BMCR_ANENABLE | BMCR_FULLDPLX);
2162 
2163  if (tp->link_config.duplex == DUPLEX_FULL)
2164  new_bmcr |= BMCR_FULLDPLX;
2165 
2166  if (new_bmcr != bmcr) {
2167  /* BMCR_SPEED1000 is a reserved bit that needs
2168  * to be set on write.
2169  */
2170  new_bmcr |= BMCR_SPEED1000;
2171 
2172  /* Force a linkdown */
2173  if (tp->link_up) {
2174  u32 adv;
2175 
2176  err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
2177  adv &= ~(ADVERTISE_1000XFULL |
2179  ADVERTISE_SLCT);
2180  tg3_writephy(tp, MII_ADVERTISE, adv);
2181  tg3_writephy(tp, MII_BMCR, bmcr |
2182  BMCR_ANRESTART |
2183  BMCR_ANENABLE);
2184  udelay(10);
2185  netdev_link_down(tp->dev);
2186  }
2187  tg3_writephy(tp, MII_BMCR, new_bmcr);
2188  bmcr = new_bmcr;
2189  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2190  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2191  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) {
2193  bmsr |= BMSR_LSTATUS;
2194  else
2195  bmsr &= ~BMSR_LSTATUS;
2196  }
2197  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
2198  }
2199  }
2200 
2201  if (bmsr & BMSR_LSTATUS) {
2202  current_speed = SPEED_1000;
2203  current_link_up = 1;
2204  if (bmcr & BMCR_FULLDPLX)
2205  current_duplex = DUPLEX_FULL;
2206  else
2207  current_duplex = DUPLEX_HALF;
2208 
2209  local_adv = 0;
2210  remote_adv = 0;
2211 
2212  if (bmcr & BMCR_ANENABLE) {
2213  u32 common;
2214 
2215  err |= tg3_readphy(tp, MII_ADVERTISE, &local_adv);
2216  err |= tg3_readphy(tp, MII_LPA, &remote_adv);
2217  common = local_adv & remote_adv;
2218  if (common & (ADVERTISE_1000XHALF |
2221  current_duplex = DUPLEX_FULL;
2222  else
2223  current_duplex = DUPLEX_HALF;
2224 
2225  tp->link_config.rmt_adv =
2226  mii_adv_to_ethtool_adv_x(remote_adv);
2227  } else if (!tg3_flag(tp, 5780_CLASS)) {
2228  /* Link is up via parallel detect */
2229  } else {
2230  current_link_up = 0;
2231  }
2232  }
2233  }
2234 
2235 fiber_setup_done:
2236  if (current_link_up && current_duplex == DUPLEX_FULL)
2237  tg3_setup_flow_control(tp, local_adv, remote_adv);
2238 
2239  tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX;
2240  if (tp->link_config.active_duplex == DUPLEX_HALF)
2241  tp->mac_mode |= MAC_MODE_HALF_DUPLEX;
2242 
2243  tw32_f(MAC_MODE, tp->mac_mode);
2244  udelay(40);
2245 
2247 
2248  tp->link_config.active_speed = current_speed;
2249  tp->link_config.active_duplex = current_duplex;
2250 
2251  tg3_test_and_report_link_chg(tp, current_link_up);
2252  return err;
2253 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define SPEED_1000
Definition: atl1e.h:52
#define MII_ADVERTISE
Definition: atl1e.h:875
uint16_t u16
Definition: stdint.h:21
#define MII_LPA
Definition: atl1e.h:876
#define tr32(reg)
Definition: tg3.h:3339
#define SERDES_TG3_LINK_UP
Definition: tg3.h:2444
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
static void tg3_clear_mac_status(struct tg3 *tp)
Definition: tg3_phy.c:1946
#define SERDES_TG3_SPEED_100
Definition: tg3.h:2446
#define MAC_MODE_PORT_MODE_MASK
Definition: tg3.h:504
#define BMCR_ANRESTART
Definition: mii.h:46
#define SERDES_TG3_SGMII_MODE
Definition: tg3.h:2443
#define SERDES_TG3_SPEED_1000
Definition: tg3.h:2447
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
#define SERDES_AN_TIMEOUT_5714S
Definition: tg3.h:3152
#define ASIC_REV_5720
Definition: tg3.h:320
u16 advertising[4]
Definition: tulip.c:418
static u16 tg3_advert_flowctrl_1000X(u8 flow_ctrl)
Definition: tg3_phy.c:1355
#define SPEED_10
Definition: atl1e.h:50
#define GET_ASIC_REV(CHIP_REV_ID)
Definition: tg3.h:298
#define TX_STATUS_LINK_UP
Definition: tg3.h:639
#define BMCR_SPEED1000
Definition: mii.h:43
#define SPEED_100
Definition: atl1e.h:51
static void tg3_setup_flow_control(struct tg3 *tp, u32 lcladv, u32 rmtadv)
Definition: tg3_phy.c:1124
#define ADVERTISE_1000XHALF
Definition: mii.h:77
int tg3_phy_reset(struct tg3 *tp)
Definition: tg3_phy.c:622
static u32 mii_adv_to_ethtool_adv_x(u32 adv)
Definition: tg3.h:3436
#define ADVERTISE_SLCT
Definition: mii.h:72
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define DUPLEX_FULL
Definition: bnx2.h:111
#define DUPLEX_UNKNOWN
Definition: tg3.h:156
static u32 ethtool_adv_to_mii_adv_x(u32 ethadv)
Definition: tg3.h:3452
static struct tulip_private * tp
Definition: tulip.c:442
#define SPEED_UNKNOWN
Definition: tg3.h:150
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define ASIC_REV_5719
Definition: tg3.h:319
#define MAC_MODE_PORT_MODE_MII
Definition: tg3.h:507
#define BMSR_LSTATUS
Definition: mii.h:57
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define AUTONEG_ENABLE
Definition: tg3_phy.c:864
static int tg3_test_and_report_link_chg(struct tg3 *tp, int curr_link_up)
Definition: tg3_phy.c:1928
#define MAC_MODE_PORT_MODE_GMII
Definition: tg3.h:506
#define MAC_EVENT_LNKSTATE_CHANGED
Definition: tg3.h:546
#define MAC_MODE_HALF_DUPLEX
Definition: tg3.h:503
#define SERDES_TG3_1000X_STATUS
Definition: tg3.h:2442
#define MAC_EVENT
Definition: tg3.h:544
#define MII_BMCR
Definition: atl1e.h:871
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define SERDES_TG3_FULL_DUPLEX
Definition: tg3.h:2445
struct ib_cm_common common
Definition: ib_mad.h:11
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define ASIC_REV_5714
Definition: tg3.h:307
#define BMCR_ANENABLE
Definition: mii.h:49
#define MII_BMSR
Definition: atl1e.h:872
#define MAC_MODE
Definition: tg3.h:501
#define TG3_PHYFLG_PARALLEL_DETECT
Definition: tg3.h:3252
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
#define BMCR_FULLDPLX
Definition: mii.h:45
#define MAC_TX_STATUS
Definition: tg3.h:635
#define ADVERTISE_1000XFULL
Definition: mii.h:75
#define DUPLEX_HALF
Definition: bnx2.h:110

References ADVERTISE_1000XFULL, ADVERTISE_1000XHALF, ADVERTISE_1000XPAUSE, ADVERTISE_1000XPSE_ASYM, ADVERTISE_SLCT, tulip_private::advertising, ASIC_REV_5714, ASIC_REV_5719, ASIC_REV_5720, AUTONEG_ENABLE, BMCR_ANENABLE, BMCR_ANRESTART, BMCR_FULLDPLX, BMCR_SPEED1000, BMSR_LSTATUS, common, DUPLEX_FULL, DUPLEX_HALF, DUPLEX_UNKNOWN, ethtool_adv_to_mii_adv_x(), GET_ASIC_REV, MAC_EVENT, MAC_EVENT_LNKSTATE_CHANGED, MAC_MODE, MAC_MODE_HALF_DUPLEX, MAC_MODE_PORT_MODE_GMII, MAC_MODE_PORT_MODE_MASK, MAC_MODE_PORT_MODE_MII, MAC_TX_STATUS, mii_adv_to_ethtool_adv_x(), MII_ADVERTISE, MII_BMCR, MII_BMSR, MII_LPA, netdev_link_down(), SERDES_AN_TIMEOUT_5714S, SERDES_TG3_1000X_STATUS, SERDES_TG3_FULL_DUPLEX, SERDES_TG3_LINK_UP, SERDES_TG3_SGMII_MODE, SERDES_TG3_SPEED_100, SERDES_TG3_SPEED_1000, SPEED_10, SPEED_100, SPEED_1000, SPEED_UNKNOWN, tg3_advert_flowctrl_1000X(), tg3_clear_mac_status(), tg3_flag, tg3_phy_reset(), TG3_PHYFLG_PARALLEL_DETECT, tg3_readphy(), tg3_setup_flow_control(), tg3_test_and_report_link_chg(), tg3_writephy(), tp, tr32, tw32_f, TX_STATUS_LINK_UP, and udelay().

Referenced by tg3_setup_phy().

◆ tg3_setup_copper_phy()

static int tg3_setup_copper_phy ( struct tg3 tp,
int  force_reset 
)
static

Definition at line 2255 of file tg3_phy.c.

2256 { DBGP("%s\n", __func__);
2257 
2258  int current_link_up;
2259  u32 bmsr, val;
2260  u32 lcl_adv, rmt_adv;
2261  u16 current_speed;
2262  u8 current_duplex;
2263  int i, err;
2264 
2265  tw32(MAC_EVENT, 0);
2266 
2272  udelay(40);
2273 
2274  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
2276  (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL));
2277  udelay(80);
2278  }
2279 
2281 
2282  /* Some third-party PHYs need to be reset on link going
2283  * down.
2284  */
2285  if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
2286  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
2287  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
2288  netdev_link_ok(tp->dev)) {
2289  tg3_readphy(tp, MII_BMSR, &bmsr);
2290  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
2291  !(bmsr & BMSR_LSTATUS))
2292  force_reset = 1;
2293  }
2294  if (force_reset)
2295  tg3_phy_reset(tp);
2296 
2297  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) {
2298  tg3_readphy(tp, MII_BMSR, &bmsr);
2299  if (tg3_readphy(tp, MII_BMSR, &bmsr) ||
2300  !tg3_flag(tp, INIT_COMPLETE))
2301  bmsr = 0;
2302 
2303  if (!(bmsr & BMSR_LSTATUS)) {
2304  err = tg3_init_5401phy_dsp(tp);
2305  if (err)
2306  return err;
2307 
2308  tg3_readphy(tp, MII_BMSR, &bmsr);
2309  for (i = 0; i < 1000; i++) {
2310  udelay(10);
2311  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
2312  (bmsr & BMSR_LSTATUS)) {
2313  udelay(40);
2314  break;
2315  }
2316  }
2317 
2318  if ((tp->phy_id & TG3_PHY_ID_REV_MASK) ==
2320  !(bmsr & BMSR_LSTATUS) &&
2321  tp->link_config.active_speed == SPEED_1000) {
2322  err = tg3_phy_reset(tp);
2323  if (!err)
2324  err = tg3_init_5401phy_dsp(tp);
2325  if (err)
2326  return err;
2327  }
2328  }
2329  } else if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
2330  tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) {
2331  /* 5701 {A0,B0} CRC bug workaround */
2332  tg3_writephy(tp, 0x15, 0x0a75);
2333  tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8c68);
2334  tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68);
2335  tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8c68);
2336  }
2337 
2338  /* Clear pending interrupts... */
2341 
2342  if (tp->phy_flags & TG3_PHYFLG_USE_MI_INTERRUPT)
2344  else if (!(tp->phy_flags & TG3_PHYFLG_IS_FET))
2346 
2347  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
2348  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
2349  if (tp->led_ctrl == LED_CTRL_MODE_PHY_1)
2352  else
2354  }
2355 
2356  current_link_up = 0;
2357  current_speed = SPEED_INVALID;
2358  current_duplex = DUPLEX_INVALID;
2359 
2360  if (tp->phy_flags & TG3_PHYFLG_CAPACITIVE_COUPLING) {
2361  err = tg3_phy_auxctl_read(tp,
2363  &val);
2364  if (!err && !(val & (1 << 10))) {
2367  val | (1 << 10));
2368  goto relink;
2369  }
2370  }
2371 
2372  bmsr = 0;
2373  for (i = 0; i < 100; i++) {
2374  tg3_readphy(tp, MII_BMSR, &bmsr);
2375  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
2376  (bmsr & BMSR_LSTATUS))
2377  break;
2378  udelay(40);
2379  }
2380 
2381  if (bmsr & BMSR_LSTATUS) {
2382  u32 aux_stat, bmcr;
2383 
2384  tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat);
2385  for (i = 0; i < 2000; i++) {
2386  udelay(10);
2387  if (!tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat) &&
2388  aux_stat)
2389  break;
2390  }
2391 
2392  tg3_aux_stat_to_speed_duplex(tp, aux_stat,
2393  &current_speed,
2394  &current_duplex);
2395 
2396  bmcr = 0;
2397  for (i = 0; i < 200; i++) {
2398  tg3_readphy(tp, MII_BMCR, &bmcr);
2399  if (tg3_readphy(tp, MII_BMCR, &bmcr))
2400  continue;
2401  if (bmcr && bmcr != 0x7fff)
2402  break;
2403  udelay(10);
2404  }
2405 
2406  lcl_adv = 0;
2407  rmt_adv = 0;
2408 
2409  tp->link_config.active_speed = current_speed;
2410  tp->link_config.active_duplex = current_duplex;
2411 
2412  if ((bmcr & BMCR_ANENABLE) &&
2414  tp->link_config.advertising)) {
2415  if (tg3_adv_1000T_flowctrl_ok(tp, &lcl_adv,
2416  &rmt_adv)) {
2417  current_link_up = 1;
2418  }
2419  }
2420 
2421  if (current_link_up == 1 &&
2422  tp->link_config.active_duplex == DUPLEX_FULL)
2423  tg3_setup_flow_control(tp, lcl_adv, rmt_adv);
2424  }
2425 
2426 relink:
2427  if (current_link_up == 0) {
2429 
2430  tg3_readphy(tp, MII_BMSR, &bmsr);
2431  if ((!tg3_readphy(tp, MII_BMSR, &bmsr) && (bmsr & BMSR_LSTATUS)) ||
2432  (tp->mac_mode & MAC_MODE_PORT_INT_LPBACK))
2433  current_link_up = 1;
2434  }
2435 
2436  tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK;
2437  if (current_link_up == 1) {
2438  if (tp->link_config.active_speed == SPEED_100 ||
2439  tp->link_config.active_speed == SPEED_10)
2440  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2441  else
2442  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2443  } else if (tp->phy_flags & TG3_PHYFLG_IS_FET)
2444  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2445  else
2446  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2447 
2448  tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX;
2449  if (tp->link_config.active_duplex == DUPLEX_HALF)
2450  tp->mac_mode |= MAC_MODE_HALF_DUPLEX;
2451 
2452  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) {
2453  if (current_link_up == 1 &&
2454  tg3_5700_link_polarity(tp, tp->link_config.active_speed))
2455  tp->mac_mode |= MAC_MODE_LINK_POLARITY;
2456  else
2457  tp->mac_mode &= ~MAC_MODE_LINK_POLARITY;
2458  }
2459 
2460  /* ??? Without this setting Netgear GA302T PHY does not
2461  * ??? send/receive packets...
2462  */
2463  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5411 &&
2464  tp->pci_chip_rev_id == CHIPREV_ID_5700_ALTIMA) {
2465  tp->mi_mode |= MAC_MI_MODE_AUTO_POLL;
2466  tw32_f(MAC_MI_MODE, tp->mi_mode);
2467  udelay(80);
2468  }
2469 
2470  tw32_f(MAC_MODE, tp->mac_mode);
2471  udelay(40);
2472 
2473  /* Enabled attention when the link has changed state. */
2475  udelay(40);
2476 
2477  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 &&
2478  current_link_up == 1 &&
2479  tp->link_config.active_speed == SPEED_1000 &&
2480  (tg3_flag(tp, PCIX_MODE) || tg3_flag(tp, PCI_HIGH_SPEED))) {
2481  udelay(120);
2482  /* NOTE: this freezes for mdc? */
2486  udelay(40);
2487  tg3_write_mem(tp,
2490  }
2491 
2492  /* Prevent send BD corruption. */
2493  if (tg3_flag(tp, CLKREQ_BUG)) {
2494  u16 oldlnkctl, newlnkctl;
2495 
2496  pci_read_config_word(tp->pdev,
2497  tp->pcie_cap + PCI_EXP_LNKCTL,
2498  &oldlnkctl);
2499  if (tp->link_config.active_speed == SPEED_100 ||
2500  tp->link_config.active_speed == SPEED_10)
2501  newlnkctl = oldlnkctl & ~PCI_EXP_LNKCTL_CLKREQ_EN;
2502  else
2503  newlnkctl = oldlnkctl | PCI_EXP_LNKCTL_CLKREQ_EN;
2504  if (newlnkctl != oldlnkctl)
2505  pci_write_config_word(tp->pdev,
2506  tp->pcie_cap + PCI_EXP_LNKCTL,
2507  newlnkctl);
2508  }
2509 
2510  if (current_link_up != netdev_link_ok(tp->dev)) {
2511  if (current_link_up)
2512  netdev_link_up(tp->dev);
2513  else
2514  netdev_link_down(tp->dev);
2516  }
2517 
2518  return 0;
2519 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:86
#define SPEED_1000
Definition: atl1e.h:52
uint16_t u16
Definition: stdint.h:21
#define PCI_EXP_LNKCTL
Definition: tg3.h:17
#define TG3_PHYFLG_USE_MI_INTERRUPT
Definition: tg3.h:3236
static void tg3_phy_copper_begin(struct tg3 *tp)
Definition: tg3_phy.c:1158
void __asmcall int val
Definition: setjmp.h:12
static void tg3_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1261
#define TG3_PHY_ID_BCM5411
Definition: tg3.h:3188
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
#define SPEED_INVALID
Definition: bnx2.h:106
#define CHIPREV_ID_5701_B0
Definition: tg3.h:268
#define MAC_MODE_PORT_MODE_MASK
Definition: tg3.h:504
#define ASIC_REV_5700
Definition: tg3.h:299
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:423
#define TG3_PHY_ID_REV_MASK
Definition: tg3.h:3214
#define MAC_STATUS_MI_COMPLETION
Definition: tg3.h:538
#define MII_TG3_IMASK
Definition: tg3.h:2392
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
void netdev_link_down(struct net_device *netdev)
Mark network device as having link down.
Definition: netdevice.c:230
#define MAC_MODE_LINK_POLARITY
Definition: tg3.h:513
u16 advertising[4]
Definition: tulip.c:418
static int tg3_adv_1000T_flowctrl_ok(struct tg3 *tp, u32 *lcladv, u32 *rmtadv)
Definition: tg3_phy.c:1067
#define MAC_STATUS_CFG_CHANGED
Definition: tg3.h:534
#define SPEED_10
Definition: atl1e.h:50
#define GET_ASIC_REV(CHIP_REV_ID)
Definition: tg3.h:298
#define TG3_PHY_REV_BCM5401_B0
Definition: tg3.h:3215
#define MII_TG3_INT_LINKCHG
Definition: tg3.h:2395
#define SPEED_100
Definition: atl1e.h:51
#define MII_TG3_AUX_STAT
Definition: tg3.h:2378
static void tg3_setup_flow_control(struct tg3 *tp, u32 lcladv, u32 rmtadv)
Definition: tg3_phy.c:1124
#define TG3_PHYFLG_CAPACITIVE_COUPLING
Definition: tg3.h:3244
int tg3_phy_reset(struct tg3 *tp)
Definition: tg3_phy.c:622
#define TG3_PHYFLG_IS_FET
Definition: tg3.h:3241
#define DBGP(...)
Definition: compiler.h:532
#define MII_TG3_ISTAT
Definition: tg3.h:2391
#define MAC_STATUS_SYNC_CHANGED
Definition: tg3.h:535
#define DUPLEX_INVALID
Definition: bnx2.h:112
static void netdev_link_up(struct net_device *netdev)
Mark network device as having link up.
Definition: netdevice.h:788
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:639
#define DUPLEX_FULL
Definition: bnx2.h:111
#define LED_CTRL_MODE_PHY_1
Definition: tg3.h:566
static int tg3_init_5401phy_dsp(struct tg3 *tp)
Definition: tg3_phy.c:839
static struct tulip_private * tp
Definition: tulip.c:442
#define ASIC_REV_5704
Definition: tg3.h:302
#define ASIC_REV_5705
Definition: tg3.h:303
#define ASIC_REV_5703
Definition: tg3.h:301
#define MAC_MODE_PORT_INT_LPBACK
Definition: tg3.h:509
#define MII_TG3_MISC_SHDW
Definition: tg3.h:2400
#define MAC_MODE_PORT_MODE_MII
Definition: tg3.h:507
#define BMSR_LSTATUS
Definition: mii.h:57
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define MII_TG3_AUXCTL_SHDWSEL_MISCTEST
Definition: tg3.h:2369
#define CHIPREV_ID_5700_ALTIMA
Definition: tg3.h:265
#define MAC_MODE_PORT_MODE_GMII
Definition: tg3.h:506
#define MAC_EVENT_LNKSTATE_CHANGED
Definition: tg3.h:546
#define MAC_MODE_HALF_DUPLEX
Definition: tg3.h:503
#define MAC_EVENT
Definition: tg3.h:544
#define MII_BMCR
Definition: atl1e.h:871
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MII_TG3_EXT_CTRL
Definition: tg3.h:2322
#define MII_TG3_EXT_CTRL_LNK3_LED_MODE
Definition: tg3.h:2324
static int tg3_5700_link_polarity(struct tg3 *tp, u32 speed)
Definition: tg3_phy.c:1197
static int tg3_phy_auxctl_read(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:548
#define MAC_MI_MODE_AUTO_POLL
Definition: tg3.h:621
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:222
#define MAC_STATUS
Definition: tg3.h:530
#define CHIPREV_ID_5701_A0
Definition: tg3.h:267
void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
Definition: tg3_hw.c:922
#define MII_TG3_AUXCTL_SHDWSEL_PWRCTL
Definition: tg3.h:2362
#define NIC_SRAM_FIRMWARE_MBOX_MAGIC2
Definition: tg3.h:2205
#define tw32(reg, val)
Definition: tg3.h:3329
#define MAC_MI_MODE
Definition: tg3.h:618
static void tg3_aux_stat_to_speed_duplex(struct tg3 *tp, u32 val, u16 *speed, u8 *duplex)
Definition: tg3_phy.c:1019
#define BMCR_ANENABLE
Definition: mii.h:49
static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
Definition: tg3_phy.c:738
#define MII_BMSR
Definition: atl1e.h:872
#define MAC_MODE
Definition: tg3.h:501
#define MAC_STATUS_LNKSTATE_CHANGED
Definition: tg3.h:537
#define PCI_EXP_LNKCTL_CLKREQ_EN
Definition: tg3.h:18
uint8_t u8
Definition: stdint.h:19
uint32_t u32
Definition: stdint.h:23
#define TG3_PHY_ID_MASK
Definition: tg3.h:3185
#define TG3_PHY_ID_BCM5401
Definition: tg3.h:3187
#define NIC_SRAM_FIRMWARE_MBOX
Definition: tg3.h:2203
#define DUPLEX_HALF
Definition: bnx2.h:110
#define ASIC_REV_5701
Definition: tg3.h:300

References tulip_private::advertising, ASIC_REV_5700, ASIC_REV_5701, ASIC_REV_5703, ASIC_REV_5704, ASIC_REV_5705, BMCR_ANENABLE, BMSR_LSTATUS, CHIPREV_ID_5700_ALTIMA, CHIPREV_ID_5701_A0, CHIPREV_ID_5701_B0, DBGP, DUPLEX_FULL, DUPLEX_HALF, DUPLEX_INVALID, GET_ASIC_REV, LED_CTRL_MODE_PHY_1, MAC_EVENT, MAC_EVENT_LNKSTATE_CHANGED, MAC_MI_MODE, MAC_MI_MODE_AUTO_POLL, MAC_MODE, MAC_MODE_HALF_DUPLEX, MAC_MODE_LINK_POLARITY, MAC_MODE_PORT_INT_LPBACK, MAC_MODE_PORT_MODE_GMII, MAC_MODE_PORT_MODE_MASK, MAC_MODE_PORT_MODE_MII, MAC_STATUS, MAC_STATUS_CFG_CHANGED, MAC_STATUS_LNKSTATE_CHANGED, MAC_STATUS_MI_COMPLETION, MAC_STATUS_SYNC_CHANGED, MII_BMCR, MII_BMSR, MII_TG3_AUX_STAT, MII_TG3_AUXCTL_SHDWSEL_MISCTEST, MII_TG3_AUXCTL_SHDWSEL_PWRCTL, MII_TG3_EXT_CTRL, MII_TG3_EXT_CTRL_LNK3_LED_MODE, MII_TG3_IMASK, MII_TG3_INT_LINKCHG, MII_TG3_ISTAT, MII_TG3_MISC_SHDW, netdev_link_down(), netdev_link_ok(), netdev_link_up(), NIC_SRAM_FIRMWARE_MBOX, NIC_SRAM_FIRMWARE_MBOX_MAGIC2, PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_CLKREQ_EN, pci_read_config_word(), pci_write_config_word(), SPEED_10, SPEED_100, SPEED_1000, SPEED_INVALID, tg3_5700_link_polarity(), tg3_adv_1000T_flowctrl_ok(), tg3_aux_stat_to_speed_duplex(), tg3_copper_is_advertising_all(), tg3_flag, tg3_init_5401phy_dsp(), tg3_link_report(), tg3_phy_auxctl_read(), tg3_phy_auxctl_write(), tg3_phy_copper_begin(), TG3_PHY_ID_BCM5401, TG3_PHY_ID_BCM5411, TG3_PHY_ID_MASK, TG3_PHY_ID_REV_MASK, tg3_phy_reset(), TG3_PHY_REV_BCM5401_B0, TG3_PHYFLG_CAPACITIVE_COUPLING, TG3_PHYFLG_IS_FET, TG3_PHYFLG_USE_MI_INTERRUPT, tg3_readphy(), tg3_setup_flow_control(), tg3_write_mem(), tg3_writephy(), tp, tw32, tw32_f, udelay(), and val.

Referenced by tg3_setup_phy().

◆ tg3_setup_phy()

int tg3_setup_phy ( struct tg3 tp,
int  force_reset 
)

Definition at line 2521 of file tg3_phy.c.

2522 { DBGP("%s\n", __func__);
2523 
2524  u32 val;
2525  int err;
2526 
2527  if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES)
2528  err = tg3_setup_fiber_phy(tp, force_reset);
2529  else if (tp->phy_flags & TG3_PHYFLG_MII_SERDES)
2530  err = tg3_setup_fiber_mii_phy(tp, force_reset);
2531  else
2532  err = tg3_setup_copper_phy(tp, force_reset);
2533 
2534  val = (2 << TX_LENGTHS_IPG_CRS_SHIFT) |
2535  (6 << TX_LENGTHS_IPG_SHIFT);
2536  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720)
2537  val |= tr32(MAC_TX_LENGTHS) &
2540 
2541  if (tp->link_config.active_speed == SPEED_1000 &&
2542  tp->link_config.active_duplex == DUPLEX_HALF)
2544  (0xff << TX_LENGTHS_SLOT_TIME_SHIFT));
2545  else
2547  (32 << TX_LENGTHS_SLOT_TIME_SHIFT));
2548 
2549  if (!tg3_flag(tp, 5705_PLUS)) {
2550  if (netdev_link_ok(tp->dev)) {
2552  } else {
2554  }
2555  }
2556 
2558  if (!netdev_link_ok(tp->dev))
2560  else
2563 
2564  return err;
2565 }
#define SPEED_1000
Definition: atl1e.h:52
#define TX_LENGTHS_IPG_SHIFT
Definition: tg3.h:646
#define tr32(reg)
Definition: tg3.h:3339
void __asmcall int val
Definition: setjmp.h:12
#define PCIE_PWR_MGMT_L1_THRESH_MSK
Definition: tg3.h:2088
#define ASIC_REV_5720
Definition: tg3.h:320
#define TX_LENGTHS_JMB_FRM_LEN_MSK
Definition: tg3.h:649
#define GET_ASIC_REV(CHIP_REV_ID)
Definition: tg3.h:298
static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
Definition: tg3_phy.c:2061
#define TX_LENGTHS_CNT_DWN_VAL_MSK
Definition: tg3.h:650
#define TG3_PHYFLG_PHY_SERDES
Definition: tg3.h:3237
#define TG3_PHYFLG_MII_SERDES
Definition: tg3.h:3238
#define DBGP(...)
Definition: compiler.h:532
#define MAC_TX_LENGTHS
Definition: tg3.h:642
#define TX_LENGTHS_SLOT_TIME_SHIFT
Definition: tg3.h:644
static int netdev_link_ok(struct net_device *netdev)
Check link state of network device.
Definition: netdevice.h:639
static struct tulip_private * tp
Definition: tulip.c:442
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
#define HOSTCC_STAT_COAL_TICKS
Definition: tg3.h:1350
static int tg3_setup_fiber_phy(struct tg3 *tp, int force_reset)
Definition: tg3_phy.c:1958
#define tw32(reg, val)
Definition: tg3.h:3329
static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
Definition: tg3_phy.c:2255
#define PCIE_PWR_MGMT_THRESH
Definition: tg3.h:2087
#define TX_LENGTHS_IPG_CRS_SHIFT
Definition: tg3.h:648
#define DEFAULT_STAT_COAL_TICKS
Definition: tg3.h:1351
uint32_t u32
Definition: stdint.h:23
#define DUPLEX_HALF
Definition: bnx2.h:110

References ASIC_REV_5720, DBGP, DEFAULT_STAT_COAL_TICKS, DUPLEX_HALF, GET_ASIC_REV, HOSTCC_STAT_COAL_TICKS, MAC_TX_LENGTHS, netdev_link_ok(), PCIE_PWR_MGMT_L1_THRESH_MSK, PCIE_PWR_MGMT_THRESH, SPEED_1000, tg3_flag, TG3_PHYFLG_MII_SERDES, TG3_PHYFLG_PHY_SERDES, tg3_setup_copper_phy(), tg3_setup_fiber_mii_phy(), tg3_setup_fiber_phy(), tp, tr32, tw32, TX_LENGTHS_CNT_DWN_VAL_MSK, TX_LENGTHS_IPG_CRS_SHIFT, TX_LENGTHS_IPG_SHIFT, TX_LENGTHS_JMB_FRM_LEN_MSK, TX_LENGTHS_SLOT_TIME_SHIFT, and val.

Referenced by tg3_init_one(), tg3_poll_link(), and tg3_reset_hw().

Variable Documentation

◆ subsys_id_to_phy_id

struct subsys_tbl_ent subsys_id_to_phy_id[]
static

Definition at line 141 of file tg3_phy.c.

Referenced by tg3_lookup_by_subsys().