aw_ccung: Support clock factors where factor=0, factor is effectively 1
This happens in two cases for a20 clocks: pll_core for 'n' factor: factor=0, val=1 factor=n, val=n ahb divisor: factor=0,val=/2 factor=n,val=/2^n Reviewed by: manu Differential Revision: https://reviews.freebsd.org/D15806
This commit is contained in:
parent
aab8510031
commit
85f58288a7
@ -72,6 +72,7 @@ struct aw_clk_init {
|
||||
#define AW_CLK_FACTOR_ZERO_BASED 0x0002
|
||||
#define AW_CLK_FACTOR_HAS_COND 0x0004
|
||||
#define AW_CLK_FACTOR_FIXED 0x0008
|
||||
#define AW_CLK_FACTOR_ZERO_IS_ONE 0x0010
|
||||
|
||||
struct aw_clk_factor {
|
||||
uint32_t shift; /* Shift bits for the factor */
|
||||
@ -110,6 +111,8 @@ aw_clk_get_factor(uint32_t val, struct aw_clk_factor *factor)
|
||||
return (factor->value);
|
||||
|
||||
factor_val = (val & factor->mask) >> factor->shift;
|
||||
if (factor_val == 0 && (factor->flags & AW_CLK_FACTOR_ZERO_IS_ONE))
|
||||
factor_val = 1;
|
||||
|
||||
if (factor->flags & AW_CLK_FACTOR_POWER_OF_TWO)
|
||||
factor_val = 1 << factor_val;
|
||||
|
Loading…
Reference in New Issue
Block a user