📄 skxmac2.c
字号:
/****************************************************************************** * * Name: skxmac2.c * Project: GEnesis, PCI Gigabit Ethernet Adapter * Version: $Revision: 1.1.1.1 $ * Date: $Date: 2005/06/27 17:05:05 $ * Purpose: Contains functions to initialize the MACs and PHYs * ******************************************************************************//****************************************************************************** * * (C)Copyright 1998-2003 SysKonnect GmbH. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * The information in this file is provided "AS IS" without warranty. * ******************************************************************************//****************************************************************************** * * History: * * $Log: skxmac2.c,v $ * Revision 1.1.1.1 2005/06/27 17:05:05 linuxpark * Initial import. * * Revision 1.91 2003/02/05 15:09:34 rschmidt * Removed setting of 'Collision Test'-bit in SkGmInitPhyMarv(). * Disabled auto-update for speed, duplex and flow-control when * auto-negotiation is not enabled (Bug Id #10766). * Editorial changes. * * Revision 1.90 2003/01/29 13:35:19 rschmidt * Increment Rx FIFO Overflow counter only in DEBUG-mode. * Corrected define for blinking active LED. * * Revision 1.89 2003/01/28 16:37:45 rschmidt * Changed init for blinking active LED * * Revision 1.88 2003/01/28 10:09:38 rschmidt * Added debug outputs in SkGmInitMac(). * Added customized init of LED registers in SkGmInitPhyMarv(), * for blinking active LED (#ifdef ACT_LED_BLINK) and * for normal duplex LED (#ifdef DUP_LED_NORMAL). * Editorial changes. * * Revision 1.87 2002/12/10 14:39:05 rschmidt * Improved initialization of GPHY in SkGmInitPhyMarv(). * Editorial changes. * * Revision 1.86 2002/12/09 15:01:12 rschmidt * Added setup of Ext. PHY Specific Ctrl Reg (downshift feature). * * Revision 1.85 2002/12/05 14:09:16 rschmidt * Improved avoiding endless loop in SkGmPhyWrite(), SkGmPhyWrite(). * Added additional advertising for 10Base-T when 100Base-T is selected. * Added case SK_PHY_MARV_FIBER for YUKON Fiber adapter. * Editorial changes. * * Revision 1.84 2002/11/15 12:50:09 rschmidt * Changed SkGmCableDiagStatus() when getting results. * * Revision 1.83 2002/11/13 10:28:29 rschmidt * Added some typecasts to avoid compiler warnings. * * Revision 1.82 2002/11/13 09:20:46 rschmidt * Replaced for(..) with do {} while (...) in SkXmUpdateStats(). * Replaced 2 macros GM_IN16() with 1 GM_IN32() in SkGmMacStatistic(). * Added SkGmCableDiagStatus() for Virtual Cable Test (VCT). * Editorial changes. * * Revision 1.81 2002/10/28 14:28:08 rschmidt * Changed MAC address setup for GMAC in SkGmInitMac(). * Optimized handling of counter overflow IRQ in SkGmOverflowStatus(). * Editorial changes. * * Revision 1.80 2002/10/14 15:29:44 rschmidt * Corrected disabling of all PHY IRQs. * Added WA for deviation #16 (address used for pause packets). * Set Pause Mode in SkMacRxTxEnable() only for Genesis. * Added IRQ and counter for Receive FIFO Overflow in DEBUG-mode. * SkXmTimeStamp() replaced by SkMacTimeStamp(). * Added clearing of GMAC Tx FIFO Underrun IRQ in SkGmIrq(). * Editorial changes. * * Revision 1.79 2002/10/10 15:55:36 mkarl * changes for PLinkSpeedUsed * * Revision 1.78 2002/09/12 09:39:51 rwahl * Removed deactivate code for SIRQ overflow event separate for TX/RX. * * Revision 1.77 2002/09/09 12:26:37 mkarl * added handling for Yukon to SkXmTimeStamp * * Revision 1.76 2002/08/21 16:41:16 rschmidt * Added bit GPC_ENA_XC (Enable MDI crossover) in HWCFG_MODE. * Added forced speed settings in SkGmInitPhyMarv(). * Added settings of full/half duplex capabilities for YUKON Fiber. * Editorial changes. * * Revision 1.75 2002/08/16 15:12:01 rschmidt * Replaced all if(GIChipId == CHIP_ID_GENESIS) with new entry GIGenesis. * Added function SkMacHashing() for ADDR-Module. * Removed functions SkXmClrSrcCheck(), SkXmClrHashAddr() (calls replaced * with macros). * Removed functions SkGmGetMuxConfig(). * Added HWCFG_MODE init for YUKON Fiber. * Changed initialization of GPHY in SkGmInitPhyMarv(). * Changed check of parameter in SkXmMacStatistic(). * Editorial changes. * * Revision 1.74 2002/08/12 14:00:17 rschmidt * Replaced usage of Broadcom PHY Ids with defines. * Corrected error messages in SkGmMacStatistic(). * Made SkMacPromiscMode() public for ADDR-Modul. * Editorial changes. * * Revision 1.73 2002/08/08 16:26:24 rschmidt * Improved reset sequence for YUKON in SkGmHardRst() and SkGmInitMac(). * Replaced XMAC Rx High Watermark init value with SK_XM_RX_HI_WM. * Editorial changes. * * Revision 1.72 2002/07/24 15:11:19 rschmidt * Fixed wrong placement of parenthesis. * Editorial changes. * * Revision 1.71 2002/07/23 16:05:18 rschmidt * Added global functions for PHY: SkGePhyRead(), SkGePhyWrite(). * Fixed Tx Counter Overflow IRQ (Bug ID #10730). * Editorial changes. * * Revision 1.70 2002/07/18 14:27:27 rwahl * Fixed syntax error. * * Revision 1.69 2002/07/17 17:08:47 rwahl * Fixed check in SkXmMacStatistic(). * * Revision 1.68 2002/07/16 07:35:24 rwahl * Removed check for cleared mib counter in SkGmResetCounter(). * * Revision 1.67 2002/07/15 18:35:56 rwahl * Added SkXmUpdateStats(), SkGmUpdateStats(), SkXmMacStatistic(), * SkGmMacStatistic(), SkXmResetCounter(), SkGmResetCounter(), * SkXmOverflowStatus(), SkGmOverflowStatus(). * Changes to SkXmIrq() & SkGmIrq(): Combined SIRQ Overflow for both * RX & TX. * Changes to SkGmInitMac(): call to SkGmResetCounter(). * Editorial changes. * * Revision 1.66 2002/07/15 15:59:30 rschmidt * Added PHY Address in SkXmPhyRead(), SkXmPhyWrite(). * Added MIB Clear Counter in SkGmInitMac(). * Added Duplex and Flow-Control settings. * Reset all Multicast filtering Hash reg. in SkGmInitMac(). * Added new function: SkGmGetMuxConfig(). * Editorial changes. * * Revision 1.65 2002/06/10 09:35:39 rschmidt * Replaced C++ comments (//). * Added #define VCPU around VCPUwaitTime. * Editorial changes. * * Revision 1.64 2002/06/05 08:41:10 rschmidt * Added function for XMAC2: SkXmTimeStamp(). * Added function for YUKON: SkGmSetRxCmd(). * Changed SkGmInitMac() resp. SkGmHardRst(). * Fixed wrong variable in SkXmAutoNegLipaXmac() (debug mode). * SkXmRxTxEnable() replaced by SkMacRxTxEnable(). * Editorial changes. * * Revision 1.63 2002/04/25 13:04:44 rschmidt * Changes for handling YUKON. * Use of #ifdef OTHER_PHY to eliminate code for unused Phy types. * Macros for XMAC PHY access PHY_READ(), PHY_WRITE() replaced * by functions SkXmPhyRead(), SkXmPhyWrite(); * Removed use of PRxCmd to setup XMAC. * Added define PHY_B_AS_PAUSE_MSK for BCom Pause Res. * Added setting of XM_RX_DIS_CEXT in SkXmInitMac(). * Removed status parameter from MAC IRQ handler SkMacIrq(), * SkXmIrq() and SkGmIrq(). * SkXmAutoNegLipa...() for ext. Phy replaced by SkMacAutoNegLipaPhy(). * Added SkMac...() functions to handle both XMAC and GMAC. * Added functions for YUKON: SkGmHardRst(), SkGmSoftRst(), * SkGmSetRxTxEn(), SkGmIrq(), SkGmInitMac(), SkGmInitPhyMarv(), * SkGmAutoNegDoneMarv(), SkGmPhyRead(), SkGmPhyWrite(). * Changes for V-CPU support. * Editorial changes. * * Revision 1.62 2001/08/06 09:50:14 rschmidt * Workaround BCOM Errata #1 for the C5 type. * Editorial changes. * * Revision 1.61 2001/02/09 15:40:59 rassmann * Editorial changes. * * Revision 1.60 2001/02/07 15:02:01 cgoos * Added workaround for Fujitsu switch link down. * * Revision 1.59 2001/01/10 09:38:06 cgoos * Fixed Broadcom C0/A1 Id check for workaround. * * Revision 1.58 2000/11/29 11:30:38 cgoos * Changed DEBUG sections with NW output to xDEBUG * * Revision 1.57 2000/11/27 12:40:40 rassmann * Suppressing preamble after first access to BCom, not before (#10556). * * Revision 1.56 2000/11/09 12:32:48 rassmann * Renamed variables. * * Revision 1.55 2000/11/09 11:30:10 rassmann * WA: Waiting after releasing reset until BCom chip is accessible. * * Revision 1.54 2000/10/02 14:10:27 rassmann * Reading BCOM PHY after releasing reset until it returns a valid value. * * Revision 1.53 2000/07/27 12:22:11 gklug * fix: possible endless loop in XmHardRst. * * Revision 1.52 2000/05/22 08:48:31 malthoff * Fix: #10523 errata valid for all BCOM PHYs. * * Revision 1.51 2000/05/17 12:52:18 malthoff * Fixes BCom link errata (#10523). * * Revision 1.50 1999/11/22 13:40:14 cgoos * Changed license header to GPL. * * Revision 1.49 1999/11/22 08:12:13 malthoff * Add workaround for power consumption feature of BCom C0 chip. * * Revision 1.48 1999/11/16 08:39:01 malthoff * Fix: MDIO preamble suppression is port dependent. * * Revision 1.47 1999/08/27 08:55:35 malthoff * 1000BT: Optimizing MDIO transfer by oppressing MDIO preamble. * * Revision 1.46 1999/08/13 11:01:12 malthoff * Fix for 1000BT: pFlowCtrlMode was not set correctly. * * Revision 1.45 1999/08/12 19:18:28 malthoff * 1000BT Fixes: Do not owerwrite XM_MMU_CMD. * Do not execute BCOM A1 workaround for B1 chips. * Fix pause frame setting. * Always set PHY_B_AC_TX_TST in PHY_BCOM_AUX_CTRL. * * Revision 1.44 1999/08/03 15:23:48 cgoos * Fixed setting of PHY interrupt mask in half duplex mode. * * Revision 1.43 1999/08/03 15:22:17 cgoos * Added some debug output. * Disabled XMac GP0 interrupt for external PHYs. * * Revision 1.42 1999/08/02 08:39:23 malthoff * BCOM PHY: TX LED: To get the mono flop behaviour it is required * to set the LED Traffic Mode bit in PHY_BCOM_P_EXT_CTRL. * * Revision 1.41 1999/07/30 06:54:31 malthoff * Add temp. workarounds for the BCOM Phy revision A1. * * Revision 1.40 1999/06/01 07:43:26 cgoos * Changed Link Mode Status in SkXmAutoNegDone... from FULL/HALF to * AUTOFULL/AUTOHALF. * * Revision 1.39 1999/05/19 07:29:51 cgoos * Changes for 1000Base-T. * * Revision 1.38 1999/04/08 14:35:10 malthoff * Add code for enabling signal detect. Enabling signal detect is disabled. * * Revision 1.37 1999/03/12 13:42:54 malthoff * Add: Jumbo Frame Support. * Add: Receive modes SK_LENERR_OK_ON/OFF and * SK_BIG_PK_OK_ON/OFF in SkXmSetRxCmd(). * * Revision 1.36 1999/03/08 10:10:55 gklug * fix: AutoSensing did switch to next mode even if LiPa indicated offline * * Revision 1.35 1999/02/22 15:16:41 malthoff * Remove some compiler warnings. * * Revision 1.34 1999/01/22 09:19:59 gklug * fix: Init DupMode and InitPauseMd are now called in RxTxEnable * * Revision 1.33 1998/12/11 15:19:11 gklug * chg: lipa autoneg stati * chg: debug messages * chg: do NOT use spurious XmIrq * * Revision 1.32 1998/12/10 11:08:44 malthoff * bug fix: pAC has been used for IOs in SkXmHardRst(). * SkXmInitPhy() is also called for the Diag in SkXmInitMac(). * * Revision 1.31 1998/12/10 10:39:11 gklug * fix: do 4 RESETS of the XMAC at the beginning * fix: dummy read interrupt source register BEFORE initializing the Phy * add: debug messages * fix: Linkpartners autoneg capability cannot be shown by TX_PAGE interrupt * * Revision 1.30 1998/12/07 12:18:32 gklug * add: refinement of autosense mode: take into account the autoneg cap of LiPa * * Revision 1.29 1998/12/07 07:12:29 gklug * fix: if page is received the link is down. * * Revision 1.28 1998/12/01 10:12:47 gklug * chg: if spurious IRQ from XMAC encountered, save it * * Revision 1.27 1998/11/26 07:33:38 gklug * add: InitPhy call is now in XmInit function * * Revision 1.26 1998/11/18 13:38:24 malthoff * 'Imsk' is also unused in SkXmAutoNegDone. * * Revision 1.25 1998/11/18 13:28:01 malthoff * Remove unused variable 'Reg' in SkXmAutoNegDone(). * * Revision 1.24 1998/11/18 13:18:45 gklug * add: workaround for xmac errata #1 * add: detect Link Down also when Link partner requested config * chg: XMIrq is only used when link is up * * Revision 1.23 1998/11/04 07:07:04 cgoos * Added function SkXmRxTxEnable. * * Revision 1.22 1998/10/30 07:35:54 gklug * fix: serve LinkDown interrupt when link is already down * * Revision 1.21 1998/10/29 15:32:03 gklug * fix: Link Down signaling * * Revision 1.20 1998/10/29 11:17:27 gklug * fix: AutoNegDone bug * * Revision 1.19 1998/10/29 10:14:43 malthoff * Add endainesss comment for reading/writing MAC addresses. * * Revision 1.18 1998/10/28 07:48:55 cgoos * Fix: ASS somtimes signaled although link is up. * * Revision 1.17 1998/10/26 07:55:39 malthoff * Fix in SkXmInitPauseMd(): Pause Mode * was disabled and not enabled. * Fix in SkXmAutoNegDone(): Checking Mode bits * always failed, becaues of some missing braces. * * Revision 1.16 1998/10/22 09:46:52 gklug * fix SysKonnectFileId typo * * Revision 1.15 1998/10/21 05:51:37 gklug * add: para DoLoop to InitPhy function for loopback set-up * * Revision 1.14 1998/10/16 10:59:23 malthoff * Remove Lint warning for dummy reads. * * Revision 1.13 1998/10/15 14:01:20 malthoff * Fix: SkXmAutoNegDone() is (int) but does not return a value. * * Revision 1.12 1998/10/14 14:45:04 malthoff * Remove SKERR_SIRQ_E0xx and SKERR_SIRQ_E0xxMSG by * SKERR_HWI_Exx and SKERR_HWI_E0xxMSG to be independent * from the Sirq module. * * Revision 1.11 1998/10/14 13:59:01 gklug * add: InitPhy function * * Revision 1.10 1998/10/14 11:20:57 malthoff * Make SkXmAutoNegDone() public, because it's * used in diagnostics, too. * The Link Up event to the RLMT is issued in SkXmIrq(). * SkXmIrq() is not available in diagnostics. * Use PHY_READ when reading PHY registers. * * Revision 1.9 1998/10/14 05:50:10 cgoos * Added definition for Para. * * Revision 1.8 1998/10/14 05:41:28 gklug * add: Xmac IRQ * add: auto-negotiation done function * * Revision 1.7 1998/10/09 06:55:20 malthoff * The configuration of the XMACs Tx Request Threshold * depends from the drivers port usage now. The port * usage is configured in GIPortUsage. * * Revision 1.6 1998/10/05 07:48:00 malthoff * minor changes * * Revision 1.5 1998/10/01 07:03:54 gklug * add: dummy function for XMAC ISR * * Revision 1.4 1998/09/30 12:37:44 malthoff * Add SkXmSetRxCmd() and related code. * * Revision 1.3 1998/09/28 13:26:40 malthoff * Add SkXmInitMac(), SkXmInitDupMd(), and SkXmInitPauseMd() * * Revision 1.2 1998/09/16 14:34:21 malthoff * Add SkXmClrExactAddr(), SkXmClrSrcCheck(), * SkXmClrHashAddr(), SkXmFlushTxFifo(), * SkXmFlushRxFifo(), and SkXmHardRst(). * Finish Coding of SkXmSoftRst(). * The sources may be compiled now. * * Revision 1.1 1998/09/04 10:05:56 malthoff * Created. * * ******************************************************************************/#include <config.h>#ifdef CONFIG_SK98#include "h/skdrv1st.h"#include "h/skdrv2nd.h"/* typedefs *******************************************************************//* BCOM PHY magic pattern list */typedef struct s_PhyHack { int PhyReg; /* Phy register */ SK_U16 PhyVal; /* Value to write */} BCOM_HACK;/* local variables ************************************************************/static const char SysKonnectFileId[] = "@(#)$Id: skxmac2.c,v 1.1.1.1 2005/06/27 17:05:05 linuxpark Exp $ (C) SK ";BCOM_HACK BcomRegA1Hack[] = { { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1104 }, { 0x17, 0x0013 }, { 0x15, 0x0404 }, { 0x17, 0x8006 }, { 0x15, 0x0132 }, { 0x17, 0x8006 }, { 0x15, 0x0232 }, { 0x17, 0x800D }, { 0x15, 0x000F }, { 0x18, 0x0420 }, { 0, 0 }};BCOM_HACK BcomRegC0Hack[] = { { 0x18, 0x0c20 }, { 0x17, 0x0012 }, { 0x15, 0x1204 }, { 0x17, 0x0013 }, { 0x15, 0x0A04 }, { 0x18, 0x0420 }, { 0, 0 }};/* function prototypes ********************************************************/static void SkXmInitPhyXmac(SK_AC*, SK_IOC, int, SK_BOOL);static void SkXmInitPhyBcom(SK_AC*, SK_IOC, int, SK_BOOL);static void SkGmInitPhyMarv(SK_AC*, SK_IOC, int, SK_BOOL);static int SkXmAutoNegDoneXmac(SK_AC*, SK_IOC, int);static int SkXmAutoNegDoneBcom(SK_AC*, SK_IOC, int);static int SkGmAutoNegDoneMarv(SK_AC*, SK_IOC, int);#ifdef OTHER_PHYstatic void SkXmInitPhyLone(SK_AC*, SK_IOC, int, SK_BOOL);static void SkXmInitPhyNat (SK_AC*, SK_IOC, int, SK_BOOL);static int SkXmAutoNegDoneLone(SK_AC*, SK_IOC, int);static int SkXmAutoNegDoneNat (SK_AC*, SK_IOC, int);#endif /* OTHER_PHY *//****************************************************************************** * * SkXmPhyRead() - Read from XMAC PHY register * * Description: reads a 16-bit word from XMAC PHY or ext. PHY * * Returns: * nothing */void SkXmPhyRead(SK_AC *pAC, /* Adapter Context */SK_IOC IoC, /* I/O Context */int Port, /* Port Index (MAC_1 + n) */int PhyReg, /* Register Address (Offset) */SK_U16 *pVal) /* Pointer to Value */{ SK_U16 Mmu; SK_GEPORT *pPrt; pPrt = &pAC->GIni.GP[Port]; /* write the PHY register's address */ XM_OUT16(IoC, Port, XM_PHY_ADDR, PhyReg | pPrt->PhyAddr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -