1143439Sobrien/***************************************************************************\
2143439Sobrien|*                                                                           *|
3143439Sobrien|*       Copyright 2001-2004 NVIDIA Corporation.  All Rights Reserved.       *|
4143439Sobrien|*                                                                           *|
5143439Sobrien|*     THE INFORMATION CONTAINED HEREIN  IS PROPRIETARY AND CONFIDENTIAL     *|
6143439Sobrien|*     TO NVIDIA, CORPORATION.   USE,  REPRODUCTION OR DISCLOSURE TO ANY     *|
7143439Sobrien|*     THIRD PARTY IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORP.       *|
8143439Sobrien|*                                                                           *|
9143439Sobrien|*     THE INFORMATION CONTAINED HEREIN IS PROVIDED  "AS IS" WITHOUT         *|
10143439Sobrien|*     EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING ALL IMPLIED        *|
11143439Sobrien|*     WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A     *|
12143439Sobrien|*     PARTICULAR PURPOSE.                                                   *|
13143439Sobrien|*                                                                           *|
14143439Sobrien\***************************************************************************/
15143439Sobrien
16143439Sobrien/*
17143439Sobrien    FILE:   phy.h
18143439Sobrien    DATE:   2/7/00
19143439Sobrien
20143439Sobrien    This file contains the functional interface to the PHY.
21143439Sobrien*/
22143439Sobrien#ifndef _PHY_H_
23143439Sobrien#define _PHY_H_
24143439Sobrien
25143439Sobrien//#include "basetype.h"
26143439Sobrien//#include "nvevent.h"
27143439Sobrien
28143439Sobrien#ifdef __cplusplus
29143439Sobrienextern "C" {
30143439Sobrien#endif
31143439Sobrien
32143439Sobrien#define DEFAULT_PHY_ADDRESS   1
33143439Sobrien
34143439Sobrien
35143439Sobrien#define HDP_VERSION_STRING "HDR P: $Revision: #23 $"
36143439Sobrien
37143439Sobrien//
38143439Sobrien// Defaults for PHY timeout values.
39143439Sobrien//
40143439Sobrien#define PHY_POWER_ISOLATION_MS_TIMEOUT_DEFAULT      50
41143439Sobrien#define PHY_RESET_MS_TIMEOUT_DEFAULT                50
42143439Sobrien#define PHY_AUTONEG_MS_TIMEOUT_DEFAULT              3000
43143439Sobrien#define PHY_LINK_UP_MS_TIMEOUT_DEFAULT              2400
44143439Sobrien#define PHY_RDWR_US_TIMEOUT_DEFAULT                 2048
45143439Sobrien#define PHY_POWER_DOWN_US_TIMEOUT_DEFAULT           500
46143439Sobrien
47143439Sobrien
48143439Sobrien/////////////////////////////////////////////////////////////////////////
49143439Sobrien// The phy module knows the values that need to go into the phy registers
50143439Sobrien// but typically the method of writing those registers is controlled by
51143439Sobrien// another module (usually the adapter because it is really the hardware
52143439Sobrien// interface.) Hence, the phy needs routines to call to read and write the
53143439Sobrien// phy registers. This structure with appropriate routines will be provided
54143439Sobrien// in the PHY_Open call.
55143439Sobrien
56143439Sobrientypedef NV_API_CALL NV_SINT32 (* PFN_READ_PHY)  (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 *pulValue);
57143439Sobrientypedef NV_API_CALL NV_SINT32 (* PFN_WRITE_PHY) (PNV_VOID pvData, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 ulValue);
58143439Sobrien
59143439Sobrientypedef struct  PHY_SUPPORT_API
60143439Sobrien{
61143439Sobrien    PNV_VOID            pADCX;
62143439Sobrien    PFN_READ_PHY        pfnRead;
63143439Sobrien    PFN_WRITE_PHY       pfnWrite;
64143439Sobrien	// PFN_EVENT_OCCURED   pfnEventOccurred;
65143439Sobrien
66143439Sobrien    //
67143439Sobrien    // These fields are passed down via the FD.  FD get's them
68143439Sobrien    // from the registry.  They allow one to fine tune the timeout
69143439Sobrien    // values in the PHY.
70143439Sobrien    //
71143439Sobrien    NV_UINT32	PhyPowerIsolationTimeoutInms;
72143439Sobrien	NV_UINT32	PhyResetTimeoutInms;
73143439Sobrien	NV_UINT32	PhyAutonegotiateTimeoutInms;
74143439Sobrien	NV_UINT32	PhyLinkupTimeoutInms;
75143439Sobrien	NV_UINT32	PhyPowerdownOnCloseInus;
76143439Sobrien
77143439Sobrien}   PHY_SUPPORT_API, *PPHY_SUPPORT_API;
78143439Sobrien/////////////////////////////////////////////////////////////////////////
79143439Sobrien
80143439Sobrien
81143439Sobrien/////////////////////////////////////////////////////////////////////////
82143439Sobrien// The functional typedefs for the PHY Api
83143439Sobrientypedef NV_SINT32 (* PFN_PHY_INIT) (PNV_VOID pvContext, NV_UINT32 *pulLinkState, NV_UINT32 PhyMode);
84143439Sobrientypedef NV_SINT32 (* PFN_PHY_DEINIT) (PNV_VOID pvContext);
85143439Sobrientypedef NV_SINT32 (* PFN_PHY_CLOSE) (PNV_VOID pvContext);
86143439Sobrientypedef NV_SINT32 (* PFN_GET_LINK_SPEED) (PNV_VOID pvContext);
87143439Sobrientypedef NV_SINT32 (* PFN_GET_LINK_MODE) (PNV_VOID pvContext);
88143439Sobrientypedef NV_SINT32 (* PFN_GET_LINK_STATE) (PNV_VOID pvContext, NV_UINT32 *pulLinkState);
89143439Sobrientypedef NV_SINT32 (* PFN_IS_LINK_INITIALIZING) (PNV_VOID pvContext);
90143439Sobrientypedef NV_SINT32 (* PFN_RESET_PHY_INIT_STATE) (PNV_VOID pvContext);
91143439Sobrientypedef NV_SINT32 (* PFN_FORCE_SPEED_DUPLEX) (PNV_VOID pvContext, NV_UINT16 usSpeed, NV_UINT8 ucForceDpx, NV_UINT8 ucForceMode);
92143439Sobrientypedef NV_SINT32 (* PFN_PHY_POWERDOWN) (PNV_VOID pvContext);
93143439Sobrientypedef NV_SINT32 (* PFN_SET_LOW_SPEED_FOR_PM) (PNV_VOID pvContext);
94143439Sobrien
95143439Sobrien
96143439Sobrientypedef struct  _PHY_API
97143439Sobrien{
98143439Sobrien    // This is the context to pass back in as the first arg on all
99143439Sobrien    // the calls in the API below.
100143439Sobrien    PNV_VOID               pPHYCX;
101143439Sobrien
102143439Sobrien    PFN_PHY_INIT                pfnInit;
103143439Sobrien    PFN_PHY_INIT                pfnInitFast;
104143439Sobrien    PFN_PHY_DEINIT                pfnDeinit;
105143439Sobrien    PFN_PHY_CLOSE                pfnClose;
106143439Sobrien    PFN_GET_LINK_SPEED            pfnGetLinkSpeed;
107143439Sobrien    PFN_GET_LINK_MODE            pfnGetLinkMode;
108143439Sobrien    PFN_GET_LINK_STATE            pfnGetLinkState;
109143439Sobrien    PFN_IS_LINK_INITIALIZING    pfnIsLinkInitializing;
110143439Sobrien    PFN_RESET_PHY_INIT_STATE    pfnResetPhyInitState;
111143439Sobrien    PFN_FORCE_SPEED_DUPLEX        pfnForceSpeedDuplex;
112143439Sobrien    PFN_PHY_POWERDOWN            pfnPowerdown;
113143439Sobrien    PFN_SET_LOW_SPEED_FOR_PM    pfnSetLowSpeedForPM;
114143439Sobrien}   PHY_API, *PPHY_API;
115143439Sobrien/////////////////////////////////////////////////////////////////////////
116143439Sobrien
117143439Sobrien
118143439Sobrien/////////////////////////////////////////////////////////////////////////
119143439Sobrien// This is the one function in the PHY interface that is publicly
120143439Sobrien// available. The rest of the interface is returned in the pPhyApi;
121143439Sobrien// The first argument needs to be cast to a POS_API structure ptr.
122143439Sobrien// On input the second argument is a ptr to a PPHY_SUPPORT_API.
123143439Sobrien// On output, the second argument should be treated as a ptr to a
124143439Sobrien// PPHY_API and set appropriately.
125143439Sobrienextern NV_SINT32 PHY_Open (PNV_VOID pvOSApi, PNV_VOID pPhyApi, NV_UINT32 *pulPhyAddr, NV_UINT32 *pulPhyConnected);
126143439Sobrien/////////////////////////////////////////////////////////////////////////
127143439Sobrien
128143439Sobrien
129143439Sobrien/////////////////////////////////////////////////////////////////////////
130143439Sobrien// Here are the error codes the phy functions can return.
131143439Sobrien#define PHYERR_NONE                                 0x0000
132143439Sobrien#define PHYERR_COULD_NOT_ALLOC_CONTEXT              0x0001
133143439Sobrien#define PHYERR_RESET_NEVER_FINISHED                 0x0002
134143439Sobrien#define PHYERR_NO_AVAILABLE_LINK_SPEED              0x0004
135143439Sobrien#define PHYERR_INVALID_SETTINGS                     0x0005
136143439Sobrien#define PHYERR_READ_FAILED                          0x0006
137143439Sobrien#define PHYERR_WRITE_FAILED                         0x0007
138143439Sobrien#define PHYERR_NO_PHY                               0x0008
139143439Sobrien#define PHYERR_NO_RESOURCE                          0x0009
140143439Sobrien#define PHYERR_POWER_ISOLATION_TIMEOUT              0x000A
141143439Sobrien#define PHYERR_POWER_DOWN_TIMEOUT                   0x000B
142143439Sobrien#define PHYERR_AUTONEG_TIMEOUT                      0x000C
143143439Sobrien#define PHYERR_PHY_LINK_SPEED_UNCHANGED             0x000D
144143439Sobrien
145143439Sobrien#define PHY_INVALID_PHY_ADDR                    0xFFFF;
146143439Sobrien
147143439Sobrien/////////////////////////////////////////////////////////////////////////
148143439Sobrien
149143439Sobrien// This value can be used in the ulPhyLinkSpeed field.
150143439Sobrien#define PHY_LINK_SPEED_UNKNOWN          0x0FFFFFFFF
151143439Sobrien
152143439Sobrien//
153143439Sobrien// Values used to configure PHY mode.
154143439Sobrien//
155143439Sobrien#define PHY_MODE_MII    1
156143439Sobrien#define PHY_MODE_RGMII  2
157143439Sobrien
158143439Sobrientypedef NV_VOID (* PTIMER_FUNC) (PNV_VOID pvContext);
159143439Sobrien
160143439Sobrien#ifdef __cplusplus
161143439Sobrien} // extern "C"
162143439Sobrien#endif
163143439Sobrien
164143439Sobrien#endif //_PHY_H_
165