allwinner: clk: Correct aw_clk_get_factor

Switch test between zero based factor and power of two one.
This resulted in a miscalculation of the factor if it was a power
of two one.
Some clocks frequencies were not calculated correctly because of that.
This commit is contained in:
manu 2018-04-27 09:23:07 +00:00
parent 2ae63d9ae0
commit bc71e06405

View File

@ -110,10 +110,11 @@ aw_clk_get_factor(uint32_t val, struct aw_clk_factor *factor)
return (factor->value);
factor_val = (val & factor->mask) >> factor->shift;
if (!(factor->flags & AW_CLK_FACTOR_ZERO_BASED))
factor_val += 1;
else if (factor->flags & AW_CLK_FACTOR_POWER_OF_TWO)
if (factor->flags & AW_CLK_FACTOR_POWER_OF_TWO)
factor_val = 1 << factor_val;
else if (!(factor->flags & AW_CLK_FACTOR_ZERO_BASED))
factor_val += 1;
return (factor_val);
}