Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
30
sdk/include/lib/net/ethphy/eth_mdio_bus.h
Normal file
30
sdk/include/lib/net/ethphy/eth_mdio_bus.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef __ETH_MDIO_BUS_H_
|
||||
#define __ETH_MDIO_BUS_H_
|
||||
|
||||
struct netdev;
|
||||
|
||||
/*
|
||||
* The Bus class for PHYs. Devices which provide access to
|
||||
* PHYs should register using this structure
|
||||
*/
|
||||
struct ethernet_mdio_bus {
|
||||
struct dev_obj dev;
|
||||
|
||||
void *priv;
|
||||
int (*read)(void *priv, uint16 phy_addr, uint16 regnum);
|
||||
int (*write)(void *priv, uint16 phy_addr, uint16 regnum, uint16 val);
|
||||
|
||||
/*
|
||||
* A lock to ensure that only one thing can read/write
|
||||
* the MDIO bus at a time
|
||||
*/
|
||||
// struct mutex mdio_lock;
|
||||
};
|
||||
|
||||
int32 eth_mdio_bus_attach(uint32 dev_id, struct ethernet_mdio_bus *p_mii_bus);
|
||||
int32 eth_mdio_bus_open(struct ethernet_mdio_bus *p_mii_bus, struct netdev *p_netdev);
|
||||
int32 eth_mdio_bus_close(struct ethernet_mdio_bus *p_mii_bus);
|
||||
int32 eth_mdio_bus_write(struct ethernet_mdio_bus *p_mii_bus, uint16 phy_addr, uint16 reg_addr, uint16 data);
|
||||
int32 eth_mdio_bus_read(struct ethernet_mdio_bus *p_mii_bus, uint16 phy_addr, uint16 reg_addr);
|
||||
|
||||
#endif
|
||||
386
sdk/include/lib/net/ethphy/eth_phy.h
Normal file
386
sdk/include/lib/net/ethphy/eth_phy.h
Normal file
@@ -0,0 +1,386 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sdk/include/lib/ethernet_phy/eth_phy.h
|
||||
* @author HUGE-IC Application Team
|
||||
* @version V1.0.0
|
||||
* @date 10-10-2018
|
||||
* @brief Framework and drivers for configuring and reading different PHYs
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2018 HUGE-IC</center></h2>
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __ETH_PHY_H__
|
||||
#define __ETH_PHY_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "ethtool.h"
|
||||
#include "mii.h"
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/** @weakgroup NETWORK_PHY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup NETWORK_PHY_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define PHY_ADAPTIVE_ADDR -1
|
||||
|
||||
#define PHY_INIT_TIMEOUT 100000
|
||||
#define PHY_STATE_TIME 1
|
||||
#define PHY_FORCE_TIMEOUT 10
|
||||
#define PHY_AN_TIMEOUT 10
|
||||
|
||||
#define PHY_MAX_ADDR 32
|
||||
|
||||
#define PHY_BASIC_FEATURES (SUPPORTED_10baseT_Half | \
|
||||
SUPPORTED_10baseT_Full | \
|
||||
SUPPORTED_100baseT_Half | \
|
||||
SUPPORTED_100baseT_Full | \
|
||||
SUPPORTED_Autoneg | \
|
||||
SUPPORTED_TP | \
|
||||
SUPPORTED_MII)
|
||||
|
||||
#define PHY_GBIT_FEATURES (PHY_BASIC_FEATURES | \
|
||||
SUPPORTED_1000baseT_Half | \
|
||||
SUPPORTED_1000baseT_Full)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup NETWORK_PHY_Exported_Typedefs Exported Typedefs
|
||||
* @{
|
||||
*/
|
||||
|
||||
struct netdev;
|
||||
struct ethernet_phy_device;
|
||||
|
||||
/* PHY state machine states:
|
||||
*
|
||||
* DOWN: PHY device and driver are not ready for anything. probe
|
||||
* should be called if and only if the PHY is in this state,
|
||||
* given that the PHY device exists.
|
||||
* - PHY driver probe function will, depending on the PHY, set
|
||||
* the state to STARTING or READY
|
||||
*
|
||||
* STARTING: PHY device is coming up, and the ethernet driver is
|
||||
* not ready. PHY drivers may set this in the probe function.
|
||||
* If they do, they are responsible for making sure the state is
|
||||
* eventually set to indicate whether the PHY is UP or READY,
|
||||
* depending on the state when the PHY is done starting up.
|
||||
* - PHY driver will set the state to READY
|
||||
* - start will set the state to PENDING
|
||||
*
|
||||
* READY: PHY is ready to send and receive packets, but the
|
||||
* controller is not. By default, PHYs which do not implement
|
||||
* probe will be set to this state by phy_probe(). If the PHY
|
||||
* driver knows the PHY is ready, and the PHY state is STARTING,
|
||||
* then it sets this STATE.
|
||||
* - start will set the state to UP
|
||||
*
|
||||
* PENDING: PHY device is coming up, but the ethernet driver is
|
||||
* ready. phy_start will set this state if the PHY state is
|
||||
* STARTING.
|
||||
* - PHY driver will set the state to UP when the PHY is ready
|
||||
*
|
||||
* UP: The PHY and attached device are ready to do work.
|
||||
* Interrupts should be started here.
|
||||
* - timer moves to AN
|
||||
*
|
||||
* AN: The PHY is currently negotiating the link state. Link is
|
||||
* therefore down for now. phy_timer will set this state when it
|
||||
* detects the state is UP. config_aneg will set this state
|
||||
* whenever called with phydev->autoneg set to AUTONEG_ENABLE.
|
||||
* - If autonegotiation finishes, but there's no link, it sets
|
||||
* the state to NOLINK.
|
||||
* - If aneg finishes with link, it sets the state to RUNNING,
|
||||
* and calls adjust_link
|
||||
* - If autonegotiation did not finish after an arbitrary amount
|
||||
* of time, autonegotiation should be tried again if the PHY
|
||||
* supports "magic" autonegotiation (back to AN)
|
||||
* - If it didn't finish, and no magic_aneg, move to FORCING.
|
||||
*
|
||||
* NOLINK: PHY is up, but not currently plugged in.
|
||||
* - If the timer notes that the link comes back, we move to RUNNING
|
||||
* - config_aneg moves to AN
|
||||
* - phy_stop moves to HALTED
|
||||
*
|
||||
* FORCING: PHY is being configured with forced settings
|
||||
* - if link is up, move to RUNNING
|
||||
* - If link is down, we drop to the next highest setting, and
|
||||
* retry (FORCING) after a timeout
|
||||
* - phy_stop moves to HALTED
|
||||
*
|
||||
* RUNNING: PHY is currently up, running, and possibly sending
|
||||
* and/or receiving packets
|
||||
* - timer will set CHANGELINK if we're polling (this ensures the
|
||||
* link state is polled every other cycle of this state machine,
|
||||
* which makes it every other second)
|
||||
* - irq will set CHANGELINK
|
||||
* - config_aneg will set AN
|
||||
* - phy_stop moves to HALTED
|
||||
*
|
||||
* CHANGELINK: PHY experienced a change in link state
|
||||
* - timer moves to RUNNING if link
|
||||
* - timer moves to NOLINK if the link is down
|
||||
* - phy_stop moves to HALTED
|
||||
*
|
||||
* HALTED: PHY is up, but no polling or interrupts are done. Or
|
||||
* PHY is in an error state.
|
||||
*
|
||||
* - phy_start moves to RESUMING
|
||||
*
|
||||
* RESUMING: PHY was halted, but now wants to run again.
|
||||
* - If we are forcing, or aneg is done, timer moves to RUNNING
|
||||
* - If aneg is not done, timer moves to AN
|
||||
* - phy_stop moves to HALTED
|
||||
*/
|
||||
enum ethernet_phy_state {
|
||||
ETH_PHY_DOWN = 0,
|
||||
ETH_PHY_STARTING,
|
||||
ETH_PHY_READY,
|
||||
ETH_PHY_PENDING,
|
||||
ETH_PHY_UP,
|
||||
ETH_PHY_AN,
|
||||
ETH_PHY_RUNNING,
|
||||
ETH_PHY_NOLINK,
|
||||
ETH_PHY_FORCING,
|
||||
ETH_PHY_CHANGELINK,
|
||||
ETH_PHY_HALTED,
|
||||
ETH_PHY_RESUMING
|
||||
};
|
||||
|
||||
/* struct phy_driver: Driver structure for a particular PHY type
|
||||
*
|
||||
* phy_id: The result of reading the UID registers of this PHY
|
||||
* type, and ANDing them with the phy_id_mask. This driver
|
||||
* only works for PHYs with IDs which match this field
|
||||
* name: The friendly name of this PHY type
|
||||
* phy_id_mask: Defines the important bits of the phy_id
|
||||
* features: A list of features (speed, duplex, etc) supported
|
||||
* by this PHY
|
||||
* flags: A bitfield defining certain other features this PHY
|
||||
* supports (like interrupts)
|
||||
*
|
||||
* The drivers must implement config_aneg and read_status. All
|
||||
* other functions are optional. Note that none of these
|
||||
* functions should be called from interrupt time. The goal is
|
||||
* for the bus read/write functions to be able to block when the
|
||||
* bus transaction is happening, and be freed up by an interrupt
|
||||
* (The MPC85xx has this ability, though it is not currently
|
||||
* supported in the driver).
|
||||
*/
|
||||
struct ethernet_phy_driver {
|
||||
uint32 features;
|
||||
|
||||
/*
|
||||
* Called to initialize the PHY,
|
||||
* including after a reset
|
||||
*/
|
||||
int (*config_init)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/*
|
||||
* Called during discovery. Used to set
|
||||
* up device-specific structures, if any
|
||||
*/
|
||||
// int (*probe)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/* PHY Power Management */
|
||||
// int (*suspend)(struct ethernet_phy_device *phydev);
|
||||
// int (*resume)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/*
|
||||
* Configures the advertisement and resets
|
||||
* autonegotiation if phydev->autoneg is on,
|
||||
* forces the speed to the current settings in phydev
|
||||
* if phydev->autoneg is off
|
||||
*/
|
||||
int (*config_aneg)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/* Determines the negotiated speed and duplex */
|
||||
int (*read_status)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/* Clears any pending interrupts */
|
||||
// int (*ack_interrupt)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/* Enables or disables interrupts */
|
||||
// int (*config_intr)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/*
|
||||
* Checks if the PHY generated an interrupt.
|
||||
* For multi-PHY devices with shared PHY interrupt pin
|
||||
*/
|
||||
// int (*did_interrupt)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/* Clears up any memory if needed */
|
||||
// void (*remove)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/* Returns true if this is a suitable driver for the given
|
||||
* phydev. If NULL, matching is based on phy_id and
|
||||
* phy_id_mask.
|
||||
*/
|
||||
// int (*match_phy_device)(struct ethernet_phy_device *phydev);
|
||||
|
||||
/* Handles ethtool queries for hardware time stamping. */
|
||||
// int (*ts_info)(struct ethernet_phy_device *phydev, struct ethtool_ts_info *ti);
|
||||
|
||||
/* Handles SIOCSHWTSTAMP ioctl for hardware time stamping. */
|
||||
// int (*hwtstamp)(struct ethernet_phy_device *phydev, struct ifreq *ifr);
|
||||
|
||||
/*
|
||||
* Requests a Rx timestamp for 'skb'. If the skb is accepted,
|
||||
* the phy driver promises to deliver it using netif_rx() as
|
||||
* soon as a timestamp becomes available. One of the
|
||||
* PTP_CLASS_ values is passed in 'type'. The function must
|
||||
* return true if the skb is accepted for delivery.
|
||||
*/
|
||||
// bool (*rxtstamp)(struct ethernet_phy_device *dev, struct sk_buff *skb, int type);
|
||||
|
||||
/*
|
||||
* Requests a Tx timestamp for 'skb'. The phy driver promises
|
||||
* to deliver it using skb_complete_tx_timestamp() as soon as a
|
||||
* timestamp becomes available. One of the PTP_CLASS_ values
|
||||
* is passed in 'type'.
|
||||
*/
|
||||
// void (*txtstamp)(struct ethernet_phy_device *dev, struct sk_buff *skb, int type);
|
||||
|
||||
/* Some devices (e.g. qnap TS-119P II) require PHY register changes to
|
||||
* enable Wake on LAN, so set_wol is provided to be called in the
|
||||
* ethernet driver's set_wol function. */
|
||||
// int (*set_wol)(struct ethernet_phy_device *dev, struct ethtool_wolinfo *wol);
|
||||
|
||||
/* See set_wol, but for checking whether Wake on LAN is enabled. */
|
||||
// void (*get_wol)(struct ethernet_phy_device *dev, struct ethtool_wolinfo *wol);
|
||||
};
|
||||
|
||||
/* phy_device: An instance of a PHY
|
||||
*
|
||||
* p_emac_dev: Pointer to the bus this PHY is on
|
||||
* phy_id: UID for this device found during discovery
|
||||
* state: state of the PHY for management purposes
|
||||
* addr: Bus address of PHY
|
||||
* link_timeout: The number of timer firings to wait before the
|
||||
* giving up on the current attempt at acquiring a link
|
||||
* adjust_link: Callback for the enet controller to respond to
|
||||
* changes in the link state.
|
||||
* adjust_state: Callback for the enet driver to respond to
|
||||
* changes in the state machine.
|
||||
*
|
||||
* speed, duplex, pause, supported, advertising, and
|
||||
* autoneg are used like in mii_if_info
|
||||
*
|
||||
* interrupts currently only supports enabled or disabled,
|
||||
* but could be changed in the future to support enabling
|
||||
* and disabling specific interrupts
|
||||
*
|
||||
* Contains some infrastructure for polling and interrupt
|
||||
* handling, as well as handling shifts in PHY hardware state
|
||||
*/
|
||||
struct ethernet_phy_device {
|
||||
struct dev_obj dev;
|
||||
|
||||
/* Bus address of the PHY (0-31) */
|
||||
int16 addr;
|
||||
/* phy driver pointer */
|
||||
struct ethernet_phy_driver *drv;
|
||||
|
||||
struct ethernet_mdio_bus *bus;
|
||||
|
||||
struct netdev *ndev;
|
||||
|
||||
uint32 phy_id;
|
||||
|
||||
enum ethernet_phy_state state;
|
||||
|
||||
/*
|
||||
* forced speed & duplex (no autoneg)
|
||||
* partner speed & duplex & pause (autoneg)
|
||||
*/
|
||||
int16 speed;
|
||||
int16 duplex;
|
||||
int16 pause;
|
||||
int16 asym_pause;
|
||||
|
||||
/* The most recently read link state */
|
||||
int16 link;
|
||||
|
||||
/* Union of PHY and Attached devices' supported modes */
|
||||
/* See mii.h for more info */
|
||||
uint32 supported;
|
||||
uint32 advertising;
|
||||
|
||||
uint32 autoneg;
|
||||
|
||||
uint32 link_timeout;
|
||||
|
||||
/* last state */
|
||||
int16 last_speed;
|
||||
int16 last_duplex;
|
||||
int16 last_link;
|
||||
|
||||
//os_task_t task;
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup NETWORK_PHY_Exported_Functions Exported Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern struct ethernet_phy_driver genphy_driver;
|
||||
|
||||
uint16 phy_read(struct ethernet_phy_device *phydev, uint16 reg);
|
||||
void phy_write(struct ethernet_phy_device *phydev, uint16 reg, uint16 val);
|
||||
|
||||
void eth_phy_device_create(struct ethernet_phy_device *dev);
|
||||
uint8 eth_get_phy_device(struct ethernet_phy_device *dev);
|
||||
int32 eth_phy_connect_direct(struct ethernet_phy_device *phydev);
|
||||
uint8 eth_phy_start_aneg(struct ethernet_phy_device *phydev);
|
||||
|
||||
int genphy_config_init(struct ethernet_phy_device *phydev);
|
||||
int genphy_restart_aneg(struct ethernet_phy_device *phydev);
|
||||
int genphy_config_aneg(struct ethernet_phy_device *phydev);
|
||||
int genphy_update_link(struct ethernet_phy_device *phydev);
|
||||
int genphy_read_status(struct ethernet_phy_device *phydev);
|
||||
void eth_phy_state_machine(struct ethernet_phy_device *phydev);
|
||||
void eth_phy_start_machine(struct ethernet_phy_device *phydev);
|
||||
|
||||
int32 eth_phy_open(struct ethernet_phy_device *phydev, struct ethernet_mdio_bus *mdio_bus, struct netdev *ndev);
|
||||
void eth_phy_close(struct ethernet_phy_device *phydev);
|
||||
void eth_phy_attach(uint32 dev_id, struct ethernet_phy_device *phydev);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__ETH_PHY_H__
|
||||
|
||||
/*************************** (C) COPYRIGHT 2018 HUGE-IC ***** END OF FILE *****/
|
||||
166
sdk/include/lib/net/ethphy/ethtool.h
Normal file
166
sdk/include/lib/net/ethphy/ethtool.h
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sdk/include/lib/ethernet_phy/ethtool.h
|
||||
* @author HUGE-IC Application Team
|
||||
* @version V1.0.0
|
||||
* @date 10-10-2018
|
||||
* @brief Defines for Linux ethtool
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2018 HUGE-IC</center></h2>
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __ETHTOOL_H__
|
||||
#define __ETHTOOL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/** @weakgroup NETWORK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup NETWORK_ETHTOOL Ethtool
|
||||
* @brief Defines for Linux ethtool
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup NETWORK_ETHTOOL_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Indicates what features are supported by the interface. */
|
||||
#define SUPPORTED_10baseT_Half (1 << 0)
|
||||
#define SUPPORTED_10baseT_Full (1 << 1)
|
||||
#define SUPPORTED_100baseT_Half (1 << 2)
|
||||
#define SUPPORTED_100baseT_Full (1 << 3)
|
||||
#define SUPPORTED_1000baseT_Half (1 << 4)
|
||||
#define SUPPORTED_1000baseT_Full (1 << 5)
|
||||
#define SUPPORTED_Autoneg (1 << 6)
|
||||
#define SUPPORTED_TP (1 << 7)
|
||||
#define SUPPORTED_AUI (1 << 8)
|
||||
#define SUPPORTED_MII (1 << 9)
|
||||
#define SUPPORTED_FIBRE (1 << 10)
|
||||
#define SUPPORTED_BNC (1 << 11)
|
||||
#define SUPPORTED_10000baseT_Full (1 << 12)
|
||||
#define SUPPORTED_Pause (1 << 13)
|
||||
#define SUPPORTED_Asym_Pause (1 << 14)
|
||||
#define SUPPORTED_2500baseX_Full (1 << 15)
|
||||
#define SUPPORTED_Backplane (1 << 16)
|
||||
#define SUPPORTED_1000baseKX_Full (1 << 17)
|
||||
#define SUPPORTED_10000baseKX4_Full (1 << 18)
|
||||
#define SUPPORTED_10000baseKR_Full (1 << 19)
|
||||
#define SUPPORTED_10000baseR_FEC (1 << 20)
|
||||
#define SUPPORTED_20000baseMLD2_Full (1 << 21)
|
||||
#define SUPPORTED_20000baseKR2_Full (1 << 22)
|
||||
#define SUPPORTED_40000baseKR4_Full (1 << 23)
|
||||
#define SUPPORTED_40000baseCR4_Full (1 << 24)
|
||||
#define SUPPORTED_40000baseSR4_Full (1 << 25)
|
||||
#define SUPPORTED_40000baseLR4_Full (1 << 26)
|
||||
|
||||
/* Indicates what features are advertised by the interface. */
|
||||
#define ADVERTISED_10baseT_Half (1 << 0)
|
||||
#define ADVERTISED_10baseT_Full (1 << 1)
|
||||
#define ADVERTISED_100baseT_Half (1 << 2)
|
||||
#define ADVERTISED_100baseT_Full (1 << 3)
|
||||
#define ADVERTISED_1000baseT_Half (1 << 4)
|
||||
#define ADVERTISED_1000baseT_Full (1 << 5)
|
||||
#define ADVERTISED_Autoneg (1 << 6)
|
||||
#define ADVERTISED_TP (1 << 7)
|
||||
#define ADVERTISED_AUI (1 << 8)
|
||||
#define ADVERTISED_MII (1 << 9)
|
||||
#define ADVERTISED_FIBRE (1 << 10)
|
||||
#define ADVERTISED_BNC (1 << 11)
|
||||
#define ADVERTISED_10000baseT_Full (1 << 12)
|
||||
#define ADVERTISED_Pause (1 << 13)
|
||||
#define ADVERTISED_Asym_Pause (1 << 14)
|
||||
#define ADVERTISED_2500baseX_Full (1 << 15)
|
||||
#define ADVERTISED_Backplane (1 << 16)
|
||||
#define ADVERTISED_1000baseKX_Full (1 << 17)
|
||||
#define ADVERTISED_10000baseKX4_Full (1 << 18)
|
||||
#define ADVERTISED_10000baseKR_Full (1 << 19)
|
||||
#define ADVERTISED_10000baseR_FEC (1 << 20)
|
||||
#define ADVERTISED_20000baseMLD2_Full (1 << 21)
|
||||
#define ADVERTISED_20000baseKR2_Full (1 << 22)
|
||||
#define ADVERTISED_40000baseKR4_Full (1 << 23)
|
||||
#define ADVERTISED_40000baseCR4_Full (1 << 24)
|
||||
#define ADVERTISED_40000baseSR4_Full (1 << 25)
|
||||
#define ADVERTISED_40000baseLR4_Full (1 << 26)
|
||||
|
||||
/* The following are all involved in forcing a particular link mode for the
|
||||
* device for setting things. When getting the devices settings, these
|
||||
* indicate the current mode and whether it was forced up into this mode or
|
||||
* autonegotiated.
|
||||
*/
|
||||
|
||||
/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */
|
||||
#define SPEED_10 10
|
||||
#define SPEED_100 100
|
||||
#define SPEED_1000 1000
|
||||
#define SPEED_2500 2500
|
||||
#define SPEED_10000 10000
|
||||
#define SPEED_UNKNOWN -1
|
||||
|
||||
/* Duplex, half or full. */
|
||||
#define DUPLEX_HALF 0x00
|
||||
#define DUPLEX_FULL 0x01
|
||||
#define DUPLEX_UNKNOWN 0xff
|
||||
|
||||
/* Which connector port. */
|
||||
#define PORT_TP 0x00
|
||||
#define PORT_AUI 0x01
|
||||
#define PORT_MII 0x02
|
||||
#define PORT_FIBRE 0x03
|
||||
#define PORT_BNC 0x04
|
||||
#define PORT_DA 0x05
|
||||
#define PORT_NONE 0xEF
|
||||
#define PORT_OTHER 0xFF
|
||||
|
||||
/* Which transceiver to use. */
|
||||
#define XCVR_INTERNAL 0x00
|
||||
#define XCVR_EXTERNAL 0x01
|
||||
#define XCVR_DUMMY1 0x02
|
||||
#define XCVR_DUMMY2 0x03
|
||||
#define XCVR_DUMMY3 0x04
|
||||
|
||||
/* Enable or disable autonegotiation. If this is set to enable, the forced
|
||||
* link modes above are completely ignored.
|
||||
*/
|
||||
#define AUTONEG_DISABLE 0x00
|
||||
#define AUTONEG_ENABLE 0x01
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__ETHTOOL_H__
|
||||
|
||||
/*************************** (C) COPYRIGHT 2018 HUGE-IC ***** END OF FILE *****/
|
||||
205
sdk/include/lib/net/ethphy/mii.h
Normal file
205
sdk/include/lib/net/ethphy/mii.h
Normal file
@@ -0,0 +1,205 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sdk/include/lib/ethernet_phy/mii.h
|
||||
* @author HUGE-IC Application Team
|
||||
* @version V1.0.0
|
||||
* @date 10-10-2018
|
||||
* @brief definitions for MII-compatible transceivers
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2018 HUGE-IC</center></h2>
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MII_H__
|
||||
#define __MII_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/** @weakgroup NETWORK
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup NETWORK_MII MII Register
|
||||
* @brief definitions for MII-compatible transceivers
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup MII_Exported_Constants Exported Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Generic MII registers. */
|
||||
#define MII_BMCR 0x00 /*!< Basic mode control register */
|
||||
#define MII_BMSR 0x01 /*!< Basic mode status register */
|
||||
#define MII_PHYSID1 0x02 /*!< PHYS ID 1 */
|
||||
#define MII_PHYSID2 0x03 /*!< PHYS ID 2 */
|
||||
#define MII_ADVERTISE 0x04 /*!< Advertisement control reg */
|
||||
#define MII_LPA 0x05 /*!< Link partner ability reg */
|
||||
#define MII_EXPANSION 0x06 /*!< Expansion register */
|
||||
#define MII_CTRL1000 0x09 /*!< 1000BASE-T control */
|
||||
#define MII_STAT1000 0x0a /*!< 1000BASE-T status */
|
||||
#define MII_MMD_CTRL 0x0d /*!< MMD Access Control Register */
|
||||
#define MII_MMD_DATA 0x0e /*!< MMD Access Data Register */
|
||||
#define MII_ESTATUS 0x0f /*!< Extended Status */
|
||||
#define MII_DCOUNTER 0x12 /*!< Disconnect counter */
|
||||
#define MII_FCSCOUNTER 0x13 /*!< False carrier counter */
|
||||
#define MII_NWAYTEST 0x14 /*!< N-way auto-neg test reg */
|
||||
#define MII_RERRCOUNTER 0x15 /*!< Receive error counter */
|
||||
#define MII_SREVISION 0x16 /*!< Silicon revision */
|
||||
#define MII_RESV1 0x17 /*!< Reserved... */
|
||||
#define MII_LBRERROR 0x18 /*!< Lpback, rx, bypass error */
|
||||
#define MII_PHYADDR 0x19 /*!< PHY address */
|
||||
#define MII_RESV2 0x1a /*!< Reserved... */
|
||||
#define MII_TPISTATUS 0x1b /*!< TPI status for 10mbps */
|
||||
#define MII_NCONFIG 0x1c /*!< Network interface config */
|
||||
|
||||
/* Basic mode control register. */
|
||||
#define BMCR_RESV 0x003f /*!< Unused... */
|
||||
#define BMCR_SPEED1000 0x0040 /*!< MSB of Speed (1000) */
|
||||
#define BMCR_CTST 0x0080 /*!< Collision test */
|
||||
#define BMCR_FULLDPLX 0x0100 /*!< Full duplex */
|
||||
#define BMCR_ANRESTART 0x0200 /*!< Auto negotiation restart */
|
||||
#define BMCR_ISOLATE 0x0400 /*!< Isolate data paths from MII */
|
||||
#define BMCR_PDOWN 0x0800 /*!< Enable low power state */
|
||||
#define BMCR_ANENABLE 0x1000 /*!< Enable auto negotiation */
|
||||
#define BMCR_SPEED100 0x2000 /*!< Select 100Mbps */
|
||||
#define BMCR_LOOPBACK 0x4000 /*!< TXD loopback bits */
|
||||
#define BMCR_RESET 0x8000 /*!< Reset to default state */
|
||||
|
||||
/* Basic mode status register. */
|
||||
#define BMSR_ERCAP 0x0001 /*!< Ext-reg capability */
|
||||
#define BMSR_JCD 0x0002 /*!< Jabber detected */
|
||||
#define BMSR_LSTATUS 0x0004 /*!< Link status */
|
||||
#define BMSR_ANEGCAPABLE 0x0008 /*!< Able to do auto-negotiation */
|
||||
#define BMSR_RFAULT 0x0010 /*!< Remote fault detected */
|
||||
#define BMSR_ANEGCOMPLETE 0x0020 /*!< Auto-negotiation complete */
|
||||
#define BMSR_RESV 0x00c0 /*!< Unused... */
|
||||
#define BMSR_ESTATEN 0x0100 /*!< Extended Status in R15 */
|
||||
#define BMSR_100HALF2 0x0200 /*!< Can do 100BASE-T2 HDX */
|
||||
#define BMSR_100FULL2 0x0400 /*!< Can do 100BASE-T2 FDX */
|
||||
#define BMSR_10HALF 0x0800 /*!< Can do 10mbps, half-duplex */
|
||||
#define BMSR_10FULL 0x1000 /*!< Can do 10mbps, full-duplex */
|
||||
#define BMSR_100HALF 0x2000 /*!< Can do 100mbps, half-duplex */
|
||||
#define BMSR_100FULL 0x4000 /*!< Can do 100mbps, full-duplex */
|
||||
#define BMSR_100BASE4 0x8000 /*!< Can do 100mbps, 4k packets */
|
||||
|
||||
/* Advertisement control register. */
|
||||
#define ADVERTISE_SLCT 0x001f /*!< Selector bits */
|
||||
#define ADVERTISE_CSMA 0x0001 /*!< Only selector supported */
|
||||
#define ADVERTISE_10HALF 0x0020 /*!< Try for 10mbps half-duplex */
|
||||
#define ADVERTISE_1000XFULL 0x0020 /*!< Try for 1000BASE-X full-duplex */
|
||||
#define ADVERTISE_10FULL 0x0040 /*!< Try for 10mbps full-duplex */
|
||||
#define ADVERTISE_1000XHALF 0x0040 /*!< Try for 1000BASE-X half-duplex */
|
||||
#define ADVERTISE_100HALF 0x0080 /*!< Try for 100mbps half-duplex */
|
||||
#define ADVERTISE_1000XPAUSE 0x0080 /*!< Try for 1000BASE-X pause */
|
||||
#define ADVERTISE_100FULL 0x0100 /*!< Try for 100mbps full-duplex */
|
||||
#define ADVERTISE_1000XPSE_ASYM 0x0100 /*!< Try for 1000BASE-X asym pause */
|
||||
#define ADVERTISE_100BASE4 0x0200 /*!< Try for 100mbps 4k packets */
|
||||
#define ADVERTISE_PAUSE_CAP 0x0400 /*!< Try for pause */
|
||||
#define ADVERTISE_PAUSE_ASYM 0x0800 /*!< Try for asymetric pause */
|
||||
#define ADVERTISE_RESV 0x1000 /*!< Unused... */
|
||||
#define ADVERTISE_RFAULT 0x2000 /*!< Say we can detect faults */
|
||||
#define ADVERTISE_LPACK 0x4000 /*!< Ack link partners response */
|
||||
#define ADVERTISE_NPAGE 0x8000 /*!< Next page bit */
|
||||
|
||||
#define ADVERTISE_FULL (ADVERTISE_100FULL | ADVERTISE_10FULL | \
|
||||
ADVERTISE_CSMA)
|
||||
#define ADVERTISE_ALL (ADVERTISE_10HALF | ADVERTISE_10FULL | \
|
||||
ADVERTISE_100HALF | ADVERTISE_100FULL)
|
||||
|
||||
/* Link partner ability register. */
|
||||
#define LPA_SLCT 0x001f /*!< Same as advertise selector */
|
||||
#define LPA_10HALF 0x0020 /*!< Can do 10mbps half-duplex */
|
||||
#define LPA_1000XFULL 0x0020 /*!< Can do 1000BASE-X full-duplex */
|
||||
#define LPA_10FULL 0x0040 /*!< Can do 10mbps full-duplex */
|
||||
#define LPA_1000XHALF 0x0040 /*!< Can do 1000BASE-X half-duplex */
|
||||
#define LPA_100HALF 0x0080 /*!< Can do 100mbps half-duplex */
|
||||
#define LPA_1000XPAUSE 0x0080 /*!< Can do 1000BASE-X pause */
|
||||
#define LPA_100FULL 0x0100 /*!< Can do 100mbps full-duplex */
|
||||
#define LPA_1000XPAUSE_ASYM 0x0100 /*!< Can do 1000BASE-X pause asym */
|
||||
#define LPA_100BASE4 0x0200 /*!< Can do 100mbps 4k packets */
|
||||
#define LPA_PAUSE_CAP 0x0400 /*!< Can pause */
|
||||
#define LPA_PAUSE_ASYM 0x0800 /*!< Can pause asymetrically */
|
||||
#define LPA_RESV 0x1000 /*!< Unused... */
|
||||
#define LPA_RFAULT 0x2000 /*!< Link partner faulted */
|
||||
#define LPA_LPACK 0x4000 /*!< Link partner acked us */
|
||||
#define LPA_NPAGE 0x8000 /*!< Next page bit */
|
||||
|
||||
#define LPA_DUPLEX (LPA_10FULL | LPA_100FULL)
|
||||
#define LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4)
|
||||
|
||||
/* Expansion register for auto-negotiation. */
|
||||
#define EXPANSION_NWAY 0x0001 /*!< Can do N-way auto-nego */
|
||||
#define EXPANSION_LCWP 0x0002 /*!< Got new RX page code word */
|
||||
#define EXPANSION_ENABLENPAGE 0x0004 /*!< This enables npage words */
|
||||
#define EXPANSION_NPCAPABLE 0x0008 /*!< Link partner supports npage */
|
||||
#define EXPANSION_MFAULTS 0x0010 /*!< Multiple faults detected */
|
||||
#define EXPANSION_RESV 0xffe0 /*!< Unused... */
|
||||
|
||||
#define ESTATUS_1000_TFULL 0x2000 /*!< Can do 1000BT Full */
|
||||
#define ESTATUS_1000_THALF 0x1000 /*!< Can do 1000BT Half */
|
||||
|
||||
/* N-way test register. */
|
||||
#define NWAYTEST_RESV1 0x00ff /*!< Unused... */
|
||||
#define NWAYTEST_LOOPBACK 0x0100 /*!< Enable loopback for N-way */
|
||||
#define NWAYTEST_RESV2 0xfe00 /*!< Unused... */
|
||||
|
||||
/* 1000BASE-T Control register */
|
||||
#define ADVERTISE_1000FULL 0x0200 /*!< Advertise 1000BASE-T full duplex */
|
||||
#define ADVERTISE_1000HALF 0x0100 /*!< Advertise 1000BASE-T half duplex */
|
||||
#define CTL1000_AS_MASTER 0x0800
|
||||
#define CTL1000_ENABLE_MASTER 0x1000
|
||||
|
||||
/* 1000BASE-T Status register */
|
||||
#define LPA_1000LOCALRXOK 0x2000 /*!< Link partner local receiver status */
|
||||
#define LPA_1000REMRXOK 0x1000 /*!< Link partner remote receiver status*/
|
||||
#define LPA_1000FULL 0x0800 /*!< Link partner 1000BASE-T full duplex*/
|
||||
#define LPA_1000HALF 0x0400 /*!< Link partner 1000BASE-T half duplex*/
|
||||
|
||||
/* Flow control flags */
|
||||
#define FLOW_CTRL_TX 0x01
|
||||
#define FLOW_CTRL_RX 0x02
|
||||
|
||||
/* MMD Access Control register fields */
|
||||
#define MII_MMD_CTRL_DEVAD_MASK 0x1f /*!< Mask MMD DEVAD */
|
||||
#define MII_MMD_CTRL_ADDR 0x0000 /*!< Address */
|
||||
#define MII_MMD_CTRL_NOINCR 0x4000 /*!< no post increment */
|
||||
#define MII_MMD_CTRL_INCR_RDWT 0x8000 /*!< post increment on reads & writes */
|
||||
#define MII_MMD_CTRL_INCR_ON_WT 0xC000 /*!< post increment on writes only */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //__MII_H__
|
||||
|
||||
/*************************** (C) COPYRIGHT 2018 HUGE-IC ***** END OF FILE *****/
|
||||
|
||||
7
sdk/include/lib/net/ethphy/phy/auto_phy.h
Normal file
7
sdk/include/lib/net/ethphy/phy/auto_phy.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __AUTO_PHY_H_
|
||||
#define __AUTO_PHY_H_
|
||||
|
||||
extern struct ethernet_phy_driver auto_phy_driver;
|
||||
|
||||
|
||||
#endif
|
||||
7
sdk/include/lib/net/ethphy/phy/ip101g.h
Normal file
7
sdk/include/lib/net/ethphy/phy/ip101g.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __IP101G_H_
|
||||
#define __IP101G_H_
|
||||
|
||||
extern struct ethernet_phy_driver ip101g_driver;
|
||||
|
||||
|
||||
#endif
|
||||
7
sdk/include/lib/net/ethphy/phy/rtl8201f.h
Normal file
7
sdk/include/lib/net/ethphy/phy/rtl8201f.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __RTL8201F_H_
|
||||
#define __RTL8201F_H_
|
||||
|
||||
extern struct ethernet_phy_driver rtl8201f_driver;
|
||||
|
||||
|
||||
#endif
|
||||
7
sdk/include/lib/net/ethphy/phy/sz18201.h
Normal file
7
sdk/include/lib/net/ethphy/phy/sz18201.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __SZ18201_H_
|
||||
#define __SZ18201_H_
|
||||
|
||||
extern struct ethernet_phy_driver sz18201_driver;
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user