2 * tg3.c: Broadcom Tigon3 ethernet driver.
4 * Copyright (C) 2001, 2002 David S. Miller (davem@redhat.com)
5 * Copyright (C) 2001, 2002 Jeff Garzik (jgarzik@mandrakesoft.com)
6 * Copyright (C) 2003 Eric Biederman (ebiederman@lnxi.com) [etherboot port]
9 FILE_LICENCE ( GPL2_ONLY
);
11 /* 11-13-2003 timlegge Fix Issue with NetGear GA302T
12 * 11-18-2003 ebiederm Generalize NetGear Fix to what the code was supposed to be.
13 * 01-06-2005 Alf (Frederic Olivie) Add Dell bcm 5751 (0x1677) support
14 * 04-15-2005 Martin Vogt Add Fujitsu Siemens Computer (FSC) 0x1734 bcm 5751 0x105d support
17 #include "etherboot.h"
21 #include <gpxe/ethernet.h>
26 #define SUPPORT_COPPER_PHY 1
27 #define SUPPORT_FIBER_PHY 1
28 #define SUPPORT_LINK_REPORT 1
29 #define SUPPORT_PARTNO_STR 1
30 #define SUPPORT_PHY_STR 1
32 static struct tg3 tg3
;
34 /* These numbers seem to be hard coded in the NIC firmware somehow.
35 * You can't change the ring sizes, but you can change where you place
36 * them in the NIC onboard memory.
38 #define TG3_RX_RING_SIZE 512
39 #define TG3_DEF_RX_RING_PENDING 20 /* RX_RING_PENDING seems to be o.k. at 20 and 200 */
40 #define TG3_RX_RCB_RING_SIZE 1024
42 /* (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 ? \
44 #define TG3_TX_RING_SIZE 512
45 #define TG3_DEF_TX_RING_PENDING (TG3_TX_RING_SIZE - 1)
47 #define TG3_RX_RING_BYTES (sizeof(struct tg3_rx_buffer_desc) * TG3_RX_RING_SIZE)
48 #define TG3_RX_RCB_RING_BYTES (sizeof(struct tg3_rx_buffer_desc) * TG3_RX_RCB_RING_SIZE)
50 #define TG3_TX_RING_BYTES (sizeof(struct tg3_tx_buffer_desc) * TG3_TX_RING_SIZE)
51 #define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1))
52 #define PREV_TX(N) (((N) - 1) & (TG3_TX_RING_SIZE - 1))
54 #define RX_PKT_BUF_SZ (1536 + 2 + 64)
57 uint8_t dst_addr
[ETH_ALEN
];
58 uint8_t src_addr
[ETH_ALEN
];
60 uint8_t data
[ETH_FRAME_LEN
- ETH_HLEN
];
64 struct tg3_rx_buffer_desc rx_std
[TG3_RX_RING_SIZE
];
65 struct tg3_rx_buffer_desc rx_rcb
[TG3_RX_RCB_RING_SIZE
];
66 struct tg3_tx_buffer_desc tx_ring
[TG3_TX_RING_SIZE
];
67 struct tg3_hw_status hw_status
;
68 struct tg3_hw_stats hw_stats
;
69 unsigned char rx_bufs
[TG3_DEF_RX_RING_PENDING
][RX_PKT_BUF_SZ
];
70 struct eth_frame tx_frame
[2];
74 * pci_save_state - save the PCI configuration space of a device before suspending
75 * @dev: - PCI device that we're dealing with
76 * @buffer: - buffer to hold config space context
78 * @buffer must be large enough to hold the entire PCI 2.2 config space
81 static int pci_save_state(struct pci_device
*dev
, uint32_t *buffer
)
84 for (i
= 0; i
< 16; i
++)
85 pci_read_config_dword(dev
, i
* 4,&buffer
[i
]);
90 * pci_restore_state - Restore the saved state of a PCI device
91 * @dev: - PCI device that we're dealing with
92 * @buffer: - saved PCI config space
95 static int pci_restore_state(struct pci_device
*dev
, uint32_t *buffer
)
99 for (i
= 0; i
< 16; i
++)
100 pci_write_config_dword(dev
,i
* 4, buffer
[i
]);
104 static void tg3_write_indirect_reg32(uint32_t off
, uint32_t val
)
106 pci_write_config_dword(tg3
.pdev
, TG3PCI_REG_BASE_ADDR
, off
);
107 pci_write_config_dword(tg3
.pdev
, TG3PCI_REG_DATA
, val
);
110 #define tw32(reg,val) tg3_write_indirect_reg32((reg),(val))
111 #define tw32_mailbox(reg, val) writel(((val) & 0xffffffff), tg3.regs + (reg))
112 #define tw16(reg,val) writew(((val) & 0xffff), tg3.regs + (reg))
113 #define tw8(reg,val) writeb(((val) & 0xff), tg3.regs + (reg))
114 #define tr32(reg) readl(tg3.regs + (reg))
115 #define tr16(reg) readw(tg3.regs + (reg))
116 #define tr8(reg) readb(tg3.regs + (reg))
118 static void tw32_carefully(uint32_t reg
, uint32_t val
)
125 static void tw32_mailbox2(uint32_t reg
, uint32_t val
)
127 tw32_mailbox(reg
, val
);
131 static void tg3_write_mem(uint32_t off
, uint32_t val
)
133 pci_write_config_dword(tg3
.pdev
, TG3PCI_MEM_WIN_BASE_ADDR
, off
);
134 pci_write_config_dword(tg3
.pdev
, TG3PCI_MEM_WIN_DATA
, val
);
136 /* Always leave this as zero. */
137 pci_write_config_dword(tg3
.pdev
, TG3PCI_MEM_WIN_BASE_ADDR
, 0);
140 static void tg3_read_mem(uint32_t off
, uint32_t *val
)
142 pci_write_config_dword(tg3
.pdev
, TG3PCI_MEM_WIN_BASE_ADDR
, off
);
143 pci_read_config_dword(tg3
.pdev
, TG3PCI_MEM_WIN_DATA
, val
);
145 /* Always leave this as zero. */
146 pci_write_config_dword(tg3
.pdev
, TG3PCI_MEM_WIN_BASE_ADDR
, 0);
149 static void tg3_disable_ints(struct tg3
*tp
)
151 tw32(TG3PCI_MISC_HOST_CTRL
,
152 (tp
->misc_host_ctrl
| MISC_HOST_CTRL_MASK_PCI_INT
));
153 tw32_mailbox2(MAILBOX_INTERRUPT_0
+ TG3_64BIT_REG_LOW
, 0x00000001);
156 static void tg3_switch_clocks(struct tg3
*tp
)
158 uint32_t orig_clock_ctrl
, clock_ctrl
;
160 clock_ctrl
= tr32(TG3PCI_CLOCK_CTRL
);
162 orig_clock_ctrl
= clock_ctrl
;
163 clock_ctrl
&= (CLOCK_CTRL_FORCE_CLKRUN
| CLOCK_CTRL_CLKRUN_OENABLE
| 0x1f);
164 tp
->pci_clock_ctrl
= clock_ctrl
;
166 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
) &&
167 (!((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5750
)
168 && (tp
->tg3_flags
& TG3_FLAG_ENABLE_ASF
))) &&
169 (orig_clock_ctrl
& CLOCK_CTRL_44MHZ_CORE
)!=0) {
170 tw32_carefully(TG3PCI_CLOCK_CTRL
,
171 clock_ctrl
| (CLOCK_CTRL_44MHZ_CORE
| CLOCK_CTRL_ALTCLK
));
172 tw32_carefully(TG3PCI_CLOCK_CTRL
,
173 clock_ctrl
| (CLOCK_CTRL_ALTCLK
));
175 tw32_carefully(TG3PCI_CLOCK_CTRL
, clock_ctrl
);
178 #define PHY_BUSY_LOOPS 5000
180 static int tg3_readphy(struct tg3
*tp
, int reg
, uint32_t *val
)
185 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
& ~MAC_MI_MODE_AUTO_POLL
);
189 frame_val
= ((PHY_ADDR
<< MI_COM_PHY_ADDR_SHIFT
) &
190 MI_COM_PHY_ADDR_MASK
);
191 frame_val
|= ((reg
<< MI_COM_REG_ADDR_SHIFT
) &
192 MI_COM_REG_ADDR_MASK
);
193 frame_val
|= (MI_COM_CMD_READ
| MI_COM_START
);
195 tw32_carefully(MAC_MI_COM
, frame_val
);
197 loops
= PHY_BUSY_LOOPS
;
198 while (loops
-- > 0) {
200 frame_val
= tr32(MAC_MI_COM
);
202 if ((frame_val
& MI_COM_BUSY
) == 0) {
204 frame_val
= tr32(MAC_MI_COM
);
211 *val
= frame_val
& MI_COM_DATA_MASK
;
215 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
);
220 static int tg3_writephy(struct tg3
*tp
, int reg
, uint32_t val
)
225 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
& ~MAC_MI_MODE_AUTO_POLL
);
227 frame_val
= ((PHY_ADDR
<< MI_COM_PHY_ADDR_SHIFT
) &
228 MI_COM_PHY_ADDR_MASK
);
229 frame_val
|= ((reg
<< MI_COM_REG_ADDR_SHIFT
) &
230 MI_COM_REG_ADDR_MASK
);
231 frame_val
|= (val
& MI_COM_DATA_MASK
);
232 frame_val
|= (MI_COM_CMD_WRITE
| MI_COM_START
);
234 tw32_carefully(MAC_MI_COM
, frame_val
);
236 loops
= PHY_BUSY_LOOPS
;
237 while (loops
-- > 0) {
239 frame_val
= tr32(MAC_MI_COM
);
240 if ((frame_val
& MI_COM_BUSY
) == 0) {
242 frame_val
= tr32(MAC_MI_COM
);
251 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
);
256 static int tg3_writedsp(struct tg3
*tp
, uint16_t addr
, uint16_t val
)
259 err
= tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
, addr
);
260 err
|= tg3_writephy(tp
, MII_TG3_DSP_RW_PORT
, val
);
265 static void tg3_phy_set_wirespeed(struct tg3
*tp
)
269 if (tp
->tg3_flags2
& TG3_FLG2_NO_ETH_WIRE_SPEED
)
272 tg3_writephy(tp
, MII_TG3_AUX_CTRL
, 0x7007);
273 tg3_readphy(tp
, MII_TG3_AUX_CTRL
, &val
);
274 tg3_writephy(tp
, MII_TG3_AUX_CTRL
, (val
| (1 << 15) | (1 << 4)));
277 static int tg3_bmcr_reset(struct tg3
*tp
)
279 uint32_t phy_control
;
282 /* OK, reset it, and poll the BMCR_RESET bit until it
283 * clears or we time out.
285 phy_control
= BMCR_RESET
;
286 err
= tg3_writephy(tp
, MII_BMCR
, phy_control
);
292 err
= tg3_readphy(tp
, MII_BMCR
, &phy_control
);
296 if ((phy_control
& BMCR_RESET
) == 0) {
308 static int tg3_wait_macro_done(struct tg3
*tp
)
315 tg3_readphy(tp
, 0x16, &tmp32
);
316 if ((tmp32
& 0x1000) == 0)
325 static int tg3_phy_write_and_check_testpat(struct tg3
*tp
, int *resetp
)
327 static const uint32_t test_pat
[4][6] = {
328 { 0x00005555, 0x00000005, 0x00002aaa, 0x0000000a, 0x00003456, 0x00000003 },
329 { 0x00002aaa, 0x0000000a, 0x00003333, 0x00000003, 0x0000789a, 0x00000005 },
330 { 0x00005a5a, 0x00000005, 0x00002a6a, 0x0000000a, 0x00001bcd, 0x00000003 },
331 { 0x00002a5a, 0x0000000a, 0x000033c3, 0x00000003, 0x00002ef1, 0x00000005 }
335 for (chan
= 0; chan
< 4; chan
++) {
338 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
,
339 (chan
* 0x2000) | 0x0200);
340 tg3_writephy(tp
, 0x16, 0x0002);
342 for (i
= 0; i
< 6; i
++)
343 tg3_writephy(tp
, MII_TG3_DSP_RW_PORT
,
346 tg3_writephy(tp
, 0x16, 0x0202);
347 if (tg3_wait_macro_done(tp
)) {
352 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
,
353 (chan
* 0x2000) | 0x0200);
354 tg3_writephy(tp
, 0x16, 0x0082);
355 if (tg3_wait_macro_done(tp
)) {
360 tg3_writephy(tp
, 0x16, 0x0802);
361 if (tg3_wait_macro_done(tp
)) {
366 for (i
= 0; i
< 6; i
+= 2) {
369 tg3_readphy(tp
, MII_TG3_DSP_RW_PORT
, &low
);
370 tg3_readphy(tp
, MII_TG3_DSP_RW_PORT
, &high
);
371 if (tg3_wait_macro_done(tp
)) {
377 if (low
!= test_pat
[chan
][i
] ||
378 high
!= test_pat
[chan
][i
+1]) {
379 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
, 0x000b);
380 tg3_writephy(tp
, MII_TG3_DSP_RW_PORT
, 0x4001);
381 tg3_writephy(tp
, MII_TG3_DSP_RW_PORT
, 0x4005);
391 static int tg3_phy_reset_chanpat(struct tg3
*tp
)
395 for (chan
= 0; chan
< 4; chan
++) {
398 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
,
399 (chan
* 0x2000) | 0x0200);
400 tg3_writephy(tp
, 0x16, 0x0002);
401 for (i
= 0; i
< 6; i
++)
402 tg3_writephy(tp
, MII_TG3_DSP_RW_PORT
, 0x000);
403 tg3_writephy(tp
, 0x16, 0x0202);
404 if (tg3_wait_macro_done(tp
))
411 static int tg3_phy_reset_5703_4_5(struct tg3
*tp
)
413 uint32_t reg32
, phy9_orig
;
414 int retries
, do_phy_reset
, err
;
420 err
= tg3_bmcr_reset(tp
);
426 /* Disable transmitter and interrupt. */
427 tg3_readphy(tp
, MII_TG3_EXT_CTRL
, ®32
);
429 tg3_writephy(tp
, MII_TG3_EXT_CTRL
, reg32
);
431 /* Set full-duplex, 1000 mbps. */
432 tg3_writephy(tp
, MII_BMCR
,
433 BMCR_FULLDPLX
| TG3_BMCR_SPEED1000
);
435 /* Set to master mode. */
436 tg3_readphy(tp
, MII_TG3_CTRL
, &phy9_orig
);
437 tg3_writephy(tp
, MII_TG3_CTRL
,
438 (MII_TG3_CTRL_AS_MASTER
|
439 MII_TG3_CTRL_ENABLE_AS_MASTER
));
441 /* Enable SM_DSP_CLOCK and 6dB. */
442 tg3_writephy(tp
, MII_TG3_AUX_CTRL
, 0x0c00);
444 /* Block the PHY control access. */
445 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
, 0x8005);
446 tg3_writephy(tp
, MII_TG3_DSP_RW_PORT
, 0x0800);
448 err
= tg3_phy_write_and_check_testpat(tp
, &do_phy_reset
);
453 err
= tg3_phy_reset_chanpat(tp
);
457 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
, 0x8005);
458 tg3_writephy(tp
, MII_TG3_DSP_RW_PORT
, 0x0000);
460 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
, 0x8200);
461 tg3_writephy(tp
, 0x16, 0x0000);
463 tg3_writephy(tp
, MII_TG3_AUX_CTRL
, 0x0400);
465 tg3_writephy(tp
, MII_TG3_CTRL
, phy9_orig
);
467 tg3_readphy(tp
, MII_TG3_EXT_CTRL
, ®32
);
469 tg3_writephy(tp
, MII_TG3_EXT_CTRL
, reg32
);
474 /* This will reset the tigon3 PHY if there is no valid
477 static int tg3_phy_reset(struct tg3
*tp
)
482 err
= tg3_readphy(tp
, MII_BMSR
, &phy_status
);
483 err
|= tg3_readphy(tp
, MII_BMSR
, &phy_status
);
487 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) ||
488 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
) ||
489 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
)) {
490 err
= tg3_phy_reset_5703_4_5(tp
);
495 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5750
) {
496 // Taken from Broadcom's source code
497 tg3_writephy(tp
, 0x18, 0x0c00);
498 tg3_writephy(tp
, 0x17, 0x000a);
499 tg3_writephy(tp
, 0x15, 0x310b);
500 tg3_writephy(tp
, 0x17, 0x201f);
501 tg3_writephy(tp
, 0x15, 0x9506);
502 tg3_writephy(tp
, 0x17, 0x401f);
503 tg3_writephy(tp
, 0x15, 0x14e2);
504 tg3_writephy(tp
, 0x18, 0x0400);
506 err
= tg3_bmcr_reset(tp
);
510 tg3_phy_set_wirespeed(tp
);
514 static void tg3_set_power_state_0(struct tg3
*tp
)
516 uint16_t power_control
;
519 /* Make sure register accesses (indirect or otherwise)
520 * will function correctly.
522 pci_write_config_dword(tp
->pdev
, TG3PCI_MISC_HOST_CTRL
, tp
->misc_host_ctrl
);
524 pci_read_config_word(tp
->pdev
, pm
+ PCI_PM_CTRL
, &power_control
);
526 power_control
|= PCI_PM_CTRL_PME_STATUS
;
527 power_control
&= ~(PCI_PM_CTRL_STATE_MASK
);
529 pci_write_config_word(tp
->pdev
, pm
+ PCI_PM_CTRL
, power_control
);
531 tw32_carefully(GRC_LOCAL_CTRL
, tp
->grc_local_ctrl
);
537 #if SUPPORT_LINK_REPORT
538 static void tg3_link_report(struct tg3
*tp
)
540 if (!tp
->carrier_ok
) {
541 printf("Link is down.\n");
543 printf("Link is up at %d Mbps, %s duplex. %s %s %s\n",
544 (tp
->link_config
.active_speed
== SPEED_1000
?
546 (tp
->link_config
.active_speed
== SPEED_100
?
548 (tp
->link_config
.active_duplex
== DUPLEX_FULL
?
550 (tp
->tg3_flags
& TG3_FLAG_TX_PAUSE
) ? "TX" : "",
551 (tp
->tg3_flags
& TG3_FLAG_RX_PAUSE
) ? "RX" : "",
552 (tp
->tg3_flags
& (TG3_FLAG_TX_PAUSE
|TG3_FLAG_RX_PAUSE
)) ? "flow control" : "");
556 #define tg3_link_report(tp)
559 static void tg3_setup_flow_control(struct tg3
*tp
, uint32_t local_adv
, uint32_t remote_adv
)
561 uint32_t new_tg3_flags
= 0;
563 if (local_adv
& ADVERTISE_PAUSE_CAP
) {
564 if (local_adv
& ADVERTISE_PAUSE_ASYM
) {
565 if (remote_adv
& LPA_PAUSE_CAP
)
569 else if (remote_adv
& LPA_PAUSE_ASYM
)
573 if (remote_adv
& LPA_PAUSE_CAP
)
578 } else if (local_adv
& ADVERTISE_PAUSE_ASYM
) {
579 if ((remote_adv
& LPA_PAUSE_CAP
) &&
580 (remote_adv
& LPA_PAUSE_ASYM
))
581 new_tg3_flags
|= TG3_FLAG_TX_PAUSE
;
584 tp
->tg3_flags
&= ~(TG3_FLAG_RX_PAUSE
| TG3_FLAG_TX_PAUSE
);
585 tp
->tg3_flags
|= new_tg3_flags
;
587 if (new_tg3_flags
& TG3_FLAG_RX_PAUSE
)
588 tp
->rx_mode
|= RX_MODE_FLOW_CTRL_ENABLE
;
590 tp
->rx_mode
&= ~RX_MODE_FLOW_CTRL_ENABLE
;
592 if (new_tg3_flags
& TG3_FLAG_TX_PAUSE
)
593 tp
->tx_mode
|= TX_MODE_FLOW_CTRL_ENABLE
;
595 tp
->tx_mode
&= ~TX_MODE_FLOW_CTRL_ENABLE
;
598 #if SUPPORT_COPPER_PHY
599 static void tg3_aux_stat_to_speed_duplex(
600 struct tg3
*tp __unused
, uint32_t val
, uint8_t *speed
, uint8_t *duplex
)
602 static const uint8_t map
[] = {
603 [0] = (SPEED_INVALID
<< 2) | DUPLEX_INVALID
,
604 [MII_TG3_AUX_STAT_10HALF
>> 8] = (SPEED_10
<< 2) | DUPLEX_HALF
,
605 [MII_TG3_AUX_STAT_10FULL
>> 8] = (SPEED_10
<< 2) | DUPLEX_FULL
,
606 [MII_TG3_AUX_STAT_100HALF
>> 8] = (SPEED_100
<< 2) | DUPLEX_HALF
,
607 [MII_TG3_AUX_STAT_100_4
>> 8] = (SPEED_INVALID
<< 2) | DUPLEX_INVALID
,
608 [MII_TG3_AUX_STAT_100FULL
>> 8] = (SPEED_100
<< 2) | DUPLEX_FULL
,
609 [MII_TG3_AUX_STAT_1000HALF
>> 8] = (SPEED_1000
<< 2) | DUPLEX_HALF
,
610 [MII_TG3_AUX_STAT_1000FULL
>> 8] = (SPEED_1000
<< 2) | DUPLEX_FULL
,
613 result
= map
[(val
& MII_TG3_AUX_STAT_SPDMASK
) >> 8];
614 *speed
= result
>> 2;
615 *duplex
= result
& 3;
618 static int tg3_phy_copper_begin(struct tg3
*tp
)
622 tp
->link_config
.advertising
=
623 (ADVERTISED_10baseT_Half
| ADVERTISED_10baseT_Full
|
624 ADVERTISED_100baseT_Half
| ADVERTISED_100baseT_Full
|
625 ADVERTISED_1000baseT_Half
| ADVERTISED_1000baseT_Full
|
626 ADVERTISED_Autoneg
| ADVERTISED_MII
);
628 if (tp
->tg3_flags
& TG3_FLAG_10_100_ONLY
) {
629 tp
->link_config
.advertising
&=
630 ~(ADVERTISED_1000baseT_Half
| ADVERTISED_1000baseT_Full
);
633 new_adv
= (ADVERTISE_CSMA
| ADVERTISE_PAUSE_CAP
);
634 if (tp
->link_config
.advertising
& ADVERTISED_10baseT_Half
) {
635 new_adv
|= ADVERTISE_10HALF
;
637 if (tp
->link_config
.advertising
& ADVERTISED_10baseT_Full
) {
638 new_adv
|= ADVERTISE_10FULL
;
640 if (tp
->link_config
.advertising
& ADVERTISED_100baseT_Half
) {
641 new_adv
|= ADVERTISE_100HALF
;
643 if (tp
->link_config
.advertising
& ADVERTISED_100baseT_Full
) {
644 new_adv
|= ADVERTISE_100FULL
;
646 tg3_writephy(tp
, MII_ADVERTISE
, new_adv
);
648 if (tp
->link_config
.advertising
&
649 (ADVERTISED_1000baseT_Half
| ADVERTISED_1000baseT_Full
)) {
651 if (tp
->link_config
.advertising
& ADVERTISED_1000baseT_Half
) {
652 new_adv
|= MII_TG3_CTRL_ADV_1000_HALF
;
654 if (tp
->link_config
.advertising
& ADVERTISED_1000baseT_Full
) {
655 new_adv
|= MII_TG3_CTRL_ADV_1000_FULL
;
657 if (!(tp
->tg3_flags
& TG3_FLAG_10_100_ONLY
) &&
658 (tp
->pci_chip_rev_id
== CHIPREV_ID_5701_A0
||
659 tp
->pci_chip_rev_id
== CHIPREV_ID_5701_B0
)) {
660 new_adv
|= (MII_TG3_CTRL_AS_MASTER
|
661 MII_TG3_CTRL_ENABLE_AS_MASTER
);
663 tg3_writephy(tp
, MII_TG3_CTRL
, new_adv
);
665 tg3_writephy(tp
, MII_TG3_CTRL
, 0);
668 tg3_writephy(tp
, MII_BMCR
, BMCR_ANENABLE
| BMCR_ANRESTART
);
673 static int tg3_init_5401phy_dsp(struct tg3
*tp
)
677 /* Turn off tap power management. */
678 err
= tg3_writephy(tp
, MII_TG3_AUX_CTRL
, 0x0c20);
680 err
|= tg3_writedsp(tp
, 0x0012, 0x1804);
681 err
|= tg3_writedsp(tp
, 0x0013, 0x1204);
682 err
|= tg3_writedsp(tp
, 0x8006, 0x0132);
683 err
|= tg3_writedsp(tp
, 0x8006, 0x0232);
684 err
|= tg3_writedsp(tp
, 0x201f, 0x0a20);
691 static int tg3_setup_copper_phy(struct tg3
*tp
)
694 uint32_t bmsr
, dummy
;
697 tw32_carefully(MAC_STATUS
,
698 (MAC_STATUS_SYNC_CHANGED
| MAC_STATUS_CFG_CHANGED
699 | MAC_STATUS_LNKSTATE_CHANGED
));
701 tp
->mi_mode
= MAC_MI_MODE_BASE
;
702 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
);
704 tg3_writephy(tp
, MII_TG3_AUX_CTRL
, 0x02);
706 /* Some third-party PHYs need to be reset on link going
709 if ( ( (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) ||
710 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
) ||
711 (tp
->pci_chip_rev_id
== CHIPREV_ID_5705_A0
)) &&
713 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
714 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
715 if (!(bmsr
& BMSR_LSTATUS
))
719 if ((tp
->phy_id
& PHY_ID_MASK
) == PHY_ID_BCM5401
) {
720 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
721 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
723 if (!(tp
->tg3_flags
& TG3_FLAG_INIT_COMPLETE
))
726 if (!(bmsr
& BMSR_LSTATUS
)) {
727 err
= tg3_init_5401phy_dsp(tp
);
731 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
732 for (i
= 0; i
< 1000; i
++) {
734 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
735 if (bmsr
& BMSR_LSTATUS
) {
741 if ((tp
->phy_id
& PHY_ID_REV_MASK
) == PHY_REV_BCM5401_B0
&&
742 !(bmsr
& BMSR_LSTATUS
) &&
743 tp
->link_config
.active_speed
== SPEED_1000
) {
744 err
= tg3_phy_reset(tp
);
746 err
= tg3_init_5401phy_dsp(tp
);
751 } else if (tp
->pci_chip_rev_id
== CHIPREV_ID_5701_A0
||
752 tp
->pci_chip_rev_id
== CHIPREV_ID_5701_B0
) {
753 /* 5701 {A0,B0} CRC bug workaround */
754 tg3_writephy(tp
, 0x15, 0x0a75);
755 tg3_writephy(tp
, 0x1c, 0x8c68);
756 tg3_writephy(tp
, 0x1c, 0x8d68);
757 tg3_writephy(tp
, 0x1c, 0x8c68);
760 /* Clear pending interrupts... */
761 tg3_readphy(tp
, MII_TG3_ISTAT
, &dummy
);
762 tg3_readphy(tp
, MII_TG3_ISTAT
, &dummy
);
764 tg3_writephy(tp
, MII_TG3_IMASK
, ~0);
766 if (tp
->led_mode
== led_mode_three_link
)
767 tg3_writephy(tp
, MII_TG3_EXT_CTRL
,
768 MII_TG3_EXT_CTRL_LNK3_LED_MODE
);
770 tg3_writephy(tp
, MII_TG3_EXT_CTRL
, 0);
774 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
775 tg3_readphy(tp
, MII_BMSR
, &bmsr
);
777 if (bmsr
& BMSR_LSTATUS
) {
778 uint32_t aux_stat
, bmcr
;
780 tg3_readphy(tp
, MII_TG3_AUX_STAT
, &aux_stat
);
781 for (i
= 0; i
< 2000; i
++) {
783 tg3_readphy(tp
, MII_TG3_AUX_STAT
, &aux_stat
);
788 tg3_aux_stat_to_speed_duplex(tp
, aux_stat
,
789 &tp
->link_config
.active_speed
,
790 &tp
->link_config
.active_duplex
);
791 tg3_readphy(tp
, MII_BMCR
, &bmcr
);
792 tg3_readphy(tp
, MII_BMCR
, &bmcr
);
793 if (bmcr
& BMCR_ANENABLE
) {
798 /* Force autoneg restart if we are exiting
801 tg3_readphy(tp
, MII_TG3_CTRL
, &gig_ctrl
);
802 if (!(gig_ctrl
& (MII_TG3_CTRL_ADV_1000_HALF
|
803 MII_TG3_CTRL_ADV_1000_FULL
))) {
811 if (current_link_up
== 1 &&
812 (tp
->link_config
.active_duplex
== DUPLEX_FULL
)) {
813 uint32_t local_adv
, remote_adv
;
815 tg3_readphy(tp
, MII_ADVERTISE
, &local_adv
);
816 local_adv
&= (ADVERTISE_PAUSE_CAP
| ADVERTISE_PAUSE_ASYM
);
818 tg3_readphy(tp
, MII_LPA
, &remote_adv
);
819 remote_adv
&= (LPA_PAUSE_CAP
| LPA_PAUSE_ASYM
);
821 /* If we are not advertising full pause capability,
822 * something is wrong. Bring the link down and reconfigure.
824 if (local_adv
!= ADVERTISE_PAUSE_CAP
) {
827 tg3_setup_flow_control(tp
, local_adv
, remote_adv
);
831 if (current_link_up
== 0) {
834 tg3_phy_copper_begin(tp
);
836 tg3_readphy(tp
, MII_BMSR
, &tmp
);
837 tg3_readphy(tp
, MII_BMSR
, &tmp
);
838 if (tmp
& BMSR_LSTATUS
)
842 tp
->mac_mode
&= ~MAC_MODE_PORT_MODE_MASK
;
843 if (current_link_up
== 1) {
844 if (tp
->link_config
.active_speed
== SPEED_100
||
845 tp
->link_config
.active_speed
== SPEED_10
)
846 tp
->mac_mode
|= MAC_MODE_PORT_MODE_MII
;
848 tp
->mac_mode
|= MAC_MODE_PORT_MODE_GMII
;
850 tp
->mac_mode
|= MAC_MODE_PORT_MODE_GMII
;
852 tp
->mac_mode
&= ~MAC_MODE_HALF_DUPLEX
;
853 if (tp
->link_config
.active_duplex
== DUPLEX_HALF
)
854 tp
->mac_mode
|= MAC_MODE_HALF_DUPLEX
;
856 tp
->mac_mode
&= ~MAC_MODE_LINK_POLARITY
;
857 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5700
) {
858 if ((tp
->led_mode
== led_mode_link10
) ||
859 (current_link_up
== 1 &&
860 tp
->link_config
.active_speed
== SPEED_10
))
861 tp
->mac_mode
|= MAC_MODE_LINK_POLARITY
;
863 if (current_link_up
== 1)
864 tp
->mac_mode
|= MAC_MODE_LINK_POLARITY
;
865 tw32(MAC_LED_CTRL
, LED_CTRL_PHY_MODE_1
);
868 /* ??? Without this setting Netgear GA302T PHY does not
869 * ??? send/receive packets...
870 * With this other PHYs cannot bring up the link
872 if ((tp
->phy_id
& PHY_ID_MASK
) == PHY_ID_BCM5411
&&
873 tp
->pci_chip_rev_id
== CHIPREV_ID_5700_ALTIMA
) {
874 tp
->mi_mode
|= MAC_MI_MODE_AUTO_POLL
;
875 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
);
878 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
880 /* Link change polled. */
881 tw32_carefully(MAC_EVENT
, 0);
883 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5700
&&
884 current_link_up
== 1 &&
885 tp
->link_config
.active_speed
== SPEED_1000
&&
886 ((tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
) ||
887 (tp
->tg3_flags
& TG3_FLAG_PCI_HIGH_SPEED
))) {
889 tw32_carefully(MAC_STATUS
,
890 (MAC_STATUS_SYNC_CHANGED
| MAC_STATUS_CFG_CHANGED
));
892 NIC_SRAM_FIRMWARE_MBOX
,
893 NIC_SRAM_FIRMWARE_MBOX_MAGIC2
);
896 if (current_link_up
!= tp
->carrier_ok
) {
897 tp
->carrier_ok
= current_link_up
;
904 #define tg3_setup_copper_phy(TP) (-EINVAL)
905 #endif /* SUPPORT_COPPER_PHY */
907 #if SUPPORT_FIBER_PHY
908 struct tg3_fiber_aneginfo
{
910 #define ANEG_STATE_UNKNOWN 0
911 #define ANEG_STATE_AN_ENABLE 1
912 #define ANEG_STATE_RESTART_INIT 2
913 #define ANEG_STATE_RESTART 3
914 #define ANEG_STATE_DISABLE_LINK_OK 4
915 #define ANEG_STATE_ABILITY_DETECT_INIT 5
916 #define ANEG_STATE_ABILITY_DETECT 6
917 #define ANEG_STATE_ACK_DETECT_INIT 7
918 #define ANEG_STATE_ACK_DETECT 8
919 #define ANEG_STATE_COMPLETE_ACK_INIT 9
920 #define ANEG_STATE_COMPLETE_ACK 10
921 #define ANEG_STATE_IDLE_DETECT_INIT 11
922 #define ANEG_STATE_IDLE_DETECT 12
923 #define ANEG_STATE_LINK_OK 13
924 #define ANEG_STATE_NEXT_PAGE_WAIT_INIT 14
925 #define ANEG_STATE_NEXT_PAGE_WAIT 15
928 #define MR_AN_ENABLE 0x00000001
929 #define MR_RESTART_AN 0x00000002
930 #define MR_AN_COMPLETE 0x00000004
931 #define MR_PAGE_RX 0x00000008
932 #define MR_NP_LOADED 0x00000010
933 #define MR_TOGGLE_TX 0x00000020
934 #define MR_LP_ADV_FULL_DUPLEX 0x00000040
935 #define MR_LP_ADV_HALF_DUPLEX 0x00000080
936 #define MR_LP_ADV_SYM_PAUSE 0x00000100
937 #define MR_LP_ADV_ASYM_PAUSE 0x00000200
938 #define MR_LP_ADV_REMOTE_FAULT1 0x00000400
939 #define MR_LP_ADV_REMOTE_FAULT2 0x00000800
940 #define MR_LP_ADV_NEXT_PAGE 0x00001000
941 #define MR_TOGGLE_RX 0x00002000
942 #define MR_NP_RX 0x00004000
944 #define MR_LINK_OK 0x80000000
946 unsigned long link_time
, cur_time
;
948 uint32_t ability_match_cfg
;
949 int ability_match_count
;
951 char ability_match
, idle_match
, ack_match
;
953 uint32_t txconfig
, rxconfig
;
954 #define ANEG_CFG_NP 0x00000080
955 #define ANEG_CFG_ACK 0x00000040
956 #define ANEG_CFG_RF2 0x00000020
957 #define ANEG_CFG_RF1 0x00000010
958 #define ANEG_CFG_PS2 0x00000001
959 #define ANEG_CFG_PS1 0x00008000
960 #define ANEG_CFG_HD 0x00004000
961 #define ANEG_CFG_FD 0x00002000
962 #define ANEG_CFG_INVAL 0x00001f06
967 #define ANEG_TIMER_ENAB 2
968 #define ANEG_FAILED -1
970 #define ANEG_STATE_SETTLE_TIME 10000
972 static int tg3_fiber_aneg_smachine(struct tg3
*tp
,
973 struct tg3_fiber_aneginfo
*ap
)
979 if (ap
->state
== ANEG_STATE_UNKNOWN
) {
983 ap
->ability_match_cfg
= 0;
984 ap
->ability_match_count
= 0;
985 ap
->ability_match
= 0;
991 if (tr32(MAC_STATUS
) & MAC_STATUS_RCVD_CFG
) {
992 rx_cfg_reg
= tr32(MAC_RX_AUTO_NEG
);
994 if (rx_cfg_reg
!= ap
->ability_match_cfg
) {
995 ap
->ability_match_cfg
= rx_cfg_reg
;
996 ap
->ability_match
= 0;
997 ap
->ability_match_count
= 0;
999 if (++ap
->ability_match_count
> 1) {
1000 ap
->ability_match
= 1;
1001 ap
->ability_match_cfg
= rx_cfg_reg
;
1004 if (rx_cfg_reg
& ANEG_CFG_ACK
)
1012 ap
->ability_match_cfg
= 0;
1013 ap
->ability_match_count
= 0;
1014 ap
->ability_match
= 0;
1020 ap
->rxconfig
= rx_cfg_reg
;
1024 case ANEG_STATE_UNKNOWN
:
1025 if (ap
->flags
& (MR_AN_ENABLE
| MR_RESTART_AN
))
1026 ap
->state
= ANEG_STATE_AN_ENABLE
;
1029 case ANEG_STATE_AN_ENABLE
:
1030 ap
->flags
&= ~(MR_AN_COMPLETE
| MR_PAGE_RX
);
1031 if (ap
->flags
& MR_AN_ENABLE
) {
1034 ap
->ability_match_cfg
= 0;
1035 ap
->ability_match_count
= 0;
1036 ap
->ability_match
= 0;
1040 ap
->state
= ANEG_STATE_RESTART_INIT
;
1042 ap
->state
= ANEG_STATE_DISABLE_LINK_OK
;
1046 case ANEG_STATE_RESTART_INIT
:
1047 ap
->link_time
= ap
->cur_time
;
1048 ap
->flags
&= ~(MR_NP_LOADED
);
1050 tw32(MAC_TX_AUTO_NEG
, 0);
1051 tp
->mac_mode
|= MAC_MODE_SEND_CONFIGS
;
1052 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1054 ret
= ANEG_TIMER_ENAB
;
1055 ap
->state
= ANEG_STATE_RESTART
;
1058 case ANEG_STATE_RESTART
:
1059 delta
= ap
->cur_time
- ap
->link_time
;
1060 if (delta
> ANEG_STATE_SETTLE_TIME
) {
1061 ap
->state
= ANEG_STATE_ABILITY_DETECT_INIT
;
1063 ret
= ANEG_TIMER_ENAB
;
1067 case ANEG_STATE_DISABLE_LINK_OK
:
1071 case ANEG_STATE_ABILITY_DETECT_INIT
:
1072 ap
->flags
&= ~(MR_TOGGLE_TX
);
1073 ap
->txconfig
= (ANEG_CFG_FD
| ANEG_CFG_PS1
);
1074 tw32(MAC_TX_AUTO_NEG
, ap
->txconfig
);
1075 tp
->mac_mode
|= MAC_MODE_SEND_CONFIGS
;
1076 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1078 ap
->state
= ANEG_STATE_ABILITY_DETECT
;
1081 case ANEG_STATE_ABILITY_DETECT
:
1082 if (ap
->ability_match
!= 0 && ap
->rxconfig
!= 0) {
1083 ap
->state
= ANEG_STATE_ACK_DETECT_INIT
;
1087 case ANEG_STATE_ACK_DETECT_INIT
:
1088 ap
->txconfig
|= ANEG_CFG_ACK
;
1089 tw32(MAC_TX_AUTO_NEG
, ap
->txconfig
);
1090 tp
->mac_mode
|= MAC_MODE_SEND_CONFIGS
;
1091 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1093 ap
->state
= ANEG_STATE_ACK_DETECT
;
1096 case ANEG_STATE_ACK_DETECT
:
1097 if (ap
->ack_match
!= 0) {
1098 if ((ap
->rxconfig
& ~ANEG_CFG_ACK
) ==
1099 (ap
->ability_match_cfg
& ~ANEG_CFG_ACK
)) {
1100 ap
->state
= ANEG_STATE_COMPLETE_ACK_INIT
;
1102 ap
->state
= ANEG_STATE_AN_ENABLE
;
1104 } else if (ap
->ability_match
!= 0 &&
1105 ap
->rxconfig
== 0) {
1106 ap
->state
= ANEG_STATE_AN_ENABLE
;
1110 case ANEG_STATE_COMPLETE_ACK_INIT
:
1111 if (ap
->rxconfig
& ANEG_CFG_INVAL
) {
1115 ap
->flags
&= ~(MR_LP_ADV_FULL_DUPLEX
|
1116 MR_LP_ADV_HALF_DUPLEX
|
1117 MR_LP_ADV_SYM_PAUSE
|
1118 MR_LP_ADV_ASYM_PAUSE
|
1119 MR_LP_ADV_REMOTE_FAULT1
|
1120 MR_LP_ADV_REMOTE_FAULT2
|
1121 MR_LP_ADV_NEXT_PAGE
|
1124 if (ap
->rxconfig
& ANEG_CFG_FD
)
1125 ap
->flags
|= MR_LP_ADV_FULL_DUPLEX
;
1126 if (ap
->rxconfig
& ANEG_CFG_HD
)
1127 ap
->flags
|= MR_LP_ADV_HALF_DUPLEX
;
1128 if (ap
->rxconfig
& ANEG_CFG_PS1
)
1129 ap
->flags
|= MR_LP_ADV_SYM_PAUSE
;
1130 if (ap
->rxconfig
& ANEG_CFG_PS2
)
1131 ap
->flags
|= MR_LP_ADV_ASYM_PAUSE
;
1132 if (ap
->rxconfig
& ANEG_CFG_RF1
)
1133 ap
->flags
|= MR_LP_ADV_REMOTE_FAULT1
;
1134 if (ap
->rxconfig
& ANEG_CFG_RF2
)
1135 ap
->flags
|= MR_LP_ADV_REMOTE_FAULT2
;
1136 if (ap
->rxconfig
& ANEG_CFG_NP
)
1137 ap
->flags
|= MR_LP_ADV_NEXT_PAGE
;
1139 ap
->link_time
= ap
->cur_time
;
1141 ap
->flags
^= (MR_TOGGLE_TX
);
1142 if (ap
->rxconfig
& 0x0008)
1143 ap
->flags
|= MR_TOGGLE_RX
;
1144 if (ap
->rxconfig
& ANEG_CFG_NP
)
1145 ap
->flags
|= MR_NP_RX
;
1146 ap
->flags
|= MR_PAGE_RX
;
1148 ap
->state
= ANEG_STATE_COMPLETE_ACK
;
1149 ret
= ANEG_TIMER_ENAB
;
1152 case ANEG_STATE_COMPLETE_ACK
:
1153 if (ap
->ability_match
!= 0 &&
1154 ap
->rxconfig
== 0) {
1155 ap
->state
= ANEG_STATE_AN_ENABLE
;
1158 delta
= ap
->cur_time
- ap
->link_time
;
1159 if (delta
> ANEG_STATE_SETTLE_TIME
) {
1160 if (!(ap
->flags
& (MR_LP_ADV_NEXT_PAGE
))) {
1161 ap
->state
= ANEG_STATE_IDLE_DETECT_INIT
;
1163 if ((ap
->txconfig
& ANEG_CFG_NP
) == 0 &&
1164 !(ap
->flags
& MR_NP_RX
)) {
1165 ap
->state
= ANEG_STATE_IDLE_DETECT_INIT
;
1173 case ANEG_STATE_IDLE_DETECT_INIT
:
1174 ap
->link_time
= ap
->cur_time
;
1175 tp
->mac_mode
&= ~MAC_MODE_SEND_CONFIGS
;
1176 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1178 ap
->state
= ANEG_STATE_IDLE_DETECT
;
1179 ret
= ANEG_TIMER_ENAB
;
1182 case ANEG_STATE_IDLE_DETECT
:
1183 if (ap
->ability_match
!= 0 &&
1184 ap
->rxconfig
== 0) {
1185 ap
->state
= ANEG_STATE_AN_ENABLE
;
1188 delta
= ap
->cur_time
- ap
->link_time
;
1189 if (delta
> ANEG_STATE_SETTLE_TIME
) {
1190 /* XXX another gem from the Broadcom driver :( */
1191 ap
->state
= ANEG_STATE_LINK_OK
;
1195 case ANEG_STATE_LINK_OK
:
1196 ap
->flags
|= (MR_AN_COMPLETE
| MR_LINK_OK
);
1200 case ANEG_STATE_NEXT_PAGE_WAIT_INIT
:
1201 /* ??? unimplemented */
1204 case ANEG_STATE_NEXT_PAGE_WAIT
:
1205 /* ??? unimplemented */
1216 static int tg3_setup_fiber_phy(struct tg3
*tp
)
1218 uint32_t orig_pause_cfg
;
1219 uint16_t orig_active_speed
;
1220 uint8_t orig_active_duplex
;
1221 int current_link_up
;
1225 (tp
->tg3_flags
& (TG3_FLAG_RX_PAUSE
|
1226 TG3_FLAG_TX_PAUSE
));
1227 orig_active_speed
= tp
->link_config
.active_speed
;
1228 orig_active_duplex
= tp
->link_config
.active_duplex
;
1230 tp
->mac_mode
&= ~(MAC_MODE_PORT_MODE_MASK
| MAC_MODE_HALF_DUPLEX
);
1231 tp
->mac_mode
|= MAC_MODE_PORT_MODE_TBI
;
1232 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1234 /* Reset when initting first time or we have a link. */
1235 if (!(tp
->tg3_flags
& TG3_FLAG_INIT_COMPLETE
) ||
1236 (tr32(MAC_STATUS
) & MAC_STATUS_PCS_SYNCED
)) {
1237 /* Set PLL lock range. */
1238 tg3_writephy(tp
, 0x16, 0x8007);
1241 tg3_writephy(tp
, MII_BMCR
, BMCR_RESET
);
1243 /* Wait for reset to complete. */
1246 /* Config mode; select PMA/Ch 1 regs. */
1247 tg3_writephy(tp
, 0x10, 0x8411);
1249 /* Enable auto-lock and comdet, select txclk for tx. */
1250 tg3_writephy(tp
, 0x11, 0x0a10);
1252 tg3_writephy(tp
, 0x18, 0x00a0);
1253 tg3_writephy(tp
, 0x16, 0x41ff);
1255 /* Assert and deassert POR. */
1256 tg3_writephy(tp
, 0x13, 0x0400);
1258 tg3_writephy(tp
, 0x13, 0x0000);
1260 tg3_writephy(tp
, 0x11, 0x0a50);
1262 tg3_writephy(tp
, 0x11, 0x0a10);
1264 /* Wait for signal to stabilize */
1267 /* Deselect the channel register so we can read the PHYID
1270 tg3_writephy(tp
, 0x10, 0x8011);
1273 /* Disable link change interrupt. */
1274 tw32_carefully(MAC_EVENT
, 0);
1276 current_link_up
= 0;
1277 if (tr32(MAC_STATUS
) & MAC_STATUS_PCS_SYNCED
) {
1278 if (!(tp
->tg3_flags
& TG3_FLAG_GOT_SERDES_FLOWCTL
)) {
1279 struct tg3_fiber_aneginfo aninfo
;
1280 int status
= ANEG_FAILED
;
1284 memset(&aninfo
, 0, sizeof(aninfo
));
1285 aninfo
.flags
|= (MR_AN_ENABLE
);
1287 tw32(MAC_TX_AUTO_NEG
, 0);
1289 tmp
= tp
->mac_mode
& ~MAC_MODE_PORT_MODE_MASK
;
1290 tw32_carefully(MAC_MODE
, tmp
| MAC_MODE_PORT_MODE_GMII
);
1292 tw32_carefully(MAC_MODE
, tp
->mac_mode
| MAC_MODE_SEND_CONFIGS
);
1294 aninfo
.state
= ANEG_STATE_UNKNOWN
;
1295 aninfo
.cur_time
= 0;
1297 while (++tick
< 195000) {
1298 status
= tg3_fiber_aneg_smachine(tp
, &aninfo
);
1299 if (status
== ANEG_DONE
||
1300 status
== ANEG_FAILED
)
1306 tp
->mac_mode
&= ~MAC_MODE_SEND_CONFIGS
;
1307 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1309 if (status
== ANEG_DONE
&&
1311 (MR_AN_COMPLETE
| MR_LINK_OK
|
1312 MR_LP_ADV_FULL_DUPLEX
))) {
1313 uint32_t local_adv
, remote_adv
;
1315 local_adv
= ADVERTISE_PAUSE_CAP
;
1317 if (aninfo
.flags
& MR_LP_ADV_SYM_PAUSE
)
1318 remote_adv
|= LPA_PAUSE_CAP
;
1319 if (aninfo
.flags
& MR_LP_ADV_ASYM_PAUSE
)
1320 remote_adv
|= LPA_PAUSE_ASYM
;
1322 tg3_setup_flow_control(tp
, local_adv
, remote_adv
);
1325 TG3_FLAG_GOT_SERDES_FLOWCTL
;
1326 current_link_up
= 1;
1328 for (i
= 0; i
< 60; i
++) {
1330 tw32_carefully(MAC_STATUS
,
1331 (MAC_STATUS_SYNC_CHANGED
| MAC_STATUS_CFG_CHANGED
));
1332 if ((tr32(MAC_STATUS
) &
1333 (MAC_STATUS_SYNC_CHANGED
|
1334 MAC_STATUS_CFG_CHANGED
)) == 0)
1337 if (current_link_up
== 0 &&
1338 (tr32(MAC_STATUS
) & MAC_STATUS_PCS_SYNCED
)) {
1339 current_link_up
= 1;
1342 /* Forcing 1000FD link up. */
1343 current_link_up
= 1;
1347 tp
->mac_mode
&= ~MAC_MODE_LINK_POLARITY
;
1348 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1350 tp
->hw_status
->status
=
1351 (SD_STATUS_UPDATED
|
1352 (tp
->hw_status
->status
& ~SD_STATUS_LINK_CHG
));
1354 for (i
= 0; i
< 100; i
++) {
1356 tw32_carefully(MAC_STATUS
,
1357 (MAC_STATUS_SYNC_CHANGED
| MAC_STATUS_CFG_CHANGED
));
1358 if ((tr32(MAC_STATUS
) &
1359 (MAC_STATUS_SYNC_CHANGED
|
1360 MAC_STATUS_CFG_CHANGED
)) == 0)
1364 if ((tr32(MAC_STATUS
) & MAC_STATUS_PCS_SYNCED
) == 0)
1365 current_link_up
= 0;
1367 if (current_link_up
== 1) {
1368 tp
->link_config
.active_speed
= SPEED_1000
;
1369 tp
->link_config
.active_duplex
= DUPLEX_FULL
;
1371 tp
->link_config
.active_speed
= SPEED_INVALID
;
1372 tp
->link_config
.active_duplex
= DUPLEX_INVALID
;
1375 if (current_link_up
!= tp
->carrier_ok
) {
1376 tp
->carrier_ok
= current_link_up
;
1377 tg3_link_report(tp
);
1379 uint32_t now_pause_cfg
=
1380 tp
->tg3_flags
& (TG3_FLAG_RX_PAUSE
|
1382 if (orig_pause_cfg
!= now_pause_cfg
||
1383 orig_active_speed
!= tp
->link_config
.active_speed
||
1384 orig_active_duplex
!= tp
->link_config
.active_duplex
)
1385 tg3_link_report(tp
);
1388 if ((tr32(MAC_STATUS
) & MAC_STATUS_PCS_SYNCED
) == 0) {
1389 tw32_carefully(MAC_MODE
, tp
->mac_mode
| MAC_MODE_LINK_POLARITY
);
1390 if (tp
->tg3_flags
& TG3_FLAG_INIT_COMPLETE
) {
1391 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1398 #define tg3_setup_fiber_phy(TP) (-EINVAL)
1399 #endif /* SUPPORT_FIBER_PHY */
1401 static int tg3_setup_phy(struct tg3
*tp
)
1405 if (tp
->phy_id
== PHY_ID_SERDES
) {
1406 err
= tg3_setup_fiber_phy(tp
);
1408 err
= tg3_setup_copper_phy(tp
);
1411 if (tp
->link_config
.active_speed
== SPEED_1000
&&
1412 tp
->link_config
.active_duplex
== DUPLEX_HALF
)
1413 tw32(MAC_TX_LENGTHS
,
1414 ((2 << TX_LENGTHS_IPG_CRS_SHIFT
) |
1415 (6 << TX_LENGTHS_IPG_SHIFT
) |
1416 (0xff << TX_LENGTHS_SLOT_TIME_SHIFT
)));
1418 tw32(MAC_TX_LENGTHS
,
1419 ((2 << TX_LENGTHS_IPG_CRS_SHIFT
) |
1420 (6 << TX_LENGTHS_IPG_SHIFT
) |
1421 (32 << TX_LENGTHS_SLOT_TIME_SHIFT
)));
1427 #define MAX_WAIT_CNT 1000
1429 /* To stop a block, clear the enable bit and poll till it
1432 static int tg3_stop_block(struct tg3
*tp
, unsigned long ofs
, uint32_t enable_bit
)
1437 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
||
1438 GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5787
) {
1445 /* We can't enable/disable these bits of the
1446 * 5705 or 5787, just say success.
1458 for (i
= 0; i
< MAX_WAIT_CNT
; i
++) {
1461 if ((val
& enable_bit
) == 0)
1465 if (i
== MAX_WAIT_CNT
) {
1466 printf( "tg3_stop_block timed out, ofs=%#lx enable_bit=%3x\n",
1474 static int tg3_abort_hw(struct tg3
*tp
)
1479 tg3_disable_ints(tp
);
1481 tp
->rx_mode
&= ~RX_MODE_ENABLE
;
1482 tw32_carefully(MAC_RX_MODE
, tp
->rx_mode
);
1484 err
= tg3_stop_block(tp
, RCVBDI_MODE
, RCVBDI_MODE_ENABLE
);
1485 err
|= tg3_stop_block(tp
, RCVLPC_MODE
, RCVLPC_MODE_ENABLE
);
1486 err
|= tg3_stop_block(tp
, RCVLSC_MODE
, RCVLSC_MODE_ENABLE
);
1487 err
|= tg3_stop_block(tp
, RCVDBDI_MODE
, RCVDBDI_MODE_ENABLE
);
1488 err
|= tg3_stop_block(tp
, RCVDCC_MODE
, RCVDCC_MODE_ENABLE
);
1489 err
|= tg3_stop_block(tp
, RCVCC_MODE
, RCVCC_MODE_ENABLE
);
1491 err
|= tg3_stop_block(tp
, SNDBDS_MODE
, SNDBDS_MODE_ENABLE
);
1492 err
|= tg3_stop_block(tp
, SNDBDI_MODE
, SNDBDI_MODE_ENABLE
);
1493 err
|= tg3_stop_block(tp
, SNDDATAI_MODE
, SNDDATAI_MODE_ENABLE
);
1494 err
|= tg3_stop_block(tp
, RDMAC_MODE
, RDMAC_MODE_ENABLE
);
1495 err
|= tg3_stop_block(tp
, SNDDATAC_MODE
, SNDDATAC_MODE_ENABLE
);
1496 err
|= tg3_stop_block(tp
, SNDBDC_MODE
, SNDBDC_MODE_ENABLE
);
1500 tp
->mac_mode
&= ~MAC_MODE_TDE_ENABLE
;
1501 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1503 tp
->tx_mode
&= ~TX_MODE_ENABLE
;
1504 tw32_carefully(MAC_TX_MODE
, tp
->tx_mode
);
1506 for (i
= 0; i
< MAX_WAIT_CNT
; i
++) {
1508 if (!(tr32(MAC_TX_MODE
) & TX_MODE_ENABLE
))
1511 if (i
>= MAX_WAIT_CNT
) {
1512 printf("tg3_abort_hw timed out TX_MODE_ENABLE will not clear MAC_TX_MODE=%x\n",
1513 (unsigned int) tr32(MAC_TX_MODE
));
1517 err
= tg3_stop_block(tp
, HOSTCC_MODE
, HOSTCC_MODE_ENABLE
);
1518 err
|= tg3_stop_block(tp
, WDMAC_MODE
, WDMAC_MODE_ENABLE
);
1519 err
|= tg3_stop_block(tp
, MBFREE_MODE
, MBFREE_MODE_ENABLE
);
1521 val
= tr32(FTQ_RESET
);
1522 val
|= FTQ_RESET_DMA_READ_QUEUE
| FTQ_RESET_DMA_HIGH_PRI_READ
|
1523 FTQ_RESET_SEND_BD_COMPLETION
| FTQ_RESET_DMA_WRITE
|
1524 FTQ_RESET_DMA_HIGH_PRI_WRITE
| FTQ_RESET_SEND_DATA_COMPLETION
|
1525 FTQ_RESET_HOST_COALESCING
| FTQ_RESET_MAC_TX
|
1526 FTQ_RESET_RX_BD_COMPLETE
| FTQ_RESET_RX_LIST_PLCMT
|
1527 FTQ_RESET_RX_DATA_COMPLETION
;
1528 tw32(FTQ_RESET
, val
);
1530 err
|= tg3_stop_block(tp
, BUFMGR_MODE
, BUFMGR_MODE_ENABLE
);
1531 err
|= tg3_stop_block(tp
, MEMARB_MODE
, MEMARB_MODE_ENABLE
);
1535 memset(tp
->hw_status
, 0, TG3_HW_STATUS_SIZE
);
1541 static void tg3_chip_reset(struct tg3
*tp
)
1545 if (!(tp
->tg3_flags2
& TG3_FLG2_SUN_5704
)) {
1546 /* Force NVRAM to settle.
1547 * This deals with a chip bug which can result in EEPROM
1550 if (tp
->tg3_flags
& TG3_FLAG_NVRAM
) {
1553 tw32(NVRAM_SWARB
, SWARB_REQ_SET1
);
1554 for (i
= 0; i
< 100000; i
++) {
1555 if (tr32(NVRAM_SWARB
) & SWARB_GNT1
)
1561 /* In Etherboot we don't need to worry about the 5701
1562 * REG_WRITE_BUG because we do all register writes indirectly.
1565 // Alf: here patched
1567 val
= GRC_MISC_CFG_CORECLK_RESET
;
1568 if (tp
->tg3_flags2
& TG3_FLG2_PCI_EXPRESS
) {
1569 if (tr32(0x7e2c) == 0x60) {
1572 if (tp
->pci_chip_rev_id
!= CHIPREV_ID_5750_A0
) {
1573 tw32(GRC_MISC_CFG
, (1 << 29));
1578 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
)
1579 || (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5750
)
1580 || (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5787
)) {
1581 val
|= GRC_MISC_CFG_KEEP_GPHY_POWER
;
1584 // Alf : Please VALIDATE THIS.
1585 // It is necessary in my case (5751) to prevent a reboot, but
1586 // I have no idea about a side effect on any other version.
1587 // It appears to be what's done in tigon3.c from Broadcom
1588 if (tp
->pci_chip_rev_id
!= CHIPREV_ID_5750_A0
) {
1589 tw32(GRC_MISC_CFG
, 0x20000000) ;
1593 tw32(GRC_MISC_CFG
, val
);
1595 /* Flush PCI posted writes. The normal MMIO registers
1596 * are inaccessible at this time so this is the only
1597 * way to make this reliably. I tried to use indirect
1598 * register read/write but this upset some 5701 variants.
1600 pci_read_config_dword(tp
->pdev
, PCI_COMMAND
, &val
);
1604 /* Re-enable indirect register accesses. */
1605 pci_write_config_dword(tp
->pdev
, TG3PCI_MISC_HOST_CTRL
,
1606 tp
->misc_host_ctrl
);
1608 /* Set MAX PCI retry to zero. */
1609 val
= (PCISTATE_ROM_ENABLE
| PCISTATE_ROM_RETRY_ENABLE
);
1610 if (tp
->pci_chip_rev_id
== CHIPREV_ID_5704_A0
&&
1611 (tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
))
1612 val
|= PCISTATE_RETRY_SAME_DMA
;
1613 pci_write_config_dword(tp
->pdev
, TG3PCI_PCISTATE
, val
);
1615 pci_restore_state(tp
->pdev
, tp
->pci_cfg_state
);
1617 /* Make sure PCI-X relaxed ordering bit is clear. */
1618 pci_read_config_dword(tp
->pdev
, TG3PCI_X_CAPS
, &val
);
1619 val
&= ~PCIX_CAPS_RELAXED_ORDERING
;
1620 pci_write_config_dword(tp
->pdev
, TG3PCI_X_CAPS
, val
);
1622 tw32(MEMARB_MODE
, MEMARB_MODE_ENABLE
);
1624 if (((tp
->nic_sram_data_cfg
& NIC_SRAM_DATA_CFG_MINI_PCI
) != 0) &&
1625 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
)) {
1626 tp
->pci_clock_ctrl
|=
1627 (CLOCK_CTRL_FORCE_CLKRUN
| CLOCK_CTRL_CLKRUN_OENABLE
);
1628 tw32(TG3PCI_CLOCK_CTRL
, tp
->pci_clock_ctrl
);
1631 tw32(TG3PCI_MISC_HOST_CTRL
, tp
->misc_host_ctrl
);
1634 static void tg3_stop_fw(struct tg3
*tp
)
1636 if (tp
->tg3_flags
& TG3_FLAG_ENABLE_ASF
) {
1640 tg3_write_mem(NIC_SRAM_FW_CMD_MBOX
, FWCMD_NICDRV_PAUSE_FW
);
1641 val
= tr32(GRC_RX_CPU_EVENT
);
1643 tw32(GRC_RX_CPU_EVENT
, val
);
1645 /* Wait for RX cpu to ACK the event. */
1646 for (i
= 0; i
< 100; i
++) {
1647 if (!(tr32(GRC_RX_CPU_EVENT
) & (1 << 14)))
1654 static int tg3_restart_fw(struct tg3
*tp
, uint32_t state
)
1659 tg3_write_mem(NIC_SRAM_FIRMWARE_MBOX
,
1660 NIC_SRAM_FIRMWARE_MBOX_MAGIC1
);
1661 /* Wait for firmware initialization to complete. */
1662 for (i
= 0; i
< 100000; i
++) {
1663 tg3_read_mem(NIC_SRAM_FIRMWARE_MBOX
, &val
);
1664 if (val
== (uint32_t) ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1
)
1669 !(tp
->tg3_flags2
& TG3_FLG2_SUN_5704
) &&
1670 !(GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5787
)) {
1671 printf ( "Firmware will not restart magic=%#x\n",
1675 if (!(tp
->tg3_flags
& TG3_FLAG_ENABLE_ASF
)) {
1676 state
= DRV_STATE_SUSPEND
;
1679 if ((tp
->tg3_flags2
& TG3_FLG2_PCI_EXPRESS
) &&
1680 (tp
->pci_chip_rev_id
!= CHIPREV_ID_5750_A0
)) {
1681 // Enable PCIE bug fix
1682 tg3_read_mem(0x7c00, &val
);
1683 tg3_write_mem(0x7c00, val
| 0x02000000);
1685 tg3_write_mem(NIC_SRAM_FW_DRV_STATE_MBOX
, state
);
1689 static int tg3_halt(struct tg3
*tp
)
1694 return tg3_restart_fw(tp
, DRV_STATE_UNLOAD
);
1697 static void __tg3_set_mac_addr(struct tg3
*tp
)
1699 uint32_t addr_high
, addr_low
;
1702 addr_high
= ((tp
->nic
->node_addr
[0] << 8) |
1703 tp
->nic
->node_addr
[1]);
1704 addr_low
= ((tp
->nic
->node_addr
[2] << 24) |
1705 (tp
->nic
->node_addr
[3] << 16) |
1706 (tp
->nic
->node_addr
[4] << 8) |
1707 (tp
->nic
->node_addr
[5] << 0));
1708 for (i
= 0; i
< 4; i
++) {
1709 tw32(MAC_ADDR_0_HIGH
+ (i
* 8), addr_high
);
1710 tw32(MAC_ADDR_0_LOW
+ (i
* 8), addr_low
);
1713 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5700
) &&
1714 (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5701
) &&
1715 (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
)) {
1716 for(i
= 0; i
< 12; i
++) {
1717 tw32(MAC_EXTADDR_0_HIGH
+ (i
* 8), addr_high
);
1718 tw32(MAC_EXTADDR_0_LOW
+ (i
* 8), addr_low
);
1721 addr_high
= (tp
->nic
->node_addr
[0] +
1722 tp
->nic
->node_addr
[1] +
1723 tp
->nic
->node_addr
[2] +
1724 tp
->nic
->node_addr
[3] +
1725 tp
->nic
->node_addr
[4] +
1726 tp
->nic
->node_addr
[5]) &
1727 TX_BACKOFF_SEED_MASK
;
1728 tw32(MAC_TX_BACKOFF_SEED
, addr_high
);
1731 static void tg3_set_bdinfo(struct tg3
*tp
, uint32_t bdinfo_addr
,
1732 dma_addr_t mapping
, uint32_t maxlen_flags
,
1735 tg3_write_mem((bdinfo_addr
+
1736 TG3_BDINFO_HOST_ADDR
+ TG3_64BIT_REG_HIGH
),
1737 ((uint64_t) mapping
>> 32));
1738 tg3_write_mem((bdinfo_addr
+
1739 TG3_BDINFO_HOST_ADDR
+ TG3_64BIT_REG_LOW
),
1740 ((uint64_t) mapping
& 0xffffffff));
1741 tg3_write_mem((bdinfo_addr
+
1742 TG3_BDINFO_MAXLEN_FLAGS
),
1744 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
) {
1745 tg3_write_mem((bdinfo_addr
+ TG3_BDINFO_NIC_ADDR
), nic_addr
);
1750 static void tg3_init_rings(struct tg3
*tp
)
1754 /* Zero out the tg3 variables */
1755 memset(&tg3_bss
, 0, sizeof(tg3_bss
));
1756 tp
->rx_std
= &tg3_bss
.rx_std
[0];
1757 tp
->rx_rcb
= &tg3_bss
.rx_rcb
[0];
1758 tp
->tx_ring
= &tg3_bss
.tx_ring
[0];
1759 tp
->hw_status
= &tg3_bss
.hw_status
;
1760 tp
->hw_stats
= &tg3_bss
.hw_stats
;
1764 /* Initialize tx/rx rings for packet processing.
1766 * The chip has been shut down and the driver detached from
1767 * the networking, so no interrupts or new tx packets will
1768 * end up in the driver.
1771 /* Initialize invariants of the rings, we only set this
1772 * stuff once. This works because the card does not
1773 * write into the rx buffer posting rings.
1775 for (i
= 0; i
< TG3_RX_RING_SIZE
; i
++) {
1776 struct tg3_rx_buffer_desc
*rxd
;
1778 rxd
= &tp
->rx_std
[i
];
1779 rxd
->idx_len
= (RX_PKT_BUF_SZ
- 2 - 64) << RXD_LEN_SHIFT
;
1780 rxd
->type_flags
= (RXD_FLAG_END
<< RXD_FLAGS_SHIFT
);
1781 rxd
->opaque
= (RXD_OPAQUE_RING_STD
| (i
<< RXD_OPAQUE_INDEX_SHIFT
));
1783 /* Note where the receive buffer for the ring is placed */
1785 rxd
->addr_lo
= virt_to_bus(
1786 &tg3_bss
.rx_bufs
[i
%TG3_DEF_RX_RING_PENDING
][2]);
1790 #define TG3_WRITE_SETTINGS(TABLE) \
1792 const uint32_t *_table, *_end; \
1794 _end = _table + sizeof(TABLE)/sizeof(TABLE[0]); \
1795 for(; _table < _end; _table += 2) { \
1796 tw32(_table[0], _table[1]); \
1801 /* initialize/reset the tg3 */
1802 static int tg3_setup_hw(struct tg3
*tp
)
1804 uint32_t val
, rdmac_mode
;
1807 /* Simply don't support setups with extremly buggy firmware in etherboot */
1808 if (tp
->pci_chip_rev_id
== CHIPREV_ID_5701_A0
) {
1809 printf("Error 5701_A0 firmware bug detected\n");
1813 tg3_disable_ints(tp
);
1815 /* Originally this was all in tg3_init_hw */
1817 /* Force the chip into D0. */
1818 tg3_set_power_state_0(tp
);
1820 tg3_switch_clocks(tp
);
1822 tw32(TG3PCI_MEM_WIN_BASE_ADDR
, 0);
1824 // This should go somewhere else
1825 #define T3_PCIE_CAPABILITY_ID_REG 0xD0
1826 #define T3_PCIE_CAPABILITY_ID 0x10
1827 #define T3_PCIE_CAPABILITY_REG 0xD2
1829 /* Originally this was all in tg3_reset_hw */
1833 /* No need to call tg3_abort_hw here, it is called before tg3_setup_hw. */
1837 tw32(GRC_MODE
, tp
->grc_mode
); /* Redundant? */
1839 err
= tg3_restart_fw(tp
, DRV_STATE_START
);
1843 if (tp
->phy_id
== PHY_ID_SERDES
) {
1844 tp
->mac_mode
= MAC_MODE_PORT_MODE_TBI
;
1846 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
1849 /* This works around an issue with Athlon chipsets on
1850 * B3 tigon3 silicon. This bit has no effect on any
1852 * Alf: Except 5750 ! (which reboots)
1855 if (!(tp
->tg3_flags2
& TG3_FLG2_PCI_EXPRESS
))
1856 tp
->pci_clock_ctrl
|= CLOCK_CTRL_DELAY_PCI_GRANT
;
1857 tw32_carefully(TG3PCI_CLOCK_CTRL
, tp
->pci_clock_ctrl
);
1859 if (tp
->pci_chip_rev_id
== CHIPREV_ID_5704_A0
&&
1860 (tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
)) {
1861 val
= tr32(TG3PCI_PCISTATE
);
1862 val
|= PCISTATE_RETRY_SAME_DMA
;
1863 tw32(TG3PCI_PCISTATE
, val
);
1866 /* Descriptor ring init may make accesses to the
1867 * NIC SRAM area to setup the TX descriptors, so we
1868 * can only do this after the hardware has been
1869 * successfully reset.
1873 /* Clear statistics/status block in chip */
1874 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
) {
1875 for (i
= NIC_SRAM_STATS_BLK
;
1876 i
< NIC_SRAM_STATUS_BLK
+ TG3_HW_STATUS_SIZE
;
1877 i
+= sizeof(uint32_t)) {
1878 tg3_write_mem(i
, 0);
1883 /* This value is determined during the probe time DMA
1884 * engine test, tg3_setup_dma.
1886 tw32(TG3PCI_DMA_RW_CTRL
, tp
->dma_rwctrl
);
1888 tp
->grc_mode
&= ~(GRC_MODE_HOST_SENDBDS
|
1889 GRC_MODE_4X_NIC_SEND_RINGS
|
1890 GRC_MODE_NO_TX_PHDR_CSUM
|
1891 GRC_MODE_NO_RX_PHDR_CSUM
);
1892 tp
->grc_mode
|= GRC_MODE_HOST_SENDBDS
;
1893 tp
->grc_mode
|= GRC_MODE_NO_TX_PHDR_CSUM
;
1894 tp
->grc_mode
|= GRC_MODE_NO_RX_PHDR_CSUM
;
1898 (GRC_MODE_IRQ_ON_MAC_ATTN
| GRC_MODE_HOST_STACKUP
));
1900 /* Setup the timer prescalar register. Clock is always 66Mhz. */
1902 (65 << GRC_MISC_CFG_PRESCALAR_SHIFT
));
1904 /* Initialize MBUF/DESC pool. */
1905 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5787
) {
1907 } else if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
) &&
1908 (tp
->pci_chip_rev_id
!= CHIPREV_ID_5721
)) {
1909 tw32(BUFMGR_MB_POOL_ADDR
, NIC_SRAM_MBUF_POOL_BASE
);
1910 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
)
1911 tw32(BUFMGR_MB_POOL_SIZE
, NIC_SRAM_MBUF_POOL_SIZE64
);
1913 tw32(BUFMGR_MB_POOL_SIZE
, NIC_SRAM_MBUF_POOL_SIZE96
);
1914 tw32(BUFMGR_DMA_DESC_POOL_ADDR
, NIC_SRAM_DMA_DESC_POOL_BASE
);
1915 tw32(BUFMGR_DMA_DESC_POOL_SIZE
, NIC_SRAM_DMA_DESC_POOL_SIZE
);
1917 if (!(tp
->tg3_flags
& TG3_FLAG_JUMBO_ENABLE
)) {
1918 tw32(BUFMGR_MB_RDMA_LOW_WATER
,
1919 tp
->bufmgr_config
.mbuf_read_dma_low_water
);
1920 tw32(BUFMGR_MB_MACRX_LOW_WATER
,
1921 tp
->bufmgr_config
.mbuf_mac_rx_low_water
);
1922 tw32(BUFMGR_MB_HIGH_WATER
,
1923 tp
->bufmgr_config
.mbuf_high_water
);
1925 tw32(BUFMGR_MB_RDMA_LOW_WATER
,
1926 tp
->bufmgr_config
.mbuf_read_dma_low_water_jumbo
);
1927 tw32(BUFMGR_MB_MACRX_LOW_WATER
,
1928 tp
->bufmgr_config
.mbuf_mac_rx_low_water_jumbo
);
1929 tw32(BUFMGR_MB_HIGH_WATER
,
1930 tp
->bufmgr_config
.mbuf_high_water_jumbo
);
1932 tw32(BUFMGR_DMA_LOW_WATER
,
1933 tp
->bufmgr_config
.dma_low_water
);
1934 tw32(BUFMGR_DMA_HIGH_WATER
,
1935 tp
->bufmgr_config
.dma_high_water
);
1937 tw32(BUFMGR_MODE
, BUFMGR_MODE_ENABLE
| BUFMGR_MODE_ATTN_ENABLE
);
1938 for (i
= 0; i
< 2000; i
++) {
1939 if (tr32(BUFMGR_MODE
) & BUFMGR_MODE_ENABLE
)
1944 printf("tg3_setup_hw cannot enable BUFMGR\n");
1948 tw32(FTQ_RESET
, 0xffffffff);
1949 tw32(FTQ_RESET
, 0x00000000);
1950 for (i
= 0; i
< 2000; i
++) {
1951 if (tr32(FTQ_RESET
) == 0x00000000)
1956 printf("tg3_setup_hw cannot reset FTQ\n");
1960 /* Initialize TG3_BDINFO's at:
1961 * RCVDBDI_STD_BD: standard eth size rx ring
1962 * RCVDBDI_JUMBO_BD: jumbo frame rx ring
1963 * RCVDBDI_MINI_BD: small frame rx ring (??? does not work)
1966 * TG3_BDINFO_HOST_ADDR: high/low parts of DMA address of ring
1967 * TG3_BDINFO_MAXLEN_FLAGS: (rx max buffer size << 16) |
1968 * ring attribute flags
1969 * TG3_BDINFO_NIC_ADDR: location of descriptors in nic SRAM
1971 * Standard receive ring @ NIC_SRAM_RX_BUFFER_DESC, 512 entries.
1972 * Jumbo receive ring @ NIC_SRAM_RX_JUMBO_BUFFER_DESC, 256 entries.
1974 * ??? No space allocated for mini receive ring? :(
1976 * The size of each ring is fixed in the firmware, but the location is
1980 static const uint32_t table_all
[] = {
1981 /* Setup replenish thresholds. */
1982 RCVBDI_STD_THRESH
, TG3_DEF_RX_RING_PENDING
/ 8,
1984 /* Etherboot lives below 4GB */
1985 RCVDBDI_STD_BD
+ TG3_BDINFO_HOST_ADDR
+ TG3_64BIT_REG_HIGH
, 0,
1986 RCVDBDI_STD_BD
+ TG3_BDINFO_NIC_ADDR
, NIC_SRAM_RX_BUFFER_DESC
,
1988 static const uint32_t table_not_5705
[] = {
1989 /* Buffer maximum length */
1990 RCVDBDI_STD_BD
+ TG3_BDINFO_MAXLEN_FLAGS
, RX_STD_MAX_SIZE
<< BDINFO_FLAGS_MAXLEN_SHIFT
,
1992 /* Disable the mini frame rx ring */
1993 RCVDBDI_MINI_BD
+ TG3_BDINFO_MAXLEN_FLAGS
, BDINFO_FLAGS_DISABLED
,
1995 /* Disable the jumbo frame rx ring */
1996 RCVBDI_JUMBO_THRESH
, 0,
1997 RCVDBDI_JUMBO_BD
+ TG3_BDINFO_MAXLEN_FLAGS
, BDINFO_FLAGS_DISABLED
,
2001 TG3_WRITE_SETTINGS(table_all
);
2002 tw32(RCVDBDI_STD_BD
+ TG3_BDINFO_HOST_ADDR
+ TG3_64BIT_REG_LOW
,
2003 virt_to_bus(tp
->rx_std
));
2004 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
||
2005 GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5787
) {
2006 tw32(RCVDBDI_STD_BD
+ TG3_BDINFO_MAXLEN_FLAGS
,
2007 RX_STD_MAX_SIZE_5705
<< BDINFO_FLAGS_MAXLEN_SHIFT
);
2009 TG3_WRITE_SETTINGS(table_not_5705
);
2014 /* There is only one send ring on 5705 and 5787, no need to explicitly
2015 * disable the others.
2017 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
&&
2018 GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5787
) {
2019 /* Clear out send RCB ring in SRAM. */
2020 for (i
= NIC_SRAM_SEND_RCB
; i
< NIC_SRAM_RCV_RET_RCB
; i
+= TG3_BDINFO_SIZE
)
2021 tg3_write_mem(i
+ TG3_BDINFO_MAXLEN_FLAGS
, BDINFO_FLAGS_DISABLED
);
2025 tw32_mailbox(MAILBOX_SNDHOST_PROD_IDX_0
+ TG3_64BIT_REG_LOW
, 0);
2026 tw32_mailbox2(MAILBOX_SNDNIC_PROD_IDX_0
+ TG3_64BIT_REG_LOW
, 0);
2030 virt_to_bus(tp
->tx_ring
),
2031 (TG3_TX_RING_SIZE
<< BDINFO_FLAGS_MAXLEN_SHIFT
),
2032 NIC_SRAM_TX_BUFFER_DESC
);
2034 /* There is only one receive return ring on 5705 and 5787, no need to
2035 * explicitly disable the others.
2037 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
&&
2038 GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5787
) {
2039 for (i
= NIC_SRAM_RCV_RET_RCB
; i
< NIC_SRAM_STATS_BLK
; i
+= TG3_BDINFO_SIZE
) {
2040 tg3_write_mem(i
+ TG3_BDINFO_MAXLEN_FLAGS
,
2041 BDINFO_FLAGS_DISABLED
);
2046 tw32_mailbox2(MAILBOX_RCVRET_CON_IDX_0
+ TG3_64BIT_REG_LOW
, 0);
2049 NIC_SRAM_RCV_RET_RCB
,
2050 virt_to_bus(tp
->rx_rcb
),
2051 (TG3_RX_RCB_RING_SIZE
<< BDINFO_FLAGS_MAXLEN_SHIFT
),
2054 tp
->rx_std_ptr
= TG3_DEF_RX_RING_PENDING
;
2055 tw32_mailbox2(MAILBOX_RCV_STD_PROD_IDX
+ TG3_64BIT_REG_LOW
,
2058 tw32_mailbox2(MAILBOX_RCV_JUMBO_PROD_IDX
+ TG3_64BIT_REG_LOW
, 0);
2060 /* Initialize MAC address and backoff seed. */
2061 __tg3_set_mac_addr(tp
);
2063 /* Calculate RDMAC_MODE setting early, we need it to determine
2064 * the RCVLPC_STATE_ENABLE mask.
2066 rdmac_mode
= (RDMAC_MODE_ENABLE
| RDMAC_MODE_TGTABORT_ENAB
|
2067 RDMAC_MODE_MSTABORT_ENAB
| RDMAC_MODE_PARITYERR_ENAB
|
2068 RDMAC_MODE_ADDROFLOW_ENAB
| RDMAC_MODE_FIFOOFLOW_ENAB
|
2069 RDMAC_MODE_FIFOURUN_ENAB
| RDMAC_MODE_FIFOOREAD_ENAB
|
2070 RDMAC_MODE_LNGREAD_ENAB
);
2071 if (tp
->tg3_flags
& TG3_FLAG_SPLIT_MODE
)
2072 rdmac_mode
|= RDMAC_MODE_SPLIT_ENABLE
;
2073 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
) {
2074 if (tp
->pci_chip_rev_id
!= CHIPREV_ID_5705_A0
) {
2075 if (!(tr32(TG3PCI_PCISTATE
) & PCISTATE_BUS_SPEED_HIGH
) &&
2076 !(tp
->tg3_flags2
& TG3_FLG2_IS_5788
)) {
2077 rdmac_mode
|= RDMAC_MODE_FIFO_LONG_BURST
;
2082 /* Setup host coalescing engine. */
2083 tw32(HOSTCC_MODE
, 0);
2084 for (i
= 0; i
< 2000; i
++) {
2085 if (!(tr32(HOSTCC_MODE
) & HOSTCC_MODE_ENABLE
))
2090 tp
->mac_mode
= MAC_MODE_TXSTAT_ENABLE
| MAC_MODE_RXSTAT_ENABLE
|
2091 MAC_MODE_TDE_ENABLE
| MAC_MODE_RDE_ENABLE
| MAC_MODE_FHDE_ENABLE
;
2092 tw32_carefully(MAC_MODE
, tp
->mac_mode
| MAC_MODE_RXSTAT_CLEAR
| MAC_MODE_TXSTAT_CLEAR
);
2094 tp
->grc_local_ctrl
= GRC_LCLCTRL_INT_ON_ATTN
| GRC_LCLCTRL_AUTO_SEEPROM
;
2095 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5700
)
2096 tp
->grc_local_ctrl
|= (GRC_LCLCTRL_GPIO_OE1
|
2097 GRC_LCLCTRL_GPIO_OUTPUT1
);
2098 tw32_carefully(GRC_LOCAL_CTRL
, tp
->grc_local_ctrl
);
2100 tw32_mailbox(MAILBOX_INTERRUPT_0
+ TG3_64BIT_REG_LOW
, 0);
2101 tr32(MAILBOX_INTERRUPT_0
);
2103 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
) {
2104 tw32_carefully(DMAC_MODE
, DMAC_MODE_ENABLE
);
2107 val
= ( WDMAC_MODE_ENABLE
| WDMAC_MODE_TGTABORT_ENAB
|
2108 WDMAC_MODE_MSTABORT_ENAB
| WDMAC_MODE_PARITYERR_ENAB
|
2109 WDMAC_MODE_ADDROFLOW_ENAB
| WDMAC_MODE_FIFOOFLOW_ENAB
|
2110 WDMAC_MODE_FIFOURUN_ENAB
| WDMAC_MODE_FIFOOREAD_ENAB
|
2111 WDMAC_MODE_LNGREAD_ENAB
);
2112 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
) &&
2113 ((tr32(TG3PCI_PCISTATE
) & PCISTATE_BUS_SPEED_HIGH
) != 0) &&
2114 !(tp
->tg3_flags2
& TG3_FLG2_IS_5788
)) {
2115 val
|= WDMAC_MODE_RX_ACCEL
;
2118 /* Host coalescing bug fix */
2119 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5787
)
2122 tw32_carefully(WDMAC_MODE
, val
);
2124 if ((tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
) != 0) {
2125 val
= tr32(TG3PCI_X_CAPS
);
2126 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) {
2127 val
&= PCIX_CAPS_BURST_MASK
;
2128 val
|= (PCIX_CAPS_MAX_BURST_CPIOB
<< PCIX_CAPS_BURST_SHIFT
);
2129 } else if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
) {
2130 val
&= ~(PCIX_CAPS_SPLIT_MASK
| PCIX_CAPS_BURST_MASK
);
2131 val
|= (PCIX_CAPS_MAX_BURST_CPIOB
<< PCIX_CAPS_BURST_SHIFT
);
2132 if (tp
->tg3_flags
& TG3_FLAG_SPLIT_MODE
)
2133 val
|= (tp
->split_mode_max_reqs
<<
2134 PCIX_CAPS_SPLIT_SHIFT
);
2136 tw32(TG3PCI_X_CAPS
, val
);
2139 tw32_carefully(RDMAC_MODE
, rdmac_mode
);
2141 static const uint32_t table_all
[] = {
2142 /* MTU + ethernet header + FCS + optional VLAN tag */
2143 MAC_RX_MTU_SIZE
, ETH_MAX_MTU
+ ETH_HLEN
+ 8,
2145 /* The slot time is changed by tg3_setup_phy if we
2146 * run at gigabit with half duplex.
2149 (2 << TX_LENGTHS_IPG_CRS_SHIFT
) |
2150 (6 << TX_LENGTHS_IPG_SHIFT
) |
2151 (32 << TX_LENGTHS_SLOT_TIME_SHIFT
),
2153 /* Receive rules. */
2154 MAC_RCV_RULE_CFG
, RCV_RULE_CFG_DEFAULT_CLASS
,
2155 RCVLPC_CONFIG
, 0x0181,
2157 /* Receive/send statistics. */
2158 RCVLPC_STATS_ENABLE
, 0xffffff,
2159 RCVLPC_STATSCTRL
, RCVLPC_STATSCTRL_ENABLE
,
2160 SNDDATAI_STATSENAB
, 0xffffff,
2161 SNDDATAI_STATSCTRL
, (SNDDATAI_SCTRL_ENABLE
|SNDDATAI_SCTRL_FASTUPD
),
2163 /* Host coalescing engine */
2164 HOSTCC_RXCOL_TICKS
, 0,
2165 HOSTCC_TXCOL_TICKS
, LOW_TXCOL_TICKS
,
2166 HOSTCC_RXMAX_FRAMES
, 1,
2167 HOSTCC_TXMAX_FRAMES
, LOW_RXMAX_FRAMES
,
2168 HOSTCC_RXCOAL_MAXF_INT
, 1,
2169 HOSTCC_TXCOAL_MAXF_INT
, 0,
2171 /* Status/statistics block address. */
2172 /* Etherboot lives below 4GB, so HIGH == 0 */
2173 HOSTCC_STATUS_BLK_HOST_ADDR
+ TG3_64BIT_REG_HIGH
, 0,
2175 /* No need to enable 32byte coalesce mode. */
2176 HOSTCC_MODE
, HOSTCC_MODE_ENABLE
| 0,
2178 RCVCC_MODE
, RCVCC_MODE_ENABLE
| RCVCC_MODE_ATTN_ENABLE
,
2179 RCVLPC_MODE
, RCVLPC_MODE_ENABLE
,
2181 RCVDCC_MODE
, RCVDCC_MODE_ENABLE
| RCVDCC_MODE_ATTN_ENABLE
,
2183 SNDDATAC_MODE
, SNDDATAC_MODE_ENABLE
,
2184 SNDBDC_MODE
, SNDBDC_MODE_ENABLE
| SNDBDC_MODE_ATTN_ENABLE
,
2185 RCVBDI_MODE
, RCVBDI_MODE_ENABLE
| RCVBDI_MODE_RCB_ATTN_ENAB
,
2186 RCVDBDI_MODE
, RCVDBDI_MODE_ENABLE
| RCVDBDI_MODE_INV_RING_SZ
,
2187 SNDDATAI_MODE
, SNDDATAI_MODE_ENABLE
,
2188 SNDBDI_MODE
, SNDBDI_MODE_ENABLE
| SNDBDI_MODE_ATTN_ENABLE
,
2189 SNDBDS_MODE
, SNDBDS_MODE_ENABLE
| SNDBDS_MODE_ATTN_ENABLE
,
2191 /* Accept all multicast frames. */
2192 MAC_HASH_REG_0
, 0xffffffff,
2193 MAC_HASH_REG_1
, 0xffffffff,
2194 MAC_HASH_REG_2
, 0xffffffff,
2195 MAC_HASH_REG_3
, 0xffffffff,
2197 static const uint32_t table_not_5705
[] = {
2198 /* Host coalescing engine */
2199 HOSTCC_RXCOAL_TICK_INT
, 0,
2200 HOSTCC_TXCOAL_TICK_INT
, 0,
2202 /* Status/statistics block address. */
2203 /* Etherboot lives below 4GB, so HIGH == 0 */
2204 HOSTCC_STAT_COAL_TICKS
, DEFAULT_STAT_COAL_TICKS
,
2205 HOSTCC_STATS_BLK_HOST_ADDR
+ TG3_64BIT_REG_HIGH
, 0,
2206 HOSTCC_STATS_BLK_NIC_ADDR
, NIC_SRAM_STATS_BLK
,
2207 HOSTCC_STATUS_BLK_NIC_ADDR
, NIC_SRAM_STATUS_BLK
,
2209 RCVLSC_MODE
, RCVLSC_MODE_ENABLE
| RCVLSC_MODE_ATTN_ENABLE
,
2211 MBFREE_MODE
, MBFREE_MODE_ENABLE
,
2213 TG3_WRITE_SETTINGS(table_all
);
2214 tw32(HOSTCC_STATS_BLK_HOST_ADDR
+ TG3_64BIT_REG_LOW
,
2215 virt_to_bus(tp
->hw_stats
));
2216 tw32(HOSTCC_STATUS_BLK_HOST_ADDR
+ TG3_64BIT_REG_LOW
,
2217 virt_to_bus(tp
->hw_status
));
2218 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5705
&&
2219 GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5787
) {
2220 TG3_WRITE_SETTINGS(table_not_5705
);
2224 tp
->tx_mode
= TX_MODE_ENABLE
;
2225 tw32_carefully(MAC_TX_MODE
, tp
->tx_mode
);
2227 tp
->rx_mode
= RX_MODE_ENABLE
;
2228 tw32_carefully(MAC_RX_MODE
, tp
->rx_mode
);
2230 tp
->mi_mode
= MAC_MI_MODE_BASE
;
2231 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
);
2233 tw32(MAC_LED_CTRL
, 0);
2234 tw32(MAC_MI_STAT
, MAC_MI_STAT_LNKSTAT_ATTN_ENAB
);
2235 if (tp
->phy_id
== PHY_ID_SERDES
) {
2236 tw32_carefully(MAC_RX_MODE
, RX_MODE_RESET
);
2238 tp
->rx_mode
|= RX_MODE_KEEP_VLAN_TAG
; /* drop tagged vlan packets */
2239 tw32_carefully(MAC_RX_MODE
, tp
->rx_mode
);
2241 if (tp
->pci_chip_rev_id
== CHIPREV_ID_5703_A1
)
2242 tw32(MAC_SERDES_CFG
, 0x616000);
2244 /* Prevent chip from dropping frames when flow control
2247 tw32(MAC_LOW_WMARK_MAX_RX_FRAME
, 2);
2248 tr32(MAC_LOW_WMARK_MAX_RX_FRAME
);
2250 err
= tg3_setup_phy(tp
);
2252 /* Ignore CRC stats */
2254 /* Initialize receive rules. */
2255 tw32(MAC_RCV_RULE_0
, 0xc2000000 & RCV_RULE_DISABLE_MASK
);
2256 tw32(MAC_RCV_VALUE_0
, 0xffffffff & RCV_RULE_DISABLE_MASK
);
2257 tw32(MAC_RCV_RULE_1
, 0x86000004 & RCV_RULE_DISABLE_MASK
);
2258 tw32(MAC_RCV_VALUE_1
, 0xffffffff & RCV_RULE_DISABLE_MASK
);
2260 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
)
2261 || (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5750
))
2265 if (tp
->tg3_flags
& TG3_FLAG_ENABLE_ASF
)
2268 case 16: tw32(MAC_RCV_RULE_15
, 0); tw32(MAC_RCV_VALUE_15
, 0);
2269 case 15: tw32(MAC_RCV_RULE_14
, 0); tw32(MAC_RCV_VALUE_14
, 0);
2270 case 14: tw32(MAC_RCV_RULE_13
, 0); tw32(MAC_RCV_VALUE_13
, 0);
2271 case 13: tw32(MAC_RCV_RULE_12
, 0); tw32(MAC_RCV_VALUE_12
, 0);
2272 case 12: tw32(MAC_RCV_RULE_11
, 0); tw32(MAC_RCV_VALUE_11
, 0);
2273 case 11: tw32(MAC_RCV_RULE_10
, 0); tw32(MAC_RCV_VALUE_10
, 0);
2274 case 10: tw32(MAC_RCV_RULE_9
, 0); tw32(MAC_RCV_VALUE_9
, 0);
2275 case 9: tw32(MAC_RCV_RULE_8
, 0); tw32(MAC_RCV_VALUE_8
, 0);
2276 case 8: tw32(MAC_RCV_RULE_7
, 0); tw32(MAC_RCV_VALUE_7
, 0);
2277 case 7: tw32(MAC_RCV_RULE_6
, 0); tw32(MAC_RCV_VALUE_6
, 0);
2278 case 6: tw32(MAC_RCV_RULE_5
, 0); tw32(MAC_RCV_VALUE_5
, 0);
2279 case 5: tw32(MAC_RCV_RULE_4
, 0); tw32(MAC_RCV_VALUE_4
, 0);
2280 case 4: /* tw32(MAC_RCV_RULE_3, 0); tw32(MAC_RCV_VALUE_3, 0); */
2281 case 3: /* tw32(MAC_RCV_RULE_2, 0); tw32(MAC_RCV_VALUE_2, 0); */
2293 /* Chips other than 5700/5701 use the NVRAM for fetching info. */
2294 static void tg3_nvram_init(struct tg3
*tp
)
2296 tw32(GRC_EEPROM_ADDR
,
2297 (EEPROM_ADDR_FSM_RESET
|
2298 (EEPROM_DEFAULT_CLOCK_PERIOD
<<
2299 EEPROM_ADDR_CLKPERD_SHIFT
)));
2303 /* Enable seeprom accesses. */
2304 tw32_carefully(GRC_LOCAL_CTRL
,
2305 tr32(GRC_LOCAL_CTRL
) | GRC_LCLCTRL_AUTO_SEEPROM
);
2307 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5700
&&
2308 GET_ASIC_REV(tp
->pci_chip_rev_id
) != ASIC_REV_5701
) {
2309 uint32_t nvcfg1
= tr32(NVRAM_CFG1
);
2311 tp
->tg3_flags
|= TG3_FLAG_NVRAM
;
2312 if (nvcfg1
& NVRAM_CFG1_FLASHIF_ENAB
) {
2313 if (nvcfg1
& NVRAM_CFG1_BUFFERED_MODE
)
2314 tp
->tg3_flags
|= TG3_FLAG_NVRAM_BUFFERED
;
2316 nvcfg1
&= ~NVRAM_CFG1_COMPAT_BYPASS
;
2317 tw32(NVRAM_CFG1
, nvcfg1
);
2321 tp
->tg3_flags
&= ~(TG3_FLAG_NVRAM
| TG3_FLAG_NVRAM_BUFFERED
);
2326 static int tg3_nvram_read_using_eeprom(
2327 struct tg3
*tp __unused
, uint32_t offset
, uint32_t *val
)
2332 if (offset
> EEPROM_ADDR_ADDR_MASK
||
2333 (offset
% 4) != 0) {
2337 tmp
= tr32(GRC_EEPROM_ADDR
) & ~(EEPROM_ADDR_ADDR_MASK
|
2338 EEPROM_ADDR_DEVID_MASK
|
2340 tw32(GRC_EEPROM_ADDR
,
2342 (0 << EEPROM_ADDR_DEVID_SHIFT
) |
2343 ((offset
<< EEPROM_ADDR_ADDR_SHIFT
) &
2344 EEPROM_ADDR_ADDR_MASK
) |
2345 EEPROM_ADDR_READ
| EEPROM_ADDR_START
);
2347 for (i
= 0; i
< 10000; i
++) {
2348 tmp
= tr32(GRC_EEPROM_ADDR
);
2350 if (tmp
& EEPROM_ADDR_COMPLETE
)
2354 if (!(tmp
& EEPROM_ADDR_COMPLETE
)) {
2358 *val
= tr32(GRC_EEPROM_DATA
);
2362 static int tg3_nvram_read(struct tg3
*tp
, uint32_t offset
, uint32_t *val
)
2364 int i
, saw_done_clear
;
2366 if (!(tp
->tg3_flags
& TG3_FLAG_NVRAM
))
2367 return tg3_nvram_read_using_eeprom(tp
, offset
, val
);
2369 if (tp
->tg3_flags
& TG3_FLAG_NVRAM_BUFFERED
)
2370 offset
= ((offset
/ NVRAM_BUFFERED_PAGE_SIZE
) <<
2371 NVRAM_BUFFERED_PAGE_POS
) +
2372 (offset
% NVRAM_BUFFERED_PAGE_SIZE
);
2374 if (offset
> NVRAM_ADDR_MSK
)
2377 tw32(NVRAM_SWARB
, SWARB_REQ_SET1
);
2378 for (i
= 0; i
< 1000; i
++) {
2379 if (tr32(NVRAM_SWARB
) & SWARB_GNT1
)
2384 tw32(NVRAM_ADDR
, offset
);
2386 NVRAM_CMD_RD
| NVRAM_CMD_GO
|
2387 NVRAM_CMD_FIRST
| NVRAM_CMD_LAST
| NVRAM_CMD_DONE
);
2389 /* Wait for done bit to clear then set again. */
2391 for (i
= 0; i
< 1000; i
++) {
2393 if (!saw_done_clear
&&
2394 !(tr32(NVRAM_CMD
) & NVRAM_CMD_DONE
))
2396 else if (saw_done_clear
&&
2397 (tr32(NVRAM_CMD
) & NVRAM_CMD_DONE
))
2401 tw32(NVRAM_SWARB
, SWARB_REQ_CLR1
);
2405 *val
= bswap_32(tr32(NVRAM_RDDATA
));
2406 tw32(NVRAM_SWARB
, 0x20);
2411 struct subsys_tbl_ent
{
2412 uint16_t subsys_vendor
, subsys_devid
;
2416 static struct subsys_tbl_ent subsys_id_to_phy_id
[] = {
2417 /* Broadcom boards. */
2418 { 0x14e4, 0x1644, PHY_ID_BCM5401
}, /* BCM95700A6 */
2419 { 0x14e4, 0x0001, PHY_ID_BCM5701
}, /* BCM95701A5 */
2420 { 0x14e4, 0x0002, PHY_ID_BCM8002
}, /* BCM95700T6 */
2421 { 0x14e4, 0x0003, PHY_ID_SERDES
}, /* BCM95700A9 */
2422 { 0x14e4, 0x0005, PHY_ID_BCM5701
}, /* BCM95701T1 */
2423 { 0x14e4, 0x0006, PHY_ID_BCM5701
}, /* BCM95701T8 */
2424 { 0x14e4, 0x0007, PHY_ID_SERDES
}, /* BCM95701A7 */
2425 { 0x14e4, 0x0008, PHY_ID_BCM5701
}, /* BCM95701A10 */
2426 { 0x14e4, 0x8008, PHY_ID_BCM5701
}, /* BCM95701A12 */
2427 { 0x14e4, 0x0009, PHY_ID_BCM5701
}, /* BCM95703Ax1 */
2428 { 0x14e4, 0x8009, PHY_ID_BCM5701
}, /* BCM95703Ax2 */
2431 { PCI_VENDOR_ID_3COM
, 0x1000, PHY_ID_BCM5401
}, /* 3C996T */
2432 { PCI_VENDOR_ID_3COM
, 0x1006, PHY_ID_BCM5701
}, /* 3C996BT */
2433 /* { PCI_VENDOR_ID_3COM, 0x1002, PHY_ID_XXX }, 3C996CT */
2434 /* { PCI_VENDOR_ID_3COM, 0x1003, PHY_ID_XXX }, 3C997T */
2435 { PCI_VENDOR_ID_3COM
, 0x1004, PHY_ID_SERDES
}, /* 3C996SX */
2436 /* { PCI_VENDOR_ID_3COM, 0x1005, PHY_ID_XXX }, 3C997SZ */
2437 { PCI_VENDOR_ID_3COM
, 0x1007, PHY_ID_BCM5701
}, /* 3C1000T */
2438 { PCI_VENDOR_ID_3COM
, 0x1008, PHY_ID_BCM5701
}, /* 3C940BR01 */
2441 { PCI_VENDOR_ID_DELL
, 0x00d1, PHY_ID_BCM5401
}, /* VIPER */
2442 { PCI_VENDOR_ID_DELL
, 0x0106, PHY_ID_BCM5401
}, /* JAGUAR */
2443 { PCI_VENDOR_ID_DELL
, 0x0109, PHY_ID_BCM5411
}, /* MERLOT */
2444 { PCI_VENDOR_ID_DELL
, 0x010a, PHY_ID_BCM5411
}, /* SLIM_MERLOT */
2445 { PCI_VENDOR_ID_DELL
, 0x0179, PHY_ID_BCM5751
}, /* EtherXpress */
2447 /* Fujitsu Siemens Computer */
2448 { PCI_VENDOR_ID_FSC
, 0x105d, PHY_ID_BCM5751
}, /* Futro C200 */
2450 /* Compaq boards. */
2451 { PCI_VENDOR_ID_COMPAQ
, 0x007c, PHY_ID_BCM5701
}, /* BANSHEE */
2452 { PCI_VENDOR_ID_COMPAQ
, 0x009a, PHY_ID_BCM5701
}, /* BANSHEE_2 */
2453 { PCI_VENDOR_ID_COMPAQ
, 0x007d, PHY_ID_SERDES
}, /* CHANGELING */
2454 { PCI_VENDOR_ID_COMPAQ
, 0x0085, PHY_ID_BCM5701
}, /* NC7780 */
2455 { PCI_VENDOR_ID_COMPAQ
, 0x0099, PHY_ID_BCM5701
} /* NC7780_2 */
2458 static int tg3_phy_probe(struct tg3
*tp
)
2460 uint32_t eeprom_phy_id
, hw_phy_id_1
, hw_phy_id_2
;
2461 uint32_t hw_phy_id
, hw_phy_id_masked
;
2462 enum phy_led_mode eeprom_led_mode
;
2465 int eeprom_signature_found
, err
;
2467 tp
->phy_id
= PHY_ID_INVALID
;
2469 for (i
= 0; i
< sizeof(subsys_id_to_phy_id
)/sizeof(subsys_id_to_phy_id
[0]); i
++) {
2470 if ((subsys_id_to_phy_id
[i
].subsys_vendor
== tp
->subsystem_vendor
) &&
2471 (subsys_id_to_phy_id
[i
].subsys_devid
== tp
->subsystem_device
)) {
2472 tp
->phy_id
= subsys_id_to_phy_id
[i
].phy_id
;
2477 eeprom_phy_id
= PHY_ID_INVALID
;
2478 eeprom_led_mode
= led_mode_auto
;
2479 eeprom_signature_found
= 0;
2480 tg3_read_mem(NIC_SRAM_DATA_SIG
, &val
);
2481 if (val
== NIC_SRAM_DATA_SIG_MAGIC
) {
2484 tg3_read_mem(NIC_SRAM_DATA_CFG
, &nic_cfg
);
2485 tp
->nic_sram_data_cfg
= nic_cfg
;
2487 eeprom_signature_found
= 1;
2489 if ((nic_cfg
& NIC_SRAM_DATA_CFG_PHY_TYPE_MASK
) ==
2490 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER
) {
2491 eeprom_phy_id
= PHY_ID_SERDES
;
2493 uint32_t nic_phy_id
;
2495 tg3_read_mem(NIC_SRAM_DATA_PHY_ID
, &nic_phy_id
);
2496 if (nic_phy_id
!= 0) {
2497 uint32_t id1
= nic_phy_id
& NIC_SRAM_DATA_PHY_ID1_MASK
;
2498 uint32_t id2
= nic_phy_id
& NIC_SRAM_DATA_PHY_ID2_MASK
;
2500 eeprom_phy_id
= (id1
>> 16) << 10;
2501 eeprom_phy_id
|= (id2
& 0xfc00) << 16;
2502 eeprom_phy_id
|= (id2
& 0x03ff) << 0;
2506 switch (nic_cfg
& NIC_SRAM_DATA_CFG_LED_MODE_MASK
) {
2507 case NIC_SRAM_DATA_CFG_LED_TRIPLE_SPD
:
2508 eeprom_led_mode
= led_mode_three_link
;
2511 case NIC_SRAM_DATA_CFG_LED_LINK_SPD
:
2512 eeprom_led_mode
= led_mode_link10
;
2516 eeprom_led_mode
= led_mode_auto
;
2519 if (((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) ||
2520 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
) ||
2521 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
)) &&
2522 (nic_cfg
& NIC_SRAM_DATA_CFG_EEPROM_WP
)) {
2523 tp
->tg3_flags
|= TG3_FLAG_EEPROM_WRITE_PROT
;
2526 if (nic_cfg
& NIC_SRAM_DATA_CFG_ASF_ENABLE
)
2527 tp
->tg3_flags
|= TG3_FLAG_ENABLE_ASF
;
2528 if (nic_cfg
& NIC_SRAM_DATA_CFG_FIBER_WOL
)
2529 tp
->tg3_flags
|= TG3_FLAG_SERDES_WOL_CAP
;
2532 /* Now read the physical PHY_ID from the chip and verify
2533 * that it is sane. If it doesn't look good, we fall back
2534 * to either the hard-coded table based PHY_ID and failing
2535 * that the value found in the eeprom area.
2537 err
= tg3_readphy(tp
, MII_PHYSID1
, &hw_phy_id_1
);
2538 err
|= tg3_readphy(tp
, MII_PHYSID2
, &hw_phy_id_2
);
2540 hw_phy_id
= (hw_phy_id_1
& 0xffff) << 10;
2541 hw_phy_id
|= (hw_phy_id_2
& 0xfc00) << 16;
2542 hw_phy_id
|= (hw_phy_id_2
& 0x03ff) << 0;
2544 hw_phy_id_masked
= hw_phy_id
& PHY_ID_MASK
;
2546 if (!err
&& KNOWN_PHY_ID(hw_phy_id_masked
)) {
2547 tp
->phy_id
= hw_phy_id
;
2549 /* phy_id currently holds the value found in the
2550 * subsys_id_to_phy_id[] table or PHY_ID_INVALID
2551 * if a match was not found there.
2553 if (tp
->phy_id
== PHY_ID_INVALID
) {
2554 if (!eeprom_signature_found
||
2555 !KNOWN_PHY_ID(eeprom_phy_id
& PHY_ID_MASK
))
2557 tp
->phy_id
= eeprom_phy_id
;
2561 err
= tg3_phy_reset(tp
);
2565 if (tp
->pci_chip_rev_id
== CHIPREV_ID_5701_A0
||
2566 tp
->pci_chip_rev_id
== CHIPREV_ID_5701_B0
) {
2567 uint32_t mii_tg3_ctrl
;
2569 /* These chips, when reset, only advertise 10Mb
2570 * capabilities. Fix that.
2572 err
= tg3_writephy(tp
, MII_ADVERTISE
,
2574 ADVERTISE_PAUSE_CAP
|
2578 ADVERTISE_100FULL
));
2579 mii_tg3_ctrl
= (MII_TG3_CTRL_ADV_1000_HALF
|
2580 MII_TG3_CTRL_ADV_1000_FULL
|
2581 MII_TG3_CTRL_AS_MASTER
|
2582 MII_TG3_CTRL_ENABLE_AS_MASTER
);
2583 if (tp
->tg3_flags
& TG3_FLAG_10_100_ONLY
)
2586 err
|= tg3_writephy(tp
, MII_TG3_CTRL
, mii_tg3_ctrl
);
2587 err
|= tg3_writephy(tp
, MII_BMCR
,
2588 (BMCR_ANRESTART
| BMCR_ANENABLE
));
2591 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) {
2592 tg3_writephy(tp
, MII_TG3_AUX_CTRL
, 0x0c00);
2593 tg3_writephy(tp
, MII_TG3_DSP_ADDRESS
, 0x201f);
2594 tg3_writedsp(tp
, MII_TG3_DSP_RW_PORT
, 0x2aaa);
2597 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
) {
2598 tg3_writephy(tp
, 0x1c, 0x8d68);
2599 tg3_writephy(tp
, 0x1c, 0x8d68);
2602 /* Enable Ethernet@WireSpeed */
2603 tg3_phy_set_wirespeed(tp
);
2605 if (!err
&& ((tp
->phy_id
& PHY_ID_MASK
) == PHY_ID_BCM5401
)) {
2606 err
= tg3_init_5401phy_dsp(tp
);
2609 /* Determine the PHY led mode.
2610 * Be careful if this gets set wrong it can result in an inability to
2613 if (tp
->phy_id
== PHY_ID_SERDES
) {
2614 tp
->led_mode
= led_mode_three_link
;
2616 else if (tp
->subsystem_vendor
== PCI_VENDOR_ID_DELL
) {
2617 tp
->led_mode
= led_mode_link10
;
2619 tp
->led_mode
= led_mode_three_link
;
2620 if (eeprom_signature_found
&&
2621 eeprom_led_mode
!= led_mode_auto
)
2622 tp
->led_mode
= eeprom_led_mode
;
2625 if (tp
->phy_id
== PHY_ID_SERDES
)
2626 tp
->link_config
.advertising
=
2627 (ADVERTISED_1000baseT_Half
|
2628 ADVERTISED_1000baseT_Full
|
2629 ADVERTISED_Autoneg
|
2631 if (tp
->tg3_flags
& TG3_FLAG_10_100_ONLY
)
2632 tp
->link_config
.advertising
&=
2633 ~(ADVERTISED_1000baseT_Half
|
2634 ADVERTISED_1000baseT_Full
);
2639 #if SUPPORT_PARTNO_STR
2640 static void tg3_read_partno(struct tg3
*tp
)
2642 unsigned char vpd_data
[256];
2645 for (i
= 0; i
< 256; i
+= 4) {
2648 if (tg3_nvram_read(tp
, 0x100 + i
, &tmp
))
2651 vpd_data
[i
+ 0] = ((tmp
>> 0) & 0xff);
2652 vpd_data
[i
+ 1] = ((tmp
>> 8) & 0xff);
2653 vpd_data
[i
+ 2] = ((tmp
>> 16) & 0xff);
2654 vpd_data
[i
+ 3] = ((tmp
>> 24) & 0xff);
2657 /* Now parse and find the part number. */
2658 for (i
= 0; i
< 256; ) {
2659 unsigned char val
= vpd_data
[i
];
2662 if (val
== 0x82 || val
== 0x91) {
2665 (vpd_data
[i
+ 2] << 8)));
2672 block_end
= (i
+ 3 +
2674 (vpd_data
[i
+ 2] << 8)));
2676 while (i
< block_end
) {
2677 if (vpd_data
[i
+ 0] == 'P' &&
2678 vpd_data
[i
+ 1] == 'N') {
2679 int partno_len
= vpd_data
[i
+ 2];
2681 if (partno_len
> 24)
2684 memcpy(tp
->board_part_number
,
2693 /* Part number not found. */
2698 memcpy(tp
->board_part_number
, "none", sizeof("none"));
2701 #define tg3_read_partno(TP) ((TP)->board_part_number[0] = '\0')
2704 static int tg3_get_invariants(struct tg3
*tp
)
2706 uint32_t misc_ctrl_reg
;
2707 uint32_t pci_state_reg
, grc_misc_cfg
;
2709 uint8_t pci_latency
;
2713 /* Read the subsystem vendor and device ids */
2714 pci_read_config_word(tp
->pdev
, PCI_SUBSYSTEM_VENDOR_ID
, &tp
->subsystem_vendor
);
2715 pci_read_config_word(tp
->pdev
, PCI_SUBSYSTEM_ID
, &tp
->subsystem_device
);
2717 /* The sun_5704 code needs infrastructure etherboot does have
2718 * ignore it for now.
2721 /* If we have an AMD 762 or Intel ICH/ICH0 chipset, write
2722 * reordering to the mailbox registers done by the host
2723 * controller can cause major troubles. We read back from
2724 * every mailbox register write to force the writes to be
2725 * posted to the chip in order.
2727 * TG3_FLAG_MBOX_WRITE_REORDER has been forced on.
2730 /* Force memory write invalidate off. If we leave it on,
2731 * then on 5700_BX chips we have to enable a workaround.
2732 * The workaround is to set the TG3PCI_DMA_RW_CTRL boundry
2733 * to match the cacheline size. The Broadcom driver have this
2734 * workaround but turns MWI off all the times so never uses
2735 * it. This seems to suggest that the workaround is insufficient.
2737 pci_read_config_word(tp
->pdev
, PCI_COMMAND
, &pci_cmd
);
2738 pci_cmd
&= ~PCI_COMMAND_INVALIDATE
;
2739 /* Also, force SERR#/PERR# in PCI command. */
2740 pci_cmd
|= PCI_COMMAND_PARITY
| PCI_COMMAND_SERR
;
2741 pci_write_config_word(tp
->pdev
, PCI_COMMAND
, pci_cmd
);
2743 /* It is absolutely critical that TG3PCI_MISC_HOST_CTRL
2744 * has the register indirect write enable bit set before
2745 * we try to access any of the MMIO registers. It is also
2746 * critical that the PCI-X hw workaround situation is decided
2747 * before that as well.
2749 pci_read_config_dword(tp
->pdev
, TG3PCI_MISC_HOST_CTRL
, &misc_ctrl_reg
);
2751 tp
->pci_chip_rev_id
= (misc_ctrl_reg
>> MISC_HOST_CTRL_CHIPREV_SHIFT
);
2753 /* Initialize misc host control in PCI block. */
2754 tp
->misc_host_ctrl
|= (misc_ctrl_reg
&
2755 MISC_HOST_CTRL_CHIPREV
);
2756 pci_write_config_dword(tp
->pdev
, TG3PCI_MISC_HOST_CTRL
,
2757 tp
->misc_host_ctrl
);
2759 pci_read_config_byte(tp
->pdev
, PCI_LATENCY_TIMER
, &pci_latency
);
2760 if (pci_latency
< 64) {
2761 pci_write_config_byte(tp
->pdev
, PCI_LATENCY_TIMER
, 64);
2764 pci_read_config_dword(tp
->pdev
, TG3PCI_PCISTATE
, &pci_state_reg
);
2766 /* If this is a 5700 BX chipset, and we are in PCI-X
2767 * mode, enable register write workaround.
2769 * The workaround is to use indirect register accesses
2770 * for all chip writes not to mailbox registers.
2772 * In etherboot to simplify things we just always use this work around.
2774 if ((pci_state_reg
& PCISTATE_CONV_PCI_MODE
) == 0) {
2775 tp
->tg3_flags
|= TG3_FLAG_PCIX_MODE
;
2777 /* Back to back register writes can cause problems on the 5701,
2778 * the workaround is to read back all reg writes except those to
2780 * In etherboot we always use indirect register accesses so
2781 * we don't see this.
2784 if ((pci_state_reg
& PCISTATE_BUS_SPEED_HIGH
) != 0)
2785 tp
->tg3_flags
|= TG3_FLAG_PCI_HIGH_SPEED
;
2786 if ((pci_state_reg
& PCISTATE_BUS_32BIT
) != 0)
2787 tp
->tg3_flags
|= TG3_FLAG_PCI_32BIT
;
2789 /* Chip-specific fixup from Broadcom driver */
2790 if ((tp
->pci_chip_rev_id
== CHIPREV_ID_5704_A0
) &&
2791 (!(pci_state_reg
& PCISTATE_RETRY_SAME_DMA
))) {
2792 pci_state_reg
|= PCISTATE_RETRY_SAME_DMA
;
2793 pci_write_config_dword(tp
->pdev
, TG3PCI_PCISTATE
, pci_state_reg
);
2796 /* determine if it is PCIE system */
2797 // Alf : I have no idea what this is about...
2798 // But it's definitely usefull
2799 val
= pci_find_capability(tp
->pdev
, PCI_CAP_ID_EXP
);
2801 tp
->tg3_flags2
|= TG3_FLG2_PCI_EXPRESS
;
2803 /* Force the chip into D0. */
2804 tg3_set_power_state_0(tp
);
2806 /* Etherboot does not ask the tg3 to do checksums */
2807 /* Etherboot does not ask the tg3 to do jumbo frames */
2808 /* Ehterboot does not ask the tg3 to use WakeOnLan. */
2810 /* A few boards don't want Ethernet@WireSpeed phy feature */
2811 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5700
) ||
2812 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5750
) ||
2813 ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
) &&
2814 (tp
->pci_chip_rev_id
!= CHIPREV_ID_5705_A0
) &&
2815 (tp
->pci_chip_rev_id
!= CHIPREV_ID_5705_A1
))) {
2816 tp
->tg3_flags2
|= TG3_FLG2_NO_ETH_WIRE_SPEED
;
2819 /* Avoid tagged irq status etherboot does not use irqs */
2821 /* Only 5701 and later support tagged irq status mode.
2822 * Also, 5788 chips cannot use tagged irq status.
2824 * However, since etherboot does not use irqs avoid tagged irqs
2825 * status because the interrupt condition is more difficult to
2826 * fully clear in that mode.
2829 /* Since some 5700_AX && 5700_BX have problems with 32BYTE
2830 * coalesce_mode, and the rest work fine anything set.
2831 * Don't enable HOST_CC_MODE_32BYTE in etherboot.
2834 /* Initialize MAC MI mode, polling disabled. */
2835 tw32_carefully(MAC_MI_MODE
, tp
->mi_mode
);
2837 /* Initialize data/descriptor byte/word swapping. */
2838 tw32(GRC_MODE
, tp
->grc_mode
);
2840 tg3_switch_clocks(tp
);
2842 /* Clear this out for sanity. */
2843 tw32(TG3PCI_MEM_WIN_BASE_ADDR
, 0);
2845 /* Etherboot does not need to check if the PCIX_TARGET_HWBUG
2846 * is needed. It always uses it.
2852 /* The TX descriptors will reside in main memory.
2855 /* See which board we are using.
2857 grc_misc_cfg
= tr32(GRC_MISC_CFG
);
2858 grc_misc_cfg
&= GRC_MISC_CFG_BOARD_ID_MASK
;
2860 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
&&
2861 grc_misc_cfg
== GRC_MISC_CFG_BOARD_ID_5704CIOBE
) {
2862 tp
->tg3_flags
|= TG3_FLAG_SPLIT_MODE
;
2863 tp
->split_mode_max_reqs
= SPLIT_MODE_5704_MAX_REQ
;
2866 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
&&
2867 (grc_misc_cfg
== GRC_MISC_CFG_BOARD_ID_5788
||
2868 grc_misc_cfg
== GRC_MISC_CFG_BOARD_ID_5788M
))
2869 tp
->tg3_flags2
|= TG3_FLG2_IS_5788
;
2871 #define PCI_DEVICE_ID_TIGON3_5901 0x170d
2872 #define PCI_DEVICE_ID_TIGON3_5901_2 0x170e
2874 /* these are limited to 10/100 only */
2875 if (((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) &&
2876 ((grc_misc_cfg
== 0x8000) || (grc_misc_cfg
== 0x4000))) ||
2877 ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
) &&
2878 (tp
->pdev
->vendor
== PCI_VENDOR_ID_BROADCOM
) &&
2879 ((tp
->pdev
->device
== PCI_DEVICE_ID_TIGON3_5901
) ||
2880 (tp
->pdev
->device
== PCI_DEVICE_ID_TIGON3_5901_2
)))) {
2881 tp
->tg3_flags
|= TG3_FLAG_10_100_ONLY
;
2884 err
= tg3_phy_probe(tp
);
2886 printf("phy probe failed, err %d\n", err
);
2889 tg3_read_partno(tp
);
2892 /* 5700 BX chips need to have their TX producer index mailboxes
2893 * written twice to workaround a bug.
2894 * In etherboot we do this unconditionally to simplify things.
2897 /* 5700 chips can get confused if TX buffers straddle the
2898 * 4GB address boundary in some cases.
2900 * In etherboot we can ignore the problem as etherboot lives below 4GB.
2903 /* In etherboot wake-on-lan is unconditionally disabled */
2907 static int tg3_get_device_address(struct tg3
*tp
)
2909 struct nic
*nic
= tp
->nic
;
2910 uint32_t hi
, lo
, mac_offset
;
2912 if (PCI_FUNC(tp
->pdev
->devfn
) == 0)
2917 /* First try to get it from MAC address mailbox. */
2918 tg3_read_mem(NIC_SRAM_MAC_ADDR_HIGH_MBOX
, &hi
);
2919 if ((hi
>> 16) == 0x484b) {
2920 nic
->node_addr
[0] = (hi
>> 8) & 0xff;
2921 nic
->node_addr
[1] = (hi
>> 0) & 0xff;
2923 tg3_read_mem(NIC_SRAM_MAC_ADDR_LOW_MBOX
, &lo
);
2924 nic
->node_addr
[2] = (lo
>> 24) & 0xff;
2925 nic
->node_addr
[3] = (lo
>> 16) & 0xff;
2926 nic
->node_addr
[4] = (lo
>> 8) & 0xff;
2927 nic
->node_addr
[5] = (lo
>> 0) & 0xff;
2929 /* Next, try NVRAM. */
2930 else if (!tg3_nvram_read(tp
, mac_offset
+ 0, &hi
) &&
2931 !tg3_nvram_read(tp
, mac_offset
+ 4, &lo
)) {
2932 nic
->node_addr
[0] = ((hi
>> 16) & 0xff);
2933 nic
->node_addr
[1] = ((hi
>> 24) & 0xff);
2934 nic
->node_addr
[2] = ((lo
>> 0) & 0xff);
2935 nic
->node_addr
[3] = ((lo
>> 8) & 0xff);
2936 nic
->node_addr
[4] = ((lo
>> 16) & 0xff);
2937 nic
->node_addr
[5] = ((lo
>> 24) & 0xff);
2939 /* Finally just fetch it out of the MAC control regs. */
2941 hi
= tr32(MAC_ADDR_0_HIGH
);
2942 lo
= tr32(MAC_ADDR_0_LOW
);
2944 nic
->node_addr
[5] = lo
& 0xff;
2945 nic
->node_addr
[4] = (lo
>> 8) & 0xff;
2946 nic
->node_addr
[3] = (lo
>> 16) & 0xff;
2947 nic
->node_addr
[2] = (lo
>> 24) & 0xff;
2948 nic
->node_addr
[1] = hi
& 0xff;
2949 nic
->node_addr
[0] = (hi
>> 8) & 0xff;
2956 static int tg3_setup_dma(struct tg3
*tp
)
2958 tw32(TG3PCI_CLOCK_CTRL
, 0);
2960 if ((tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
) == 0) {
2962 (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT
) |
2963 (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT
) |
2964 (0x7 << DMA_RWCTRL_WRITE_WATER_SHIFT
) |
2965 (0x7 << DMA_RWCTRL_READ_WATER_SHIFT
) |
2966 (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT
);
2967 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5705
) {
2968 tp
->dma_rwctrl
&= ~(DMA_RWCTRL_MIN_DMA
<< DMA_RWCTRL_MIN_DMA_SHIFT
);
2971 if (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
)
2973 (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT
) |
2974 (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT
) |
2975 (0x3 << DMA_RWCTRL_WRITE_WATER_SHIFT
) |
2976 (0x7 << DMA_RWCTRL_READ_WATER_SHIFT
) |
2977 (0x00 << DMA_RWCTRL_MIN_DMA_SHIFT
);
2980 (0x7 << DMA_RWCTRL_PCI_WRITE_CMD_SHIFT
) |
2981 (0x6 << DMA_RWCTRL_PCI_READ_CMD_SHIFT
) |
2982 (0x3 << DMA_RWCTRL_WRITE_WATER_SHIFT
) |
2983 (0x3 << DMA_RWCTRL_READ_WATER_SHIFT
) |
2984 (0x0f << DMA_RWCTRL_MIN_DMA_SHIFT
);
2986 /* Wheee, some more chip bugs... */
2987 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) ||
2988 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
)) {
2989 uint32_t ccval
= tr32(TG3PCI_CLOCK_CTRL
) & 0x1f;
2991 if ((ccval
== 0x6) || (ccval
== 0x7)) {
2992 tp
->dma_rwctrl
|= DMA_RWCTRL_ONE_DMA
;
2997 if ((GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5703
) ||
2998 (GET_ASIC_REV(tp
->pci_chip_rev_id
) == ASIC_REV_5704
)) {
2999 tp
->dma_rwctrl
&= ~(DMA_RWCTRL_MIN_DMA
<< DMA_RWCTRL_MIN_DMA_SHIFT
);
3003 Alf : Tried that, but it does not work. Should be this way though :-(
3004 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) {
3005 tp->dma_rwctrl |= 0x001f0000;
3008 tp
->dma_rwctrl
|= DMA_RWCTRL_ASSERT_ALL_BE
;
3010 tw32(TG3PCI_DMA_RW_CTRL
, tp
->dma_rwctrl
);
3015 static void tg3_init_link_config(struct tg3
*tp
)
3017 tp
->link_config
.advertising
=
3018 (ADVERTISED_10baseT_Half
| ADVERTISED_10baseT_Full
|
3019 ADVERTISED_100baseT_Half
| ADVERTISED_100baseT_Full
|
3020 ADVERTISED_1000baseT_Half
| ADVERTISED_1000baseT_Full
|
3021 ADVERTISED_Autoneg
| ADVERTISED_MII
);
3023 tp
->link_config
.active_speed
= SPEED_INVALID
;
3024 tp
->link_config
.active_duplex
= DUPLEX_INVALID
;
3029 static const char * tg3_phy_string(struct tg3
*tp
)
3031 switch (tp
->phy_id
& PHY_ID_MASK
) {
3032 case PHY_ID_BCM5400
: return "5400";
3033 case PHY_ID_BCM5401
: return "5401";
3034 case PHY_ID_BCM5411
: return "5411";
3035 case PHY_ID_BCM5701
: return "5701";
3036 case PHY_ID_BCM5703
: return "5703";
3037 case PHY_ID_BCM5704
: return "5704";
3038 case PHY_ID_BCM5705
: return "5705";
3039 case PHY_ID_BCM5750
: return "5750";
3040 case PHY_ID_BCM5751
: return "5751";
3041 case PHY_ID_BCM5787
: return "5787";
3042 case PHY_ID_BCM8002
: return "8002/serdes";
3043 case PHY_ID_SERDES
: return "serdes";
3044 default: return "unknown";
3048 #define tg3_phy_string(TP) "?"
3052 static void tg3_poll_link(struct tg3
*tp
)
3056 mac_stat
= tr32(MAC_STATUS
);
3057 if (tp
->phy_id
== PHY_ID_SERDES
) {
3059 (mac_stat
& MAC_STATUS_LNKSTATE_CHANGED
):
3060 (mac_stat
& MAC_STATUS_PCS_SYNCED
)) {
3061 tw32_carefully(MAC_MODE
, tp
->mac_mode
& ~MAC_MODE_PORT_MODE_MASK
);
3062 tw32_carefully(MAC_MODE
, tp
->mac_mode
);
3068 if (mac_stat
& MAC_STATUS_LNKSTATE_CHANGED
) {
3074 /**************************************************************************
3075 POLL - Wait for a frame
3076 ***************************************************************************/
3077 static void tg3_ack_irqs(struct tg3
*tp
)
3079 if (tp
->hw_status
->status
& SD_STATUS_UPDATED
) {
3081 * writing any value to intr-mbox-0 clears PCI INTA# and
3082 * chip-internal interrupt pending events.
3083 * writing non-zero to intr-mbox-0 additional tells the
3084 * NIC to stop sending us irqs, engaging "in-intr-handler"
3087 tw32_mailbox(MAILBOX_INTERRUPT_0
+ TG3_64BIT_REG_LOW
,
3090 * Flush PCI write. This also guarantees that our
3091 * status block has been flushed to host memory.
3093 tr32(MAILBOX_INTERRUPT_0
+ TG3_64BIT_REG_LOW
);
3094 tp
->hw_status
->status
&= ~SD_STATUS_UPDATED
;
3098 static int tg3_poll(struct nic
*nic
, int retrieve
)
3100 /* return true if there's an ethernet packet ready to read */
3101 /* nic->packet should contain data on return */
3102 /* nic->packetlen should contain length of data */
3104 struct tg3
*tp
= &tg3
;
3109 if ( (tp
->hw_status
->idx
[0].rx_producer
!= tp
->rx_rcb_ptr
) && !retrieve
)
3114 if (tp
->hw_status
->idx
[0].rx_producer
!= tp
->rx_rcb_ptr
) {
3115 struct tg3_rx_buffer_desc
*desc
;
3117 desc
= &tp
->rx_rcb
[tp
->rx_rcb_ptr
];
3118 if ((desc
->opaque
& RXD_OPAQUE_RING_MASK
) == RXD_OPAQUE_RING_STD
) {
3119 len
= ((desc
->idx_len
& RXD_LEN_MASK
) >> RXD_LEN_SHIFT
) - 4; /* omit crc */
3121 nic
->packetlen
= len
;
3122 memcpy(nic
->packet
, bus_to_virt(desc
->addr_lo
), len
);
3125 tp
->rx_rcb_ptr
= (tp
->rx_rcb_ptr
+ 1) % TG3_RX_RCB_RING_SIZE
;
3127 /* ACK the status ring */
3128 tw32_mailbox2(MAILBOX_RCVRET_CON_IDX_0
+ TG3_64BIT_REG_LOW
, tp
->rx_rcb_ptr
);
3130 /* Refill RX ring. */
3132 tp
->rx_std_ptr
= (tp
->rx_std_ptr
+ 1) % TG3_RX_RING_SIZE
;
3133 tw32_mailbox2(MAILBOX_RCV_STD_PROD_IDX
+ TG3_64BIT_REG_LOW
, tp
->rx_std_ptr
);
3140 /**************************************************************************
3141 TRANSMIT - Transmit a frame
3142 ***************************************************************************/
3144 static void tg3_set_txd(struct tg3
*tp
, int entry
,
3145 dma_addr_t mapping
, int len
, uint32_t flags
,
3146 uint32_t mss_and_is_end
)
3148 struct tg3_tx_buffer_desc
*txd
= &tp
->tx_ring
[entry
];
3149 int is_end
= (mss_and_is_end
& 0x1);
3151 flags
|= TXD_FLAG_END
;
3155 txd
->addr_lo
= mapping
& 0xffffffff;
3156 txd
->len_flags
= (len
<< TXD_LEN_SHIFT
) | flags
;
3157 txd
->vlan_tag
= 0 << TXD_VLAN_TAG_SHIFT
;
3161 static void tg3_transmit(struct nic
*nic
, const char *dst_addr
,
3162 unsigned int type
, unsigned int size
, const char *packet
)
3164 static int frame_idx
;
3165 struct eth_frame
*frame
;
3167 /* send the packet to destination */
3168 struct tg3_tx_buffer_desc
*txd
;
3173 /* Wait until there is a free packet frame */
3176 entry
= tp
->tx_prod
;
3177 while((tp
->hw_status
->idx
[0].tx_consumer
!= entry
) &&
3178 (tp
->hw_status
->idx
[0].tx_consumer
!= PREV_TX(entry
))) {
3179 mdelay(10); /* give the nick a chance */
3180 if (++i
> 500) { /* timeout 5s for transmit */
3181 printf("transmit timed out\n");
3191 /* Copy the packet to the our local buffer */
3192 frame
= &tg3_bss
.tx_frame
[frame_idx
];
3193 memcpy(frame
->dst_addr
, dst_addr
, ETH_ALEN
);
3194 memcpy(frame
->src_addr
, nic
->node_addr
, ETH_ALEN
);
3195 frame
->type
= htons(type
);
3196 memset(frame
->data
, 0, sizeof(frame
->data
));
3197 memcpy(frame
->data
, packet
, size
);
3199 /* Setup the ring buffer entry to transmit */
3200 txd
= &tp
->tx_ring
[entry
];
3201 txd
->addr_hi
= 0; /* Etherboot runs under 4GB */
3202 txd
->addr_lo
= virt_to_bus(frame
);
3203 txd
->len_flags
= ((size
+ ETH_HLEN
) << TXD_LEN_SHIFT
) | TXD_FLAG_END
;
3204 txd
->vlan_tag
= 0 << TXD_VLAN_TAG_SHIFT
;
3206 /* Advance to the next entry */
3207 entry
= NEXT_TX(entry
);
3210 /* Packets are ready, update Tx producer idx local and on card */
3211 tw32_mailbox((MAILBOX_SNDHOST_PROD_IDX_0
+ TG3_64BIT_REG_LOW
), entry
);
3212 tw32_mailbox2((MAILBOX_SNDHOST_PROD_IDX_0
+ TG3_64BIT_REG_LOW
), entry
);
3213 tp
->tx_prod
= entry
;
3216 /**************************************************************************
3217 DISABLE - Turn off ethernet interface
3218 ***************************************************************************/
3219 static void tg3_disable ( struct nic
*nic __unused
) {
3220 struct tg3
*tp
= &tg3
;
3221 /* put the card in its initial state */
3222 /* This function serves 3 purposes.
3223 * This disables DMA and interrupts so we don't receive
3224 * unexpected packets or interrupts from the card after
3225 * etherboot has finished.
3226 * This frees resources so etherboot may use
3227 * this driver on another interface
3228 * This allows etherboot to reinitialize the interface
3229 * if something is something goes wrong.
3232 tp
->tg3_flags
&= ~(TG3_FLAG_INIT_COMPLETE
|TG3_FLAG_GOT_SERDES_FLOWCTL
);
3234 iounmap((void *)tp
->regs
);
3237 /**************************************************************************
3238 IRQ - Enable, Disable, or Force interrupts
3239 ***************************************************************************/
3240 static void tg3_irq(struct nic
*nic __unused
, irq_action_t action __unused
)
3252 static struct nic_operations tg3_operations
= {
3253 .connect
= dummy_connect
,
3255 .transmit
= tg3_transmit
,
3260 /**************************************************************************
3261 PROBE - Look for an adapter, this routine's visible to the outside
3262 You should omit the last argument struct pci_device * for a non-PCI NIC
3263 ***************************************************************************/
3264 static int tg3_probe ( struct nic
*nic
, struct pci_device
*pdev
) {
3266 struct tg3
*tp
= &tg3
;
3267 unsigned long tg3reg_base
, tg3reg_len
;
3270 memset(tp
, 0, sizeof(*tp
));
3272 adjust_pci_device(pdev
);
3275 nic
->ioaddr
= pdev
->ioaddr
;
3277 /* Find power-management capability. */
3278 pm_cap
= pci_find_capability(pdev
, PCI_CAP_ID_PM
);
3280 printf("Cannot find PowerManagement capability, aborting.\n");
3283 tg3reg_base
= pci_bar_start(pdev
, PCI_BASE_ADDRESS_0
);
3284 if (tg3reg_base
== -1UL) {
3285 printf("Unuseable bar\n");
3288 tg3reg_len
= pci_bar_size(pdev
, PCI_BASE_ADDRESS_0
);
3292 tp
->pm_cap
= pm_cap
;
3295 tp
->mi_mode
= MAC_MI_MODE_BASE
;
3296 tp
->tg3_flags
= 0 & ~TG3_FLAG_INIT_COMPLETE
;
3298 /* The word/byte swap controls here control register access byte
3299 * swapping. DMA data byte swapping is controlled in the GRC_MODE
3302 tp
->misc_host_ctrl
=
3303 MISC_HOST_CTRL_MASK_PCI_INT
|
3304 MISC_HOST_CTRL_WORD_SWAP
|
3305 MISC_HOST_CTRL_INDIR_ACCESS
|
3306 MISC_HOST_CTRL_PCISTATE_RW
;
3308 /* The NONFRM (non-frame) byte/word swap controls take effect
3309 * on descriptor entries, anything which isn't packet data.
3311 * The StrongARM chips on the board (one for tx, one for rx)
3312 * are running in big-endian mode.
3314 tp
->grc_mode
= (GRC_MODE_WSWAP_DATA
| GRC_MODE_BSWAP_DATA
|
3315 GRC_MODE_WSWAP_NONFRM_DATA
);
3316 #if __BYTE_ORDER == __BIG_ENDIAN
3317 tp
->grc_mode
|= GRC_MODE_BSWAP_NONFRM_DATA
;
3319 tp
->regs
= (unsigned long) ioremap(tg3reg_base
, tg3reg_len
);
3320 if (tp
->regs
== 0UL) {
3321 printf("Cannot map device registers, aborting\n");
3325 tg3_init_link_config(tp
);
3327 err
= tg3_get_invariants(tp
);
3329 printf("Problem fetching invariants of chip, aborting.\n");
3330 goto err_out_iounmap
;
3333 err
= tg3_get_device_address(tp
);
3335 printf("Could not obtain valid ethernet address, aborting.\n");
3336 goto err_out_iounmap
;
3339 DBG ( "Ethernet addr: %s\n", eth_ntoa ( nic
->node_addr
) );
3343 /* Now that we have fully setup the chip, save away a snapshot
3344 * of the PCI config space. We need to restore this after
3345 * GRC_MISC_CFG core clock resets and some resume events.
3347 pci_save_state(tp
->pdev
, tp
->pci_cfg_state
);
3349 printf("Tigon3 [partno(%s) rev %hx PHY(%s)] (PCI%s:%s:%s)\n",
3350 tp
->board_part_number
,
3351 tp
->pci_chip_rev_id
,
3353 ((tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
) ? "X" : ""),
3354 ((tp
->tg3_flags
& TG3_FLAG_PCI_HIGH_SPEED
) ?
3355 ((tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
) ? "133MHz" : "66MHz") :
3356 ((tp
->tg3_flags
& TG3_FLAG_PCIX_MODE
) ? "100MHz" : "33MHz")),
3357 ((tp
->tg3_flags
& TG3_FLAG_PCI_32BIT
) ? "32-bit" : "64-bit"));
3360 err
= tg3_setup_hw(tp
);
3362 goto err_out_disable
;
3364 tp
->tg3_flags
|= TG3_FLAG_INIT_COMPLETE
;
3366 /* Wait for a reasonable time for the link to come up */
3368 for(i
= 0; !tp
->carrier_ok
&& (i
< VALID_LINK_TIMEOUT
*100); i
++) {
3372 if (!tp
->carrier_ok
){
3373 printf("Valid link not established\n");
3374 goto err_out_disable
;
3377 nic
->nic_op
= &tg3_operations
;
3381 iounmap((void *)tp
->regs
);
3389 static struct pci_device_id tg3_nics
[] = {
3390 PCI_ROM(0x14e4, 0x1644, "tg3-5700", "Broadcom Tigon 3 5700", 0),
3391 PCI_ROM(0x14e4, 0x1645, "tg3-5701", "Broadcom Tigon 3 5701", 0),
3392 PCI_ROM(0x14e4, 0x1646, "tg3-5702", "Broadcom Tigon 3 5702", 0),
3393 PCI_ROM(0x14e4, 0x1647, "tg3-5703", "Broadcom Tigon 3 5703", 0),
3394 PCI_ROM(0x14e4, 0x1648, "tg3-5704", "Broadcom Tigon 3 5704", 0),
3395 PCI_ROM(0x14e4, 0x164d, "tg3-5702FE", "Broadcom Tigon 3 5702FE", 0),
3396 PCI_ROM(0x14e4, 0x1653, "tg3-5705", "Broadcom Tigon 3 5705", 0),
3397 PCI_ROM(0x14e4, 0x1654, "tg3-5705_2", "Broadcom Tigon 3 5705_2", 0),
3398 PCI_ROM(0x14e4, 0x1659, "tg3-5721", "Broadcom Tigon 3 5721", 0),
3399 PCI_ROM(0x14e4, 0x165d, "tg3-5705M", "Broadcom Tigon 3 5705M", 0),
3400 PCI_ROM(0x14e4, 0x165e, "tg3-5705M_2", "Broadcom Tigon 3 5705M_2", 0),
3401 PCI_ROM(0x14e4, 0x1677, "tg3-5751", "Broadcom Tigon 3 5751", 0),
3402 PCI_ROM(0x14e4, 0x167a, "tg3-5754", "Broadcom Tigon 3 5754", 0),
3403 PCI_ROM(0x14e4, 0x1693, "tg3-5787", "Broadcom Tigon 3 5787", 0),
3404 PCI_ROM(0x14e4, 0x1696, "tg3-5782", "Broadcom Tigon 3 5782", 0),
3405 PCI_ROM(0x14e4, 0x169a, "tg3-5786", "Broadcom Tigon 3 5786", 0),
3406 PCI_ROM(0x14e4, 0x169c, "tg3-5788", "Broadcom Tigon 3 5788", 0),
3407 PCI_ROM(0x14e4, 0x169d, "tg3-5789", "Broadcom Tigon 3 5789", 0),
3408 PCI_ROM(0x14e4, 0x16a6, "tg3-5702X", "Broadcom Tigon 3 5702X", 0),
3409 PCI_ROM(0x14e4, 0x16a7, "tg3-5703X", "Broadcom Tigon 3 5703X", 0),
3410 PCI_ROM(0x14e4, 0x16a8, "tg3-5704S", "Broadcom Tigon 3 5704S", 0),
3411 PCI_ROM(0x14e4, 0x16c6, "tg3-5702A3", "Broadcom Tigon 3 5702A3", 0),
3412 PCI_ROM(0x14e4, 0x16c7, "tg3-5703A3", "Broadcom Tigon 3 5703A3", 0),
3413 PCI_ROM(0x14e4, 0x170d, "tg3-5901", "Broadcom Tigon 3 5901", 0),
3414 PCI_ROM(0x14e4, 0x170e, "tg3-5901_2", "Broadcom Tigon 3 5901_2", 0),
3415 PCI_ROM(0x1148, 0x4400, "tg3-9DXX", "Syskonnect 9DXX", 0),
3416 PCI_ROM(0x1148, 0x4500, "tg3-9MXX", "Syskonnect 9MXX", 0),
3417 PCI_ROM(0x173b, 0x03e8, "tg3-ac1000", "Altima AC1000", 0),
3418 PCI_ROM(0x173b, 0x03e9, "tg3-ac1001", "Altima AC1001", 0),
3419 PCI_ROM(0x173b, 0x03ea, "tg3-ac9100", "Altima AC9100", 0),
3420 PCI_ROM(0x173b, 0x03eb, "tg3-ac1003", "Altima AC1003", 0),
3421 PCI_ROM(0x0e11, 0x00ca, "tg3-hp", "HP Tigon 3", 0),
3424 PCI_DRIVER ( tg3_driver
, tg3_nics
, PCI_NO_CLASS
);
3426 DRIVER ( "TG3", nic_driver
, pci_driver
, tg3_driver
,
3427 tg3_probe
, tg3_disable
);