linux/drivers/net/ethernet/ti/davinci_emac.c
/**
 * emac_update_phystatus - Update Phy status
 * @priv: The DaVinci EMAC private adapter structure
 *
 * Updates phy status and takes action for network queue if required
 * based upon link status
 *
 */
Update Phy status
@priv: The DaVinci EMAC private adapter structure

Updates phy status and takes action for network queue if required
based upon link status
Update Phy status @priv : The DaVinci EMAC private adapter structure Updates phy status and takes action for network queue if required based upon link status
static void emac_update_phystatus(struct emac_priv *priv)
{
	u32 mac_control;
	u32 new_duplex;
	u32 cur_duplex;
	struct net_device *ndev = priv->ndev;
	mac_control = emac_read(EMAC_MACCONTROL);
	cur_duplex = (mac_control & EMAC_MACCONTROL_FULLDUPLEXEN) ?
			DUPLEX_FULL : DUPLEX_HALF;
	if (ndev->phydev)
		new_duplex = ndev->phydev->duplex;
	else
		new_duplex = DUPLEX_FULL;
	if ((priv->link) && (new_duplex != cur_duplex)) {
		priv->duplex = new_duplex;
		if (DUPLEX_FULL == priv->duplex)
			mac_control |= (EMAC_MACCONTROL_FULLDUPLEXEN);
		else
			mac_control &= ~(EMAC_MACCONTROL_FULLDUPLEXEN);
	}
	if (priv->speed == SPEED_1000 && (priv->version == EMAC_VERSION_2)) {
		mac_control = emac_read(EMAC_MACCONTROL);
		mac_control |= (EMAC_DM646X_MACCONTORL_GIG |
				EMAC_DM646X_MACCONTORL_GIGFORCE);
	} else {
		mac_control &= ~(EMAC_DM646X_MACCONTORL_GIGFORCE |
					EMAC_DM646X_MACCONTORL_GIG);
		if (priv->rmii_en && (priv->speed == SPEED_100))
			mac_control |= EMAC_MACCONTROL_RMIISPEED_MASK;
		else
			mac_control &= ~EMAC_MACCONTROL_RMIISPEED_MASK;
	}
	emac_write(EMAC_MACCONTROL, mac_control);
	if (priv->link) {
		if (!netif_carrier_ok(ndev))
			netif_carrier_on(ndev);
		if (netif_running(ndev) && netif_queue_stopped(ndev))
			netif_wake_queue(ndev);
	} else {
		if (netif_carrier_ok(ndev))
			netif_carrier_off(ndev);
		if (!netif_queue_stopped(ndev))
			netif_stop_queue(ndev);
	}
}
static void emac_update_phystatus ( struct emac_priv * priv ) { u32 mac_control ; u32 new_duplex ; u32 cur_duplex ; struct net_device * ndev = priv -> ndev ; mac_control = emac_read ( EMAC_MACCONTROL ) ; cur_duplex = ( mac_control & EMAC_MACCONTROL_FULLDUPLEXEN ) ? DUPLEX_FULL : DUPLEX_HALF ; if ( ndev -> phydev ) new_duplex = ndev -> phydev -> duplex ; else new_duplex = DUPLEX_FULL ; if ( ( priv -> link ) && ( new_duplex != cur_duplex ) ) { priv -> duplex = new_duplex ; if ( DUPLEX_FULL == priv -> duplex ) mac_control |= ( EMAC_MACCONTROL_FULLDUPLEXEN ) ; else mac_control &= ~ ( EMAC_MACCONTROL_FULLDUPLEXEN ) ; } if ( priv -> speed == SPEED_1000 && ( priv -> version == EMAC_VERSION_2 ) ) { mac_control = emac_read ( EMAC_MACCONTROL ) ; mac_control |= ( EMAC_DM646X_MACCONTORL_GIG | EMAC_DM646X_MACCONTORL_GIGFORCE ) ; } else { mac_control &= ~ ( EMAC_DM646X_MACCONTORL_GIGFORCE | EMAC_DM646X_MACCONTORL_GIG ) ; if ( priv -> rmii_en && ( priv -> speed == SPEED_100 ) ) mac_control |= EMAC_MACCONTROL_RMIISPEED_MASK ; else mac_control &= ~ EMAC_MACCONTROL_RMIISPEED_MASK ; } emac_write ( EMAC_MACCONTROL , mac_control ) ; if ( priv -> link ) { if ( ! netif_carrier_ok ( ndev ) ) netif_carrier_on ( ndev ) ; if ( netif_running ( ndev ) && netif_queue_stopped ( ndev ) ) netif_wake_queue ( ndev ) ; } else { if ( netif_carrier_ok ( ndev ) ) netif_carrier_off ( ndev ) ; if ( ! netif_queue_stopped ( ndev ) ) netif_stop_queue ( ndev ) ; } }
emac_update_phystatus - Update Phy status
 @priv: The DaVinci EMAC private adapter structure
emac_update_phystatus - Update Phy status @priv : The DaVinci EMAC private adapter structure
/* We get called only if link has changed (speed/duplex/status) */ /* Clear the GIG bit and GIGFORCE bit */ /* Update mac_control if changed */ /* link ON */ /* reactivate the transmit queue if it is stopped */ /* link OFF */