diff options
author | Haojian Zhuang <haojian.zhuang@linaro.org> | 2013-06-08 10:47:18 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-06-15 23:23:49 -0400 |
commit | d57dfe7508af2b528e26d84792edec1e7d919682 (patch) | |
tree | f3be7ce2e20cdf9fad2528b4a1972e29df20a662 | |
parent | ba492e900704ba00d43c7af9d94b00da4df52587 (diff) |
clk: divider: add CLK_DIVIDER_HIWORD_MASK flag
In both Hisilicon & Rockchip Cortex-A9 based chips, they don't use the
paradigm of reading-changing-writing the register contents.
Instead they use a hiword mask to indicate the changed bits.
When b01 should be set as setting divider, it also needs to indicate
the change by setting hiword mask (b11 << 16).
The patch adds divider flag for this usage.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r-- | drivers/clk/clk-divider.c | 15 | ||||
-rw-r--r-- | include/linux/clk-provider.h | 5 |
2 files changed, 18 insertions, 2 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 6024e60e49aa..6d55eb2cb959 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c | |||
@@ -227,8 +227,12 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, | |||
227 | if (divider->lock) | 227 | if (divider->lock) |
228 | spin_lock_irqsave(divider->lock, flags); | 228 | spin_lock_irqsave(divider->lock, flags); |
229 | 229 | ||
230 | val = readl(divider->reg); | 230 | if (divider->flags & CLK_DIVIDER_HIWORD_MASK) { |
231 | val &= ~(div_mask(divider) << divider->shift); | 231 | val = div_mask(divider) << (divider->shift + 16); |
232 | } else { | ||
233 | val = readl(divider->reg); | ||
234 | val &= ~(div_mask(divider) << divider->shift); | ||
235 | } | ||
232 | val |= value << divider->shift; | 236 | val |= value << divider->shift; |
233 | writel(val, divider->reg); | 237 | writel(val, divider->reg); |
234 | 238 | ||
@@ -255,6 +259,13 @@ static struct clk *_register_divider(struct device *dev, const char *name, | |||
255 | struct clk *clk; | 259 | struct clk *clk; |
256 | struct clk_init_data init; | 260 | struct clk_init_data init; |
257 | 261 | ||
262 | if (clk_divider_flags & CLK_DIVIDER_HIWORD_MASK) { | ||
263 | if (width + shift > 16) { | ||
264 | pr_warn("divider value exceeds LOWORD field\n"); | ||
265 | return ERR_PTR(-EINVAL); | ||
266 | } | ||
267 | } | ||
268 | |||
258 | /* allocate the divider */ | 269 | /* allocate the divider */ |
259 | div = kzalloc(sizeof(struct clk_divider), GFP_KERNEL); | 270 | div = kzalloc(sizeof(struct clk_divider), GFP_KERNEL); |
260 | if (!div) { | 271 | if (!div) { |
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 37ad97961e5a..d77f1267f419 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h | |||
@@ -257,6 +257,10 @@ struct clk_div_table { | |||
257 | * Some hardware implementations gracefully handle this case and allow a | 257 | * Some hardware implementations gracefully handle this case and allow a |
258 | * zero divisor by not modifying their input clock | 258 | * zero divisor by not modifying their input clock |
259 | * (divide by one / bypass). | 259 | * (divide by one / bypass). |
260 | * CLK_DIVIDER_HIWORD_MASK - The divider settings are only in lower 16-bit | ||
261 | * of this register, and mask of divider bits are in higher 16-bit of this | ||
262 | * register. While setting the divider bits, higher 16-bit should also be | ||
263 | * updated to indicate changing divider bits. | ||
260 | */ | 264 | */ |
261 | struct clk_divider { | 265 | struct clk_divider { |
262 | struct clk_hw hw; | 266 | struct clk_hw hw; |
@@ -271,6 +275,7 @@ struct clk_divider { | |||
271 | #define CLK_DIVIDER_ONE_BASED BIT(0) | 275 | #define CLK_DIVIDER_ONE_BASED BIT(0) |
272 | #define CLK_DIVIDER_POWER_OF_TWO BIT(1) | 276 | #define CLK_DIVIDER_POWER_OF_TWO BIT(1) |
273 | #define CLK_DIVIDER_ALLOW_ZERO BIT(2) | 277 | #define CLK_DIVIDER_ALLOW_ZERO BIT(2) |
278 | #define CLK_DIVIDER_HIWORD_MASK BIT(3) | ||
274 | 279 | ||
275 | extern const struct clk_ops clk_divider_ops; | 280 | extern const struct clk_ops clk_divider_ops; |
276 | struct clk *clk_register_divider(struct device *dev, const char *name, | 281 | struct clk *clk_register_divider(struct device *dev, const char *name, |