Changeset View
Changeset View
Standalone View
Standalone View
head/sys/arm/allwinner/clkng/aw_clk.h
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
#define AW_CLK_HAS_FRAC 0x0020 | #define AW_CLK_HAS_FRAC 0x0020 | ||||
#define AW_CLK_HAS_UPDATE 0x0040 | #define AW_CLK_HAS_UPDATE 0x0040 | ||||
#define AW_CLK_HAS_PREDIV 0x0080 | #define AW_CLK_HAS_PREDIV 0x0080 | ||||
#define AW_CLK_FACTOR_POWER_OF_TWO 0x0001 | #define AW_CLK_FACTOR_POWER_OF_TWO 0x0001 | ||||
#define AW_CLK_FACTOR_ZERO_BASED 0x0002 | #define AW_CLK_FACTOR_ZERO_BASED 0x0002 | ||||
#define AW_CLK_FACTOR_HAS_COND 0x0004 | #define AW_CLK_FACTOR_HAS_COND 0x0004 | ||||
#define AW_CLK_FACTOR_FIXED 0x0008 | #define AW_CLK_FACTOR_FIXED 0x0008 | ||||
#define AW_CLK_FACTOR_ZERO_IS_ONE 0x0010 | |||||
struct aw_clk_factor { | struct aw_clk_factor { | ||||
uint32_t shift; /* Shift bits for the factor */ | uint32_t shift; /* Shift bits for the factor */ | ||||
uint32_t mask; /* Mask to get the factor, will be override by the clk methods */ | uint32_t mask; /* Mask to get the factor, will be override by the clk methods */ | ||||
uint32_t width; /* Number of bits for the factor */ | uint32_t width; /* Number of bits for the factor */ | ||||
uint32_t value; /* Fixed value, depends on AW_CLK_FACTOR_FIXED */ | uint32_t value; /* Fixed value, depends on AW_CLK_FACTOR_FIXED */ | ||||
uint32_t cond_shift; | uint32_t cond_shift; | ||||
Show All 22 Lines | if (factor->flags & AW_CLK_FACTOR_HAS_COND) { | ||||
if (cond != factor->cond_value) | if (cond != factor->cond_value) | ||||
return (1); | return (1); | ||||
} | } | ||||
if (factor->flags & AW_CLK_FACTOR_FIXED) | if (factor->flags & AW_CLK_FACTOR_FIXED) | ||||
return (factor->value); | return (factor->value); | ||||
factor_val = (val & factor->mask) >> factor->shift; | 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) | if (factor->flags & AW_CLK_FACTOR_POWER_OF_TWO) | ||||
factor_val = 1 << factor_val; | factor_val = 1 << factor_val; | ||||
else if (!(factor->flags & AW_CLK_FACTOR_ZERO_BASED)) | else if (!(factor->flags & AW_CLK_FACTOR_ZERO_BASED)) | ||||
factor_val += 1; | factor_val += 1; | ||||
return (factor_val); | return (factor_val); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines |