1/***************************************************************************\ 2|* *| 3|* Copyright 2001-2004 NVIDIA Corporation. All Rights Reserved. *| 4|* *| 5|* THE INFORMATION CONTAINED HEREIN IS PROPRIETARY AND CONFIDENTIAL *| 6|* TO NVIDIA, CORPORATION. USE, REPRODUCTION OR DISCLOSURE TO ANY *| 7|* THIRD PARTY IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORP. *| 8|* *| 9|* THE INFORMATION CONTAINED HEREIN IS PROVIDED "AS IS" WITHOUT *| 10|* EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING ALL IMPLIED *| 11|* WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A *| 12|* PARTICULAR PURPOSE. *| 13|* *| 14\***************************************************************************/ 15 16/* 17 FILE: phy.h 18 DATE: 2/7/00 19 20 This file contains the functional interface to the PHY. 21*/ 22#ifndef _PHY_H_ 23#define _PHY_H_ 24 25//#include "basetype.h" 26//#include "nvevent.h" 27 28#ifdef __cplusplus 29extern "C" { 30#endif 31 32#define DEFAULT_PHY_ADDRESS 1 33 34 35#define HDP_VERSION_STRING "HDR P: $Revision: #23 $" 36 37// 38// Defaults for PHY timeout values. 39// 40#define PHY_POWER_ISOLATION_MS_TIMEOUT_DEFAULT 50 41#define PHY_RESET_MS_TIMEOUT_DEFAULT 50 42#define PHY_AUTONEG_MS_TIMEOUT_DEFAULT 3000 43#define PHY_LINK_UP_MS_TIMEOUT_DEFAULT 2400 44#define PHY_RDWR_US_TIMEOUT_DEFAULT 2048 45#define PHY_POWER_DOWN_US_TIMEOUT_DEFAULT 500 46 47 48///////////////////////////////////////////////////////////////////////// 49// The phy module knows the values that need to go into the phy registers 50// but typically the method of writing those registers is controlled by 51// another module (usually the adapter because it is really the hardware 52// interface.) Hence, the phy needs routines to call to read and write the 53// phy registers. This structure with appropriate routines will be provided 54// in the PHY_Open call. 55 56typedef NV_API_CALL NV_SINT32 (* PFN_READ_PHY) (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 *pulValue); 57typedef NV_API_CALL NV_SINT32 (* PFN_WRITE_PHY) (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 ulValue); 58 59typedef struct PHY_SUPPORT_API 60{ 61 PNV_VOID pADCX; 62 PFN_READ_PHY pfnRead; 63 PFN_WRITE_PHY pfnWrite; 64 // PFN_EVENT_OCCURED pfnEventOccurred; 65 66 // 67 // These fields are passed down via the FD. FD get's them 68 // from the registry. They allow one to fine tune the timeout 69 // values in the PHY. 70 // 71 NV_UINT32 PhyPowerIsolationTimeoutInms; 72 NV_UINT32 PhyResetTimeoutInms; 73 NV_UINT32 PhyAutonegotiateTimeoutInms; 74 NV_UINT32 PhyLinkupTimeoutInms; 75 NV_UINT32 PhyPowerdownOnCloseInus; 76 77} PHY_SUPPORT_API, *PPHY_SUPPORT_API; 78///////////////////////////////////////////////////////////////////////// 79 80 81///////////////////////////////////////////////////////////////////////// 82// The functional typedefs for the PHY Api 83typedef NV_SINT32 (* PFN_PHY_INIT) (PNV_VOID pvContext, NV_UINT32 *pulLinkState, NV_UINT32 PhyMode); 84typedef NV_SINT32 (* PFN_PHY_DEINIT) (PNV_VOID pvContext); 85typedef NV_SINT32 (* PFN_PHY_CLOSE) (PNV_VOID pvContext); 86typedef NV_SINT32 (* PFN_GET_LINK_SPEED) (PNV_VOID pvContext); 87typedef NV_SINT32 (* PFN_GET_LINK_MODE) (PNV_VOID pvContext); 88typedef NV_SINT32 (* PFN_GET_LINK_STATE) (PNV_VOID pvContext, NV_UINT32 *pulLinkState); 89typedef NV_SINT32 (* PFN_IS_LINK_INITIALIZING) (PNV_VOID pvContext); 90typedef NV_SINT32 (* PFN_RESET_PHY_INIT_STATE) (PNV_VOID pvContext); 91typedef NV_SINT32 (* PFN_FORCE_SPEED_DUPLEX) (PNV_VOID pvContext, NV_UINT16 usSpeed, NV_UINT8 ucForceDpx, NV_UINT8 ucForceMode); 92typedef NV_SINT32 (* PFN_PHY_POWERDOWN) (PNV_VOID pvContext); 93typedef NV_SINT32 (* PFN_SET_LOW_SPEED_FOR_PM) (PNV_VOID pvContext); 94 95 96typedef struct _PHY_API 97{ 98 // This is the context to pass back in as the first arg on all 99 // the calls in the API below. 100 PNV_VOID pPHYCX; 101 102 PFN_PHY_INIT pfnInit; 103 PFN_PHY_INIT pfnInitFast; 104 PFN_PHY_DEINIT pfnDeinit; 105 PFN_PHY_CLOSE pfnClose; 106 PFN_GET_LINK_SPEED pfnGetLinkSpeed; 107 PFN_GET_LINK_MODE pfnGetLinkMode; 108 PFN_GET_LINK_STATE pfnGetLinkState; 109 PFN_IS_LINK_INITIALIZING pfnIsLinkInitializing; 110 PFN_RESET_PHY_INIT_STATE pfnResetPhyInitState; 111 PFN_FORCE_SPEED_DUPLEX pfnForceSpeedDuplex; 112 PFN_PHY_POWERDOWN pfnPowerdown; 113 PFN_SET_LOW_SPEED_FOR_PM pfnSetLowSpeedForPM; 114} PHY_API, *PPHY_API; 115///////////////////////////////////////////////////////////////////////// 116 117 118///////////////////////////////////////////////////////////////////////// 119// This is the one function in the PHY interface that is publicly 120// available. The rest of the interface is returned in the pPhyApi; 121// The first argument needs to be cast to a POS_API structure ptr. 122// On input the second argument is a ptr to a PPHY_SUPPORT_API. 123// On output, the second argument should be treated as a ptr to a 124// PPHY_API and set appropriately. 125extern NV_SINT32 PHY_Open (PNV_VOID pvOSApi, PNV_VOID pPhyApi, NV_UINT32 *pulPhyAddr, NV_UINT32 *pulPhyConnected); 126///////////////////////////////////////////////////////////////////////// 127 128 129///////////////////////////////////////////////////////////////////////// 130// Here are the error codes the phy functions can return. 131#define PHYERR_NONE 0x0000 132#define PHYERR_COULD_NOT_ALLOC_CONTEXT 0x0001 133#define PHYERR_RESET_NEVER_FINISHED 0x0002 134#define PHYERR_NO_AVAILABLE_LINK_SPEED 0x0004 135#define PHYERR_INVALID_SETTINGS 0x0005 136#define PHYERR_READ_FAILED 0x0006 137#define PHYERR_WRITE_FAILED 0x0007 138#define PHYERR_NO_PHY 0x0008 139#define PHYERR_NO_RESOURCE 0x0009 140#define PHYERR_POWER_ISOLATION_TIMEOUT 0x000A 141#define PHYERR_POWER_DOWN_TIMEOUT 0x000B 142#define PHYERR_AUTONEG_TIMEOUT 0x000C 143#define PHYERR_PHY_LINK_SPEED_UNCHANGED 0x000D 144 145#define PHY_INVALID_PHY_ADDR 0xFFFF; 146 147///////////////////////////////////////////////////////////////////////// 148 149// This value can be used in the ulPhyLinkSpeed field. 150#define PHY_LINK_SPEED_UNKNOWN 0x0FFFFFFFF 151 152// 153// Values used to configure PHY mode. 154// 155#define PHY_MODE_MII 1 156#define PHY_MODE_RGMII 2 157 158typedef NV_VOID (* PTIMER_FUNC) (PNV_VOID pvContext); 159 160#ifdef __cplusplus 161} // extern "C" 162#endif 163 164#endif //_PHY_H_ 165