1 /******************************************************************************
4 * Project: Gigabit Ethernet Adapters, Common Modules
5 * Version: $Revision: 1.97 $
6 * Date: $Date: 2003/10/02 16:45:31 $
7 * Purpose: Contains functions to initialize the adapter
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect.
14 * (C)Copyright 2002-2003 Marvell.
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * The information in this file is provided "AS IS" without warranty.
23 ******************************************************************************/
25 #include "h/skdrv1st.h"
26 #include "h/skdrv2nd.h"
28 /* global variables ***********************************************************/
30 /* local variables ************************************************************/
32 #if (defined(DEBUG) || ((!defined(LINT)) && (!defined(SK_SLIM))))
33 static const char SysKonnectFileId
[] =
34 "@(#) $Id: skgeinit.c,v 1.97 2003/10/02 16:45:31 rschmidt Exp $ (C) Marvell.";
38 int RxQOff
; /* Receive Queue Address Offset */
39 int XsQOff
; /* Sync Tx Queue Address Offset */
40 int XaQOff
; /* Async Tx Queue Address Offset */
42 static struct s_QOffTab QOffTab
[] = {
43 {Q_R1
, Q_XS1
, Q_XA1
}, {Q_R2
, Q_XS2
, Q_XA2
}
51 static struct s_Config OemConfig
= {
52 {'O','E','M','_','C','o','n','f'},
60 /******************************************************************************
62 * SkGePollRxD() - Enable / Disable Descriptor Polling of RxD Ring
65 * Enable or disable the descriptor polling of the receive descriptor
66 * ring (RxD) for port 'Port'.
67 * The new configuration is *not* saved over any SkGeStopPort() and
68 * SkGeInitPort() calls.
74 SK_AC
*pAC
, /* adapter context */
75 SK_IOC IoC
, /* IO context */
76 int Port
, /* Port Index (MAC_1 + n) */
77 SK_BOOL PollRxD
) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
81 pPrt
= &pAC
->GIni
.GP
[Port
];
83 SK_OUT32(IoC
, Q_ADDR(pPrt
->PRxQOff
, Q_CSR
), (PollRxD
) ?
84 CSR_ENA_POL
: CSR_DIS_POL
);
88 /******************************************************************************
90 * SkGePollTxD() - Enable / Disable Descriptor Polling of TxD Rings
93 * Enable or disable the descriptor polling of the transmit descriptor
94 * ring(s) (TxD) for port 'Port'.
95 * The new configuration is *not* saved over any SkGeStopPort() and
96 * SkGeInitPort() calls.
102 SK_AC
*pAC
, /* adapter context */
103 SK_IOC IoC
, /* IO context */
104 int Port
, /* Port Index (MAC_1 + n) */
105 SK_BOOL PollTxD
) /* SK_TRUE (enable pol.), SK_FALSE (disable pol.) */
110 pPrt
= &pAC
->GIni
.GP
[Port
];
112 DWord
= (SK_U32
)(PollTxD
? CSR_ENA_POL
: CSR_DIS_POL
);
114 if (pPrt
->PXSQSize
!= 0) {
115 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXsQOff
, Q_CSR
), DWord
);
118 if (pPrt
->PXAQSize
!= 0) {
119 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXaQOff
, Q_CSR
), DWord
);
124 /******************************************************************************
126 * SkGeYellowLED() - Switch the yellow LED on or off.
129 * Switch the yellow LED on or off.
132 * This function may be called any time after SkGeInit(Level 1).
138 SK_AC
*pAC
, /* adapter context */
139 SK_IOC IoC
, /* IO context */
140 int State
) /* yellow LED state, 0 = OFF, 0 != ON */
143 /* Switch yellow LED OFF */
144 SK_OUT8(IoC
, B0_LED
, LED_STAT_OFF
);
147 /* Switch yellow LED ON */
148 SK_OUT8(IoC
, B0_LED
, LED_STAT_ON
);
150 } /* SkGeYellowLED */
153 #if (!defined(SK_SLIM) || defined(GENESIS))
154 /******************************************************************************
156 * SkGeXmitLED() - Modify the Operational Mode of a transmission LED.
159 * The Rx or Tx LED which is specified by 'Led' will be
160 * enabled, disabled or switched on in test mode.
163 * 'Led' must contain the address offset of the LEDs INI register.
166 * SkGeXmitLED(pAC, IoC, MR_ADDR(Port, TX_LED_INI), SK_LED_ENA);
172 SK_AC
*pAC
, /* adapter context */
173 SK_IOC IoC
, /* IO context */
174 int Led
, /* offset to the LED Init Value register */
175 int Mode
) /* Mode may be SK_LED_DIS, SK_LED_ENA, SK_LED_TST */
181 LedIni
= SK_XMIT_DUR
* (SK_U32
)pAC
->GIni
.GIHstClkFact
/ 100;
182 SK_OUT32(IoC
, Led
+ XMIT_LED_INI
, LedIni
);
183 SK_OUT8(IoC
, Led
+ XMIT_LED_CTRL
, LED_START
);
186 SK_OUT8(IoC
, Led
+ XMIT_LED_TST
, LED_T_ON
);
187 SK_OUT32(IoC
, Led
+ XMIT_LED_CNT
, 100);
188 SK_OUT8(IoC
, Led
+ XMIT_LED_CTRL
, LED_START
);
193 * Do NOT stop the LED Timer here. The LED might be
194 * in on state. But it needs to go off.
196 SK_OUT32(IoC
, Led
+ XMIT_LED_CNT
, 0);
197 SK_OUT8(IoC
, Led
+ XMIT_LED_TST
, LED_T_OFF
);
202 * 1000BT: The Transmit LED is driven by the PHY.
203 * But the default LED configuration is used for
204 * Level One and Broadcom PHYs.
205 * (Broadcom: It may be that PHY_B_PEC_EN_LTR has to be set.)
206 * (In this case it has to be added here. But we will see. XXX)
209 #endif /* !SK_SLIM || GENESIS */
212 /******************************************************************************
214 * DoCalcAddr() - Calculates the start and the end address of a queue.
217 * This function calculates the start and the end address of a queue.
218 * Afterwards the 'StartVal' is incremented to the next start position.
219 * If the port is already initialized the calculated values
220 * will be checked against the configured values and an
221 * error will be returned, if they are not equal.
222 * If the port is not initialized the values will be written to
223 * *StartAdr and *EndAddr.
227 * 1: configuration error
229 static int DoCalcAddr(
230 SK_AC
*pAC
, /* adapter context */
231 SK_GEPORT SK_FAR
*pPrt
, /* port index */
232 int QuSize
, /* size of the queue to configure in kB */
233 SK_U32 SK_FAR
*StartVal
, /* start value for address calculation */
234 SK_U32 SK_FAR
*QuStartAddr
,/* start addr to calculate */
235 SK_U32 SK_FAR
*QuEndAddr
) /* end address to calculate */
247 EndVal
= *StartVal
+ ((SK_U32
)QuSize
* 1024) - 1;
248 NextStart
= EndVal
+ 1;
251 if (pPrt
->PState
>= SK_PRT_INIT
) {
252 if (*StartVal
!= *QuStartAddr
|| EndVal
!= *QuEndAddr
) {
257 *QuStartAddr
= *StartVal
;
261 *StartVal
= NextStart
;
265 /******************************************************************************
267 * SkGeInitAssignRamToQueues() - allocate default queue sizes
270 * This function assigns the memory to the different queues and ports.
271 * When DualNet is set to SK_TRUE all ports get the same amount of memory.
272 * Otherwise the first port gets most of the memory and all the
273 * other ports just the required minimum.
274 * This function can only be called when pAC->GIni.GIRamSize and
275 * pAC->GIni.GIMacsFound have been initialized, usually this happens
280 * 1 - invalid input values
281 * 2 - not enough memory
284 int SkGeInitAssignRamToQueues(
285 SK_AC
*pAC
, /* Adapter context */
286 int ActivePort
, /* Active Port in RLMT mode */
287 SK_BOOL DualNet
) /* adapter context */
290 int UsedKilobytes
; /* memory already assigned */
291 int ActivePortKilobytes
; /* memory available for active port */
296 if (ActivePort
>= pAC
->GIni
.GIMacsFound
) {
297 SK_DBG_MSG(pAC
, SK_DBGMOD_HWM
, SK_DBGCAT_INIT
,
298 ("SkGeInitAssignRamToQueues: ActivePort (%d) invalid\n",
302 if (((pAC
->GIni
.GIMacsFound
* (SK_MIN_RXQ_SIZE
+ SK_MIN_TXQ_SIZE
)) +
303 ((RAM_QUOTA_SYNC
== 0) ? 0 : SK_MIN_TXQ_SIZE
)) > pAC
->GIni
.GIRamSize
) {
304 SK_DBG_MSG(pAC
, SK_DBGMOD_HWM
, SK_DBGCAT_INIT
,
305 ("SkGeInitAssignRamToQueues: Not enough memory (%d)\n",
306 pAC
->GIni
.GIRamSize
));
311 /* every port gets the same amount of memory */
312 ActivePortKilobytes
= pAC
->GIni
.GIRamSize
/ pAC
->GIni
.GIMacsFound
;
313 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
315 pGePort
= &pAC
->GIni
.GP
[i
];
317 /* take away the minimum memory for active queues */
318 ActivePortKilobytes
-= (SK_MIN_RXQ_SIZE
+ SK_MIN_TXQ_SIZE
);
320 /* receive queue gets the minimum + 80% of the rest */
321 pGePort
->PRxQSize
= (int) (ROUND_QUEUE_SIZE_KB((
322 ActivePortKilobytes
* (unsigned long) RAM_QUOTA_RX
) / 100))
325 ActivePortKilobytes
-= (pGePort
->PRxQSize
- SK_MIN_RXQ_SIZE
);
327 /* synchronous transmit queue */
328 pGePort
->PXSQSize
= 0;
330 /* asynchronous transmit queue */
331 pGePort
->PXAQSize
= (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes
+
336 /* Rlmt Mode or single link adapter */
338 /* Set standby queue size defaults for all standby ports */
339 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
341 if (i
!= ActivePort
) {
342 pGePort
= &pAC
->GIni
.GP
[i
];
344 pGePort
->PRxQSize
= SK_MIN_RXQ_SIZE
;
345 pGePort
->PXAQSize
= SK_MIN_TXQ_SIZE
;
346 pGePort
->PXSQSize
= 0;
349 UsedKilobytes
+= pGePort
->PRxQSize
+ pGePort
->PXAQSize
;
353 ActivePortKilobytes
= pAC
->GIni
.GIRamSize
- UsedKilobytes
;
355 /* assign it to the active port */
356 /* first take away the minimum memory */
357 ActivePortKilobytes
-= (SK_MIN_RXQ_SIZE
+ SK_MIN_TXQ_SIZE
);
358 pGePort
= &pAC
->GIni
.GP
[ActivePort
];
360 /* receive queue get's the minimum + 80% of the rest */
361 pGePort
->PRxQSize
= (int) (ROUND_QUEUE_SIZE_KB((ActivePortKilobytes
*
362 (unsigned long) RAM_QUOTA_RX
) / 100)) + SK_MIN_RXQ_SIZE
;
364 ActivePortKilobytes
-= (pGePort
->PRxQSize
- SK_MIN_RXQ_SIZE
);
366 /* synchronous transmit queue */
367 pGePort
->PXSQSize
= 0;
369 /* asynchronous transmit queue */
370 pGePort
->PXAQSize
= (int) ROUND_QUEUE_SIZE_KB(ActivePortKilobytes
) +
374 VCPUprintf(0, "PRxQSize=%u, PXSQSize=%u, PXAQSize=%u\n",
375 pGePort
->PRxQSize
, pGePort
->PXSQSize
, pGePort
->PXAQSize
);
379 } /* SkGeInitAssignRamToQueues */
381 /******************************************************************************
383 * SkGeCheckQSize() - Checks the Adapters Queue Size Configuration
386 * This function verifies the Queue Size Configuration specified
387 * in the variables PRxQSize, PXSQSize, and PXAQSize of all
389 * This requirements must be fullfilled to have a valid configuration:
390 * - The size of all queues must not exceed GIRamSize.
391 * - The queue sizes must be specified in units of 8 kB.
392 * - The size of Rx queues of available ports must not be
393 * smaller than 16 kB.
394 * - The size of at least one Tx queue (synch. or asynch.)
395 * of available ports must not be smaller than 16 kB
396 * when Jumbo Frames are used.
397 * - The RAM start and end addresses must not be changed
398 * for ports which are already initialized.
399 * Furthermore SkGeCheckQSize() defines the Start and End Addresses
400 * of all ports and stores them into the HWAC port structure.
403 * 0: Queue Size Configuration valid
404 * 1: Queue Size Configuration invalid
406 static int SkGeCheckQSize(
407 SK_AC
*pAC
, /* adapter context */
408 int Port
) /* port index */
416 int UsedMem
; /* total memory used (max. found ports) */
424 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
425 pPrt
= &pAC
->GIni
.GP
[i
];
427 if ((pPrt
->PRxQSize
& QZ_UNITS
) != 0 ||
428 (pPrt
->PXSQSize
& QZ_UNITS
) != 0 ||
429 (pPrt
->PXAQSize
& QZ_UNITS
) != 0) {
431 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E012
, SKERR_HWI_E012MSG
);
435 if (i
== Port
&& pPrt
->PRxQSize
< SK_MIN_RXQ_SIZE
) {
436 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E011
, SKERR_HWI_E011MSG
);
441 * the size of at least one Tx queue (synch. or asynch.) has to be > 0.
442 * if Jumbo Frames are used, this size has to be >= 16 kB.
444 if ((i
== Port
&& pPrt
->PXSQSize
== 0 && pPrt
->PXAQSize
== 0) ||
445 (pAC
->GIni
.GIPortUsage
== SK_JUMBO_LINK
&&
446 ((pPrt
->PXSQSize
> 0 && pPrt
->PXSQSize
< SK_MIN_TXQ_SIZE
) ||
447 (pPrt
->PXAQSize
> 0 && pPrt
->PXAQSize
< SK_MIN_TXQ_SIZE
)))) {
448 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E023
, SKERR_HWI_E023MSG
);
452 UsedMem
+= pPrt
->PRxQSize
+ pPrt
->PXSQSize
+ pPrt
->PXAQSize
;
455 if (UsedMem
> pAC
->GIni
.GIRamSize
) {
456 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E012
, SKERR_HWI_E012MSG
);
459 #endif /* !SK_SLIM */
461 /* Now start address calculation */
462 StartAddr
= pAC
->GIni
.GIRamOffs
;
463 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
464 pPrt
= &pAC
->GIni
.GP
[i
];
466 /* Calculate/Check values for the receive queue */
467 Rtv2
= DoCalcAddr(pAC
, pPrt
, pPrt
->PRxQSize
, &StartAddr
,
468 &pPrt
->PRxQRamStart
, &pPrt
->PRxQRamEnd
);
471 /* Calculate/Check values for the synchronous Tx queue */
472 Rtv2
= DoCalcAddr(pAC
, pPrt
, pPrt
->PXSQSize
, &StartAddr
,
473 &pPrt
->PXsQRamStart
, &pPrt
->PXsQRamEnd
);
476 /* Calculate/Check values for the asynchronous Tx queue */
477 Rtv2
= DoCalcAddr(pAC
, pPrt
, pPrt
->PXAQSize
, &StartAddr
,
478 &pPrt
->PXaQRamStart
, &pPrt
->PXaQRamEnd
);
482 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E013
, SKERR_HWI_E013MSG
);
488 } /* SkGeCheckQSize */
492 /******************************************************************************
494 * SkGeInitMacArb() - Initialize the MAC Arbiter
497 * This function initializes the MAC Arbiter.
498 * It must not be called if there is still an
499 * initialized or active port.
504 static void SkGeInitMacArb(
505 SK_AC
*pAC
, /* adapter context */
506 SK_IOC IoC
) /* IO context */
508 /* release local reset */
509 SK_OUT16(IoC
, B3_MA_TO_CTRL
, MA_RST_CLR
);
511 /* configure timeout values */
512 SK_OUT8(IoC
, B3_MA_TOINI_RX1
, SK_MAC_TO_53
);
513 SK_OUT8(IoC
, B3_MA_TOINI_RX2
, SK_MAC_TO_53
);
514 SK_OUT8(IoC
, B3_MA_TOINI_TX1
, SK_MAC_TO_53
);
515 SK_OUT8(IoC
, B3_MA_TOINI_TX2
, SK_MAC_TO_53
);
517 SK_OUT8(IoC
, B3_MA_RCINI_RX1
, 0);
518 SK_OUT8(IoC
, B3_MA_RCINI_RX2
, 0);
519 SK_OUT8(IoC
, B3_MA_RCINI_TX1
, 0);
520 SK_OUT8(IoC
, B3_MA_RCINI_TX2
, 0);
522 /* recovery values are needed for XMAC II Rev. B2 only */
523 /* Fast Output Enable Mode was intended to use with Rev. B2, but now? */
526 * There is no start or enable button to push, therefore
527 * the MAC arbiter is configured and enabled now.
529 } /* SkGeInitMacArb */
532 /******************************************************************************
534 * SkGeInitPktArb() - Initialize the Packet Arbiter
537 * This function initializes the Packet Arbiter.
538 * It must not be called if there is still an
539 * initialized or active port.
544 static void SkGeInitPktArb(
545 SK_AC
*pAC
, /* adapter context */
546 SK_IOC IoC
) /* IO context */
548 /* release local reset */
549 SK_OUT16(IoC
, B3_PA_CTRL
, PA_RST_CLR
);
551 /* configure timeout values */
552 SK_OUT16(IoC
, B3_PA_TOINI_RX1
, SK_PKT_TO_MAX
);
553 SK_OUT16(IoC
, B3_PA_TOINI_RX2
, SK_PKT_TO_MAX
);
554 SK_OUT16(IoC
, B3_PA_TOINI_TX1
, SK_PKT_TO_MAX
);
555 SK_OUT16(IoC
, B3_PA_TOINI_TX2
, SK_PKT_TO_MAX
);
558 * enable timeout timers if jumbo frames not used
559 * NOTE: the packet arbiter timeout interrupt is needed for
560 * half duplex hangup workaround
562 if (pAC
->GIni
.GIPortUsage
!= SK_JUMBO_LINK
) {
563 if (pAC
->GIni
.GIMacsFound
== 1) {
564 SK_OUT16(IoC
, B3_PA_CTRL
, PA_ENA_TO_TX1
);
567 SK_OUT16(IoC
, B3_PA_CTRL
, PA_ENA_TO_TX1
| PA_ENA_TO_TX2
);
570 } /* SkGeInitPktArb */
574 /******************************************************************************
576 * SkGeInitMacFifo() - Initialize the MAC FIFOs
579 * Initialize all MAC FIFOs of the specified port
584 static void SkGeInitMacFifo(
585 SK_AC
*pAC
, /* adapter context */
586 SK_IOC IoC
, /* IO context */
587 int Port
) /* Port Index (MAC_1 + n) */
595 * - release local reset
596 * - use default value for MAC FIFO size
597 * - setup defaults for the control register
602 if (pAC
->GIni
.GIGenesis
) {
603 /* Configure Rx MAC FIFO */
604 SK_OUT8(IoC
, MR_ADDR(Port
, RX_MFF_CTRL2
), MFF_RST_CLR
);
605 SK_OUT16(IoC
, MR_ADDR(Port
, RX_MFF_CTRL1
), MFF_RX_CTRL_DEF
);
606 SK_OUT8(IoC
, MR_ADDR(Port
, RX_MFF_CTRL2
), MFF_ENA_OP_MD
);
608 /* Configure Tx MAC FIFO */
609 SK_OUT8(IoC
, MR_ADDR(Port
, TX_MFF_CTRL2
), MFF_RST_CLR
);
610 SK_OUT16(IoC
, MR_ADDR(Port
, TX_MFF_CTRL1
), MFF_TX_CTRL_DEF
);
611 SK_OUT8(IoC
, MR_ADDR(Port
, TX_MFF_CTRL2
), MFF_ENA_OP_MD
);
613 /* Enable frame flushing if jumbo frames used */
614 if (pAC
->GIni
.GIPortUsage
== SK_JUMBO_LINK
) {
615 SK_OUT16(IoC
, MR_ADDR(Port
, RX_MFF_CTRL1
), MFF_ENA_FLUSH
);
621 if (pAC
->GIni
.GIYukon
) {
622 /* set Rx GMAC FIFO Flush Mask */
623 SK_OUT16(IoC
, MR_ADDR(Port
, RX_GMF_FL_MSK
), (SK_U16
)RX_FF_FL_DEF_MSK
);
625 Word
= (SK_U16
)GMF_RX_CTRL_DEF
;
627 /* disable Rx GMAC FIFO Flush for YUKON-Lite Rev. A0 only */
628 if (pAC
->GIni
.GIYukonLite
&& pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
) {
630 Word
&= ~GMF_RX_F_FL_ON
;
633 /* Configure Rx MAC FIFO */
634 SK_OUT8(IoC
, MR_ADDR(Port
, RX_GMF_CTRL_T
), (SK_U8
)GMF_RST_CLR
);
635 SK_OUT16(IoC
, MR_ADDR(Port
, RX_GMF_CTRL_T
), Word
);
637 /* set Rx GMAC FIFO Flush Threshold (default: 0x0a -> 56 bytes) */
638 SK_OUT16(IoC
, MR_ADDR(Port
, RX_GMF_FL_THR
), RX_GMF_FL_THR_DEF
);
640 /* Configure Tx MAC FIFO */
641 SK_OUT8(IoC
, MR_ADDR(Port
, TX_GMF_CTRL_T
), (SK_U8
)GMF_RST_CLR
);
642 SK_OUT16(IoC
, MR_ADDR(Port
, TX_GMF_CTRL_T
), (SK_U16
)GMF_TX_CTRL_DEF
);
645 SK_IN32(IoC
, MR_ADDR(Port
, RX_GMF_AF_THR
), &DWord
);
646 SK_IN32(IoC
, MR_ADDR(Port
, TX_GMF_AE_THR
), &DWord
);
649 /* set Tx GMAC FIFO Almost Empty Threshold */
650 /* SK_OUT32(IoC, MR_ADDR(Port, TX_GMF_AE_THR), 0); */
654 } /* SkGeInitMacFifo */
656 #ifdef SK_LNK_SYNC_CNT
657 /******************************************************************************
659 * SkGeLoadLnkSyncCnt() - Load the Link Sync Counter and starts counting
662 * This function starts the Link Sync Counter of the specified
663 * port and enables the generation of an Link Sync IRQ.
664 * The Link Sync Counter may be used to detect an active link,
665 * if autonegotiation is not used.
668 * o To ensure receiving the Link Sync Event the LinkSyncCounter
669 * should be initialized BEFORE clearing the XMAC's reset!
670 * o Enable IS_LNK_SYNC_M1 and IS_LNK_SYNC_M2 after calling this
676 void SkGeLoadLnkSyncCnt(
677 SK_AC
*pAC
, /* adapter context */
678 SK_IOC IoC
, /* IO context */
679 int Port
, /* Port Index (MAC_1 + n) */
680 SK_U32 CntVal
) /* Counter value */
688 SK_OUT8(IoC
, MR_ADDR(Port
, LNK_SYNC_CTRL
), LED_STOP
);
692 * Each time starting the Link Sync Counter an IRQ is generated
693 * by the adapter. See problem report entry from 21.07.98
695 * Workaround: Disable Link Sync IRQ and clear the unexpeced IRQ
696 * if no IRQ is already pending.
699 SK_IN32(IoC
, B0_ISRC
, &ISrc
);
700 SK_IN32(IoC
, B0_IMSK
, &OrgIMsk
);
702 NewIMsk
= OrgIMsk
& ~IS_LNK_SYNC_M1
;
703 if ((ISrc
& IS_LNK_SYNC_M1
) != 0) {
708 NewIMsk
= OrgIMsk
& ~IS_LNK_SYNC_M2
;
709 if ((ISrc
& IS_LNK_SYNC_M2
) != 0) {
714 SK_OUT32(IoC
, B0_IMSK
, NewIMsk
);
718 SK_OUT32(IoC
, MR_ADDR(Port
, LNK_SYNC_INI
), CntVal
);
721 SK_OUT8(IoC
, MR_ADDR(Port
, LNK_SYNC_CTRL
), LED_START
);
724 /* clear the unexpected IRQ, and restore the interrupt mask */
725 SK_OUT8(IoC
, MR_ADDR(Port
, LNK_SYNC_CTRL
), LED_CLR_IRQ
);
726 SK_OUT32(IoC
, B0_IMSK
, OrgIMsk
);
728 } /* SkGeLoadLnkSyncCnt*/
729 #endif /* SK_LNK_SYNC_CNT */
731 #if defined(SK_DIAG) || defined(SK_CFG_SYNC)
732 /******************************************************************************
734 * SkGeCfgSync() - Configure synchronous bandwidth for this port.
737 * This function may be used to configure synchronous bandwidth
738 * to the specified port. This may be done any time after
739 * initializing the port. The configuration values are NOT saved
740 * in the HWAC port structure and will be overwritten any
741 * time when stopping and starting the port.
742 * Any values for the synchronous configuration will be ignored
743 * if the size of the synchronous queue is zero!
745 * The default configuration for the synchronous service is
746 * TXA_ENA_FSYNC. This means if the size of
747 * the synchronous queue is unequal zero but no specific
748 * synchronous bandwidth is configured, the synchronous queue
749 * will always have the 'unlimited' transmit priority!
751 * This mode will be restored if the synchronous bandwidth is
752 * deallocated ('IntTime' = 0 and 'LimCount' = 0).
756 * 1: parameter configuration error
757 * 2: try to configure quality of service although no
758 * synchronous queue is configured
761 SK_AC
*pAC
, /* adapter context */
762 SK_IOC IoC
, /* IO context */
763 int Port
, /* Port Index (MAC_1 + n) */
764 SK_U32 IntTime
, /* Interval Timer Value in units of 8ns */
765 SK_U32 LimCount
, /* Number of bytes to transfer during IntTime */
766 int SyncMode
) /* Sync Mode: TXA_ENA_ALLOC | TXA_DIS_ALLOC | 0 */
772 /* check the parameters */
773 if (LimCount
> IntTime
||
774 (LimCount
== 0 && IntTime
!= 0) ||
775 (LimCount
!= 0 && IntTime
== 0)) {
777 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E010
, SKERR_HWI_E010MSG
);
781 if (pAC
->GIni
.GP
[Port
].PXSQSize
== 0) {
782 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E009
, SKERR_HWI_E009MSG
);
786 /* calculate register values */
787 IntTime
= (IntTime
/ 2) * pAC
->GIni
.GIHstClkFact
/ 100;
788 LimCount
= LimCount
/ 8;
790 if (IntTime
> TXA_MAX_VAL
|| LimCount
> TXA_MAX_VAL
) {
791 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E010
, SKERR_HWI_E010MSG
);
796 * - Enable 'Force Sync' to ensure the synchronous queue
797 * has the priority while configuring the new values.
798 * - Also 'disable alloc' to ensure the settings complies
799 * to the SyncMode parameter.
800 * - Disable 'Rate Control' to configure the new values.
801 * - write IntTime and LimCount
802 * - start 'Rate Control' and disable 'Force Sync'
803 * if Interval Timer or Limit Counter not zero.
805 SK_OUT8(IoC
, MR_ADDR(Port
, TXA_CTRL
),
806 TXA_ENA_FSYNC
| TXA_DIS_ALLOC
| TXA_STOP_RC
);
808 SK_OUT32(IoC
, MR_ADDR(Port
, TXA_ITI_INI
), IntTime
);
809 SK_OUT32(IoC
, MR_ADDR(Port
, TXA_LIM_INI
), LimCount
);
811 SK_OUT8(IoC
, MR_ADDR(Port
, TXA_CTRL
),
812 (SK_U8
)(SyncMode
& (TXA_ENA_ALLOC
| TXA_DIS_ALLOC
)));
814 if (IntTime
!= 0 || LimCount
!= 0) {
815 SK_OUT8(IoC
, MR_ADDR(Port
, TXA_CTRL
), TXA_DIS_FSYNC
| TXA_START_RC
);
820 #endif /* SK_DIAG || SK_CFG_SYNC*/
823 /******************************************************************************
825 * DoInitRamQueue() - Initialize the RAM Buffer Address of a single Queue
828 * If the queue is used, enable and initialize it.
829 * Make sure the queue is still reset, if it is not used.
834 static void DoInitRamQueue(
835 SK_AC
*pAC
, /* adapter context */
836 SK_IOC IoC
, /* IO context */
837 int QuIoOffs
, /* Queue IO Address Offset */
838 SK_U32 QuStartAddr
, /* Queue Start Address */
839 SK_U32 QuEndAddr
, /* Queue End Address */
840 int QuType
) /* Queue Type (SK_RX_SRAM_Q|SK_RX_BRAM_Q|SK_TX_RAM_Q) */
845 if (QuStartAddr
!= QuEndAddr
) {
846 /* calculate thresholds, assume we have a big Rx queue */
847 RxUpThresVal
= (QuEndAddr
+ 1 - QuStartAddr
- SK_RB_ULPP
) / 8;
848 RxLoThresVal
= (QuEndAddr
+ 1 - QuStartAddr
- SK_RB_LLPP_B
)/8;
850 /* build HW address format */
851 QuStartAddr
= QuStartAddr
/ 8;
852 QuEndAddr
= QuEndAddr
/ 8;
854 /* release local reset */
855 SK_OUT8(IoC
, RB_ADDR(QuIoOffs
, RB_CTRL
), RB_RST_CLR
);
857 /* configure addresses */
858 SK_OUT32(IoC
, RB_ADDR(QuIoOffs
, RB_START
), QuStartAddr
);
859 SK_OUT32(IoC
, RB_ADDR(QuIoOffs
, RB_END
), QuEndAddr
);
860 SK_OUT32(IoC
, RB_ADDR(QuIoOffs
, RB_WP
), QuStartAddr
);
861 SK_OUT32(IoC
, RB_ADDR(QuIoOffs
, RB_RP
), QuStartAddr
);
865 /* configure threshold for small Rx Queue */
866 RxLoThresVal
+= (SK_RB_LLPP_B
- SK_RB_LLPP_S
) / 8;
868 /* continue with SK_RX_BRAM_Q */
870 /* write threshold for Rx Queue */
872 SK_OUT32(IoC
, RB_ADDR(QuIoOffs
, RB_RX_UTPP
), RxUpThresVal
);
873 SK_OUT32(IoC
, RB_ADDR(QuIoOffs
, RB_RX_LTPP
), RxLoThresVal
);
875 /* the high priority threshold not used */
879 * Do NOT use Store & Forward under normal operation due to
880 * performance optimization (GENESIS only).
881 * But if Jumbo Frames are configured (XMAC Tx FIFO is only 4 kB)
882 * or YUKON is used ((GMAC Tx FIFO is only 1 kB)
883 * we NEED Store & Forward of the RAM buffer.
885 if (pAC
->GIni
.GIPortUsage
== SK_JUMBO_LINK
||
887 /* enable Store & Forward Mode for the Tx Side */
888 SK_OUT8(IoC
, RB_ADDR(QuIoOffs
, RB_CTRL
), RB_ENA_STFWD
);
893 /* set queue operational */
894 SK_OUT8(IoC
, RB_ADDR(QuIoOffs
, RB_CTRL
), RB_ENA_OP_MD
);
897 /* ensure the queue is still disabled */
898 SK_OUT8(IoC
, RB_ADDR(QuIoOffs
, RB_CTRL
), RB_RST_SET
);
900 } /* DoInitRamQueue */
903 /******************************************************************************
905 * SkGeInitRamBufs() - Initialize the RAM Buffer Queues
908 * Initialize all RAM Buffer Queues of the specified port
913 static void SkGeInitRamBufs(
914 SK_AC
*pAC
, /* adapter context */
915 SK_IOC IoC
, /* IO context */
916 int Port
) /* Port Index (MAC_1 + n) */
921 pPrt
= &pAC
->GIni
.GP
[Port
];
923 if (pPrt
->PRxQSize
== SK_MIN_RXQ_SIZE
) {
924 RxQType
= SK_RX_SRAM_Q
; /* small Rx Queue */
927 RxQType
= SK_RX_BRAM_Q
; /* big Rx Queue */
930 DoInitRamQueue(pAC
, IoC
, pPrt
->PRxQOff
, pPrt
->PRxQRamStart
,
931 pPrt
->PRxQRamEnd
, RxQType
);
933 DoInitRamQueue(pAC
, IoC
, pPrt
->PXsQOff
, pPrt
->PXsQRamStart
,
934 pPrt
->PXsQRamEnd
, SK_TX_RAM_Q
);
936 DoInitRamQueue(pAC
, IoC
, pPrt
->PXaQOff
, pPrt
->PXaQRamStart
,
937 pPrt
->PXaQRamEnd
, SK_TX_RAM_Q
);
939 } /* SkGeInitRamBufs */
942 /******************************************************************************
944 * SkGeInitRamIface() - Initialize the RAM Interface
947 * This function initializes the Adapters RAM Interface.
950 * This function is used in the diagnostics.
955 void SkGeInitRamIface(
956 SK_AC
*pAC
, /* adapter context */
957 SK_IOC IoC
) /* IO context */
959 /* release local reset */
960 SK_OUT16(IoC
, B3_RI_CTRL
, RI_RST_CLR
);
962 /* configure timeout values */
963 SK_OUT8(IoC
, B3_RI_WTO_R1
, SK_RI_TO_53
);
964 SK_OUT8(IoC
, B3_RI_WTO_XA1
, SK_RI_TO_53
);
965 SK_OUT8(IoC
, B3_RI_WTO_XS1
, SK_RI_TO_53
);
966 SK_OUT8(IoC
, B3_RI_RTO_R1
, SK_RI_TO_53
);
967 SK_OUT8(IoC
, B3_RI_RTO_XA1
, SK_RI_TO_53
);
968 SK_OUT8(IoC
, B3_RI_RTO_XS1
, SK_RI_TO_53
);
969 SK_OUT8(IoC
, B3_RI_WTO_R2
, SK_RI_TO_53
);
970 SK_OUT8(IoC
, B3_RI_WTO_XA2
, SK_RI_TO_53
);
971 SK_OUT8(IoC
, B3_RI_WTO_XS2
, SK_RI_TO_53
);
972 SK_OUT8(IoC
, B3_RI_RTO_R2
, SK_RI_TO_53
);
973 SK_OUT8(IoC
, B3_RI_RTO_XA2
, SK_RI_TO_53
);
974 SK_OUT8(IoC
, B3_RI_RTO_XS2
, SK_RI_TO_53
);
976 } /* SkGeInitRamIface */
979 /******************************************************************************
981 * SkGeInitBmu() - Initialize the BMU state machines
984 * Initialize all BMU state machines of the specified port
989 static void SkGeInitBmu(
990 SK_AC
*pAC
, /* adapter context */
991 SK_IOC IoC
, /* IO context */
992 int Port
) /* Port Index (MAC_1 + n) */
998 pPrt
= &pAC
->GIni
.GP
[Port
];
1000 RxWm
= SK_BMU_RX_WM
;
1001 TxWm
= SK_BMU_TX_WM
;
1003 if (!pAC
->GIni
.GIPciSlot64
&& !pAC
->GIni
.GIPciClock66
) {
1004 /* for better performance */
1009 /* Rx Queue: Release all local resets and set the watermark */
1010 SK_OUT32(IoC
, Q_ADDR(pPrt
->PRxQOff
, Q_CSR
), CSR_CLR_RESET
);
1011 SK_OUT32(IoC
, Q_ADDR(pPrt
->PRxQOff
, Q_F
), RxWm
);
1014 * Tx Queue: Release all local resets if the queue is used !
1017 if (pPrt
->PXSQSize
!= 0) {
1018 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXsQOff
, Q_CSR
), CSR_CLR_RESET
);
1019 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXsQOff
, Q_F
), TxWm
);
1022 if (pPrt
->PXAQSize
!= 0) {
1023 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXaQOff
, Q_CSR
), CSR_CLR_RESET
);
1024 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXaQOff
, Q_F
), TxWm
);
1027 * Do NOT enable the descriptor poll timers here, because
1028 * the descriptor addresses are not specified yet.
1033 /******************************************************************************
1035 * TestStopBit() - Test the stop bit of the queue
1038 * Stopping a queue is not as simple as it seems to be.
1039 * If descriptor polling is enabled, it may happen
1040 * that RX/TX stop is done and SV idle is NOT set.
1041 * In this case we have to issue another stop command.
1044 * The queues control status register
1046 static SK_U32
TestStopBit(
1047 SK_AC
*pAC
, /* Adapter Context */
1048 SK_IOC IoC
, /* IO Context */
1049 int QuIoOffs
) /* Queue IO Address Offset */
1051 SK_U32 QuCsr
; /* CSR contents */
1053 SK_IN32(IoC
, Q_ADDR(QuIoOffs
, Q_CSR
), &QuCsr
);
1055 if ((QuCsr
& (CSR_STOP
| CSR_SV_IDLE
)) == 0) {
1056 /* Stop Descriptor overridden by start command */
1057 SK_OUT32(IoC
, Q_ADDR(QuIoOffs
, Q_CSR
), CSR_STOP
);
1059 SK_IN32(IoC
, Q_ADDR(QuIoOffs
, Q_CSR
), &QuCsr
);
1066 /******************************************************************************
1068 * SkGeStopPort() - Stop the Rx/Tx activity of the port 'Port'.
1071 * After calling this function the descriptor rings and Rx and Tx
1072 * queues of this port may be reconfigured.
1074 * It is possible to stop the receive and transmit path separate or
1077 * Dir = SK_STOP_TX Stops the transmit path only and resets the MAC.
1078 * The receive queue is still active and
1079 * the pending Rx frames may be still transferred
1081 * SK_STOP_RX Stop the receive path. The tansmit path
1082 * has to be stopped once before.
1083 * SK_STOP_ALL SK_STOP_TX + SK_STOP_RX
1085 * RstMode = SK_SOFT_RST Resets the MAC. The PHY is still alive.
1086 * SK_HARD_RST Resets the MAC and the PHY.
1089 * 1) A Link Down event was signaled for a port. Therefore the activity
1090 * of this port should be stopped and a hardware reset should be issued
1091 * to enable the workaround of XMAC Errata #2. But the received frames
1092 * should not be discarded.
1094 * SkGeStopPort(pAC, IoC, Port, SK_STOP_TX, SK_HARD_RST);
1095 * (transfer all pending Rx frames)
1096 * SkGeStopPort(pAC, IoC, Port, SK_STOP_RX, SK_HARD_RST);
1099 * 2) An event was issued which request the driver to switch
1100 * the 'virtual active' link to an other already active port
1101 * as soon as possible. The frames in the receive queue of this
1102 * port may be lost. But the PHY must not be reset during this
1105 * SkGeStopPort(pAC, IoC, Port, SK_STOP_ALL, SK_SOFT_RST);
1108 * Extended Description:
1109 * If SK_STOP_TX is set,
1110 * o disable the MAC's receive and transmitter to prevent
1111 * from sending incomplete frames
1112 * o stop the port's transmit queues before terminating the
1113 * BMUs to prevent from performing incomplete PCI cycles
1115 * - The network Rx and Tx activity and PCI Tx transfer is
1117 * o reset the MAC depending on the RstMode
1118 * o Stop Interval Timer and Limit Counter of Tx Arbiter,
1119 * also disable Force Sync bit and Enable Alloc bit.
1120 * o perform a local reset of the port's Tx path
1121 * - reset the PCI FIFO of the async Tx queue
1122 * - reset the PCI FIFO of the sync Tx queue
1123 * - reset the RAM Buffer async Tx queue
1124 * - reset the RAM Buffer sync Tx queue
1125 * - reset the MAC Tx FIFO
1126 * o switch Link and Tx LED off, stop the LED counters
1128 * If SK_STOP_RX is set,
1129 * o stop the port's receive queue
1130 * - The path data transfer activity is fully stopped now.
1131 * o perform a local reset of the port's Rx path
1132 * - reset the PCI FIFO of the Rx queue
1133 * - reset the RAM Buffer receive queue
1134 * - reset the MAC Rx FIFO
1135 * o switch Rx LED off, stop the LED counter
1137 * If all ports are stopped,
1138 * o reset the RAM Interface.
1141 * o This function may be called during the driver states RESET_PORT and
1145 SK_AC
*pAC
, /* adapter context */
1146 SK_IOC IoC
, /* I/O context */
1147 int Port
, /* port to stop (MAC_1 + n) */
1148 int Dir
, /* Direction to Stop (SK_STOP_RX, SK_STOP_TX, SK_STOP_ALL) */
1149 int RstMode
)/* Reset Mode (SK_SOFT_RST, SK_HARD_RST) */
1153 #endif /* !SK_DIAG */
1162 pPrt
= &pAC
->GIni
.GP
[Port
];
1164 if ((Dir
& SK_STOP_TX
) != 0) {
1165 /* disable receiver and transmitter */
1166 SkMacRxTxDisable(pAC
, IoC
, Port
);
1168 /* stop both transmit queues */
1170 * If the BMU is in the reset state CSR_STOP will terminate
1173 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXsQOff
, Q_CSR
), CSR_STOP
);
1174 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXaQOff
, Q_CSR
), CSR_STOP
);
1176 ToutStart
= SkOsGetTime(pAC
);
1180 * Clear packet arbiter timeout to make sure
1181 * this loop will terminate.
1183 SK_OUT16(IoC
, B3_PA_CTRL
, (SK_U16
)((Port
== MAC_1
) ?
1184 PA_CLR_TO_TX1
: PA_CLR_TO_TX2
));
1187 * If the transfer stucks at the MAC the STOP command will not
1188 * terminate if we don't flush the XMAC's transmit FIFO !
1190 SkMacFlushTxFifo(pAC
, IoC
, Port
);
1192 XsCsr
= TestStopBit(pAC
, IoC
, pPrt
->PXsQOff
);
1193 XaCsr
= TestStopBit(pAC
, IoC
, pPrt
->PXaQOff
);
1195 if (SkOsGetTime(pAC
) - ToutStart
> (SK_TICKS_PER_SEC
/ 18)) {
1197 * Timeout of 1/18 second reached.
1198 * This needs to be checked at 1/18 sec only.
1202 /* Might be a problem when the driver event handler
1203 * calls StopPort again. XXX.
1206 /* Fatal Error, Loop aborted */
1207 SK_ERR_LOG(pAC
, SK_ERRCL_HW
, SKERR_HWI_E018
,
1211 SkEventQueue(pAC
, SKGE_DRV
, SK_DRV_PORT_FAIL
, Para
);
1212 #endif /* !SK_DIAG */
1216 * Cache incoherency workaround: Assume a start command
1217 * has been lost while sending the frame.
1219 ToutStart
= SkOsGetTime(pAC
);
1221 if ((XsCsr
& CSR_STOP
) != 0) {
1222 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXsQOff
, Q_CSR
), CSR_START
);
1224 if ((XaCsr
& CSR_STOP
) != 0) {
1225 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXaQOff
, Q_CSR
), CSR_START
);
1230 * Because of the ASIC problem report entry from 21.08.1998 it is
1231 * required to wait until CSR_STOP is reset and CSR_SV_IDLE is set.
1233 } while ((XsCsr
& (CSR_STOP
| CSR_SV_IDLE
)) != CSR_SV_IDLE
||
1234 (XaCsr
& (CSR_STOP
| CSR_SV_IDLE
)) != CSR_SV_IDLE
);
1236 /* Reset the MAC depending on the RstMode */
1237 if (RstMode
== SK_SOFT_RST
) {
1238 SkMacSoftRst(pAC
, IoC
, Port
);
1241 SkMacHardRst(pAC
, IoC
, Port
);
1244 /* Disable Force Sync bit and Enable Alloc bit */
1245 SK_OUT8(IoC
, MR_ADDR(Port
, TXA_CTRL
),
1246 TXA_DIS_FSYNC
| TXA_DIS_ALLOC
| TXA_STOP_RC
);
1248 /* Stop Interval Timer and Limit Counter of Tx Arbiter */
1249 SK_OUT32(IoC
, MR_ADDR(Port
, TXA_ITI_INI
), 0L);
1250 SK_OUT32(IoC
, MR_ADDR(Port
, TXA_LIM_INI
), 0L);
1252 /* Perform a local reset of the port's Tx path */
1254 /* Reset the PCI FIFO of the async Tx queue */
1255 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXaQOff
, Q_CSR
), CSR_SET_RESET
);
1256 /* Reset the PCI FIFO of the sync Tx queue */
1257 SK_OUT32(IoC
, Q_ADDR(pPrt
->PXsQOff
, Q_CSR
), CSR_SET_RESET
);
1258 /* Reset the RAM Buffer async Tx queue */
1259 SK_OUT8(IoC
, RB_ADDR(pPrt
->PXaQOff
, RB_CTRL
), RB_RST_SET
);
1260 /* Reset the RAM Buffer sync Tx queue */
1261 SK_OUT8(IoC
, RB_ADDR(pPrt
->PXsQOff
, RB_CTRL
), RB_RST_SET
);
1263 /* Reset Tx MAC FIFO */
1265 if (pAC
->GIni
.GIGenesis
) {
1266 /* Note: MFF_RST_SET does NOT reset the XMAC ! */
1267 SK_OUT8(IoC
, MR_ADDR(Port
, TX_MFF_CTRL2
), MFF_RST_SET
);
1269 /* switch Link and Tx LED off, stop the LED counters */
1270 /* Link LED is switched off by the RLMT and the Diag itself */
1271 SkGeXmitLED(pAC
, IoC
, MR_ADDR(Port
, TX_LED_INI
), SK_LED_DIS
);
1273 #endif /* GENESIS */
1276 if (pAC
->GIni
.GIYukon
) {
1277 /* Reset TX MAC FIFO */
1278 SK_OUT8(IoC
, MR_ADDR(Port
, TX_GMF_CTRL_T
), (SK_U8
)GMF_RST_SET
);
1283 if ((Dir
& SK_STOP_RX
) != 0) {
1285 * The RX Stop Command will not terminate if no buffers
1286 * are queued in the RxD ring. But it will always reach
1287 * the Idle state. Therefore we can use this feature to
1288 * stop the transfer of received packets.
1290 /* stop the port's receive queue */
1291 SK_OUT32(IoC
, Q_ADDR(pPrt
->PRxQOff
, Q_CSR
), CSR_STOP
);
1296 * Clear packet arbiter timeout to make sure
1297 * this loop will terminate
1299 SK_OUT16(IoC
, B3_PA_CTRL
, (SK_U16
)((Port
== MAC_1
) ?
1300 PA_CLR_TO_RX1
: PA_CLR_TO_RX2
));
1302 DWord
= TestStopBit(pAC
, IoC
, pPrt
->PRxQOff
);
1304 /* timeout if i==0 (bug fix for #10748) */
1306 SK_ERR_LOG(pAC
, SK_ERRCL_HW
, SKERR_HWI_E024
,
1311 * because of the ASIC problem report entry from 21.08.98
1312 * it is required to wait until CSR_STOP is reset and
1313 * CSR_SV_IDLE is set.
1315 } while ((DWord
& (CSR_STOP
| CSR_SV_IDLE
)) != CSR_SV_IDLE
);
1317 /* The path data transfer activity is fully stopped now */
1319 /* Perform a local reset of the port's Rx path */
1321 /* Reset the PCI FIFO of the Rx queue */
1322 SK_OUT32(IoC
, Q_ADDR(pPrt
->PRxQOff
, Q_CSR
), CSR_SET_RESET
);
1323 /* Reset the RAM Buffer receive queue */
1324 SK_OUT8(IoC
, RB_ADDR(pPrt
->PRxQOff
, RB_CTRL
), RB_RST_SET
);
1326 /* Reset Rx MAC FIFO */
1328 if (pAC
->GIni
.GIGenesis
) {
1330 SK_OUT8(IoC
, MR_ADDR(Port
, RX_MFF_CTRL2
), MFF_RST_SET
);
1332 /* switch Rx LED off, stop the LED counter */
1333 SkGeXmitLED(pAC
, IoC
, MR_ADDR(Port
, RX_LED_INI
), SK_LED_DIS
);
1335 #endif /* GENESIS */
1338 if (pAC
->GIni
.GIYukon
) {
1339 /* Reset Rx MAC FIFO */
1340 SK_OUT8(IoC
, MR_ADDR(Port
, RX_GMF_CTRL_T
), (SK_U8
)GMF_RST_SET
);
1344 } /* SkGeStopPort */
1347 /******************************************************************************
1349 * SkGeInit0() - Level 0 Initialization
1352 * - Initialize the BMU address offsets
1357 static void SkGeInit0(
1358 SK_AC
*pAC
, /* adapter context */
1359 SK_IOC IoC
) /* IO context */
1364 for (i
= 0; i
< SK_MAX_MACS
; i
++) {
1365 pPrt
= &pAC
->GIni
.GP
[i
];
1367 pPrt
->PState
= SK_PRT_RESET
;
1368 pPrt
->PRxQOff
= QOffTab
[i
].RxQOff
;
1369 pPrt
->PXsQOff
= QOffTab
[i
].XsQOff
;
1370 pPrt
->PXaQOff
= QOffTab
[i
].XaQOff
;
1371 pPrt
->PCheckPar
= SK_FALSE
;
1373 pPrt
->PPrevShorts
= 0;
1374 pPrt
->PLinkResCt
= 0;
1375 pPrt
->PAutoNegTOCt
= 0;
1378 pPrt
->PRxLim
= SK_DEF_RX_WA_LIM
;
1379 pPrt
->PLinkMode
= (SK_U8
)SK_LMODE_AUTOFULL
;
1380 pPrt
->PLinkSpeedCap
= (SK_U8
)SK_LSPEED_CAP_1000MBPS
;
1381 pPrt
->PLinkSpeed
= (SK_U8
)SK_LSPEED_1000MBPS
;
1382 pPrt
->PLinkSpeedUsed
= (SK_U8
)SK_LSPEED_STAT_UNKNOWN
;
1383 pPrt
->PLinkModeConf
= (SK_U8
)SK_LMODE_AUTOSENSE
;
1384 pPrt
->PFlowCtrlMode
= (SK_U8
)SK_FLOW_MODE_SYM_OR_REM
;
1385 pPrt
->PLinkCap
= (SK_U8
)(SK_LMODE_CAP_HALF
| SK_LMODE_CAP_FULL
|
1386 SK_LMODE_CAP_AUTOHALF
| SK_LMODE_CAP_AUTOFULL
);
1387 pPrt
->PLinkModeStatus
= (SK_U8
)SK_LMODE_STAT_UNKNOWN
;
1388 pPrt
->PFlowCtrlCap
= (SK_U8
)SK_FLOW_MODE_SYM_OR_REM
;
1389 pPrt
->PFlowCtrlStatus
= (SK_U8
)SK_FLOW_STAT_NONE
;
1391 pPrt
->PMSMode
= (SK_U8
)SK_MS_MODE_AUTO
;
1392 pPrt
->PMSStatus
= (SK_U8
)SK_MS_STAT_UNSET
;
1393 pPrt
->PLipaAutoNeg
= (SK_U8
)SK_LIPA_UNKNOWN
;
1394 pPrt
->PAutoNegFail
= SK_FALSE
;
1395 pPrt
->PHWLinkUp
= SK_FALSE
;
1396 pPrt
->PLinkBroken
= SK_TRUE
; /* See WA code */
1397 pPrt
->PPhyPowerState
= PHY_PM_OPERATIONAL_MODE
;
1398 pPrt
->PMacColThres
= TX_COL_DEF
;
1399 pPrt
->PMacJamLen
= TX_JAM_LEN_DEF
;
1400 pPrt
->PMacJamIpgVal
= TX_JAM_IPG_DEF
;
1401 pPrt
->PMacJamIpgData
= TX_IPG_JAM_DEF
;
1402 pPrt
->PMacIpgData
= IPG_DATA_DEF
;
1403 pPrt
->PMacLimit4
= SK_FALSE
;
1406 pAC
->GIni
.GIPortUsage
= SK_RED_LINK
;
1407 pAC
->GIni
.GILedBlinkCtrl
= (SK_U16
)OemConfig
.Value
;
1408 pAC
->GIni
.GIValIrqMask
= IS_ALL_MSK
;
1414 /******************************************************************************
1416 * SkGePciReset() - Reset PCI interface
1419 * o Read PCI configuration.
1420 * o Change power state to 3.
1421 * o Change power state to 0.
1422 * o Restore PCI configuration.
1426 * 1: Power state could not be changed to 3.
1428 static int SkGePciReset(
1429 SK_AC
*pAC
, /* adapter context */
1430 SK_IOC IoC
) /* IO context */
1439 SK_U8 ConfigSpace
[PCI_CFG_SIZE
];
1442 * Note: Switching to D3 state is like a software reset.
1443 * Switching from D3 to D0 is a hardware reset.
1444 * We have to save and restore the configuration space.
1446 for (i
= 0; i
< PCI_CFG_SIZE
; i
++) {
1447 SkPciReadCfgDWord(pAC
, i
*4, &ConfigSpace
[i
]);
1450 /* We know the RAM Interface Arbiter is enabled. */
1451 SkPciWriteCfgWord(pAC
, PCI_PM_CTL_STS
, PCI_PM_STATE_D3
);
1452 SkPciReadCfgWord(pAC
, PCI_PM_CTL_STS
, &PmCtlSts
);
1454 if ((PmCtlSts
& PCI_PM_STATE_MSK
) != PCI_PM_STATE_D3
) {
1458 /* Return to D0 state. */
1459 SkPciWriteCfgWord(pAC
, PCI_PM_CTL_STS
, PCI_PM_STATE_D0
);
1461 /* Check for D0 state. */
1462 SkPciReadCfgWord(pAC
, PCI_PM_CTL_STS
, &PmCtlSts
);
1464 if ((PmCtlSts
& PCI_PM_STATE_MSK
) != PCI_PM_STATE_D0
) {
1468 /* Check PCI Config Registers. */
1469 SkPciReadCfgWord(pAC
, PCI_COMMAND
, &PciCmd
);
1470 SkPciReadCfgByte(pAC
, PCI_CACHE_LSZ
, &Cls
);
1471 SkPciReadCfgDWord(pAC
, PCI_BASE_1ST
, &Bp1
);
1472 SkPciReadCfgDWord(pAC
, PCI_BASE_2ND
, &Bp2
);
1473 SkPciReadCfgByte(pAC
, PCI_LAT_TIM
, &Lat
);
1475 if (PciCmd
!= 0 || Cls
!= (SK_U8
)0 || Lat
!= (SK_U8
)0 ||
1476 (Bp1
& 0xfffffff0L
) != 0 || Bp2
!= 1) {
1480 /* Restore PCI Config Space. */
1481 for (i
= 0; i
< PCI_CFG_SIZE
; i
++) {
1482 SkPciWriteCfgDWord(pAC
, i
*4, ConfigSpace
[i
]);
1486 } /* SkGePciReset */
1488 #endif /* SK_PCI_RESET */
1490 /******************************************************************************
1492 * SkGeInit1() - Level 1 Initialization
1495 * o Do a software reset.
1496 * o Clear all reset bits.
1497 * o Verify that the detected hardware is present.
1498 * Return an error if not.
1499 * o Get the hardware configuration
1500 * + Read the number of MACs/Ports.
1501 * + Read the RAM size.
1502 * + Read the PCI Revision Id.
1503 * + Find out the adapters host clock speed
1504 * + Read and check the PHY type
1508 * 5: Unexpected PHY type detected
1509 * 6: HW self test failed
1511 static int SkGeInit1(
1512 SK_AC
*pAC
, /* adapter context */
1513 SK_IOC IoC
) /* IO context */
1524 /* save CLK_RUN bits (YUKON-Lite) */
1525 SK_IN16(IoC
, B0_CTST
, &CtrlStat
);
1528 (void)SkGePciReset(pAC
, IoC
);
1529 #endif /* SK_PCI_RESET */
1531 /* do the SW-reset */
1532 SK_OUT8(IoC
, B0_CTST
, CS_RST_SET
);
1534 /* release the SW-reset */
1535 SK_OUT8(IoC
, B0_CTST
, CS_RST_CLR
);
1537 /* reset all error bits in the PCI STATUS register */
1539 * Note: PCI Cfg cycles cannot be used, because they are not
1540 * available on some platforms after 'boot time'.
1542 SK_IN16(IoC
, PCI_C(PCI_STATUS
), &Word
);
1544 SK_OUT8(IoC
, B2_TST_CTRL1
, TST_CFG_WRITE_ON
);
1545 SK_OUT16(IoC
, PCI_C(PCI_STATUS
), (SK_U16
)(Word
| PCI_ERRBITS
));
1546 SK_OUT8(IoC
, B2_TST_CTRL1
, TST_CFG_WRITE_OFF
);
1548 /* release Master Reset */
1549 SK_OUT8(IoC
, B0_CTST
, CS_MRST_CLR
);
1552 CtrlStat
|= CS_CLK_RUN_ENA
;
1553 #endif /* CLK_RUN */
1555 /* restore CLK_RUN bits */
1556 SK_OUT16(IoC
, B0_CTST
, (SK_U16
)(CtrlStat
&
1557 (CS_CLK_RUN_HOT
| CS_CLK_RUN_RST
| CS_CLK_RUN_ENA
)));
1559 /* read Chip Identification Number */
1560 SK_IN8(IoC
, B2_CHIP_ID
, &Byte
);
1561 pAC
->GIni
.GIChipId
= Byte
;
1563 /* read number of MACs */
1564 SK_IN8(IoC
, B2_MAC_CFG
, &Byte
);
1565 pAC
->GIni
.GIMacsFound
= (Byte
& CFG_SNG_MAC
) ? 1 : 2;
1567 /* get Chip Revision Number */
1568 pAC
->GIni
.GIChipRev
= (SK_U8
)((Byte
& CFG_CHIP_R_MSK
) >> 4);
1570 /* get diff. PCI parameters */
1571 SK_IN16(IoC
, B0_CTST
, &CtrlStat
);
1573 /* read the adapters RAM size */
1574 SK_IN8(IoC
, B2_E_0
, &Byte
);
1576 pAC
->GIni
.GIGenesis
= SK_FALSE
;
1577 pAC
->GIni
.GIYukon
= SK_FALSE
;
1578 pAC
->GIni
.GIYukonLite
= SK_FALSE
;
1581 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
1583 pAC
->GIni
.GIGenesis
= SK_TRUE
;
1585 if (Byte
== (SK_U8
)3) {
1586 /* special case: 4 x 64k x 36, offset = 0x80000 */
1587 pAC
->GIni
.GIRamSize
= 1024;
1588 pAC
->GIni
.GIRamOffs
= (SK_U32
)512 * 1024;
1591 pAC
->GIni
.GIRamSize
= (int)Byte
* 512;
1592 pAC
->GIni
.GIRamOffs
= 0;
1594 /* all GE adapters work with 53.125 MHz host clock */
1595 pAC
->GIni
.GIHstClkFact
= SK_FACT_53
;
1597 /* set Descr. Poll Timer Init Value to 250 ms */
1598 pAC
->GIni
.GIPollTimerVal
=
1599 SK_DPOLL_DEF
* (SK_U32
)pAC
->GIni
.GIHstClkFact
/ 100;
1601 #endif /* GENESIS */
1604 if (pAC
->GIni
.GIChipId
!= CHIP_ID_GENESIS
) {
1606 pAC
->GIni
.GIYukon
= SK_TRUE
;
1608 pAC
->GIni
.GIRamSize
= (Byte
== (SK_U8
)0) ? 128 : (int)Byte
* 4;
1610 pAC
->GIni
.GIRamOffs
= 0;
1612 /* WA for chip Rev. A */
1613 pAC
->GIni
.GIWolOffs
= (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
&&
1614 pAC
->GIni
.GIChipRev
== 0) ? WOL_REG_OFFS
: 0;
1616 /* get PM Capabilities of PCI config space */
1617 SK_IN16(IoC
, PCI_C(PCI_PM_CAP_REG
), &Word
);
1619 /* check if VAUX is available */
1620 if (((CtrlStat
& CS_VAUX_AVAIL
) != 0) &&
1621 /* check also if PME from D3cold is set */
1622 ((Word
& PCI_PME_D3C_SUP
) != 0)) {
1623 /* set entry in GE init struct */
1624 pAC
->GIni
.GIVauxAvail
= SK_TRUE
;
1627 if (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON_LITE
) {
1628 /* this is Rev. A1 */
1629 pAC
->GIni
.GIYukonLite
= SK_TRUE
;
1632 /* save Flash-Address Register */
1633 SK_IN32(IoC
, B2_FAR
, &DWord
);
1635 /* test Flash-Address Register */
1636 SK_OUT8(IoC
, B2_FAR
+ 3, 0xff);
1637 SK_IN8(IoC
, B2_FAR
+ 3, &Byte
);
1640 /* this is Rev. A0 */
1641 pAC
->GIni
.GIYukonLite
= SK_TRUE
;
1643 /* restore Flash-Address Register */
1644 SK_OUT32(IoC
, B2_FAR
, DWord
);
1648 /* switch power to VCC (WA for VAUX problem) */
1649 SK_OUT8(IoC
, B0_POWER_CTRL
, (SK_U8
)(PC_VAUX_ENA
| PC_VCC_ENA
|
1650 PC_VAUX_OFF
| PC_VCC_ON
));
1652 /* read the Interrupt source */
1653 SK_IN32(IoC
, B0_ISRC
, &DWord
);
1655 if ((DWord
& IS_HW_ERR
) != 0) {
1656 /* read the HW Error Interrupt source */
1657 SK_IN32(IoC
, B0_HWE_ISRC
, &DWord
);
1659 if ((DWord
& IS_IRQ_SENSOR
) != 0) {
1660 /* disable HW Error IRQ */
1661 pAC
->GIni
.GIValIrqMask
&= ~IS_HW_ERR
;
1665 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
1666 /* set GMAC Link Control reset */
1667 SK_OUT16(IoC
, MR_ADDR(i
, GMAC_LINK_CTRL
), GMLC_RST_SET
);
1669 /* clear GMAC Link Control reset */
1670 SK_OUT16(IoC
, MR_ADDR(i
, GMAC_LINK_CTRL
), GMLC_RST_CLR
);
1672 /* all YU chips work with 78.125 MHz host clock */
1673 pAC
->GIni
.GIHstClkFact
= SK_FACT_78
;
1675 pAC
->GIni
.GIPollTimerVal
= SK_DPOLL_MAX
; /* 215 ms */
1679 /* check if 64-bit PCI Slot is present */
1680 pAC
->GIni
.GIPciSlot64
= (SK_BOOL
)((CtrlStat
& CS_BUS_SLOT_SZ
) != 0);
1682 /* check if 66 MHz PCI Clock is active */
1683 pAC
->GIni
.GIPciClock66
= (SK_BOOL
)((CtrlStat
& CS_BUS_CLOCK
) != 0);
1685 /* read PCI HW Revision Id. */
1686 SK_IN8(IoC
, PCI_C(PCI_REV_ID
), &Byte
);
1687 pAC
->GIni
.GIPciHwRev
= Byte
;
1689 /* read the PMD type */
1690 SK_IN8(IoC
, B2_PMD_TYP
, &Byte
);
1691 pAC
->GIni
.GICopperType
= (SK_U8
)(Byte
== 'T');
1693 /* read the PHY type */
1694 SK_IN8(IoC
, B2_E_1
, &Byte
);
1696 Byte
&= 0x0f; /* the PHY type is stored in the lower nibble */
1697 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
1700 if (pAC
->GIni
.GIGenesis
) {
1703 pAC
->GIni
.GP
[i
].PhyAddr
= PHY_ADDR_XMAC
;
1706 pAC
->GIni
.GP
[i
].PhyAddr
= PHY_ADDR_BCOM
;
1707 pAC
->GIni
.GP
[i
].PMSCap
= (SK_U8
)(SK_MS_CAP_AUTO
|
1708 SK_MS_CAP_MASTER
| SK_MS_CAP_SLAVE
);
1712 pAC
->GIni
.GP
[i
].PhyAddr
= PHY_ADDR_LONE
;
1715 pAC
->GIni
.GP
[i
].PhyAddr
= PHY_ADDR_NAT
;
1717 #endif /* OTHER_PHY */
1719 /* ERROR: unexpected PHY type detected */
1724 #endif /* GENESIS */
1727 if (pAC
->GIni
.GIYukon
) {
1729 if (Byte
< (SK_U8
)SK_PHY_MARV_COPPER
) {
1730 /* if this field is not initialized */
1731 Byte
= (SK_U8
)SK_PHY_MARV_COPPER
;
1733 pAC
->GIni
.GICopperType
= SK_TRUE
;
1736 pAC
->GIni
.GP
[i
].PhyAddr
= PHY_ADDR_MARV
;
1738 if (pAC
->GIni
.GICopperType
) {
1740 pAC
->GIni
.GP
[i
].PLinkSpeedCap
= (SK_U8
)(SK_LSPEED_CAP_AUTO
|
1741 SK_LSPEED_CAP_10MBPS
| SK_LSPEED_CAP_100MBPS
|
1742 SK_LSPEED_CAP_1000MBPS
);
1744 pAC
->GIni
.GP
[i
].PLinkSpeed
= (SK_U8
)SK_LSPEED_AUTO
;
1746 pAC
->GIni
.GP
[i
].PMSCap
= (SK_U8
)(SK_MS_CAP_AUTO
|
1747 SK_MS_CAP_MASTER
| SK_MS_CAP_SLAVE
);
1750 Byte
= (SK_U8
)SK_PHY_MARV_FIBER
;
1755 pAC
->GIni
.GP
[i
].PhyType
= (int)Byte
;
1757 SK_DBG_MSG(pAC
, SK_DBGMOD_HWM
, SK_DBGCAT_INIT
,
1758 ("PHY type: %d PHY addr: %04x\n", Byte
,
1759 pAC
->GIni
.GP
[i
].PhyAddr
));
1762 /* get MAC Type & set function pointers dependent on */
1764 if (pAC
->GIni
.GIGenesis
) {
1766 pAC
->GIni
.GIMacType
= SK_MAC_XMAC
;
1768 pAC
->GIni
.GIFunc
.pFnMacUpdateStats
= SkXmUpdateStats
;
1769 pAC
->GIni
.GIFunc
.pFnMacStatistic
= SkXmMacStatistic
;
1770 pAC
->GIni
.GIFunc
.pFnMacResetCounter
= SkXmResetCounter
;
1771 pAC
->GIni
.GIFunc
.pFnMacOverflow
= SkXmOverflowStatus
;
1773 #endif /* GENESIS */
1776 if (pAC
->GIni
.GIYukon
) {
1778 pAC
->GIni
.GIMacType
= SK_MAC_GMAC
;
1780 pAC
->GIni
.GIFunc
.pFnMacUpdateStats
= SkGmUpdateStats
;
1781 pAC
->GIni
.GIFunc
.pFnMacStatistic
= SkGmMacStatistic
;
1782 pAC
->GIni
.GIFunc
.pFnMacResetCounter
= SkGmResetCounter
;
1783 pAC
->GIni
.GIFunc
.pFnMacOverflow
= SkGmOverflowStatus
;
1785 #ifdef SPECIAL_HANDLING
1786 if (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
) {
1787 /* check HW self test result */
1788 SK_IN8(IoC
, B2_E_3
, &Byte
);
1789 if (Byte
& B2_E3_RES_MASK
) {
1801 /******************************************************************************
1803 * SkGeInit2() - Level 2 Initialization
1806 * - start the Blink Source Counter
1807 * - start the Descriptor Poll Timer
1808 * - configure the MAC-Arbiter
1809 * - configure the Packet-Arbiter
1810 * - enable the Tx Arbiters
1811 * - enable the RAM Interface Arbiter
1816 static void SkGeInit2(
1817 SK_AC
*pAC
, /* adapter context */
1818 SK_IOC IoC
) /* IO context */
1822 #endif /* GENESIS */
1825 /* start the Descriptor Poll Timer */
1826 if (pAC
->GIni
.GIPollTimerVal
!= 0) {
1827 if (pAC
->GIni
.GIPollTimerVal
> SK_DPOLL_MAX
) {
1828 pAC
->GIni
.GIPollTimerVal
= SK_DPOLL_MAX
;
1830 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E017
, SKERR_HWI_E017MSG
);
1832 SK_OUT32(IoC
, B28_DPT_INI
, pAC
->GIni
.GIPollTimerVal
);
1833 SK_OUT8(IoC
, B28_DPT_CTRL
, DPT_START
);
1837 if (pAC
->GIni
.GIGenesis
) {
1838 /* start the Blink Source Counter */
1839 DWord
= SK_BLK_DUR
* (SK_U32
)pAC
->GIni
.GIHstClkFact
/ 100;
1841 SK_OUT32(IoC
, B2_BSC_INI
, DWord
);
1842 SK_OUT8(IoC
, B2_BSC_CTRL
, BSC_START
);
1845 * Configure the MAC Arbiter and the Packet Arbiter.
1846 * They will be started once and never be stopped.
1848 SkGeInitMacArb(pAC
, IoC
);
1850 SkGeInitPktArb(pAC
, IoC
);
1852 #endif /* GENESIS */
1855 if (pAC
->GIni
.GIYukon
) {
1856 /* start Time Stamp Timer */
1857 SK_OUT8(IoC
, GMAC_TI_ST_CTRL
, (SK_U8
)GMT_ST_START
);
1861 /* enable the Tx Arbiters */
1862 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
1863 SK_OUT8(IoC
, MR_ADDR(i
, TXA_CTRL
), TXA_ENA_ARB
);
1866 /* enable the RAM Interface Arbiter */
1867 SkGeInitRamIface(pAC
, IoC
);
1871 /******************************************************************************
1873 * SkGeInit() - Initialize the GE Adapter with the specified level.
1876 * Level 0: Initialize the Module structures.
1877 * Level 1: Generic Hardware Initialization. The IOP/MemBase pointer has
1878 * to be set before calling this level.
1880 * o Do a software reset.
1881 * o Clear all reset bits.
1882 * o Verify that the detected hardware is present.
1883 * Return an error if not.
1884 * o Get the hardware configuration
1885 * + Set GIMacsFound with the number of MACs.
1886 * + Store the RAM size in GIRamSize.
1887 * + Save the PCI Revision ID in GIPciHwRev.
1889 * if Number of MACs > SK_MAX_MACS
1891 * After returning from Level 0 the adapter
1892 * may be accessed with IO operations.
1894 * Level 2: start the Blink Source Counter
1898 * 1: Number of MACs exceeds SK_MAX_MACS (after level 1)
1899 * 2: Adapter not present or not accessible
1900 * 3: Illegal initialization level
1901 * 4: Initialization Level 1 Call missing
1902 * 5: Unexpected PHY type detected
1903 * 6: HW self test failed
1906 SK_AC
*pAC
, /* adapter context */
1907 SK_IOC IoC
, /* IO context */
1908 int Level
) /* initialization level */
1910 int RetVal
; /* return value */
1914 SK_DBG_MSG(pAC
, SK_DBGMOD_HWM
, SK_DBGCAT_INIT
,
1915 ("SkGeInit(Level %d)\n", Level
));
1919 /* Initialization Level 0 */
1920 SkGeInit0(pAC
, IoC
);
1921 pAC
->GIni
.GILevel
= SK_INIT_DATA
;
1925 /* Initialization Level 1 */
1926 RetVal
= SkGeInit1(pAC
, IoC
);
1931 /* check if the adapter seems to be accessible */
1932 SK_OUT32(IoC
, B2_IRQM_INI
, SK_TEST_VAL
);
1933 SK_IN32(IoC
, B2_IRQM_INI
, &DWord
);
1934 SK_OUT32(IoC
, B2_IRQM_INI
, 0L);
1936 if (DWord
!= SK_TEST_VAL
) {
1941 /* check if the number of GIMacsFound matches SK_MAX_MACS */
1942 if (pAC
->GIni
.GIMacsFound
> SK_MAX_MACS
) {
1947 /* Level 1 successfully passed */
1948 pAC
->GIni
.GILevel
= SK_INIT_IO
;
1952 /* Initialization Level 2 */
1953 if (pAC
->GIni
.GILevel
!= SK_INIT_IO
) {
1955 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E002
, SKERR_HWI_E002MSG
);
1956 #endif /* !SK_DIAG */
1960 SkGeInit2(pAC
, IoC
);
1962 /* Level 2 successfully passed */
1963 pAC
->GIni
.GILevel
= SK_INIT_RUN
;
1967 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E003
, SKERR_HWI_E003MSG
);
1976 /******************************************************************************
1978 * SkGeDeInit() - Deinitialize the adapter
1981 * All ports of the adapter will be stopped if not already done.
1982 * Do a software reset and switch off all LEDs.
1988 SK_AC
*pAC
, /* adapter context */
1989 SK_IOC IoC
) /* IO context */
1994 #ifdef SK_PHY_LP_MODE
1997 #endif /* SK_PHY_LP_MODE */
1999 #if (!defined(SK_SLIM) && !defined(VCPU))
2000 /* ensure I2C is ready */
2001 SkI2cWaitIrq(pAC
, IoC
);
2004 /* stop all current transfer activity */
2005 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
2006 if (pAC
->GIni
.GP
[i
].PState
!= SK_PRT_STOP
&&
2007 pAC
->GIni
.GP
[i
].PState
!= SK_PRT_RESET
) {
2009 SkGeStopPort(pAC
, IoC
, i
, SK_STOP_ALL
, SK_HARD_RST
);
2013 #ifdef SK_PHY_LP_MODE
2015 * for power saving purposes within mobile environments
2016 * we set the PHY to coma mode and switch to D3 power state.
2018 if (pAC
->GIni
.GIYukonLite
&&
2019 pAC
->GIni
.GIChipRev
== CHIP_REV_YU_LITE_A3
) {
2021 /* for all ports switch PHY to coma mode */
2022 for (i
= 0; i
< pAC
->GIni
.GIMacsFound
; i
++) {
2024 SkGmEnterLowPowerMode(pAC
, IoC
, i
, PHY_PM_DEEP_SLEEP
);
2027 if (pAC
->GIni
.GIVauxAvail
) {
2028 /* switch power to VAUX */
2029 Byte
= PC_VAUX_ENA
| PC_VCC_ENA
| PC_VAUX_ON
| PC_VCC_OFF
;
2031 SK_OUT8(IoC
, B0_POWER_CTRL
, Byte
);
2034 /* switch to D3 state */
2035 SK_IN16(IoC
, PCI_C(PCI_PM_CTL_STS
), &PmCtlSts
);
2037 PmCtlSts
|= PCI_PM_STATE_D3
;
2039 SK_OUT8(IoC
, B2_TST_CTRL1
, TST_CFG_WRITE_ON
);
2041 SK_OUT16(IoC
, PCI_C(PCI_PM_CTL_STS
), PmCtlSts
);
2043 #endif /* SK_PHY_LP_MODE */
2045 /* Reset all bits in the PCI STATUS register */
2047 * Note: PCI Cfg cycles cannot be used, because they are not
2048 * available on some platforms after 'boot time'.
2050 SK_IN16(IoC
, PCI_C(PCI_STATUS
), &Word
);
2052 SK_OUT8(IoC
, B2_TST_CTRL1
, TST_CFG_WRITE_ON
);
2053 SK_OUT16(IoC
, PCI_C(PCI_STATUS
), (SK_U16
)(Word
| PCI_ERRBITS
));
2054 SK_OUT8(IoC
, B2_TST_CTRL1
, TST_CFG_WRITE_OFF
);
2056 /* do the reset, all LEDs are switched off now */
2057 SK_OUT8(IoC
, B0_CTST
, CS_RST_SET
);
2059 pAC
->GIni
.GILevel
= SK_INIT_DATA
;
2063 /******************************************************************************
2065 * SkGeInitPort() Initialize the specified port.
2068 * PRxQSize, PXSQSize, and PXAQSize has to be
2069 * configured for the specified port before calling this function.
2070 * The descriptor rings has to be initialized too.
2072 * o (Re)configure queues of the specified port.
2073 * o configure the MAC of the specified port.
2074 * o put ASIC and MAC(s) in operational mode.
2075 * o initialize Rx/Tx and Sync LED
2076 * o initialize RAM Buffers and MAC FIFOs
2078 * The port is ready to connect when returning.
2081 * The MAC's Rx and Tx state machine is still disabled when returning.
2085 * 1: Queue size initialization error. The configured values
2086 * for PRxQSize, PXSQSize, or PXAQSize are invalid for one
2087 * or more queues. The specified port was NOT initialized.
2088 * An error log entry was generated.
2089 * 2: The port has to be stopped before it can be initialized again.
2092 SK_AC
*pAC
, /* adapter context */
2093 SK_IOC IoC
, /* IO context */
2094 int Port
) /* Port to configure */
2098 pPrt
= &pAC
->GIni
.GP
[Port
];
2100 if (SkGeCheckQSize(pAC
, Port
) != 0) {
2101 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E004
, SKERR_HWI_E004MSG
);
2105 if (pPrt
->PState
== SK_PRT_INIT
|| pPrt
->PState
== SK_PRT_RUN
) {
2106 SK_ERR_LOG(pAC
, SK_ERRCL_SW
, SKERR_HWI_E005
, SKERR_HWI_E005MSG
);
2110 /* configuration ok, initialize the Port now */
2113 if (pAC
->GIni
.GIGenesis
) {
2114 /* initialize Rx, Tx and Link LED */
2116 * If 1000BT Phy needs LED initialization than swap
2117 * LED and XMAC initialization order
2119 SkGeXmitLED(pAC
, IoC
, MR_ADDR(Port
, TX_LED_INI
), SK_LED_ENA
);
2120 SkGeXmitLED(pAC
, IoC
, MR_ADDR(Port
, RX_LED_INI
), SK_LED_ENA
);
2121 /* The Link LED is initialized by RLMT or Diagnostics itself */
2123 SkXmInitMac(pAC
, IoC
, Port
);
2125 #endif /* GENESIS */
2128 if (pAC
->GIni
.GIYukon
) {
2130 SkGmInitMac(pAC
, IoC
, Port
);
2134 /* do NOT initialize the Link Sync Counter */
2136 SkGeInitMacFifo(pAC
, IoC
, Port
);
2138 SkGeInitRamBufs(pAC
, IoC
, Port
);
2140 if (pPrt
->PXSQSize
!= 0) {
2141 /* enable Force Sync bit if synchronous queue available */
2142 SK_OUT8(IoC
, MR_ADDR(Port
, TXA_CTRL
), TXA_ENA_FSYNC
);
2145 SkGeInitBmu(pAC
, IoC
, Port
);
2147 /* mark port as initialized */
2148 pPrt
->PState
= SK_PRT_INIT
;
2151 } /* SkGeInitPort */