diff options
author | Steve Hodgson <shodgson@solarflare.com> | 2009-11-25 11:11:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-26 18:59:28 -0500 |
commit | 26deba501371c215f95624ede81ab5b611fd7d95 (patch) | |
tree | 60b788e440fcb45f5902b42cffe15feb8aa2a5b4 /drivers/net/sfc | |
parent | 1338344a84f5ea60a6689127d2717845e8564b1a (diff) |
sfc: Only switch Falcon MAC clocks as necessary
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r-- | drivers/net/sfc/falcon.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index e1b9ce30429a..9eec88502101 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -2183,11 +2183,29 @@ static int falcon_mdio_read(struct net_device *net_dev, | |||
2183 | return rc; | 2183 | return rc; |
2184 | } | 2184 | } |
2185 | 2185 | ||
2186 | static void falcon_clock_mac(struct efx_nic *efx) | ||
2187 | { | ||
2188 | unsigned strap_val; | ||
2189 | efx_oword_t nic_stat; | ||
2190 | |||
2191 | /* Configure the NIC generated MAC clock correctly */ | ||
2192 | efx_reado(efx, &nic_stat, FR_AB_NIC_STAT); | ||
2193 | strap_val = EFX_IS10G(efx) ? 5 : 3; | ||
2194 | if (falcon_rev(efx) >= FALCON_REV_B0) { | ||
2195 | EFX_SET_OWORD_FIELD(nic_stat, FRF_BB_EE_STRAP_EN, 1); | ||
2196 | EFX_SET_OWORD_FIELD(nic_stat, FRF_BB_EE_STRAP, strap_val); | ||
2197 | efx_writeo(efx, &nic_stat, FR_AB_NIC_STAT); | ||
2198 | } else { | ||
2199 | /* Falcon A1 does not support 1G/10G speed switching | ||
2200 | * and must not be used with a PHY that does. */ | ||
2201 | BUG_ON(EFX_OWORD_FIELD(nic_stat, FRF_AB_STRAP_PINS) != | ||
2202 | strap_val); | ||
2203 | } | ||
2204 | } | ||
2205 | |||
2186 | int falcon_switch_mac(struct efx_nic *efx) | 2206 | int falcon_switch_mac(struct efx_nic *efx) |
2187 | { | 2207 | { |
2188 | struct efx_mac_operations *old_mac_op = efx->mac_op; | 2208 | struct efx_mac_operations *old_mac_op = efx->mac_op; |
2189 | efx_oword_t nic_stat; | ||
2190 | unsigned strap_val; | ||
2191 | int rc = 0; | 2209 | int rc = 0; |
2192 | 2210 | ||
2193 | /* Don't try to fetch MAC stats while we're switching MACs */ | 2211 | /* Don't try to fetch MAC stats while we're switching MACs */ |
@@ -2206,24 +2224,11 @@ int falcon_switch_mac(struct efx_nic *efx) | |||
2206 | efx->mac_op = (EFX_IS10G(efx) ? | 2224 | efx->mac_op = (EFX_IS10G(efx) ? |
2207 | &falcon_xmac_operations : &falcon_gmac_operations); | 2225 | &falcon_xmac_operations : &falcon_gmac_operations); |
2208 | 2226 | ||
2209 | /* Always push the NIC_STAT_REG setting even if the mac hasn't | ||
2210 | * changed, because this function is run post online reset */ | ||
2211 | efx_reado(efx, &nic_stat, FR_AB_NIC_STAT); | ||
2212 | strap_val = EFX_IS10G(efx) ? 5 : 3; | ||
2213 | if (falcon_rev(efx) >= FALCON_REV_B0) { | ||
2214 | EFX_SET_OWORD_FIELD(nic_stat, FRF_BB_EE_STRAP_EN, 1); | ||
2215 | EFX_SET_OWORD_FIELD(nic_stat, FRF_BB_EE_STRAP, strap_val); | ||
2216 | efx_writeo(efx, &nic_stat, FR_AB_NIC_STAT); | ||
2217 | } else { | ||
2218 | /* Falcon A1 does not support 1G/10G speed switching | ||
2219 | * and must not be used with a PHY that does. */ | ||
2220 | BUG_ON(EFX_OWORD_FIELD(nic_stat, FRF_AB_STRAP_PINS) != | ||
2221 | strap_val); | ||
2222 | } | ||
2223 | |||
2224 | if (old_mac_op == efx->mac_op) | 2227 | if (old_mac_op == efx->mac_op) |
2225 | goto out; | 2228 | goto out; |
2226 | 2229 | ||
2230 | falcon_clock_mac(efx); | ||
2231 | |||
2227 | EFX_LOG(efx, "selected %cMAC\n", EFX_IS10G(efx) ? 'X' : 'G'); | 2232 | EFX_LOG(efx, "selected %cMAC\n", EFX_IS10G(efx) ? 'X' : 'G'); |
2228 | /* Not all macs support a mac-level link state */ | 2233 | /* Not all macs support a mac-level link state */ |
2229 | efx->mac_up = true; | 2234 | efx->mac_up = true; |
@@ -2982,6 +2987,9 @@ int falcon_init_nic(struct efx_nic *efx) | |||
2982 | efx_writeo(efx, &temp, FR_AB_GPIO_CTL); | 2987 | efx_writeo(efx, &temp, FR_AB_GPIO_CTL); |
2983 | } | 2988 | } |
2984 | 2989 | ||
2990 | /* Select the correct MAC */ | ||
2991 | falcon_clock_mac(efx); | ||
2992 | |||
2985 | rc = falcon_reset_sram(efx); | 2993 | rc = falcon_reset_sram(efx); |
2986 | if (rc) | 2994 | if (rc) |
2987 | return rc; | 2995 | return rc; |