1254721Semaste/***************************************************************************\
2254721Semaste|*                                                                           *|
3254721Semaste|*       Copyright 2001-2004 NVIDIA Corporation.  All Rights Reserved.       *|
4254721Semaste|*                                                                           *|
5254721Semaste|*     THE INFORMATION CONTAINED HEREIN  IS PROPRIETARY AND CONFIDENTIAL     *|
6254721Semaste|*     TO NVIDIA, CORPORATION.   USE,  REPRODUCTION OR DISCLOSURE TO ANY     *|
7254721Semaste|*     THIRD PARTY IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORP.       *|
8254721Semaste|*                                                                           *|
9254721Semaste|*     THE INFORMATION CONTAINED HEREIN IS PROVIDED  "AS IS" WITHOUT         *|
10254721Semaste|*     EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING ALL IMPLIED        *|
11254721Semaste|*     WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A     *|
12254721Semaste|*     PARTICULAR PURPOSE.                                                   *|
13254721Semaste|*                                                                           *|
14254721Semaste\***************************************************************************/
15254721Semaste
16254721Semaste/*
17254721Semaste    FILE:   phy.h
18254721Semaste    DATE:   2/7/00
19254721Semaste
20254721Semaste    This file contains the functional interface to the PHY.
21254721Semaste*/
22254721Semaste#ifndef _PHY_H_
23254721Semaste#define _PHY_H_
24254721Semaste
25254721Semaste//#include "basetype.h"
26254721Semaste//#include "nvevent.h"
27254721Semaste
28254721Semaste#ifdef __cplusplus
29254721Semasteextern "C" {
30254721Semaste#endif
31254721Semaste
32254721Semaste#define DEFAULT_PHY_ADDRESS   1
33254721Semaste
34254721Semaste
35254721Semaste#define HDP_VERSION_STRING "HDR P: $Revision: #23 $"
36254721Semaste
37254721Semaste//
38254721Semaste// Defaults for PHY timeout values.
39254721Semaste//
40254721Semaste#define PHY_POWER_ISOLATION_MS_TIMEOUT_DEFAULT      50
41254721Semaste#define PHY_RESET_MS_TIMEOUT_DEFAULT                50
42254721Semaste#define PHY_AUTONEG_MS_TIMEOUT_DEFAULT              3000
43254721Semaste#define PHY_LINK_UP_MS_TIMEOUT_DEFAULT              2400
44254721Semaste#define PHY_RDWR_US_TIMEOUT_DEFAULT                 2048
45254721Semaste#define PHY_POWER_DOWN_US_TIMEOUT_DEFAULT           500
46254721Semaste
47254721Semaste
48254721Semaste/////////////////////////////////////////////////////////////////////////
49254721Semaste// The phy module knows the values that need to go into the phy registers
50254721Semaste// but typically the method of writing those registers is controlled by
51254721Semaste// another module (usually the adapter because it is really the hardware
52254721Semaste// interface.) Hence, the phy needs routines to call to read and write the
53254721Semaste// phy registers. This structure with appropriate routines will be provided
54254721Semaste// in the PHY_Open call.
55254721Semaste
56254721Semastetypedef NV_API_CALL NV_SINT32 (* PFN_READ_PHY)  (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 *pulValue);
57254721Semastetypedef NV_API_CALL NV_SINT32 (* PFN_WRITE_PHY) (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 ulValue);
58254721Semaste
59254721Semastetypedef struct  PHY_SUPPORT_API
60254721Semaste{
61254721Semaste    PNV_VOID            pADCX;
62254721Semaste    PFN_READ_PHY        pfnRead;
63254721Semaste    PFN_WRITE_PHY       pfnWrite;
64254721Semaste	// PFN_EVENT_OCCURED   pfnEventOccurred;
65254721Semaste
66254721Semaste    //
67254721Semaste    // These fields are passed down via the FD.  FD get's them
68254721Semaste    // from the registry.  They allow one to fine tune the timeout
69254721Semaste    // values in the PHY.
70254721Semaste    //
71254721Semaste    NV_UINT32	PhyPowerIsolationTimeoutInms;
72254721Semaste	NV_UINT32	PhyResetTimeoutInms;
73254721Semaste	NV_UINT32	PhyAutonegotiateTimeoutInms;
74254721Semaste	NV_UINT32	PhyLinkupTimeoutInms;
75254721Semaste	NV_UINT32	PhyPowerdownOnCloseInus;
76254721Semaste
77254721Semaste}   PHY_SUPPORT_API, *PPHY_SUPPORT_API;
78254721Semaste/////////////////////////////////////////////////////////////////////////
79254721Semaste
80254721Semaste
81254721Semaste/////////////////////////////////////////////////////////////////////////
82254721Semaste// The functional typedefs for the PHY Api
83254721Semastetypedef NV_SINT32 (* PFN_PHY_INIT) (PNV_VOID pvContext, NV_UINT32 *pulLinkState, NV_UINT32 PhyMode);
84254721Semastetypedef NV_SINT32 (* PFN_PHY_DEINIT) (PNV_VOID pvContext);
85254721Semastetypedef NV_SINT32 (* PFN_PHY_CLOSE) (PNV_VOID pvContext);
86254721Semastetypedef NV_SINT32 (* PFN_GET_LINK_SPEED) (PNV_VOID pvContext);
87254721Semastetypedef NV_SINT32 (* PFN_GET_LINK_MODE) (PNV_VOID pvContext);
88254721Semastetypedef NV_SINT32 (* PFN_GET_LINK_STATE) (PNV_VOID pvContext, NV_UINT32 *pulLinkState);
89254721Semastetypedef NV_SINT32 (* PFN_IS_LINK_INITIALIZING) (PNV_VOID pvContext);
90254721Semastetypedef NV_SINT32 (* PFN_RESET_PHY_INIT_STATE) (PNV_VOID pvContext);
91254721Semastetypedef NV_SINT32 (* PFN_FORCE_SPEED_DUPLEX) (PNV_VOID pvContext, NV_UINT16 usSpeed, NV_UINT8 ucForceDpx, NV_UINT8 ucForceMode);
92254721Semastetypedef NV_SINT32 (* PFN_PHY_POWERDOWN) (PNV_VOID pvContext);
93254721Semastetypedef NV_SINT32 (* PFN_SET_LOW_SPEED_FOR_PM) (PNV_VOID pvContext);
94254721Semaste
95254721Semaste
96254721Semastetypedef struct  _PHY_API
97254721Semaste{
98254721Semaste    // This is the context to pass back in as the first arg on all
99254721Semaste    // the calls in the API below.
100254721Semaste    PNV_VOID               pPHYCX;
101254721Semaste
102254721Semaste    PFN_PHY_INIT                pfnInit;
103254721Semaste    PFN_PHY_INIT                pfnInitFast;
104254721Semaste    PFN_PHY_DEINIT                pfnDeinit;
105254721Semaste    PFN_PHY_CLOSE                pfnClose;
106254721Semaste    PFN_GET_LINK_SPEED            pfnGetLinkSpeed;
107254721Semaste    PFN_GET_LINK_MODE            pfnGetLinkMode;
108254721Semaste    PFN_GET_LINK_STATE            pfnGetLinkState;
109254721Semaste    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