Commit 26deba501371c215f95624ede81ab5b611fd7d95
Committed by
David S. Miller
1 parent
1338344a84
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 25 additions and 17 deletions Side-by-side Diff
drivers/net/sfc/falcon.c
... | ... | @@ -2183,11 +2183,29 @@ |
2183 | 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 | 2206 | int falcon_switch_mac(struct efx_nic *efx) |
2187 | 2207 | { |
2188 | 2208 | struct efx_mac_operations *old_mac_op = efx->mac_op; |
2189 | - efx_oword_t nic_stat; | |
2190 | - unsigned strap_val; | |
2191 | 2209 | int rc = 0; |
2192 | 2210 | |
2193 | 2211 | /* Don't try to fetch MAC stats while we're switching MACs */ |
2194 | 2212 | |
... | ... | @@ -2206,24 +2224,11 @@ |
2206 | 2224 | efx->mac_op = (EFX_IS10G(efx) ? |
2207 | 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 | 2227 | if (old_mac_op == efx->mac_op) |
2225 | 2228 | goto out; |
2226 | 2229 | |
2230 | + falcon_clock_mac(efx); | |
2231 | + | |
2227 | 2232 | EFX_LOG(efx, "selected %cMAC\n", EFX_IS10G(efx) ? 'X' : 'G'); |
2228 | 2233 | /* Not all macs support a mac-level link state */ |
2229 | 2234 | efx->mac_up = true; |
... | ... | @@ -2981,6 +2986,9 @@ |
2981 | 2986 | EFX_SET_OWORD_FIELD(temp, FRF_AB_USE_NIC_CLK, true); |
2982 | 2987 | efx_writeo(efx, &temp, FR_AB_GPIO_CTL); |
2983 | 2988 | } |
2989 | + | |
2990 | + /* Select the correct MAC */ | |
2991 | + falcon_clock_mac(efx); | |
2984 | 2992 | |
2985 | 2993 | rc = falcon_reset_sram(efx); |
2986 | 2994 | if (rc) |