Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
phy.c File Reference
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/unistd.h>
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/phy.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
#include <linux/mdio.h>
#include <linux/atomic.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/uaccess.h>

Go to the source code of this file.

Data Structures

struct  phy_setting
 

Macros

#define pr_fmt(fmt)   KBUILD_MODNAME ": " fmt
 
#define MAX_NUM_SETTINGS   ARRAY_SIZE(settings)
 

Functions

void phy_print_status (struct phy_device *phydev)
 
 EXPORT_SYMBOL (phy_print_status)
 
int phy_ethtool_sset (struct phy_device *phydev, struct ethtool_cmd *cmd)
 
 EXPORT_SYMBOL (phy_ethtool_sset)
 
int phy_ethtool_gset (struct phy_device *phydev, struct ethtool_cmd *cmd)
 
 EXPORT_SYMBOL (phy_ethtool_gset)
 
int phy_mii_ioctl (struct phy_device *phydev, struct ifreq *ifr, int cmd)
 
 EXPORT_SYMBOL (phy_mii_ioctl)
 
int phy_start_aneg (struct phy_device *phydev)
 
 EXPORT_SYMBOL (phy_start_aneg)
 
void phy_start_machine (struct phy_device *phydev, void(*handler)(struct net_device *))
 
void phy_stop_machine (struct phy_device *phydev)
 
int phy_start_interrupts (struct phy_device *phydev)
 
 EXPORT_SYMBOL (phy_start_interrupts)
 
int phy_stop_interrupts (struct phy_device *phydev)
 
 EXPORT_SYMBOL (phy_stop_interrupts)
 
void phy_stop (struct phy_device *phydev)
 
void phy_start (struct phy_device *phydev)
 
 EXPORT_SYMBOL (phy_stop)
 
 EXPORT_SYMBOL (phy_start)
 
void phy_state_machine (struct work_struct *work)
 
int phy_init_eee (struct phy_device *phydev, bool clk_stop_enable)
 
 EXPORT_SYMBOL (phy_init_eee)
 
int phy_get_eee_err (struct phy_device *phydev)
 
 EXPORT_SYMBOL (phy_get_eee_err)
 
int phy_ethtool_get_eee (struct phy_device *phydev, struct ethtool_eee *data)
 
 EXPORT_SYMBOL (phy_ethtool_get_eee)
 
int phy_ethtool_set_eee (struct phy_device *phydev, struct ethtool_eee *data)
 
 EXPORT_SYMBOL (phy_ethtool_set_eee)
 

Macro Definition Documentation

#define MAX_NUM_SETTINGS   ARRAY_SIZE(settings)

Definition at line 163 of file phy.c.

#define pr_fmt (   fmt)    KBUILD_MODNAME ": " fmt

Definition at line 19 of file phy.c.

Function Documentation

EXPORT_SYMBOL ( phy_print_status  )
EXPORT_SYMBOL ( phy_ethtool_sset  )
EXPORT_SYMBOL ( phy_ethtool_gset  )
EXPORT_SYMBOL ( phy_mii_ioctl  )
EXPORT_SYMBOL ( phy_start_aneg  )
EXPORT_SYMBOL ( phy_start_interrupts  )
EXPORT_SYMBOL ( phy_stop_interrupts  )
EXPORT_SYMBOL ( phy_stop  )
EXPORT_SYMBOL ( phy_start  )
EXPORT_SYMBOL ( phy_init_eee  )
EXPORT_SYMBOL ( phy_get_eee_err  )
EXPORT_SYMBOL ( phy_ethtool_get_eee  )
EXPORT_SYMBOL ( phy_ethtool_set_eee  )
int phy_ethtool_get_eee ( struct phy_device phydev,
struct ethtool_eee data 
)

phy_ethtool_get_eee - get EEE supported and status : target phy_device struct : ethtool_eee data

Description: it reportes the Supported/Advertisement/LP Advertisement capabilities.

Definition at line 1144 of file phy.c.

int phy_ethtool_gset ( struct phy_device phydev,
struct ethtool_cmd cmd 
)

Definition at line 287 of file phy.c.

int phy_ethtool_set_eee ( struct phy_device phydev,
struct ethtool_eee data 
)

phy_ethtool_set_eee - set EEE supported and status : target phy_device struct : ethtool_eee data

Description: it is to program the Advertisement EEE register.

Definition at line 1180 of file phy.c.

int phy_ethtool_sset ( struct phy_device phydev,
struct ethtool_cmd cmd 
)

phy_ethtool_sset - generic ethtool sset function, handles all the details : target phy_device struct : ethtool_cmd

A few notes about parameter checking:

  • We don't set port or transceiver, so we don't care what they were set to.
  • phy_start_aneg() will make sure forced settings are sane, and choose the next best ones from the ones selected, so we don't care if ethtool tries to give us bad values.

Definition at line 241 of file phy.c.

int phy_get_eee_err ( struct phy_device phydev)

phy_get_eee_err - report the EEE wake error count : target phy_device struct

Description: it is to report the number of time where the PHY failed to complete its normal wake sequence.

Definition at line 1128 of file phy.c.

int phy_init_eee ( struct phy_device phydev,
bool  clk_stop_enable 
)

phy_init_eee - init and check the EEE feature : target phy_device struct : PHY may stop the clock during LPI

Description: it checks if the Energy-Efficient Ethernet (EEE) is supported by looking at the MMD registers 3.20 and 7.60/61 and it programs the MMD register 3.0 setting the "Clock stop enable" bit if required.

Definition at line 1048 of file phy.c.

int phy_mii_ioctl ( struct phy_device phydev,
struct ifreq ifr,
int  cmd 
)

phy_mii_ioctl - generic PHY MII ioctl interface : the phy_device struct : &struct ifreq for socket ioctl's : ioctl cmd to execute

Note that this function is currently incompatible with the PHYCONTROL layer. It changes registers without regard to current state. Use at own risk.

Definition at line 314 of file phy.c.

void phy_print_status ( struct phy_device phydev)

phy_print_status - Convenience function to print out the current phy status : the phy_device struct

Definition at line 49 of file phy.c.

void phy_start ( struct phy_device phydev)

phy_start - start or restart a PHY device : target phy_device struct

Description: Indicates the attached device's readiness to handle PHY-related work. Used during startup to start the PHY, and after a call to phy_stop() to resume operation. Also used to indicate the MDIO bus has cleared an error condition.

Definition at line 743 of file phy.c.

int phy_start_aneg ( struct phy_device phydev)

phy_start_aneg - start auto-negotiation for this PHY device : the phy_device struct

Description: Sanitizes the settings (if we're not autonegotiating them), and then calls the driver's config_aneg function. If the PHYCONTROL Layer is operating, we change the state to reflect the beginning of Auto-negotiation or forcing.

Definition at line 391 of file phy.c.

int phy_start_interrupts ( struct phy_device phydev)

phy_start_interrupts - request and enable interrupts for a PHY device : target phy_device struct

Description: Request the interrupt for the given PHY. If this fails, then we set irq to PHY_POLL. Otherwise, we enable the interrupts in the PHY. This should only be called with a valid IRQ number. Returns 0 on success or < 0 on error.

Definition at line 591 of file phy.c.

void phy_start_machine ( struct phy_device phydev,
void(*)(struct net_device *)  handler 
)

phy_start_machine - start PHY state machine tracking : the phy_device struct : callback function for state change notifications

Description: The PHY infrastructure can run a state machine which tracks whether the PHY is starting up, negotiating, etc. This function starts the timer which tracks the state of the PHY. If you want to be notified when the state changes, pass in the callback , otherwise, pass NULL. If you want to maintain your own state machine, do not call this function.

Definition at line 437 of file phy.c.

void phy_state_machine ( struct work_struct work)

phy_state_machine - Handle the state machine : work_struct that describes the work to be done

Definition at line 768 of file phy.c.

void phy_stop ( struct phy_device phydev)

phy_stop - Bring down the PHY link, and stop checking the status : target phy_device struct

Definition at line 705 of file phy.c.

int phy_stop_interrupts ( struct phy_device phydev)

phy_stop_interrupts - disable interrupts from a PHY device : target phy_device struct

Definition at line 618 of file phy.c.

void phy_stop_machine ( struct phy_device phydev)

phy_stop_machine - stop the PHY state machine tracking : target phy_device struct

Description: Stops the state machine timer, sets the state to UP (unless it wasn't up yet). This function must be called BEFORE phy_detach.

Definition at line 453 of file phy.c.