/**
* @file icss_ethdriver.h
*
* @brief
*
* \par
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
* \par
*/

#ifndef ICSS_ETHDRIVER_H_
#define ICSS_ETHDRIVER_H_

#include "icss_iSwitchDrv.h"

/**
* @def Ten_Mbps
*      This value in the MDIO Reg means 10 mbps mode is enabled
*/
#define Ten_Mbps  0xa
/**
* @def Hundread_Mbps
*      This value in the MDIO Reg means 100 mbps mode is enabled
*/
#define Hundread_Mbps 0x64
/**
* @def HALF_DUPLEX_BITMASK
*      Duplex information for TLK 110
*/
#define HALF_DUPLEX_BITMASK			0x4
/**
* @def PHY_SPEED_BITMASK
*      Speed information for TLK 110
*/
#define PHY_SPEED_BITMASK			0x2
/**
* @def PHYBMSR_OFFSET
*      BMSR register offset for TLK110
*/
#define PHYBMSR_OFFSET				0x1
/**
* @def PHYSTS_OFFSET
*      PHY Status register offset for TLK110
*/
#define PHYSTS_OFFSET				0x10
/**
* @def HALF_DUPLEX_TYPE
*      Half Duplex Type
*/
#define HALF_DUPLEX_TYPE			0x1
/**
* @def FULL_DUPLEX_TYPE
*      Full Duplex Type
*/
#define FULL_DUPLEX_TYPE			0x2

/**
 * @ingroup link_change_notification_t
 *
 * The @ref link_change_notification_t routine prototype is used for the registraton
 * of a callback routine called
 * by the the ethernet driver on a link change of an ethernet port.
 *
 * @param link_status corresponding to the MDIO Link Status Values definition in icss_middio.h
 * -->
 *    MDIO Link Status Values
 *
 *    These values indicate current PHY link status.
 *    Codes are constructed as follows
 *    Bit0: 0  for HD, 1 for FullDuplex
 *    Bit[2:1]: 10Mbps- 1, 100Mbps - 2, 1000Mbps - 3
 *
 *     MDIO_LINKSTATUS_NOLINK    0u
 *     MDIO_LINKSTATUS_HD10      2u
 *     MDIO_LINKSTATUS_FD10      3u
 *     MDIO_LINKSTATUS_HD100     4u
 *     MDIO_LINKSTATUS_FD100     5u
 *     MDIO_LINKSTATUS_FD1000    7u
 * @param port Port number - Port1 = 0, Port2 = 1
 *
 *-----------------------------------------------------------------------*/
typedef void (*link_change_notification_t)(UInt32 link_status, UInt32 port);

/**
* @brief  EthdriverRegisterLinkChangeNotification routine allows the
*			registration of a notification routine called by the driver on a
*			link change on an ethernet port
*
* @param routine Pointer to the registration routine
*
* @retval none
*/
void EthdriverRegisterLinkChangeNotification(link_change_notification_t routine);
/**
* @brief Callback function to process protocol specific handler for link status ISR
*
* @param callBack	Callback function pointer
* @param userArg	user specific parameter
*
* @retval none
*/
void RegisterPort0ISRCallback(icssCallBack_t callBack, void *userArg);
/**
* @brief Callback function to process protocol specific handler for link status ISR
*
* @param callBack	Callback function pointer
* @param userArg	user specific parameter
*
* @retval none
*/
void RegisterPort1ISRCallback(icssCallBack_t callBack, void *userArg);
/**
* @brief Function to fetch the link status of a port
*
* @param port	port number
*
* @retval 1 if link is up and 0 if link is down
*/
UInt8 GetLinkStatus(UInt32 port);
/**
* @brief API to Configure MDI/X Mode of PHY
*
* @param mdiState	Callback function pointer
*                   MDIO_ENABLE_FORCE_MDI
*                   MDIO_ENABLE_FORCE_MDIX
*                   MDIO_ENABLE_AUTO_MDIX
* @param portNum	HWPORT0(0)
*                   HWPORT1(1)
*
* @retval none
*/
void SetPhyMDIX(Uint8 mdiState,Uint8 portNum);

/**
* @brief API to Change Phy Configuration
*
* @param phyConfig	PHY_CONFIG_AUTONEG
*                   PHY_CONFIG_100FD
*                   PHY_CONFIG_10FD
*                   PHY_CONFIG_100HD
* @param portNum	HWPORT0(0)
*                   HWPORT1(1)
*
* @retval none
*/
void SetPhyConfig(Uint8 phyConfig,Uint8 portNum);

/**
* @brief  API to Enable Power Saving mode in PHY
*
* @param portNum	Callback function pointer
*                   HWPORT0(0)
*                   HWPORT1(1)
*
* @retval none
*/
void EnablePhyPowerSaveMode(Uint8 portNum);

/**
* @brief API to force Power Saving mode in PHY
*
* @param phyPowerMode	MDIO_POWERMODE_NORMAL
*                   MDIO_POWERMODE_DOWN
*                   MDIO_POWERMODE_ACTIVE_SLEEP
*                   MDIO_POWERMODE_PASSIVE_SLEEP
* @param portNum	HWPORT0(0)
*                   HWPORT1(1)
*
* @retval none
*/
void SetPhyPowerSaveMode(Uint8 phyPowerMode,Uint8 portNum);
/**
* @brief Poll PHY and find if link settings have been modified, set variable in memory
*
* @param portNum Port Number. 0/1
*
* @retval none
*/
void updatePHYStatus(Uint8 portNum);
/**
* @brief returns the PHY speed status for a port
*
* @param portNum Port Number. 0/1
*
* @retval Status. 0 means 10mbps and 1 means 100 mbps. 2 means undefined.
*/
Uint8 getSpeedStatus(Uint8 portNum);

/**
* @brief returns the PHY duplex status for a port
*
* @param portNum Port Number. 0/1
*
* @retval Status. 1 means Half Duplex and 0 means Full Duplex. 2 means not defined
*/
Uint8 getDuplexStatus(Uint8 portNum);
/**
* @brief Function to register callback function to process periodic protocol processing
*
* @param callBack	Callback function pointer
*
* @retval none
*/
void RegisterPeriodicCallback(icssCallBack_t callBack);

#endif /* ICSS_ETHDRIVER_H_ */
