libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
PHY Generic Defines

Defined Constants and Types for the Ethernet PHY More...

Macros

#define PHY_REG_BCR   0x00
 
#define PHY_REG_BSR   0x01
 
#define PHY_REG_ID1   0x02
 
#define PHY_REG_ID2   0x03
 
#define PHY_REG_ANTX   0x04
 
#define PHY_REG_ANRX   0x05
 
#define PHY_REG_ANEXP   0x06
 
#define PHY_REG_ANNPTX   0x07
 
#define PHY_REG_ANNPRX   0x08
 
#define PHY_REG_BCR_COLTEST   (1 << 7)
 
#define PHY_REG_BCR_FD   (1 << 8)
 
#define PHY_REG_BCR_ANRST   (1 << 9)
 
#define PHY_REG_BCR_ISOLATE   (1 << 10)
 
#define PHY_REG_BCR_POWERDN   (1 << 11)
 
#define PHY_REG_BCR_AN   (1 << 12)
 
#define PHY_REG_BCR_100M   (1 << 13)
 
#define PHY_REG_BCR_LOOPBACK   (1 << 14)
 
#define PHY_REG_BCR_RESET   (1 << 15)
 
#define PHY_REG_BSR_JABBER   (1 << 1)
 
#define PHY_REG_BSR_UP   (1 << 2)
 
#define PHY_REG_BSR_FAULT   (1 << 4)
 
#define PHY_REG_BSR_ANDONE   (1 << 5)
 
#define PHY0   0
 
#define PHY1   1
 

Enumerations

enum  phy_status {
  LINK_DOWN , LINK_HD_10M , LINK_HD_100M , LINK_HD_1000M ,
  LINK_HD_10000M , LINK_FD_10M , LINK_FD_100M , LINK_FD_1000M ,
  LINK_FD_10000M
}
 

Functions

void phy_reset (uint8_t phy)
 Reset the PHY. More...
 
bool phy_link_isup (uint8_t phy)
 Is the link up ? More...
 
enum phy_status phy_link_status (uint8_t phy)
 Get the current link status. More...
 
void phy_autoneg_force (uint8_t phy, enum phy_status mode)
 Force autonegotiation. More...
 
void phy_autoneg_enable (uint8_t phy)
 Enable the autonegotiation. More...
 

Detailed Description

Defined Constants and Types for the Ethernet PHY

Version
1.0.0
Author
© 2013 Frantisek Burian BuFra.nosp@m.n@se.nosp@m.znam..nosp@m.cz
Date
1 September 2013

LGPL License Terms libopencm3 License

Macro Definition Documentation

◆ PHY0

#define PHY0   0

Definition at line 79 of file phy.h.

◆ PHY1

#define PHY1   1

Definition at line 80 of file phy.h.

◆ PHY_REG_ANEXP

#define PHY_REG_ANEXP   0x06

Definition at line 50 of file phy.h.

◆ PHY_REG_ANNPRX

#define PHY_REG_ANNPRX   0x08

Definition at line 52 of file phy.h.

◆ PHY_REG_ANNPTX

#define PHY_REG_ANNPTX   0x07

Definition at line 51 of file phy.h.

◆ PHY_REG_ANRX

#define PHY_REG_ANRX   0x05

Definition at line 49 of file phy.h.

◆ PHY_REG_ANTX

#define PHY_REG_ANTX   0x04

Definition at line 48 of file phy.h.

◆ PHY_REG_BCR

#define PHY_REG_BCR   0x00

Definition at line 44 of file phy.h.

◆ PHY_REG_BCR_100M

#define PHY_REG_BCR_100M   (1 << 13)

Definition at line 64 of file phy.h.

◆ PHY_REG_BCR_AN

#define PHY_REG_BCR_AN   (1 << 12)

Definition at line 63 of file phy.h.

◆ PHY_REG_BCR_ANRST

#define PHY_REG_BCR_ANRST   (1 << 9)

Definition at line 60 of file phy.h.

◆ PHY_REG_BCR_COLTEST

#define PHY_REG_BCR_COLTEST   (1 << 7)

Definition at line 58 of file phy.h.

◆ PHY_REG_BCR_FD

#define PHY_REG_BCR_FD   (1 << 8)

Definition at line 59 of file phy.h.

◆ PHY_REG_BCR_ISOLATE

#define PHY_REG_BCR_ISOLATE   (1 << 10)

Definition at line 61 of file phy.h.

◆ PHY_REG_BCR_LOOPBACK

#define PHY_REG_BCR_LOOPBACK   (1 << 14)

Definition at line 65 of file phy.h.

◆ PHY_REG_BCR_POWERDN

#define PHY_REG_BCR_POWERDN   (1 << 11)

Definition at line 62 of file phy.h.

◆ PHY_REG_BCR_RESET

#define PHY_REG_BCR_RESET   (1 << 15)

Definition at line 66 of file phy.h.

◆ PHY_REG_BSR

#define PHY_REG_BSR   0x01

Definition at line 45 of file phy.h.

◆ PHY_REG_BSR_ANDONE

#define PHY_REG_BSR_ANDONE   (1 << 5)

Definition at line 71 of file phy.h.

◆ PHY_REG_BSR_FAULT

#define PHY_REG_BSR_FAULT   (1 << 4)

Definition at line 70 of file phy.h.

◆ PHY_REG_BSR_JABBER

#define PHY_REG_BSR_JABBER   (1 << 1)

Definition at line 68 of file phy.h.

◆ PHY_REG_BSR_UP

#define PHY_REG_BSR_UP   (1 << 2)

Definition at line 69 of file phy.h.

◆ PHY_REG_ID1

#define PHY_REG_ID1   0x02

Definition at line 46 of file phy.h.

◆ PHY_REG_ID2

#define PHY_REG_ID2   0x03

Definition at line 47 of file phy.h.

Enumeration Type Documentation

◆ phy_status

enum phy_status
Enumerator
LINK_DOWN 
LINK_HD_10M 
LINK_HD_100M 
LINK_HD_1000M 
LINK_HD_10000M 
LINK_FD_10M 
LINK_FD_100M 
LINK_FD_1000M 
LINK_FD_10000M 

Definition at line 82 of file phy.h.

Function Documentation

◆ phy_autoneg_enable()

void phy_autoneg_enable ( uint8_t  phy)

Enable the autonegotiation.

Enable the autonegotiation of the link speed and duplex mode

Parameters
[in]phyuint8_t phy ID of the PHY

Definition at line 86 of file phy_ksz80x1.c.

References eth_smi_bit_set(), PHY_REG_BCR, PHY_REG_BCR_AN, and PHY_REG_BCR_ANRST.

Here is the call graph for this function:

◆ phy_autoneg_force()

void phy_autoneg_force ( uint8_t  phy,
enum phy_status  mode 
)

Force autonegotiation.

Force the autonegotiation and set link speed and duplex mode of the link

Parameters
[in]phyuint8_t phy ID of the PHY
[in]modeenum phy_status Desired link status

Definition at line 62 of file phy_ksz80x1.c.

References eth_smi_bit_op(), LINK_FD_10000M, LINK_FD_1000M, LINK_FD_100M, LINK_FD_10M, LINK_HD_100M, PHY_REG_BCR, PHY_REG_BCR_100M, PHY_REG_BCR_AN, and PHY_REG_BCR_FD.

Here is the call graph for this function:

◆ phy_link_isup()

bool phy_link_isup ( uint8_t  phy)

Is the link up ?

Parameters
[in]phyuint8_t phy ID of the PHY
Returns
bool true, if link is up

Definition at line 46 of file phy.c.

References eth_smi_read(), PHY_REG_BSR, and PHY_REG_BSR_UP.

Here is the call graph for this function:

◆ phy_link_status()

enum phy_status phy_link_status ( uint8_t  phy)

Get the current link status.

Retrieve the link speed and duplex status of the link.

Parameters
[in]phyuint8_t phy ID of the PHY
Returns
phy_status Link status

Definition at line 1 of file phy_ksz80x1.c.

References eth_smi_read(), and KSZ80X1_CR1.

Here is the call graph for this function:

◆ phy_reset()

void phy_reset ( uint8_t  phy)

Reset the PHY.

Reset the PHY chip and wait for done

Parameters
[in]phyuint8_t phy ID of the PHY

Definition at line 57 of file phy.c.

References eth_smi_read(), eth_smi_write(), PHY_REG_BCR, and PHY_REG_BCR_RESET.

Referenced by eth_init().

Here is the call graph for this function:
Here is the caller graph for this function: