iPXE
Data Structures | Macros | Functions | Variables
tg3_phy.c File Reference
#include <mii.h>
#include <stdio.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 83 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:422
static struct tulip_private * tp
Definition: tulip.c:441
#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 431 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:422
static struct tulip_private * tp
Definition: tulip.c:441
#define MII_TG3_AUXCTL_ACTL_TX_6DB
Definition: tg3.h:2358
#define MII_TG3_AUXCTL_SHDWSEL_AUXCTL
Definition: tg3.h:2357

Definition at line 436 of file tg3_phy.c.

◆ ADVERTISED_Autoneg

#define ADVERTISED_Autoneg   (1 << 6)

Definition at line 858 of file tg3_phy.c.

◆ ADVERTISED_Pause

#define ADVERTISED_Pause   (1 << 13)

Definition at line 859 of file tg3_phy.c.

◆ ADVERTISED_TP

#define ADVERTISED_TP   (1 << 7)

Definition at line 860 of file tg3_phy.c.

◆ ADVERTISED_FIBRE

#define ADVERTISED_FIBRE   (1 << 10)

Definition at line 861 of file tg3_phy.c.

◆ AUTONEG_ENABLE

#define AUTONEG_ENABLE   0x01

Definition at line 863 of file tg3_phy.c.

◆ ANEG_STATE_UNKNOWN

#define ANEG_STATE_UNKNOWN   0

Definition at line 1292 of file tg3_phy.c.

◆ ANEG_STATE_AN_ENABLE

#define ANEG_STATE_AN_ENABLE   1

Definition at line 1293 of file tg3_phy.c.

◆ ANEG_STATE_RESTART_INIT

#define ANEG_STATE_RESTART_INIT   2

Definition at line 1294 of file tg3_phy.c.

◆ ANEG_STATE_RESTART

#define ANEG_STATE_RESTART   3

Definition at line 1295 of file tg3_phy.c.

◆ ANEG_STATE_DISABLE_LINK_OK

#define ANEG_STATE_DISABLE_LINK_OK   4

Definition at line 1296 of file tg3_phy.c.

◆ ANEG_STATE_ABILITY_DETECT_INIT

#define ANEG_STATE_ABILITY_DETECT_INIT   5

Definition at line 1297 of file tg3_phy.c.

◆ ANEG_STATE_ABILITY_DETECT

#define ANEG_STATE_ABILITY_DETECT   6

Definition at line 1298 of file tg3_phy.c.

◆ ANEG_STATE_ACK_DETECT_INIT

#define ANEG_STATE_ACK_DETECT_INIT   7

Definition at line 1299 of file tg3_phy.c.

◆ ANEG_STATE_ACK_DETECT

#define ANEG_STATE_ACK_DETECT   8

Definition at line 1300 of file tg3_phy.c.

◆ ANEG_STATE_COMPLETE_ACK_INIT

#define ANEG_STATE_COMPLETE_ACK_INIT   9

Definition at line 1301 of file tg3_phy.c.

◆ ANEG_STATE_COMPLETE_ACK

#define ANEG_STATE_COMPLETE_ACK   10

Definition at line 1302 of file tg3_phy.c.

◆ ANEG_STATE_IDLE_DETECT_INIT

#define ANEG_STATE_IDLE_DETECT_INIT   11

Definition at line 1303 of file tg3_phy.c.

◆ ANEG_STATE_IDLE_DETECT

#define ANEG_STATE_IDLE_DETECT   12

Definition at line 1304 of file tg3_phy.c.

◆ ANEG_STATE_LINK_OK

#define ANEG_STATE_LINK_OK   13

Definition at line 1305 of file tg3_phy.c.

◆ ANEG_STATE_NEXT_PAGE_WAIT_INIT

#define ANEG_STATE_NEXT_PAGE_WAIT_INIT   14

Definition at line 1306 of file tg3_phy.c.

◆ ANEG_STATE_NEXT_PAGE_WAIT

#define ANEG_STATE_NEXT_PAGE_WAIT   15

Definition at line 1307 of file tg3_phy.c.

◆ MR_AN_ENABLE

#define MR_AN_ENABLE   0x00000001

Definition at line 1310 of file tg3_phy.c.

◆ MR_RESTART_AN

#define MR_RESTART_AN   0x00000002

Definition at line 1311 of file tg3_phy.c.

◆ MR_AN_COMPLETE

#define MR_AN_COMPLETE   0x00000004

Definition at line 1312 of file tg3_phy.c.

◆ MR_PAGE_RX

#define MR_PAGE_RX   0x00000008

Definition at line 1313 of file tg3_phy.c.

◆ MR_NP_LOADED

#define MR_NP_LOADED   0x00000010

Definition at line 1314 of file tg3_phy.c.

◆ MR_TOGGLE_TX

#define MR_TOGGLE_TX   0x00000020

Definition at line 1315 of file tg3_phy.c.

◆ MR_LP_ADV_FULL_DUPLEX

#define MR_LP_ADV_FULL_DUPLEX   0x00000040

Definition at line 1316 of file tg3_phy.c.

◆ MR_LP_ADV_HALF_DUPLEX

#define MR_LP_ADV_HALF_DUPLEX   0x00000080

Definition at line 1317 of file tg3_phy.c.

◆ MR_LP_ADV_SYM_PAUSE

#define MR_LP_ADV_SYM_PAUSE   0x00000100

Definition at line 1318 of file tg3_phy.c.

◆ MR_LP_ADV_ASYM_PAUSE

#define MR_LP_ADV_ASYM_PAUSE   0x00000200

Definition at line 1319 of file tg3_phy.c.

◆ MR_LP_ADV_REMOTE_FAULT1

#define MR_LP_ADV_REMOTE_FAULT1   0x00000400

Definition at line 1320 of file tg3_phy.c.

◆ MR_LP_ADV_REMOTE_FAULT2

#define MR_LP_ADV_REMOTE_FAULT2   0x00000800

Definition at line 1321 of file tg3_phy.c.

◆ MR_LP_ADV_NEXT_PAGE

#define MR_LP_ADV_NEXT_PAGE   0x00001000

Definition at line 1322 of file tg3_phy.c.

◆ MR_TOGGLE_RX

#define MR_TOGGLE_RX   0x00002000

Definition at line 1323 of file tg3_phy.c.

◆ MR_NP_RX

#define MR_NP_RX   0x00004000

Definition at line 1324 of file tg3_phy.c.

◆ MR_LINK_OK

#define MR_LINK_OK   0x80000000

Definition at line 1326 of file tg3_phy.c.

◆ ANEG_CFG_NP

#define ANEG_CFG_NP   0x00000080

Definition at line 1336 of file tg3_phy.c.

◆ ANEG_CFG_ACK

#define ANEG_CFG_ACK   0x00000040

Definition at line 1337 of file tg3_phy.c.

◆ ANEG_CFG_RF2

#define ANEG_CFG_RF2   0x00000020

Definition at line 1338 of file tg3_phy.c.

◆ ANEG_CFG_RF1

#define ANEG_CFG_RF1   0x00000010

Definition at line 1339 of file tg3_phy.c.

◆ ANEG_CFG_PS2

#define ANEG_CFG_PS2   0x00000001

Definition at line 1340 of file tg3_phy.c.

◆ ANEG_CFG_PS1

#define ANEG_CFG_PS1   0x00008000

Definition at line 1341 of file tg3_phy.c.

◆ ANEG_CFG_HD

#define ANEG_CFG_HD   0x00004000

Definition at line 1342 of file tg3_phy.c.

◆ ANEG_CFG_FD

#define ANEG_CFG_FD   0x00002000

Definition at line 1343 of file tg3_phy.c.

◆ ANEG_CFG_INVAL

#define ANEG_CFG_INVAL   0x00001f06

Definition at line 1344 of file tg3_phy.c.

◆ ANEG_OK

#define ANEG_OK   0

Definition at line 1347 of file tg3_phy.c.

◆ ANEG_DONE

#define ANEG_DONE   1

Definition at line 1348 of file tg3_phy.c.

◆ ANEG_TIMER_ENAB

#define ANEG_TIMER_ENAB   2

Definition at line 1349 of file tg3_phy.c.

◆ ANEG_FAILED

#define ANEG_FAILED   -1

Definition at line 1350 of file tg3_phy.c.

◆ ANEG_STATE_SETTLE_TIME

#define ANEG_STATE_SETTLE_TIME   10000

Definition at line 1352 of file tg3_phy.c.

Function Documentation

◆ tg3_link_report()

static void tg3_link_report ( struct tg3 tp)
static

Definition at line 1260 of file tg3_phy.c.

1261 { DBGP("%s\n", __func__);
1262 
1263  if (!netdev_link_ok(tp->dev)) {
1264  DBGC(tp->dev, "Link is down\n");
1266  } else {
1267  DBGC(tp->dev, "Link is up at %d Mbps, %s duplex\n",
1268  (tp->link_config.active_speed == SPEED_1000 ?
1269  1000 :
1270  (tp->link_config.active_speed == SPEED_100 ?
1271  100 : 10)),
1272  (tp->link_config.active_duplex == DUPLEX_FULL ?
1273  "full" : "half"));
1274 
1275  DBGC(tp->dev, "Flow control is %s for TX and %s for RX\n",
1276  (tp->link_config.active_flowctrl & FLOW_CTRL_TX) ?
1277  "on" : "off",
1278  (tp->link_config.active_flowctrl & FLOW_CTRL_RX) ?
1279  "on" : "off");
1280 
1281  if (tp->phy_flags & TG3_PHYFLG_EEE_CAP)
1282  DBGC(tp->dev, "EEE is %s\n",
1283  tp->setlpicnt ? "enabled" : "disabled");
1284 
1286  }
1287 }
#define SPEED_1000
Definition: atl1e.h:52
static void tg3_ump_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1212
#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:636
#define DUPLEX_FULL
Definition: bnx2.h:111
static struct tulip_private * tp
Definition: tulip.c:441
#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 13 of file tg3_phy.c.

14 { DBGP("%s\n", __func__);
15 
16  if (tg3_flag(tp, 5717_PLUS)) {
17  u32 is_serdes;
18 
19  tp->phy_addr = PCI_FUNC(tp->pdev->busdevfn) + 1;
20 
21  if (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0)
22  is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES;
23  else
24  is_serdes = tr32(TG3_CPMU_PHY_STRAP) &
26  if (is_serdes)
27  tp->phy_addr += 7;
28  } else
29  tp->phy_addr = TG3_PHY_MII_ADDR;
30 }
#define PCI_FUNC(busdevfn)
Definition: pci.h:281
#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:441
#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 32 of file tg3_phy.c.

33 { DBGP("%s\n", __func__);
34 
35  int i;
36  u32 val;
37 
39  tw32(OTP_CTRL, cmd);
40 
41  /* Wait for up to 1 ms for command to execute. */
42  for (i = 0; i < 100; i++) {
43  val = tr32(OTP_STATUS);
45  break;
46  udelay(10);
47  }
48 
49  return (val & OTP_STATUS_CMD_DONE) ? 0 : -EBUSY;
50 }
#define tr32(reg)
Definition: tg3.h:3339
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define OTP_STATUS
Definition: tg3.h:2072
#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
void __asmcall int val
Definition: setjmp.h:28
#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 56 of file tg3_phy.c.

57 { DBGP("%s\n", __func__);
58 
59  u32 bhalf_otp, thalf_otp;
60 
62 
64  return 0;
65 
67 
69  return 0;
70 
71  thalf_otp = tr32(OTP_READ_DATA);
72 
74 
76  return 0;
77 
78  bhalf_otp = tr32(OTP_READ_DATA);
79 
80  return ((thalf_otp & 0x0000ffff) << 16) | (bhalf_otp >> 16);
81 }
#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:32
#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:441
#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 85 of file tg3_phy.c.

86 { DBGP("%s\n", __func__);
87 
88  u32 frame_val;
89  unsigned int loops;
90  int ret;
91 
92  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
94  (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL));
95  udelay(80);
96  }
97 
98  *val = 0x0;
99 
100  frame_val = ((tp->phy_addr << MI_COM_PHY_ADDR_SHIFT) &
102  frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
104  frame_val |= (MI_COM_CMD_READ | MI_COM_START);
105 
106  tw32_f(MAC_MI_COM, frame_val);
107 
108  loops = PHY_BUSY_LOOPS;
109  while (loops != 0) {
110  udelay(10);
111  frame_val = tr32(MAC_MI_COM);
112 
113  if ((frame_val & MI_COM_BUSY) == 0) {
114  udelay(5);
115  frame_val = tr32(MAC_MI_COM);
116  break;
117  }
118  loops -= 1;
119  }
120 
121  ret = -EBUSY;
122  if (loops != 0) {
123  *val = frame_val & MI_COM_DATA_MASK;
124  ret = 0;
125  }
126 
127  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
128  tw32_f(MAC_MI_MODE, tp->mi_mode);
129  udelay(80);
130  }
131 
132  return ret;
133 }
#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
#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:83
#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:441
#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
void __asmcall int val
Definition: setjmp.h:28
#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 204 of file tg3_phy.c.

205 { DBGP("%s\n", __func__);
206 
207  int i;
208 
209  DBGC(tp->dev, "Matching with: %x:%x\n", tp->subsystem_vendor, tp->subsystem_device);
210 
211  for (i = 0; i < (int) ARRAY_SIZE(subsys_id_to_phy_id); i++) {
212  if ((subsys_id_to_phy_id[i].subsys_vendor ==
213  tp->subsystem_vendor) &&
215  tp->subsystem_device))
216  return &subsys_id_to_phy_id[i];
217  }
218  return NULL;
219 }
static struct subsys_tbl_ent subsys_id_to_phy_id[]
Definition: tg3_phy.c:140
#define DBGC(...)
Definition: compiler.h:505
u16 subsys_devid
Definition: tg3_phy.c:136
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:441
#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 221 of file tg3_phy.c.

222 { DBGP("%s\n", __func__);
223 
224  u32 frame_val;
225  unsigned int loops;
226  int ret;
227 
228  if ((tp->phy_flags & TG3_PHYFLG_IS_FET) &&
230  return 0;
231 
232  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
234  (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL));
235  udelay(80);
236  }
237 
238  frame_val = ((tp->phy_addr << MI_COM_PHY_ADDR_SHIFT) &
240  frame_val |= ((reg << MI_COM_REG_ADDR_SHIFT) &
242  frame_val |= (val & MI_COM_DATA_MASK);
243  frame_val |= (MI_COM_CMD_WRITE | MI_COM_START);
244 
245  tw32_f(MAC_MI_COM, frame_val);
246 
247  loops = PHY_BUSY_LOOPS;
248  while (loops != 0) {
249  udelay(10);
250  frame_val = tr32(MAC_MI_COM);
251  if ((frame_val & MI_COM_BUSY) == 0) {
252  udelay(5);
253  frame_val = tr32(MAC_MI_COM);
254  break;
255  }
256  loops -= 1;
257  }
258 
259  ret = -EBUSY;
260  if (loops != 0)
261  ret = 0;
262 
263  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
264  tw32_f(MAC_MI_MODE, tp->mi_mode);
265  udelay(80);
266  }
267 
268  return ret;
269 }
#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
#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:83
#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:441
#define MI_COM_REG_ADDR_SHIFT
Definition: tg3.h:613
#define tw32_f(reg, val)
Definition: tg3.h:3333
void __asmcall int val
Definition: setjmp.h:28
#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 271 of file tg3_phy.c.

272 { DBGP("%s\n", __func__);
273 
274  u32 phy_control;
275  int limit, err;
276 
277  /* OK, reset it, and poll the BMCR_RESET bit until it
278  * clears or we time out.
279  */
280  phy_control = BMCR_RESET;
281  err = tg3_writephy(tp, MII_BMCR, phy_control);
282  if (err != 0)
283  return -EBUSY;
284 
285  limit = 5000;
286  while (limit--) {
287  err = tg3_readphy(tp, MII_BMCR, &phy_control);
288  if (err != 0)
289  return -EBUSY;
290 
291  if ((phy_control & BMCR_RESET) == 0) {
292  udelay(40);
293  break;
294  }
295  udelay(10);
296  }
297  if (limit < 0)
298  return -EBUSY;
299 
300  return 0;
301 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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:441
uint16_t limit
Limit.
Definition: librm.h:250
#define MII_BMCR
Definition: atl1e.h:871
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221
#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 303 of file tg3_phy.c.

304 { DBGP("%s\n", __func__);
305 
306  int limit = 100;
307 
308  while (limit--) {
309  u32 tmp32;
310 
311  if (!tg3_readphy(tp, MII_TG3_DSP_CONTROL, &tmp32)) {
312  if ((tmp32 & 0x1000) == 0)
313  break;
314  }
315  }
316  if (limit < 0)
317  return -EBUSY;
318 
319  return 0;
320 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#define EBUSY
Device or resource busy.
Definition: errno.h:338
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:441
uint16_t limit
Limit.
Definition: librm.h:250
#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 322 of file tg3_phy.c.

323 { DBGP("%s\n", __func__);
324 
325  static const u32 test_pat[4][6] = {
326  { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
327  { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
328  { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
329  { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
330  };
331  int chan;
332 
333  for (chan = 0; chan < 4; chan++) {
334  int i;
335 
337  (chan * 0x2000) | 0x0200);
339 
340  for (i = 0; i < 6; i++)
342  test_pat[chan][i]);
343 
345  if (tg3_wait_macro_done(tp)) {
346  *resetp = 1;
347  return -EBUSY;
348  }
349 
351  (chan * 0x2000) | 0x0200);
353  if (tg3_wait_macro_done(tp)) {
354  *resetp = 1;
355  return -EBUSY;
356  }
357 
359  if (tg3_wait_macro_done(tp)) {
360  *resetp = 1;
361  return -EBUSY;
362  }
363 
364  for (i = 0; i < 6; i += 2) {
365  u32 low, high;
366 
370  *resetp = 1;
371  return -EBUSY;
372  }
373  low &= 0x7fff;
374  high &= 0x000f;
375  if (low != test_pat[chan][i] ||
376  high != test_pat[chan][i+1]) {
380 
381  return -EBUSY;
382  }
383  }
384  }
385 
386  return 0;
387 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
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:441
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:221
#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:303
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 389 of file tg3_phy.c.

390 { DBGP("%s\n", __func__);
391 
392  int chan;
393 
394  for (chan = 0; chan < 4; chan++) {
395  int i;
396 
398  (chan * 0x2000) | 0x0200);
400  for (i = 0; i < 6; i++)
403  if (tg3_wait_macro_done(tp))
404  return -EBUSY;
405  }
406 
407  return 0;
408 }
#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:441
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221
#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:303

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 410 of file tg3_phy.c.

411 { DBGP("%s\n", __func__);
412 
413  int err;
414 
416  if (!err)
418 
419  return err;
420 }
static unsigned int unsigned int reg
Definition: myson.h:162
#define MII_TG3_DSP_RW_PORT
Definition: tg3.h:2332
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:441
void __asmcall int val
Definition: setjmp.h:28
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221
#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 422 of file tg3_phy.c.

423 { DBGP("%s\n", __func__);
424 
427 
428  return tg3_writephy(tp, MII_TG3_AUX_CTRL, set | reg);
429 }
#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:441
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221

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 440 of file tg3_phy.c.

441 { DBGP("%s\n", __func__);
442 
443  u32 reg32, phy9_orig;
444  int retries, do_phy_reset, err;
445 
446  retries = 10;
447  do_phy_reset = 1;
448  do {
449  if (do_phy_reset) {
450  err = tg3_bmcr_reset(tp);
451  if (err)
452  return err;
453  do_phy_reset = 0;
454  }
455 
456  /* Disable transmitter and interrupt. */
457  if (tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32))
458  continue;
459 
460  reg32 |= 0x3000;
462 
463  /* Set full-duplex, 1000 mbps. */
466 
467  /* Set to master mode. */
468  if (tg3_readphy(tp, MII_TG3_CTRL, &phy9_orig))
469  continue;
470 
474 
476  if (err)
477  return err;
478 
479  /* Block the PHY control access. */
480  tg3_phydsp_write(tp, 0x8005, 0x0800);
481 
482  err = tg3_phy_write_and_check_testpat(tp, &do_phy_reset);
483  if (!err)
484  break;
485  } while (--retries);
486 
487  err = tg3_phy_reset_chanpat(tp);
488  if (err)
489  return err;
490 
491  tg3_phydsp_write(tp, 0x8005, 0x0000);
492 
495 
497 
498  tg3_writephy(tp, MII_TG3_CTRL, phy9_orig);
499 
500  if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32)) {
501  reg32 &= ~0x3000;
503  } else if (!err)
504  err = -EBUSY;
505 
506  return err;
507 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#define EBUSY
Device or resource busy.
Definition: errno.h:338
static int tg3_phy_reset_chanpat(struct tg3 *tp)
Definition: tg3_phy.c:389
static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
Definition: tg3_phy.c:410
#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)
Definition: tg3_phy.c:431
#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:441
static int tg3_bmcr_reset(struct tg3 *tp)
Definition: tg3_phy.c:271
#define TG3_PHY_AUXCTL_SMDSP_DISABLE(tp)
Definition: tg3_phy.c:436
#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:221
#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:322
#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 509 of file tg3_phy.c.

510 { DBGP("%s\n", __func__);
511 
512  u32 otp, phy;
513 
514  if (!tp->phy_otp)
515  return;
516 
517  otp = tp->phy_otp;
518 
520  return;
521 
522  phy = ((otp & TG3_OTP_AGCTGT_MASK) >> TG3_OTP_AGCTGT_SHIFT);
525 
526  phy = ((otp & TG3_OTP_HPFFLTR_MASK) >> TG3_OTP_HPFFLTR_SHIFT) |
529 
530  phy = ((otp & TG3_OTP_LPFDIS_MASK) >> TG3_OTP_LPFDIS_SHIFT);
533 
534  phy = ((otp & TG3_OTP_VDAC_MASK) >> TG3_OTP_VDAC_SHIFT);
536 
537  phy = ((otp & TG3_OTP_10BTAMP_MASK) >> TG3_OTP_10BTAMP_SHIFT);
539 
540  phy = ((otp & TG3_OTP_ROFF_MASK) >> TG3_OTP_ROFF_SHIFT) |
543 
545 }
#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:410
#define TG3_PHY_AUXCTL_SMDSP_ENABLE(tp)
Definition: tg3_phy.c:431
#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:441
#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:436
#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 547 of file tg3_phy.c.

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

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 561 of file tg3_phy.c.

562 { DBGP("%s\n", __func__);
563 
564  u32 phy;
565 
566  if (!tg3_flag(tp, 5705_PLUS) ||
567  (tp->phy_flags & TG3_PHYFLG_ANY_SERDES))
568  return;
569 
570  if (tp->phy_flags & TG3_PHYFLG_IS_FET) {
571  u32 ephy;
572 
573  if (!tg3_readphy(tp, MII_TG3_FET_TEST, &ephy)) {
575 
577  ephy | MII_TG3_FET_SHADOW_EN);
578  if (!tg3_readphy(tp, reg, &phy)) {
579  if (enable)
581  else
583  tg3_writephy(tp, reg, phy);
584  }
586  }
587  } else {
588  int ret;
589 
590  ret = tg3_phy_auxctl_read(tp,
592  if (!ret) {
593  if (enable)
595  else
599  }
600  }
601 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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:422
#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:441
#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:547
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221
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 603 of file tg3_phy.c.

604 { DBGP("%s\n", __func__);
605 
606  int ret;
607  u32 val;
608 
609  if (tp->phy_flags & TG3_PHYFLG_NO_ETH_WIRE_SPEED)
610  return;
611 
613  if (!ret)
616 }
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:422
#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:441
void __asmcall int val
Definition: setjmp.h:28
static int tg3_phy_auxctl_read(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:547
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 621 of file tg3_phy.c.

622 { DBGP("%s\n", __func__);
623 
624  u32 val, cpmuctrl;
625  int err;
626 
627  DBGCP(&tp->pdev->dev, "%s\n", __func__);
628 
629  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
630  val = tr32(GRC_MISC_CFG);
632  udelay(40);
633  }
634  err = tg3_readphy(tp, MII_BMSR, &val);
635  err |= tg3_readphy(tp, MII_BMSR, &val);
636  if (err != 0)
637  return -EBUSY;
638 
639  netdev_link_down(tp->dev);
641 
642  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
643  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
644  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) {
645  err = tg3_phy_reset_5703_4_5(tp);
646  if (err)
647  return err;
648  goto out;
649  }
650 
651  cpmuctrl = 0;
652  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5784 &&
653  GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5784_AX) {
654  cpmuctrl = tr32(TG3_CPMU_CTRL);
655  if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY)
657  cpmuctrl & ~CPMU_CTRL_GPHY_10MB_RXONLY);
658  }
659 
660  err = tg3_bmcr_reset(tp);
661  if (err)
662  return err;
663 
664  if (cpmuctrl & CPMU_CTRL_GPHY_10MB_RXONLY) {
667 
668  tw32(TG3_CPMU_CTRL, cpmuctrl);
669  }
670 
671  if (GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5784_AX ||
672  GET_CHIP_REV(tp->pci_chip_rev_id) == CHIPREV_5761_AX) {
677  udelay(40);
679  }
680  }
681 
682  if (tg3_flag(tp, 5717_PLUS) &&
683  (tp->phy_flags & TG3_PHYFLG_MII_SERDES))
684  return 0;
685 
687 
688 out:
689  if ((tp->phy_flags & TG3_PHYFLG_ADC_BUG) &&
691  tg3_phydsp_write(tp, 0x201f, 0x2aaa);
692  tg3_phydsp_write(tp, 0x000a, 0x0323);
694  }
695 
696  if (tp->phy_flags & TG3_PHYFLG_5704_A0_BUG) {
699  }
700 
701  if (tp->phy_flags & TG3_PHYFLG_BER_BUG) {
703  tg3_phydsp_write(tp, 0x000a, 0x310b);
704  tg3_phydsp_write(tp, 0x201f, 0x9506);
705  tg3_phydsp_write(tp, 0x401f, 0x14e2);
707  }
708  } else if (tp->phy_flags & TG3_PHYFLG_JITTER_BUG) {
711  if (tp->phy_flags & TG3_PHYFLG_ADJUST_TRIM) {
714  MII_TG3_TEST1_TRIM_EN | 0x4);
715  } else
717 
719  }
720  }
721 
722  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) {
723  /* Cannot do read-modify-write on 5401 */
725  }
726 
727  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
728  /* adjust output voltage */
730  }
731 
734  return 0;
735 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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
static void tg3_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1260
static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
Definition: tg3_phy.c:440
#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:422
#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
#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:410
__be32 out[4]
Definition: CIB_PRM.h:36
#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:431
#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:441
#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:271
#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:436
#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:509
void __asmcall int val
Definition: setjmp.h:28
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221
#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:603
#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:561
#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 737 of file tg3_phy.c.

738 { DBGP("%s\n", __func__);
739 
740  u32 adv_reg, all_mask = 0;
741 
742  if (mask & ADVERTISED_10baseT_Half)
743  all_mask |= ADVERTISE_10HALF;
744  if (mask & ADVERTISED_10baseT_Full)
745  all_mask |= ADVERTISE_10FULL;
746  if (mask & ADVERTISED_100baseT_Half)
747  all_mask |= ADVERTISE_100HALF;
748  if (mask & ADVERTISED_100baseT_Full)
749  all_mask |= ADVERTISE_100FULL;
750 
751  if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg))
752  return 0;
753 
754  if ((adv_reg & all_mask) != all_mask)
755  return 0;
756  if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) {
757  u32 tg3_ctrl;
758 
759  all_mask = 0;
760  if (mask & ADVERTISED_1000baseT_Half)
761  all_mask |= ADVERTISE_1000HALF;
762  if (mask & ADVERTISED_1000baseT_Full)
763  all_mask |= ADVERTISE_1000FULL;
764 
765  if (tg3_readphy(tp, MII_TG3_CTRL, &tg3_ctrl))
766  return 0;
767 
768  if ((tg3_ctrl & all_mask) != all_mask)
769  return 0;
770  }
771  return 1;
772 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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:441
#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 774 of file tg3_phy.c.

775 { DBGP("%s\n", __func__);
776 
777  u16 miireg;
778 
779  if ((flow_ctrl & FLOW_CTRL_TX) && (flow_ctrl & FLOW_CTRL_RX))
780  miireg = ADVERTISE_PAUSE_CAP;
781  else if (flow_ctrl & FLOW_CTRL_TX)
782  miireg = ADVERTISE_PAUSE_ASYM;
783  else if (flow_ctrl & FLOW_CTRL_RX)
785  else
786  miireg = 0;
787 
788  return miireg;
789 }
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 791 of file tg3_phy.c.

792 { DBGP("%s\n", __func__);
793 
794  int err = 0;
795  u32 val __unused, new_adv;
796 
797  new_adv = ADVERTISE_CSMA;
798  if (advertise & ADVERTISED_10baseT_Half)
799  new_adv |= ADVERTISE_10HALF;
800  if (advertise & ADVERTISED_10baseT_Full)
801  new_adv |= ADVERTISE_10FULL;
802  if (advertise & ADVERTISED_100baseT_Half)
803  new_adv |= ADVERTISE_100HALF;
804  if (advertise & ADVERTISED_100baseT_Full)
805  new_adv |= ADVERTISE_100FULL;
806 
808 
809  err = tg3_writephy(tp, MII_ADVERTISE, new_adv);
810  if (err)
811  goto done;
812 
813  if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)
814  goto done;
815 
816  new_adv = 0;
817  if (advertise & ADVERTISED_1000baseT_Half)
818  new_adv |= MII_TG3_CTRL_ADV_1000_HALF;
819  if (advertise & ADVERTISED_1000baseT_Full)
820  new_adv |= MII_TG3_CTRL_ADV_1000_FULL;
821 
822  if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
823  tp->pci_chip_rev_id == CHIPREV_ID_5701_B0)
824  new_adv |= (MII_TG3_CTRL_AS_MASTER |
826 
827  err = tg3_writephy(tp, MII_TG3_CTRL, new_adv);
828  if (err)
829  goto done;
830 
831  if (!(tp->phy_flags & TG3_PHYFLG_EEE_CAP))
832  goto done;
833 
834 done:
835  return err;
836 }
#define MII_ADVERTISE
Definition: atl1e.h:875
#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:774
static struct tulip_private * tp
Definition: tulip.c:441
#define ADVERTISE_CSMA
Definition: mii.h:73
void __asmcall int val
Definition: setjmp.h:28
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
#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:221
#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 838 of file tg3_phy.c.

839 { DBGP("%s\n", __func__);
840 
841  int err;
842 
843  /* Turn off tap power management. */
844  /* Set Extended packet length bit */
846 
847  err |= tg3_phydsp_write(tp, 0x0012, 0x1804);
848  err |= tg3_phydsp_write(tp, 0x0013, 0x1204);
849  err |= tg3_phydsp_write(tp, 0x8006, 0x0132);
850  err |= tg3_phydsp_write(tp, 0x8006, 0x0232);
851  err |= tg3_phydsp_write(tp, 0x201f, 0x0a20);
852 
853  udelay(40);
854 
855  return err;
856 }
static int tg3_phy_auxctl_write(struct tg3 *tp, int reg, u32 set)
Definition: tg3_phy.c:422
static int tg3_phydsp_write(struct tg3 *tp, u32 reg, u32 val)
Definition: tg3_phy.c:410
#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:441
#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 865 of file tg3_phy.c.

866 { DBGP("%s\n", __func__);
867 
868  u32 adv = ADVERTISED_Autoneg |
870 
871 
872  if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY))
875  if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES))
876  adv |= ADVERTISED_100baseT_Half |
881  else
882  adv |= ADVERTISED_FIBRE;
883 
884  tp->link_config.advertising = adv;
885  tp->link_config.speed = SPEED_INVALID;
886  tp->link_config.duplex = DUPLEX_INVALID;
887  tp->link_config.autoneg = AUTONEG_ENABLE;
888  tp->link_config.active_speed = SPEED_INVALID;
889  tp->link_config.active_duplex = DUPLEX_INVALID;
890  tp->link_config.orig_speed = SPEED_INVALID;
891  tp->link_config.orig_duplex = DUPLEX_INVALID;
892  tp->link_config.orig_autoneg = AUTONEG_INVALID;
893 }
#define ADVERTISED_Autoneg
Definition: tg3_phy.c:858
#define AUTONEG_INVALID
Definition: tg3.h:2837
#define ADVERTISED_Pause
Definition: tg3_phy.c:859
#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:861
#define ADVERTISED_TP
Definition: tg3_phy.c:860
#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:441
#define AUTONEG_ENABLE
Definition: tg3_phy.c:863
#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 895 of file tg3_phy.c.

896 { DBGP("%s\n", __func__);
897 
898  u32 hw_phy_id_1, hw_phy_id_2;
899  u32 hw_phy_id, hw_phy_id_masked;
900  int err;
901 
902  /* flow control autonegotiation is default behavior */
903  tg3_flag_set(tp, PAUSE_AUTONEG);
904  tp->link_config.flowctrl = FLOW_CTRL_TX | FLOW_CTRL_RX;
905 
906  /* Reading the PHY ID register can conflict with ASF
907  * firmware access to the PHY hardware.
908  */
909  err = 0;
910  if (tg3_flag(tp, ENABLE_ASF) || tg3_flag(tp, ENABLE_APE)) {
911  hw_phy_id = hw_phy_id_masked = TG3_PHY_ID_INVALID;
912  } else {
913  /* Now read the physical PHY_ID from the chip and verify
914  * that it is sane. If it doesn't look good, we fall back
915  * to either the hard-coded table based PHY_ID and failing
916  * that the value found in the eeprom area.
917  */
918  err |= tg3_readphy(tp, MII_PHYSID1, &hw_phy_id_1);
919  err |= tg3_readphy(tp, MII_PHYSID2, &hw_phy_id_2);
920 
921  hw_phy_id = (hw_phy_id_1 & 0xffff) << 10;
922  hw_phy_id |= (hw_phy_id_2 & 0xfc00) << 16;
923  hw_phy_id |= (hw_phy_id_2 & 0x03ff) << 0;
924 
925  hw_phy_id_masked = hw_phy_id & TG3_PHY_ID_MASK;
926  }
927 
928  if (!err && TG3_KNOWN_PHY_ID(hw_phy_id_masked)) {
929  tp->phy_id = hw_phy_id;
930  if (hw_phy_id_masked == TG3_PHY_ID_BCM8002)
931  tp->phy_flags |= TG3_PHYFLG_PHY_SERDES;
932  else
933  tp->phy_flags &= ~TG3_PHYFLG_PHY_SERDES;
934  } else {
935  if (tp->phy_id != TG3_PHY_ID_INVALID) {
936  /* Do nothing, phy ID already set up in
937  * tg3_get_eeprom_hw_cfg().
938  */
939  } else {
940  struct subsys_tbl_ent *p;
941 
942  /* No eeprom signature? Try the hardcoded
943  * subsys device table.
944  */
946  if (!p) {
947  DBGC(&tp->pdev->dev, "lookup by subsys failed\n");
948  return -ENODEV;
949  }
950 
951  tp->phy_id = p->phy_id;
952  if (!tp->phy_id ||
953  tp->phy_id == TG3_PHY_ID_BCM8002)
954  tp->phy_flags |= TG3_PHYFLG_PHY_SERDES;
955  }
956  }
957 
958  if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) &&
959  ((tp->pdev->device == TG3PCI_DEVICE_TIGON3_5718 &&
960  tp->pci_chip_rev_id != CHIPREV_ID_5717_A0) ||
961  (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_57765 &&
962  tp->pci_chip_rev_id != CHIPREV_ID_57765_A0)))
963  tp->phy_flags |= TG3_PHYFLG_EEE_CAP;
964 
966 
967  if (!(tp->phy_flags & TG3_PHYFLG_ANY_SERDES) &&
968  !tg3_flag(tp, ENABLE_APE) &&
969  !tg3_flag(tp, ENABLE_ASF)) {
970  u32 bmsr;
971  u32 mask;
972 
973  tg3_readphy(tp, MII_BMSR, &bmsr);
974  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
975  (bmsr & BMSR_LSTATUS))
976  goto skip_phy_reset;
977 
978  err = tg3_phy_reset(tp);
979  if (err)
980  return err;
981 
983 
987  if (!tg3_copper_is_advertising_all(tp, mask)) {
988  tg3_phy_autoneg_cfg(tp, tp->link_config.advertising,
989  tp->link_config.flowctrl);
990 
993  }
994  }
995 
996 skip_phy_reset:
997  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) {
998  err = tg3_init_5401phy_dsp(tp);
999  if (err)
1000  return err;
1001 
1002  err = tg3_init_5401phy_dsp(tp);
1003  }
1004 
1005  return err;
1006 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
static struct subsys_tbl_ent * tg3_lookup_by_subsys(struct tg3 *tp)
Definition: tg3_phy.c:204
#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:621
static void tg3_phy_init_link_config(struct tg3 *tp)
Definition: tg3_phy.c:865
#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:791
static int tg3_init_5401phy_dsp(struct tg3 *tp)
Definition: tg3_phy.c:838
static struct tulip_private * tp
Definition: tulip.c:441
#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:221
static void tg3_phy_set_wirespeed(struct tg3 *tp)
Definition: tg3_phy.c:603
#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:737
#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 1008 of file tg3_phy.c.

1009 { DBGP("%s\n", __func__);
1010 
1011  if (tp->hw_status->status & SD_STATUS_LINK_CHG) {
1012  DBGC(tp->dev,"link_changed\n");
1013  tp->hw_status->status &= ~SD_STATUS_LINK_CHG;
1014  tg3_setup_phy(tp, 0);
1015  }
1016 }
#define DBGC(...)
Definition: compiler.h:505
int tg3_setup_phy(struct tg3 *tp, int force_reset)
Definition: tg3_phy.c:2520
#define DBGP(...)
Definition: compiler.h:532
static struct tulip_private * tp
Definition: tulip.c:441
#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 1018 of file tg3_phy.c.

1019 { DBGP("%s\n", __func__);
1020 
1021  switch (val & MII_TG3_AUX_STAT_SPDMASK) {
1023  *speed = SPEED_10;
1024  *duplex = DUPLEX_HALF;
1025  break;
1026 
1028  *speed = SPEED_10;
1029  *duplex = DUPLEX_FULL;
1030  break;
1031 
1033  *speed = SPEED_100;
1034  *duplex = DUPLEX_HALF;
1035  break;
1036 
1038  *speed = SPEED_100;
1039  *duplex = DUPLEX_FULL;
1040  break;
1041 
1043  *speed = SPEED_1000;
1044  *duplex = DUPLEX_HALF;
1045  break;
1046 
1048  *speed = SPEED_1000;
1049  *duplex = DUPLEX_FULL;
1050  break;
1051 
1052  default:
1053  if (tp->phy_flags & TG3_PHYFLG_IS_FET) {
1054  *speed = (val & MII_TG3_AUX_STAT_100) ? SPEED_100 :
1055  SPEED_10;
1057  DUPLEX_HALF;
1058  break;
1059  }
1060  *speed = SPEED_INVALID;
1062  break;
1063  }
1064 }
#define SPEED_1000
Definition: atl1e.h:52
#define MII_TG3_AUX_STAT_100FULL
Definition: tg3.h:2385
#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:441
#define MII_TG3_AUX_STAT_FULL
Definition: tg3.h:2389
void __asmcall int val
Definition: setjmp.h:28
#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 1066 of file tg3_phy.c.

1067 { DBGP("%s\n", __func__);
1068 
1069  u32 curadv, reqadv;
1070 
1071  if (tg3_readphy(tp, MII_ADVERTISE, lcladv))
1072  return 1;
1073 
1074  curadv = *lcladv & (ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
1075  reqadv = tg3_advert_flowctrl_1000T(tp->link_config.flowctrl);
1076 
1077  if (tp->link_config.active_duplex == DUPLEX_FULL) {
1078  if (curadv != reqadv)
1079  return 0;
1080 
1081  if (tg3_flag(tp, PAUSE_AUTONEG))
1082  tg3_readphy(tp, MII_LPA, rmtadv);
1083  } else {
1084  /* Reprogram the advertisement register, even if it
1085  * does not affect the current link. If the link
1086  * gets renegotiated in the future, we can save an
1087  * additional renegotiation cycle by advertising
1088  * it correctly in the first place.
1089  */
1090  if (curadv != reqadv) {
1091  *lcladv &= ~(ADVERTISE_PAUSE_CAP |
1093  tg3_writephy(tp, MII_ADVERTISE, *lcladv | reqadv);
1094  }
1095  }
1096 
1097  return 1;
1098 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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:774
#define DUPLEX_FULL
Definition: bnx2.h:111
static struct tulip_private * tp
Definition: tulip.c:441
#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:221
#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 1100 of file tg3_phy.c.

1101 { DBGP("%s\n", __func__);
1102 
1103  u8 cap = 0;
1104 
1105  if (lcladv & ADVERTISE_1000XPAUSE) {
1106  if (lcladv & ADVERTISE_1000XPSE_ASYM) {
1107  if (rmtadv & LPA_1000XPAUSE)
1108  cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
1109  else if (rmtadv & LPA_1000XPAUSE_ASYM)
1110  cap = FLOW_CTRL_RX;
1111  } else {
1112  if (rmtadv & LPA_1000XPAUSE)
1113  cap = FLOW_CTRL_TX | FLOW_CTRL_RX;
1114  }
1115  } else if (lcladv & ADVERTISE_1000XPSE_ASYM) {
1116  if ((rmtadv & LPA_1000XPAUSE) && (rmtadv & LPA_1000XPAUSE_ASYM))
1117  cap = FLOW_CTRL_TX;
1118  }
1119 
1120  return cap;
1121 }
#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 1123 of file tg3_phy.c.

1124 { DBGP("%s\n", __func__);
1125 
1126  u8 flowctrl = 0;
1127  u32 old_rx_mode = tp->rx_mode;
1128  u32 old_tx_mode = tp->tx_mode;
1129 
1130  if (tg3_flag(tp, PAUSE_AUTONEG)) {
1131  if (tp->phy_flags & TG3_PHYFLG_ANY_SERDES)
1132  flowctrl = tg3_resolve_flowctrl_1000X(lcladv, rmtadv);
1133  else
1134  flowctrl = mii_resolve_flowctrl_fdx(lcladv, rmtadv);
1135  } else
1136  flowctrl = tp->link_config.flowctrl;
1137 
1138  tp->link_config.active_flowctrl = flowctrl;
1139 
1140  if (flowctrl & FLOW_CTRL_RX)
1141  tp->rx_mode |= RX_MODE_FLOW_CTRL_ENABLE;
1142  else
1143  tp->rx_mode &= ~RX_MODE_FLOW_CTRL_ENABLE;
1144 
1145  if (old_rx_mode != tp->rx_mode)
1146  tw32_f(MAC_RX_MODE, tp->rx_mode);
1147 
1148  if (flowctrl & FLOW_CTRL_TX)
1149  tp->tx_mode |= TX_MODE_FLOW_CTRL_ENABLE;
1150  else
1151  tp->tx_mode &= ~TX_MODE_FLOW_CTRL_ENABLE;
1152 
1153  if (old_tx_mode != tp->tx_mode)
1154  tw32_f(MAC_TX_MODE, tp->tx_mode);
1155 }
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:1100
#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:441
#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 1157 of file tg3_phy.c.

1158 { DBGP("%s\n", __func__);
1159 
1160  u32 new_adv;
1161 
1162  if (tp->link_config.speed == SPEED_INVALID) {
1163  if (tp->phy_flags & TG3_PHYFLG_10_100_ONLY)
1164  tp->link_config.advertising &=
1167 
1168  tg3_phy_autoneg_cfg(tp, tp->link_config.advertising,
1169  tp->link_config.flowctrl);
1170  } else {
1171  /* Asking for a specific link mode. */
1172  if (tp->link_config.speed == SPEED_1000) {
1173  if (tp->link_config.duplex == DUPLEX_FULL)
1174  new_adv = ADVERTISED_1000baseT_Full;
1175  else
1176  new_adv = ADVERTISED_1000baseT_Half;
1177  } else if (tp->link_config.speed == SPEED_100) {
1178  if (tp->link_config.duplex == DUPLEX_FULL)
1179  new_adv = ADVERTISED_100baseT_Full;
1180  else
1181  new_adv = ADVERTISED_100baseT_Half;
1182  } else {
1183  if (tp->link_config.duplex == DUPLEX_FULL)
1184  new_adv = ADVERTISED_10baseT_Full;
1185  else
1186  new_adv = ADVERTISED_10baseT_Half;
1187  }
1188 
1189  tg3_phy_autoneg_cfg(tp, new_adv,
1190  tp->link_config.flowctrl);
1191  }
1192 
1194 }
#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:791
#define DUPLEX_FULL
Definition: bnx2.h:111
static struct tulip_private * tp
Definition: tulip.c:441
#define MII_BMCR
Definition: atl1e.h:871
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221
#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 1196 of file tg3_phy.c.

1197 { DBGP("%s\n", __func__);
1198 
1199  if (tp->led_ctrl == LED_CTRL_MODE_PHY_2)
1200  return 1;
1201  else if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5411) {
1202  if (speed != SPEED_10)
1203  return 1;
1204  } else if (speed == SPEED_10)
1205  return 1;
1206 
1207  return 0;
1208 }
#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:441
#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 1212 of file tg3_phy.c.

1213 { DBGP("%s\n", __func__);
1214 
1215  u32 reg;
1216  u32 val;
1217 
1218  if (!tg3_flag(tp, 5780_CLASS) || !tg3_flag(tp, ENABLE_ASF))
1219  return;
1220 
1222 
1224 
1226 
1227  val = 0;
1228  if (!tg3_readphy(tp, MII_BMCR, &reg))
1229  val = reg << 16;
1230  if (!tg3_readphy(tp, MII_BMSR, &reg))
1231  val |= (reg & 0xffff);
1233 
1234  val = 0;
1235  if (!tg3_readphy(tp, MII_ADVERTISE, &reg))
1236  val = reg << 16;
1237  if (!tg3_readphy(tp, MII_LPA, &reg))
1238  val |= (reg & 0xffff);
1240 
1241  val = 0;
1242  if (!(tp->phy_flags & TG3_PHYFLG_MII_SERDES)) {
1243  if (!tg3_readphy(tp, MII_CTRL1000, &reg))
1244  val = reg << 16;
1245  if (!tg3_readphy(tp, MII_STAT1000, &reg))
1246  val |= (reg & 0xffff);
1247  }
1249 
1250  if (!tg3_readphy(tp, MII_PHYADDR, &reg))
1251  val = reg << 16;
1252  else
1253  val = 0;
1255 
1257 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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
#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:441
#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 __asmcall int val
Definition: setjmp.h:28
void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
Definition: tg3_hw.c:921
#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:908

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 1354 of file tg3_phy.c.

1355 {
1356  u16 miireg;
1357 
1358  if ((flow_ctrl & FLOW_CTRL_TX) && (flow_ctrl & FLOW_CTRL_RX))
1359  miireg = ADVERTISE_1000XPAUSE;
1360  else if (flow_ctrl & FLOW_CTRL_TX)
1361  miireg = ADVERTISE_1000XPSE_ASYM;
1362  else if (flow_ctrl & FLOW_CTRL_RX)
1364  else
1365  miireg = 0;
1366 
1367  return miireg;
1368 }
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 1370 of file tg3_phy.c.

1371 {
1372  u32 mac_status = tr32(MAC_STATUS);
1373  int i;
1374 
1375  /* Reset when initting first time or we have a link. */
1376  if (tg3_flag(tp, INIT_COMPLETE) &&
1377  !(mac_status & MAC_STATUS_PCS_SYNCED))
1378  return;
1379 
1380  /* Set PLL lock range. */
1381  tg3_writephy(tp, 0x16, 0x8007);
1382 
1383  /* SW reset */
1385 
1386  /* Wait for reset to complete. */
1387  /* XXX schedule_timeout() ... */
1388  for (i = 0; i < 500; i++)
1389  udelay(10);
1390 
1391  /* Config mode; select PMA/Ch 1 regs. */
1392  tg3_writephy(tp, 0x10, 0x8411);
1393 
1394  /* Enable auto-lock and comdet, select txclk for tx. */
1395  tg3_writephy(tp, 0x11, 0x0a10);
1396 
1397  tg3_writephy(tp, 0x18, 0x00a0);
1398  tg3_writephy(tp, 0x16, 0x41ff);
1399 
1400  /* Assert and deassert POR. */
1401  tg3_writephy(tp, 0x13, 0x0400);
1402  udelay(40);
1403  tg3_writephy(tp, 0x13, 0x0000);
1404 
1405  tg3_writephy(tp, 0x11, 0x0a50);
1406  udelay(40);
1407  tg3_writephy(tp, 0x11, 0x0a10);
1408 
1409  /* Wait for signal to stabilize */
1410  /* XXX schedule_timeout() ... */
1411  for (i = 0; i < 15000; i++)
1412  udelay(10);
1413 
1414  /* Deselect the channel register so we can read the PHYID
1415  * later.
1416  */
1417  tg3_writephy(tp, 0x10, 0x8011);
1418 }
#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:441
#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:221
#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 1420 of file tg3_phy.c.

1421 {
1422  u16 flowctrl;
1423  int current_link_up;
1424  u32 sg_dig_ctrl, sg_dig_status;
1425  u32 serdes_cfg, expected_sg_dig_ctrl;
1426  int workaround, port_a;
1427 
1428  serdes_cfg = 0;
1429  expected_sg_dig_ctrl = 0;
1430  workaround = 0;
1431  port_a = 1;
1432  current_link_up = 0;
1433 
1434  if (tp->pci_chip_rev_id != CHIPREV_ID_5704_A0 &&
1435  tp->pci_chip_rev_id != CHIPREV_ID_5704_A1) {
1436  workaround = 1;
1438  port_a = 0;
1439 
1440  /* preserve bits 0-11,13,14 for signal pre-emphasis */
1441  /* preserve bits 20-23 for voltage regulator */
1442  serdes_cfg = tr32(MAC_SERDES_CFG) & 0x00f06fff;
1443  }
1444 
1445  sg_dig_ctrl = tr32(SG_DIG_CTRL);
1446 
1447  if (tp->link_config.autoneg != AUTONEG_ENABLE) {
1448  if (sg_dig_ctrl & SG_DIG_USING_HW_AUTONEG) {
1449  if (workaround) {
1450  u32 val = serdes_cfg;
1451 
1452  if (port_a)
1453  val |= 0xc010000;
1454  else
1455  val |= 0x4010000;
1457  }
1458 
1460  }
1461  if (mac_status & MAC_STATUS_PCS_SYNCED) {
1462  tg3_setup_flow_control(tp, 0, 0);
1463  current_link_up = 1;
1464  }
1465  goto out;
1466  }
1467 
1468  /* Want auto-negotiation. */
1469  expected_sg_dig_ctrl = SG_DIG_USING_HW_AUTONEG | SG_DIG_COMMON_SETUP;
1470 
1471  flowctrl = tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
1473  expected_sg_dig_ctrl |= SG_DIG_PAUSE_CAP;
1475  expected_sg_dig_ctrl |= SG_DIG_ASYM_PAUSE;
1476 
1477  if (sg_dig_ctrl != expected_sg_dig_ctrl) {
1478  if ((tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT) &&
1479  tp->serdes_counter &&
1480  ((mac_status & (MAC_STATUS_PCS_SYNCED |
1481  MAC_STATUS_RCVD_CFG)) ==
1483  tp->serdes_counter--;
1484  current_link_up = 1;
1485  goto out;
1486  }
1487 restart_autoneg:
1488  if (workaround)
1489  tw32_f(MAC_SERDES_CFG, serdes_cfg | 0xc011000);
1490  tw32_f(SG_DIG_CTRL, expected_sg_dig_ctrl | SG_DIG_SOFT_RESET);
1491  udelay(5);
1492  tw32_f(SG_DIG_CTRL, expected_sg_dig_ctrl);
1493 
1494  tp->serdes_counter = SERDES_AN_TIMEOUT_5704S;
1495  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1496  } else if (mac_status & (MAC_STATUS_PCS_SYNCED |
1498  sg_dig_status = tr32(SG_DIG_STATUS);
1499  mac_status = tr32(MAC_STATUS);
1500 
1501  if ((sg_dig_status & SG_DIG_AUTONEG_COMPLETE) &&
1502  (mac_status & MAC_STATUS_PCS_SYNCED)) {
1503  u32 local_adv = 0, remote_adv = 0;
1504 
1505  if (sg_dig_ctrl & SG_DIG_PAUSE_CAP)
1506  local_adv |= ADVERTISE_1000XPAUSE;
1507  if (sg_dig_ctrl & SG_DIG_ASYM_PAUSE)
1508  local_adv |= ADVERTISE_1000XPSE_ASYM;
1509 
1510  if (sg_dig_status & SG_DIG_PARTNER_PAUSE_CAPABLE)
1511  remote_adv |= LPA_1000XPAUSE;
1512  if (sg_dig_status & SG_DIG_PARTNER_ASYM_PAUSE)
1513  remote_adv |= LPA_1000XPAUSE_ASYM;
1514 
1515  tp->link_config.rmt_adv =
1516  mii_adv_to_ethtool_adv_x(remote_adv);
1517 
1518  tg3_setup_flow_control(tp, local_adv, remote_adv);
1519  current_link_up = 1;
1520  tp->serdes_counter = 0;
1521  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1522  } else if (!(sg_dig_status & SG_DIG_AUTONEG_COMPLETE)) {
1523  if (tp->serdes_counter)
1524  tp->serdes_counter--;
1525  else {
1526  if (workaround) {
1527  u32 val = serdes_cfg;
1528 
1529  if (port_a)
1530  val |= 0xc010000;
1531  else
1532  val |= 0x4010000;
1533 
1535  }
1536 
1538  udelay(40);
1539 
1540  /* Link parallel detection - link is up */
1541  /* only if we have PCS_SYNC and not */
1542  /* receiving config code words */
1543  mac_status = tr32(MAC_STATUS);
1544  if ((mac_status & MAC_STATUS_PCS_SYNCED) &&
1545  !(mac_status & MAC_STATUS_RCVD_CFG)) {
1546  tg3_setup_flow_control(tp, 0, 0);
1547  current_link_up = 1;
1548  tp->phy_flags |=
1550  tp->serdes_counter =
1552  } else
1553  goto restart_autoneg;
1554  }
1555  }
1556  } else {
1557  tp->serdes_counter = SERDES_AN_TIMEOUT_5704S;
1558  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1559  }
1560 
1561 out:
1562  return current_link_up;
1563 }
uint16_t u16
Definition: stdint.h:21
#define tr32(reg)
Definition: tg3.h:3339
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
#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:1354
#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:1123
#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:441
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define SG_DIG_ASYM_PAUSE
Definition: tg3.h:880
#define AUTONEG_ENABLE
Definition: tg3_phy.c:863
#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
void __asmcall int val
Definition: setjmp.h:28
#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 1565 of file tg3_phy.c.

1567 {
1568  u16 flowctrl;
1569  unsigned long delta;
1570  u32 rx_cfg_reg;
1571  int ret;
1572 
1573  if (ap->state == ANEG_STATE_UNKNOWN) {
1574  ap->rxconfig = 0;
1575  ap->link_time = 0;
1576  ap->cur_time = 0;
1577  ap->ability_match_cfg = 0;
1578  ap->ability_match_count = 0;
1579  ap->ability_match = 0;
1580  ap->idle_match = 0;
1581  ap->ack_match = 0;
1582  }
1583  ap->cur_time++;
1584 
1586  rx_cfg_reg = tr32(MAC_RX_AUTO_NEG);
1587 
1588  if (rx_cfg_reg != ap->ability_match_cfg) {
1589  ap->ability_match_cfg = rx_cfg_reg;
1590  ap->ability_match = 0;
1591  ap->ability_match_count = 0;
1592  } else {
1593  if (++ap->ability_match_count > 1) {
1594  ap->ability_match = 1;
1595  ap->ability_match_cfg = rx_cfg_reg;
1596  }
1597  }
1598  if (rx_cfg_reg & ANEG_CFG_ACK)
1599  ap->ack_match = 1;
1600  else
1601  ap->ack_match = 0;
1602 
1603  ap->idle_match = 0;
1604  } else {
1605  ap->idle_match = 1;
1606  ap->ability_match_cfg = 0;
1607  ap->ability_match_count = 0;
1608  ap->ability_match = 0;
1609  ap->ack_match = 0;
1610 
1611  rx_cfg_reg = 0;
1612  }
1613 
1614  ap->rxconfig = rx_cfg_reg;
1615  ret = ANEG_OK;
1616 
1617  switch (ap->state) {
1618  case ANEG_STATE_UNKNOWN:
1619  if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN))
1621 
1622  /* fallthru */
1623  case ANEG_STATE_AN_ENABLE:
1624  ap->flags &= ~(MR_AN_COMPLETE | MR_PAGE_RX);
1625  if (ap->flags & MR_AN_ENABLE) {
1626  ap->link_time = 0;
1627  ap->cur_time = 0;
1628  ap->ability_match_cfg = 0;
1629  ap->ability_match_count = 0;
1630  ap->ability_match = 0;
1631  ap->idle_match = 0;
1632  ap->ack_match = 0;
1633 
1635  } else {
1637  }
1638  break;
1639 
1641  ap->link_time = ap->cur_time;
1642  ap->flags &= ~(MR_NP_LOADED);
1643  ap->txconfig = 0;
1644  tw32(MAC_TX_AUTO_NEG, 0);
1645  tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
1646  tw32_f(MAC_MODE, tp->mac_mode);
1647  udelay(40);
1648 
1649  ret = ANEG_TIMER_ENAB;
1650  ap->state = ANEG_STATE_RESTART;
1651 
1652  /* fallthru */
1653  case ANEG_STATE_RESTART:
1654  delta = ap->cur_time - ap->link_time;
1655  if (delta > ANEG_STATE_SETTLE_TIME)
1657  else
1658  ret = ANEG_TIMER_ENAB;
1659  break;
1660 
1662  ret = ANEG_DONE;
1663  break;
1664 
1666  ap->flags &= ~(MR_TOGGLE_TX);
1667  ap->txconfig = ANEG_CFG_FD;
1668  flowctrl = tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
1670  ap->txconfig |= ANEG_CFG_PS1;
1672  ap->txconfig |= ANEG_CFG_PS2;
1674  tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
1675  tw32_f(MAC_MODE, tp->mac_mode);
1676  udelay(40);
1677 
1679  break;
1680 
1682  if (ap->ability_match != 0 && ap->rxconfig != 0)
1684  break;
1685 
1687  ap->txconfig |= ANEG_CFG_ACK;
1689  tp->mac_mode |= MAC_MODE_SEND_CONFIGS;
1690  tw32_f(MAC_MODE, tp->mac_mode);
1691  udelay(40);
1692 
1694 
1695  /* fallthru */
1696  case ANEG_STATE_ACK_DETECT:
1697  if (ap->ack_match != 0) {
1698  if ((ap->rxconfig & ~ANEG_CFG_ACK) ==
1699  (ap->ability_match_cfg & ~ANEG_CFG_ACK)) {
1701  } else {
1703  }
1704  } else if (ap->ability_match != 0 &&
1705  ap->rxconfig == 0) {
1707  }
1708  break;
1709 
1711  if (ap->rxconfig & ANEG_CFG_INVAL) {
1712  ret = ANEG_FAILED;
1713  break;
1714  }
1715  ap->flags &= ~(MR_LP_ADV_FULL_DUPLEX |
1722  MR_TOGGLE_RX |
1723  MR_NP_RX);
1724  if (ap->rxconfig & ANEG_CFG_FD)
1726  if (ap->rxconfig & ANEG_CFG_HD)
1728  if (ap->rxconfig & ANEG_CFG_PS1)
1729  ap->flags |= MR_LP_ADV_SYM_PAUSE;
1730  if (ap->rxconfig & ANEG_CFG_PS2)
1731  ap->flags |= MR_LP_ADV_ASYM_PAUSE;
1732  if (ap->rxconfig & ANEG_CFG_RF1)
1734  if (ap->rxconfig & ANEG_CFG_RF2)
1736  if (ap->rxconfig & ANEG_CFG_NP)
1737  ap->flags |= MR_LP_ADV_NEXT_PAGE;
1738 
1739  ap->link_time = ap->cur_time;
1740 
1741  ap->flags ^= (MR_TOGGLE_TX);
1742  if (ap->rxconfig & 0x0008)
1743  ap->flags |= MR_TOGGLE_RX;
1744  if (ap->rxconfig & ANEG_CFG_NP)
1745  ap->flags |= MR_NP_RX;
1746  ap->flags |= MR_PAGE_RX;
1747 
1749  ret = ANEG_TIMER_ENAB;
1750  break;
1751 
1753  if (ap->ability_match != 0 &&
1754  ap->rxconfig == 0) {
1756  break;
1757  }
1758  delta = ap->cur_time - ap->link_time;
1759  if (delta > ANEG_STATE_SETTLE_TIME) {
1760  if (!(ap->flags & (MR_LP_ADV_NEXT_PAGE))) {
1762  } else {
1763  if ((ap->txconfig & ANEG_CFG_NP) == 0 &&
1764  !(ap->flags & MR_NP_RX)) {
1766  } else {
1767  ret = ANEG_FAILED;
1768  }
1769  }
1770  }
1771  break;
1772 
1774  ap->link_time = ap->cur_time;
1775  tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
1776  tw32_f(MAC_MODE, tp->mac_mode);
1777  udelay(40);
1778 
1780  ret = ANEG_TIMER_ENAB;
1781  break;
1782 
1784  if (ap->ability_match != 0 &&
1785  ap->rxconfig == 0) {
1787  break;
1788  }
1789  delta = ap->cur_time - ap->link_time;
1790  if (delta > ANEG_STATE_SETTLE_TIME) {
1791  /* XXX another gem from the Broadcom driver :( */
1792  ap->state = ANEG_STATE_LINK_OK;
1793  }
1794  break;
1795 
1796  case ANEG_STATE_LINK_OK:
1797  ap->flags |= (MR_AN_COMPLETE | MR_LINK_OK);
1798  ret = ANEG_DONE;
1799  break;
1800 
1802  /* ??? unimplemented */
1803  break;
1804 
1806  /* ??? unimplemented */
1807  break;
1808 
1809  default:
1810  ret = ANEG_FAILED;
1811  break;
1812  }
1813 
1814  return ret;
1815 }
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:1293
#define tr32(reg)
Definition: tg3.h:3339
#define ANEG_STATE_UNKNOWN
Definition: tg3_phy.c:1292
#define ADVERTISE_1000XPAUSE
Definition: mii.h:79
#define ANEG_CFG_HD
Definition: tg3_phy.c:1342
#define ANEG_CFG_NP
Definition: tg3_phy.c:1336
#define MR_NP_LOADED
Definition: tg3_phy.c:1314
#define MR_LP_ADV_SYM_PAUSE
Definition: tg3_phy.c:1318
#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:1344
#define ANEG_DONE
Definition: tg3_phy.c:1348
#define ANEG_CFG_PS1
Definition: tg3_phy.c:1341
#define MR_AN_ENABLE
Definition: tg3_phy.c:1310
static u16 tg3_advert_flowctrl_1000X(u8 flow_ctrl)
Definition: tg3_phy.c:1354
static int flowctrl
Definition: sundance.c:75
#define MR_RESTART_AN
Definition: tg3_phy.c:1311
#define MR_NP_RX
Definition: tg3_phy.c:1324
#define ANEG_CFG_RF2
Definition: tg3_phy.c:1338
#define ANEG_STATE_NEXT_PAGE_WAIT
Definition: tg3_phy.c:1307
#define ANEG_STATE_IDLE_DETECT_INIT
Definition: tg3_phy.c:1303
#define MR_AN_COMPLETE
Definition: tg3_phy.c:1312
unsigned long link_time
Definition: tg3_phy.c:1328
#define ANEG_FAILED
Definition: tg3_phy.c:1350
#define ANEG_CFG_RF1
Definition: tg3_phy.c:1339
#define MR_LP_ADV_REMOTE_FAULT1
Definition: tg3_phy.c:1320
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define ANEG_CFG_PS2
Definition: tg3_phy.c:1340
static struct tulip_private * tp
Definition: tulip.c:441
#define MR_LINK_OK
Definition: tg3_phy.c:1326
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define ANEG_STATE_ABILITY_DETECT_INIT
Definition: tg3_phy.c:1297
#define MR_TOGGLE_RX
Definition: tg3_phy.c:1323
#define ANEG_STATE_IDLE_DETECT
Definition: tg3_phy.c:1304
#define ANEG_OK
Definition: tg3_phy.c:1347
#define tw32_f(reg, val)
Definition: tg3.h:3333
unsigned long cur_time
Definition: tg3_phy.c:1328
#define MR_LP_ADV_ASYM_PAUSE
Definition: tg3_phy.c:1319
#define ANEG_STATE_SETTLE_TIME
Definition: tg3_phy.c:1352
#define MAC_RX_AUTO_NEG
Definition: tg3.h:600
#define ANEG_STATE_NEXT_PAGE_WAIT_INIT
Definition: tg3_phy.c:1306
#define MAC_STATUS
Definition: tg3.h:530
#define MR_LP_ADV_HALF_DUPLEX
Definition: tg3_phy.c:1317
#define MR_PAGE_RX
Definition: tg3_phy.c:1313
#define ANEG_STATE_COMPLETE_ACK
Definition: tg3_phy.c:1302
#define ANEG_STATE_RESTART_INIT
Definition: tg3_phy.c:1294
#define ANEG_STATE_RESTART
Definition: tg3_phy.c:1295
#define tw32(reg, val)
Definition: tg3.h:3329
#define MR_TOGGLE_TX
Definition: tg3_phy.c:1315
#define ANEG_STATE_COMPLETE_ACK_INIT
Definition: tg3_phy.c:1301
#define ANEG_STATE_ACK_DETECT
Definition: tg3_phy.c:1300
#define ANEG_TIMER_ENAB
Definition: tg3_phy.c:1349
#define MR_LP_ADV_NEXT_PAGE
Definition: tg3_phy.c:1322
#define ANEG_CFG_FD
Definition: tg3_phy.c:1343
#define ANEG_STATE_DISABLE_LINK_OK
Definition: tg3_phy.c:1296
#define ANEG_CFG_ACK
Definition: tg3_phy.c:1337
#define MR_LP_ADV_FULL_DUPLEX
Definition: tg3_phy.c:1316
#define MAC_MODE
Definition: tg3.h:501
#define ANEG_STATE_ACK_DETECT_INIT
Definition: tg3_phy.c:1299
#define ANEG_STATE_ABILITY_DETECT
Definition: tg3_phy.c:1298
uint32_t u32
Definition: stdint.h:23
#define MR_LP_ADV_REMOTE_FAULT2
Definition: tg3_phy.c:1321
#define ANEG_STATE_LINK_OK
Definition: tg3_phy.c:1305

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 1817 of file tg3_phy.c.

1818 {
1819  int res = 0;
1820  struct tg3_fiber_aneginfo aninfo;
1821  int status = ANEG_FAILED;
1822  unsigned int tick;
1823  u32 tmp;
1824 
1825  tw32_f(MAC_TX_AUTO_NEG, 0);
1826 
1827  tmp = tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK;
1829  udelay(40);
1830 
1831  tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_SEND_CONFIGS);
1832  udelay(40);
1833 
1834  memset(&aninfo, 0, sizeof(aninfo));
1835  aninfo.flags |= MR_AN_ENABLE;
1836  aninfo.state = ANEG_STATE_UNKNOWN;
1837  aninfo.cur_time = 0;
1838  tick = 0;
1839  while (++tick < 195000) {
1840  status = tg3_fiber_aneg_smachine(tp, &aninfo);
1841  if (status == ANEG_DONE || status == ANEG_FAILED)
1842  break;
1843 
1844  udelay(1);
1845  }
1846 
1847  tp->mac_mode &= ~MAC_MODE_SEND_CONFIGS;
1848  tw32_f(MAC_MODE, tp->mac_mode);
1849  udelay(40);
1850 
1851  *txflags = aninfo.txconfig;
1852  *rxflags = aninfo.flags;
1853 
1854  if (status == ANEG_DONE &&
1855  (aninfo.flags & (MR_AN_COMPLETE | MR_LINK_OK |
1857  res = 1;
1858 
1859  return res;
1860 }
#define MAC_MODE_SEND_CONFIGS
Definition: tg3.h:520
#define ANEG_STATE_UNKNOWN
Definition: tg3_phy.c:1292
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:1348
#define MAC_MODE_PORT_MODE_MASK
Definition: tg3.h:504
#define MR_AN_ENABLE
Definition: tg3_phy.c:1310
static int tg3_fiber_aneg_smachine(struct tg3 *tp, struct tg3_fiber_aneginfo *ap)
Definition: tg3_phy.c:1565
unsigned long tmp
Definition: linux_pci.h:53
uint8_t status
Status.
Definition: ena.h:16
#define MR_AN_COMPLETE
Definition: tg3_phy.c:1312
#define ANEG_FAILED
Definition: tg3_phy.c:1350
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
static struct tulip_private * tp
Definition: tulip.c:441
#define MR_LINK_OK
Definition: tg3_phy.c:1326
#define MAC_MODE_PORT_MODE_GMII
Definition: tg3.h:506
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MR_LP_ADV_FULL_DUPLEX
Definition: tg3_phy.c:1316
#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 1862 of file tg3_phy.c.

1863 {
1864  int current_link_up = 0;
1865 
1866  if (!(mac_status & MAC_STATUS_PCS_SYNCED))
1867  goto out;
1868 
1869  if (tp->link_config.autoneg == AUTONEG_ENABLE) {
1870  u32 txflags, rxflags;
1871  int i;
1872 
1873  if (fiber_autoneg(tp, &txflags, &rxflags)) {
1874  u32 local_adv = 0, remote_adv = 0;
1875 
1876  if (txflags & ANEG_CFG_PS1)
1877  local_adv |= ADVERTISE_1000XPAUSE;
1878  if (txflags & ANEG_CFG_PS2)
1879  local_adv |= ADVERTISE_1000XPSE_ASYM;
1880 
1881  if (rxflags & MR_LP_ADV_SYM_PAUSE)
1882  remote_adv |= LPA_1000XPAUSE;
1883  if (rxflags & MR_LP_ADV_ASYM_PAUSE)
1884  remote_adv |= LPA_1000XPAUSE_ASYM;
1885 
1886  tp->link_config.rmt_adv =
1887  mii_adv_to_ethtool_adv_x(remote_adv);
1888 
1889  tg3_setup_flow_control(tp, local_adv, remote_adv);
1890 
1891  current_link_up = 1;
1892  }
1893  for (i = 0; i < 30; i++) {
1894  udelay(20);
1898  udelay(40);
1899  if ((tr32(MAC_STATUS) &
1901  MAC_STATUS_CFG_CHANGED)) == 0)
1902  break;
1903  }
1904 
1905  mac_status = tr32(MAC_STATUS);
1906  if (!current_link_up &&
1907  (mac_status & MAC_STATUS_PCS_SYNCED) &&
1908  !(mac_status & MAC_STATUS_RCVD_CFG))
1909  current_link_up = 1;
1910  } else {
1911  tg3_setup_flow_control(tp, 0, 0);
1912 
1913  /* Forcing 1000FD link up. */
1914  current_link_up = 1;
1915 
1916  tw32_f(MAC_MODE, (tp->mac_mode | MAC_MODE_SEND_CONFIGS));
1917  udelay(40);
1918 
1919  tw32_f(MAC_MODE, tp->mac_mode);
1920  udelay(40);
1921  }
1922 
1923 out:
1924  return current_link_up;
1925 }
#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:1318
#define MAC_STATUS_RCVD_CFG
Definition: tg3.h:533
#define ANEG_CFG_PS1
Definition: tg3_phy.c:1341
#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:1123
static int fiber_autoneg(struct tg3 *tp, u32 *txflags, u32 *rxflags)
Definition: tg3_phy.c:1817
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:1340
static struct tulip_private * tp
Definition: tulip.c:441
#define ADVERTISE_1000XPSE_ASYM
Definition: mii.h:81
#define AUTONEG_ENABLE
Definition: tg3_phy.c:863
#define tw32_f(reg, val)
Definition: tg3.h:3333
#define MR_LP_ADV_ASYM_PAUSE
Definition: tg3_phy.c:1319
#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 1927 of file tg3_phy.c.

1928 {
1929  if (curr_link_up != tp->link_up) {
1930  if (curr_link_up) {
1931  netdev_link_up(tp->dev);
1932  } else {
1933  netdev_link_down(tp->dev);
1934  if (tp->phy_flags & TG3_PHYFLG_MII_SERDES)
1935  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
1936  }
1937 
1939  return 1;
1940  }
1941 
1942  return 0;
1943 }
static void tg3_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1260
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:774
static struct tulip_private * tp
Definition: tulip.c:441
#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 1945 of file tg3_phy.c.

1946 {
1947  tw32(MAC_EVENT, 0);
1948 
1954  udelay(40);
1955 }
#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 1957 of file tg3_phy.c.

1958 {
1959  u32 orig_pause_cfg;
1960  u16 orig_active_speed;
1961  u8 orig_active_duplex;
1962  u32 mac_status;
1963  int current_link_up = force_reset;
1964  int i;
1965 
1966  orig_pause_cfg = tp->link_config.active_flowctrl;
1967  orig_active_speed = tp->link_config.active_speed;
1968  orig_active_duplex = tp->link_config.active_duplex;
1969 
1970  if (!tg3_flag(tp, HW_AUTONEG) &&
1971  tp->link_up &&
1972  tg3_flag(tp, INIT_COMPLETE)) {
1973  mac_status = tr32(MAC_STATUS);
1974  mac_status &= (MAC_STATUS_PCS_SYNCED |
1978  if (mac_status == (MAC_STATUS_PCS_SYNCED |
1982  return 0;
1983  }
1984  }
1985 
1986  tw32_f(MAC_TX_AUTO_NEG, 0);
1987 
1989  tp->mac_mode |= MAC_MODE_PORT_MODE_TBI;
1990  tw32_f(MAC_MODE, tp->mac_mode);
1991  udelay(40);
1992 
1993  if (tp->phy_id == TG3_PHY_ID_BCM8002)
1995 
1996  /* Enable link change event even when serdes polling. */
1998  udelay(40);
1999 
2000  current_link_up = 0;
2001  tp->link_config.rmt_adv = 0;
2002  mac_status = tr32(MAC_STATUS);
2003 
2004  if (tg3_flag(tp, HW_AUTONEG))
2005  current_link_up = tg3_setup_fiber_hw_autoneg(tp, mac_status);
2006  else
2007  current_link_up = tg3_setup_fiber_by_hand(tp, mac_status);
2008 
2009  tp->hw_status->status =
2011  (tp->hw_status->status & ~SD_STATUS_LINK_CHG));
2012 
2013  for (i = 0; i < 100; i++) {
2016  udelay(5);
2020  break;
2021  }
2022 
2023  mac_status = tr32(MAC_STATUS);
2024  if ((mac_status & MAC_STATUS_PCS_SYNCED) == 0) {
2025  current_link_up = 0;
2026  if (tp->link_config.autoneg == AUTONEG_ENABLE &&
2027  tp->serdes_counter == 0) {
2028  tw32_f(MAC_MODE, (tp->mac_mode |
2030  udelay(1);
2031  tw32_f(MAC_MODE, tp->mac_mode);
2032  }
2033  }
2034 
2035  if (current_link_up) {
2036  tp->link_config.active_speed = SPEED_1000;
2037  tp->link_config.active_duplex = DUPLEX_FULL;
2038  tw32(MAC_LED_CTRL, (tp->led_ctrl |
2041  } else {
2042  tp->link_config.active_speed = SPEED_UNKNOWN;
2043  tp->link_config.active_duplex = DUPLEX_UNKNOWN;
2044  tw32(MAC_LED_CTRL, (tp->led_ctrl |
2047  }
2048 
2049  if (!tg3_test_and_report_link_chg(tp, current_link_up)) {
2050  u32 now_pause_cfg = tp->link_config.active_flowctrl;
2051  if (orig_pause_cfg != now_pause_cfg ||
2052  orig_active_speed != tp->link_config.active_speed ||
2053  orig_active_duplex != tp->link_config.active_duplex)
2055  }
2056 
2057  return 0;
2058 }
#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:1260
#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:441
#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:1420
static void tg3_init_bcm8002(struct tg3 *tp)
Definition: tg3_phy.c:1370
#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:863
static int tg3_test_and_report_link_chg(struct tg3 *tp, int curr_link_up)
Definition: tg3_phy.c:1927
#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:1862

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 2060 of file tg3_phy.c.

2061 {
2062  int err = 0;
2063  u32 bmsr, bmcr;
2064  u16 current_speed = SPEED_UNKNOWN;
2065  u8 current_duplex = DUPLEX_UNKNOWN;
2066  int current_link_up = 0;
2067  u32 local_adv, remote_adv, sgsr;
2068 
2069  if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5719 ||
2070  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720) &&
2072  (sgsr & SERDES_TG3_SGMII_MODE)) {
2073 
2074  if (force_reset)
2075  tg3_phy_reset(tp);
2076 
2077  tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK;
2078 
2079  if (!(sgsr & SERDES_TG3_LINK_UP)) {
2080  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2081  } else {
2082  current_link_up = 1;
2083  if (sgsr & SERDES_TG3_SPEED_1000) {
2084  current_speed = SPEED_1000;
2085  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2086  } else if (sgsr & SERDES_TG3_SPEED_100) {
2087  current_speed = SPEED_100;
2088  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2089  } else {
2090  current_speed = SPEED_10;
2091  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2092  }
2093 
2094  if (sgsr & SERDES_TG3_FULL_DUPLEX)
2095  current_duplex = DUPLEX_FULL;
2096  else
2097  current_duplex = DUPLEX_HALF;
2098  }
2099 
2100  tw32_f(MAC_MODE, tp->mac_mode);
2101  udelay(40);
2102 
2104 
2105  goto fiber_setup_done;
2106  }
2107 
2108  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2109  tw32_f(MAC_MODE, tp->mac_mode);
2110  udelay(40);
2111 
2113 
2114  if (force_reset)
2115  tg3_phy_reset(tp);
2116 
2117  tp->link_config.rmt_adv = 0;
2118 
2119  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2120  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2121  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) {
2123  bmsr |= BMSR_LSTATUS;
2124  else
2125  bmsr &= ~BMSR_LSTATUS;
2126  }
2127 
2128  err |= tg3_readphy(tp, MII_BMCR, &bmcr);
2129 
2130  if ((tp->link_config.autoneg == AUTONEG_ENABLE) && !force_reset &&
2131  (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) {
2132  /* do nothing, just check for link up at the end */
2133  } else if (tp->link_config.autoneg == AUTONEG_ENABLE) {
2134  u32 adv, newadv;
2135 
2136  err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
2137  newadv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
2140  ADVERTISE_SLCT);
2141 
2142  newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
2143  newadv |= ethtool_adv_to_mii_adv_x(tp->link_config.advertising);
2144 
2145  if ((newadv != adv) || !(bmcr & BMCR_ANENABLE)) {
2146  tg3_writephy(tp, MII_ADVERTISE, newadv);
2147  bmcr |= BMCR_ANENABLE | BMCR_ANRESTART;
2148  tg3_writephy(tp, MII_BMCR, bmcr);
2149 
2151  tp->serdes_counter = SERDES_AN_TIMEOUT_5714S;
2152  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
2153 
2154  return err;
2155  }
2156  } else {
2157  u32 new_bmcr;
2158 
2159  bmcr &= ~BMCR_SPEED1000;
2160  new_bmcr = bmcr & ~(BMCR_ANENABLE | BMCR_FULLDPLX);
2161 
2162  if (tp->link_config.duplex == DUPLEX_FULL)
2163  new_bmcr |= BMCR_FULLDPLX;
2164 
2165  if (new_bmcr != bmcr) {
2166  /* BMCR_SPEED1000 is a reserved bit that needs
2167  * to be set on write.
2168  */
2169  new_bmcr |= BMCR_SPEED1000;
2170 
2171  /* Force a linkdown */
2172  if (tp->link_up) {
2173  u32 adv;
2174 
2175  err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
2176  adv &= ~(ADVERTISE_1000XFULL |
2178  ADVERTISE_SLCT);
2179  tg3_writephy(tp, MII_ADVERTISE, adv);
2180  tg3_writephy(tp, MII_BMCR, bmcr |
2181  BMCR_ANRESTART |
2182  BMCR_ANENABLE);
2183  udelay(10);
2184  netdev_link_down(tp->dev);
2185  }
2186  tg3_writephy(tp, MII_BMCR, new_bmcr);
2187  bmcr = new_bmcr;
2188  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2189  err |= tg3_readphy(tp, MII_BMSR, &bmsr);
2190  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714) {
2192  bmsr |= BMSR_LSTATUS;
2193  else
2194  bmsr &= ~BMSR_LSTATUS;
2195  }
2196  tp->phy_flags &= ~TG3_PHYFLG_PARALLEL_DETECT;
2197  }
2198  }
2199 
2200  if (bmsr & BMSR_LSTATUS) {
2201  current_speed = SPEED_1000;
2202  current_link_up = 1;
2203  if (bmcr & BMCR_FULLDPLX)
2204  current_duplex = DUPLEX_FULL;
2205  else
2206  current_duplex = DUPLEX_HALF;
2207 
2208  local_adv = 0;
2209  remote_adv = 0;
2210 
2211  if (bmcr & BMCR_ANENABLE) {
2212  u32 common;
2213 
2214  err |= tg3_readphy(tp, MII_ADVERTISE, &local_adv);
2215  err |= tg3_readphy(tp, MII_LPA, &remote_adv);
2216  common = local_adv & remote_adv;
2217  if (common & (ADVERTISE_1000XHALF |
2220  current_duplex = DUPLEX_FULL;
2221  else
2222  current_duplex = DUPLEX_HALF;
2223 
2224  tp->link_config.rmt_adv =
2225  mii_adv_to_ethtool_adv_x(remote_adv);
2226  } else if (!tg3_flag(tp, 5780_CLASS)) {
2227  /* Link is up via parallel detect */
2228  } else {
2229  current_link_up = 0;
2230  }
2231  }
2232  }
2233 
2234 fiber_setup_done:
2235  if (current_link_up && current_duplex == DUPLEX_FULL)
2236  tg3_setup_flow_control(tp, local_adv, remote_adv);
2237 
2238  tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX;
2239  if (tp->link_config.active_duplex == DUPLEX_HALF)
2240  tp->mac_mode |= MAC_MODE_HALF_DUPLEX;
2241 
2242  tw32_f(MAC_MODE, tp->mac_mode);
2243  udelay(40);
2244 
2246 
2247  tp->link_config.active_speed = current_speed;
2248  tp->link_config.active_duplex = current_duplex;
2249 
2250  tg3_test_and_report_link_chg(tp, current_link_up);
2251  return err;
2252 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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:1945
#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:1354
#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:1123
#define ADVERTISE_1000XHALF
Definition: mii.h:77
int tg3_phy_reset(struct tg3 *tp)
Definition: tg3_phy.c:621
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:441
#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:863
static int tg3_test_and_report_link_chg(struct tg3 *tp, int curr_link_up)
Definition: tg3_phy.c:1927
#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:221
#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 2254 of file tg3_phy.c.

2255 { DBGP("%s\n", __func__);
2256 
2257  int current_link_up;
2258  u32 bmsr, val;
2259  u32 lcl_adv, rmt_adv;
2260  u16 current_speed;
2261  u8 current_duplex;
2262  int i, err;
2263 
2264  tw32(MAC_EVENT, 0);
2265 
2271  udelay(40);
2272 
2273  if ((tp->mi_mode & MAC_MI_MODE_AUTO_POLL) != 0) {
2275  (tp->mi_mode & ~MAC_MI_MODE_AUTO_POLL));
2276  udelay(80);
2277  }
2278 
2280 
2281  /* Some third-party PHYs need to be reset on link going
2282  * down.
2283  */
2284  if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 ||
2285  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 ||
2286  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) &&
2287  netdev_link_ok(tp->dev)) {
2288  tg3_readphy(tp, MII_BMSR, &bmsr);
2289  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
2290  !(bmsr & BMSR_LSTATUS))
2291  force_reset = 1;
2292  }
2293  if (force_reset)
2294  tg3_phy_reset(tp);
2295 
2296  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5401) {
2297  tg3_readphy(tp, MII_BMSR, &bmsr);
2298  if (tg3_readphy(tp, MII_BMSR, &bmsr) ||
2299  !tg3_flag(tp, INIT_COMPLETE))
2300  bmsr = 0;
2301 
2302  if (!(bmsr & BMSR_LSTATUS)) {
2303  err = tg3_init_5401phy_dsp(tp);
2304  if (err)
2305  return err;
2306 
2307  tg3_readphy(tp, MII_BMSR, &bmsr);
2308  for (i = 0; i < 1000; i++) {
2309  udelay(10);
2310  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
2311  (bmsr & BMSR_LSTATUS)) {
2312  udelay(40);
2313  break;
2314  }
2315  }
2316 
2317  if ((tp->phy_id & TG3_PHY_ID_REV_MASK) ==
2319  !(bmsr & BMSR_LSTATUS) &&
2320  tp->link_config.active_speed == SPEED_1000) {
2321  err = tg3_phy_reset(tp);
2322  if (!err)
2323  err = tg3_init_5401phy_dsp(tp);
2324  if (err)
2325  return err;
2326  }
2327  }
2328  } else if (tp->pci_chip_rev_id == CHIPREV_ID_5701_A0 ||
2329  tp->pci_chip_rev_id == CHIPREV_ID_5701_B0) {
2330  /* 5701 {A0,B0} CRC bug workaround */
2331  tg3_writephy(tp, 0x15, 0x0a75);
2332  tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8c68);
2333  tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8d68);
2334  tg3_writephy(tp, MII_TG3_MISC_SHDW, 0x8c68);
2335  }
2336 
2337  /* Clear pending interrupts... */
2340 
2341  if (tp->phy_flags & TG3_PHYFLG_USE_MI_INTERRUPT)
2343  else if (!(tp->phy_flags & TG3_PHYFLG_IS_FET))
2345 
2346  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
2347  GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
2348  if (tp->led_ctrl == LED_CTRL_MODE_PHY_1)
2351  else
2353  }
2354 
2355  current_link_up = 0;
2356  current_speed = SPEED_INVALID;
2357  current_duplex = DUPLEX_INVALID;
2358 
2359  if (tp->phy_flags & TG3_PHYFLG_CAPACITIVE_COUPLING) {
2360  err = tg3_phy_auxctl_read(tp,
2362  &val);
2363  if (!err && !(val & (1 << 10))) {
2366  val | (1 << 10));
2367  goto relink;
2368  }
2369  }
2370 
2371  bmsr = 0;
2372  for (i = 0; i < 100; i++) {
2373  tg3_readphy(tp, MII_BMSR, &bmsr);
2374  if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
2375  (bmsr & BMSR_LSTATUS))
2376  break;
2377  udelay(40);
2378  }
2379 
2380  if (bmsr & BMSR_LSTATUS) {
2381  u32 aux_stat, bmcr;
2382 
2383  tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat);
2384  for (i = 0; i < 2000; i++) {
2385  udelay(10);
2386  if (!tg3_readphy(tp, MII_TG3_AUX_STAT, &aux_stat) &&
2387  aux_stat)
2388  break;
2389  }
2390 
2391  tg3_aux_stat_to_speed_duplex(tp, aux_stat,
2392  &current_speed,
2393  &current_duplex);
2394 
2395  bmcr = 0;
2396  for (i = 0; i < 200; i++) {
2397  tg3_readphy(tp, MII_BMCR, &bmcr);
2398  if (tg3_readphy(tp, MII_BMCR, &bmcr))
2399  continue;
2400  if (bmcr && bmcr != 0x7fff)
2401  break;
2402  udelay(10);
2403  }
2404 
2405  lcl_adv = 0;
2406  rmt_adv = 0;
2407 
2408  tp->link_config.active_speed = current_speed;
2409  tp->link_config.active_duplex = current_duplex;
2410 
2411  if ((bmcr & BMCR_ANENABLE) &&
2413  tp->link_config.advertising)) {
2414  if (tg3_adv_1000T_flowctrl_ok(tp, &lcl_adv,
2415  &rmt_adv)) {
2416  current_link_up = 1;
2417  }
2418  }
2419 
2420  if (current_link_up == 1 &&
2421  tp->link_config.active_duplex == DUPLEX_FULL)
2422  tg3_setup_flow_control(tp, lcl_adv, rmt_adv);
2423  }
2424 
2425 relink:
2426  if (current_link_up == 0) {
2428 
2429  tg3_readphy(tp, MII_BMSR, &bmsr);
2430  if ((!tg3_readphy(tp, MII_BMSR, &bmsr) && (bmsr & BMSR_LSTATUS)) ||
2431  (tp->mac_mode & MAC_MODE_PORT_INT_LPBACK))
2432  current_link_up = 1;
2433  }
2434 
2435  tp->mac_mode &= ~MAC_MODE_PORT_MODE_MASK;
2436  if (current_link_up == 1) {
2437  if (tp->link_config.active_speed == SPEED_100 ||
2438  tp->link_config.active_speed == SPEED_10)
2439  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2440  else
2441  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2442  } else if (tp->phy_flags & TG3_PHYFLG_IS_FET)
2443  tp->mac_mode |= MAC_MODE_PORT_MODE_MII;
2444  else
2445  tp->mac_mode |= MAC_MODE_PORT_MODE_GMII;
2446 
2447  tp->mac_mode &= ~MAC_MODE_HALF_DUPLEX;
2448  if (tp->link_config.active_duplex == DUPLEX_HALF)
2449  tp->mac_mode |= MAC_MODE_HALF_DUPLEX;
2450 
2451  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) {
2452  if (current_link_up == 1 &&
2453  tg3_5700_link_polarity(tp, tp->link_config.active_speed))
2454  tp->mac_mode |= MAC_MODE_LINK_POLARITY;
2455  else
2456  tp->mac_mode &= ~MAC_MODE_LINK_POLARITY;
2457  }
2458 
2459  /* ??? Without this setting Netgear GA302T PHY does not
2460  * ??? send/receive packets...
2461  */
2462  if ((tp->phy_id & TG3_PHY_ID_MASK) == TG3_PHY_ID_BCM5411 &&
2463  tp->pci_chip_rev_id == CHIPREV_ID_5700_ALTIMA) {
2464  tp->mi_mode |= MAC_MI_MODE_AUTO_POLL;
2465  tw32_f(MAC_MI_MODE, tp->mi_mode);
2466  udelay(80);
2467  }
2468 
2469  tw32_f(MAC_MODE, tp->mac_mode);
2470  udelay(40);
2471 
2472  /* Enabled attention when the link has changed state. */
2474  udelay(40);
2475 
2476  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 &&
2477  current_link_up == 1 &&
2478  tp->link_config.active_speed == SPEED_1000 &&
2479  (tg3_flag(tp, PCIX_MODE) || tg3_flag(tp, PCI_HIGH_SPEED))) {
2480  udelay(120);
2481  /* NOTE: this freezes for mdc? */
2485  udelay(40);
2486  tg3_write_mem(tp,
2489  }
2490 
2491  /* Prevent send BD corruption. */
2492  if (tg3_flag(tp, CLKREQ_BUG)) {
2493  u16 oldlnkctl, newlnkctl;
2494 
2495  pci_read_config_word(tp->pdev,
2496  tp->pcie_cap + PCI_EXP_LNKCTL,
2497  &oldlnkctl);
2498  if (tp->link_config.active_speed == SPEED_100 ||
2499  tp->link_config.active_speed == SPEED_10)
2500  newlnkctl = oldlnkctl & ~PCI_EXP_LNKCTL_CLKREQ_EN;
2501  else
2502  newlnkctl = oldlnkctl | PCI_EXP_LNKCTL_CLKREQ_EN;
2503  if (newlnkctl != oldlnkctl)
2504  pci_write_config_word(tp->pdev,
2505  tp->pcie_cap + PCI_EXP_LNKCTL,
2506  newlnkctl);
2507  }
2508 
2509  if (current_link_up != netdev_link_ok(tp->dev)) {
2510  if (current_link_up)
2511  netdev_link_up(tp->dev);
2512  else
2513  netdev_link_down(tp->dev);
2515  }
2516 
2517  return 0;
2518 }
int tg3_readphy(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:85
#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:1157
static void tg3_link_report(struct tg3 *tp)
Definition: tg3_phy.c:1260
#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:422
#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:1066
#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:1123
#define TG3_PHYFLG_CAPACITIVE_COUPLING
Definition: tg3.h:3244
int tg3_phy_reset(struct tg3 *tp)
Definition: tg3_phy.c:621
#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:774
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:636
#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:838
static struct tulip_private * tp
Definition: tulip.c:441
#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:1196
void __asmcall int val
Definition: setjmp.h:28
static int tg3_phy_auxctl_read(struct tg3 *tp, int reg, u32 *val)
Definition: tg3_phy.c:547
#define MAC_MI_MODE_AUTO_POLL
Definition: tg3.h:621
int tg3_writephy(struct tg3 *tp, int reg, u32 val)
Definition: tg3_phy.c:221
#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:921
#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:1018
#define BMCR_ANENABLE
Definition: mii.h:49
static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
Definition: tg3_phy.c:737
#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 2520 of file tg3_phy.c.

2521 { DBGP("%s\n", __func__);
2522 
2523  u32 val;
2524  int err;
2525 
2526  if (tp->phy_flags & TG3_PHYFLG_PHY_SERDES)
2527  err = tg3_setup_fiber_phy(tp, force_reset);
2528  else if (tp->phy_flags & TG3_PHYFLG_MII_SERDES)
2529  err = tg3_setup_fiber_mii_phy(tp, force_reset);
2530  else
2531  err = tg3_setup_copper_phy(tp, force_reset);
2532 
2533  val = (2 << TX_LENGTHS_IPG_CRS_SHIFT) |
2534  (6 << TX_LENGTHS_IPG_SHIFT);
2535  if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5720)
2536  val |= tr32(MAC_TX_LENGTHS) &
2539 
2540  if (tp->link_config.active_speed == SPEED_1000 &&
2541  tp->link_config.active_duplex == DUPLEX_HALF)
2543  (0xff << TX_LENGTHS_SLOT_TIME_SHIFT));
2544  else
2546  (32 << TX_LENGTHS_SLOT_TIME_SHIFT));
2547 
2548  if (!tg3_flag(tp, 5705_PLUS)) {
2549  if (netdev_link_ok(tp->dev)) {
2551  } else {
2553  }
2554  }
2555 
2557  if (!netdev_link_ok(tp->dev))
2559  else
2562 
2563  return err;
2564 }
#define SPEED_1000
Definition: atl1e.h:52
#define TX_LENGTHS_IPG_SHIFT
Definition: tg3.h:646
#define tr32(reg)
Definition: tg3.h:3339
#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:2060
#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:636
static struct tulip_private * tp
Definition: tulip.c:441
#define tg3_flag(tp, flag)
Definition: tg3.h:3365
void __asmcall int val
Definition: setjmp.h:28
#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:1957
#define tw32(reg, val)
Definition: tg3.h:3329
static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
Definition: tg3_phy.c:2254
#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 140 of file tg3_phy.c.

Referenced by tg3_lookup_by_subsys().