1 /***************************************************************************\
3 |* Copyright 2001-2004 NVIDIA Corporation. All Rights Reserved. *|
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. *|
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. *|
14 \***************************************************************************/
20 This file contains the functional interface to the PHY.
25 //#include "basetype.h"
26 //#include "nvevent.h"
32 #define DEFAULT_PHY_ADDRESS 1
35 #define HDP_VERSION_STRING "HDR P: $Revision: #23 $"
38 // Defaults for PHY timeout values.
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
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.
56 typedef NV_API_CALL NV_SINT32 (* PFN_READ_PHY) (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 *pulValue);
57 typedef NV_API_CALL NV_SINT32 (* PFN_WRITE_PHY) (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 ulValue);
59 typedef struct PHY_SUPPORT_API
63 PFN_WRITE_PHY pfnWrite;
64 // PFN_EVENT_OCCURED pfnEventOccurred;
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
71 NV_UINT32 PhyPowerIsolationTimeoutInms;
72 NV_UINT32 PhyResetTimeoutInms;
73 NV_UINT32 PhyAutonegotiateTimeoutInms;
74 NV_UINT32 PhyLinkupTimeoutInms;
75 NV_UINT32 PhyPowerdownOnCloseInus;
77 } PHY_SUPPORT_API, *PPHY_SUPPORT_API;
78 /////////////////////////////////////////////////////////////////////////
81 /////////////////////////////////////////////////////////////////////////
82 // The functional typedefs for the PHY Api
83 typedef NV_SINT32 (* PFN_PHY_INIT) (PNV_VOID pvContext, NV_UINT32 *pulLinkState, NV_UINT32 PhyMode);
84 typedef NV_SINT32 (* PFN_PHY_DEINIT) (PNV_VOID pvContext);
85 typedef NV_SINT32 (* PFN_PHY_CLOSE) (PNV_VOID pvContext);
86 typedef NV_SINT32 (* PFN_GET_LINK_SPEED) (PNV_VOID pvContext);
87 typedef NV_SINT32 (* PFN_GET_LINK_MODE) (PNV_VOID pvContext);
88 typedef NV_SINT32 (* PFN_GET_LINK_STATE) (PNV_VOID pvContext, NV_UINT32 *pulLinkState);
89 typedef NV_SINT32 (* PFN_IS_LINK_INITIALIZING) (PNV_VOID pvContext);
90 typedef NV_SINT32 (* PFN_RESET_PHY_INIT_STATE) (PNV_VOID pvContext);
91 typedef NV_SINT32 (* PFN_FORCE_SPEED_DUPLEX) (PNV_VOID pvContext, NV_UINT16 usSpeed, NV_UINT8 ucForceDpx, NV_UINT8 ucForceMode);
92 typedef NV_SINT32 (* PFN_PHY_POWERDOWN) (PNV_VOID pvContext);
93 typedef NV_SINT32 (* PFN_SET_LOW_SPEED_FOR_PM) (PNV_VOID pvContext);
96 typedef struct _PHY_API
98 // This is the context to pass back in as the first arg on all
99 // the calls in the API below.
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 /////////////////////////////////////////////////////////////////////////
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.
125 extern NV_SINT32 PHY_Open (PNV_VOID pvOSApi, PNV_VOID pPhyApi, NV_UINT32 *pulPhyAddr, NV_UINT32 *pulPhyConnected);
126 /////////////////////////////////////////////////////////////////////////
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
145 #define PHY_INVALID_PHY_ADDR 0xFFFF;
147 /////////////////////////////////////////////////////////////////////////
149 // This value can be used in the ulPhyLinkSpeed field.
150 #define PHY_LINK_SPEED_UNKNOWN 0x0FFFFFFFF
153 // Values used to configure PHY mode.
155 #define PHY_MODE_MII 1
156 #define PHY_MODE_RGMII 2
158 typedef NV_VOID (* PTIMER_FUNC) (PNV_VOID pvContext);