r82xx: enforce PLL register limits.

This fixes out-of-range frequencies that would set the PLL
registers to incorrect values rather than failing outright.
jowett
Oliver Jowett 2014-08-29 14:05:58 +01:00 zatwierdzone przez Kyle Keen
rodzic a710e4eed2
commit 1cf9215483
1 zmienionych plików z 8 dodań i 4 usunięć

Wyświetl plik

@ -505,6 +505,11 @@ static int r82xx_set_pll(struct r82xx_priv *priv, uint32_t freq)
mix_div = mix_div << 1;
}
if (mix_div > 64) {
fprintf(stderr, "[R82XX] No valid PLL values for %u Hz!\n", freq);
return -1;
}
if (priv->cfg->rafael_chip == CHIP_R828D)
vco_power_ref = 1;
@ -542,10 +547,9 @@ static int r82xx_set_pll(struct r82xx_priv *priv, uint32_t freq)
nint = (uint32_t) (vco_div / 65536);
sdm = (uint32_t) (vco_div % 65536);
if (priv->cfg->rafael_chip == CHIP_R828D && nint > 127) {
fprintf(stderr, "[R828D] No valid PLL values for %u Hz!\n", freq);
return -1;
} else if (nint > 76) {
if (nint < 13 ||
(priv->cfg->rafael_chip == CHIP_R828D && nint > 127) ||
(priv->cfg->rafael_chip != CHIP_R828D && nint > 76)) {
fprintf(stderr, "[R82XX] No valid PLL values for %u Hz!\n", freq);
return -1;
}