diff options
author | Alex Elder <elder@linaro.org> | 2014-04-21 17:11:43 -0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-04-30 14:51:38 -0400 |
commit | dc613840a625bfad38141d2d8bbdb0c7bc3d45eb (patch) | |
tree | 9cc26fa89833eee39df05a074cbcf8eb414d023d /drivers/clk/bcm/clk-kona-setup.c | |
parent | a597faccc7eedd406313e880ed05ff75bc522910 (diff) |
clk: bcm281xx: add clock hysteresis support
Add support for clock gate hysteresis control. For now, if it's
defined for a clock, it's enabled.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/bcm/clk-kona-setup.c')
-rw-r--r-- | drivers/clk/bcm/clk-kona-setup.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/clk/bcm/clk-kona-setup.c b/drivers/clk/bcm/clk-kona-setup.c index 773ad7c7dd59..e5aededdd322 100644 --- a/drivers/clk/bcm/clk-kona-setup.c +++ b/drivers/clk/bcm/clk-kona-setup.c | |||
@@ -81,6 +81,7 @@ static bool peri_clk_data_offsets_valid(struct kona_clk *bcm_clk) | |||
81 | struct peri_clk_data *peri; | 81 | struct peri_clk_data *peri; |
82 | struct bcm_clk_policy *policy; | 82 | struct bcm_clk_policy *policy; |
83 | struct bcm_clk_gate *gate; | 83 | struct bcm_clk_gate *gate; |
84 | struct bcm_clk_hyst *hyst; | ||
84 | struct bcm_clk_div *div; | 85 | struct bcm_clk_div *div; |
85 | struct bcm_clk_sel *sel; | 86 | struct bcm_clk_sel *sel; |
86 | struct bcm_clk_trig *trig; | 87 | struct bcm_clk_trig *trig; |
@@ -106,12 +107,25 @@ static bool peri_clk_data_offsets_valid(struct kona_clk *bcm_clk) | |||
106 | } | 107 | } |
107 | 108 | ||
108 | gate = &peri->gate; | 109 | gate = &peri->gate; |
110 | hyst = &peri->hyst; | ||
109 | if (gate_exists(gate)) { | 111 | if (gate_exists(gate)) { |
110 | if (gate->offset > limit) { | 112 | if (gate->offset > limit) { |
111 | pr_err("%s: bad gate offset for %s (%u > %u)\n", | 113 | pr_err("%s: bad gate offset for %s (%u > %u)\n", |
112 | __func__, name, gate->offset, limit); | 114 | __func__, name, gate->offset, limit); |
113 | return false; | 115 | return false; |
114 | } | 116 | } |
117 | |||
118 | if (hyst_exists(hyst)) { | ||
119 | if (hyst->offset > limit) { | ||
120 | pr_err("%s: bad hysteresis offset for %s " | ||
121 | "(%u > %u)\n", __func__, | ||
122 | name, hyst->offset, limit); | ||
123 | return false; | ||
124 | } | ||
125 | } | ||
126 | } else if (hyst_exists(hyst)) { | ||
127 | pr_err("%s: hysteresis but no gate for %s\n", __func__, name); | ||
128 | return false; | ||
115 | } | 129 | } |
116 | 130 | ||
117 | div = &peri->div; | 131 | div = &peri->div; |
@@ -261,6 +275,17 @@ static bool gate_valid(struct bcm_clk_gate *gate, const char *field_name, | |||
261 | return true; | 275 | return true; |
262 | } | 276 | } |
263 | 277 | ||
278 | static bool hyst_valid(struct bcm_clk_hyst *hyst, const char *clock_name) | ||
279 | { | ||
280 | if (!bit_posn_valid(hyst->en_bit, "hysteresis enable", clock_name)) | ||
281 | return false; | ||
282 | |||
283 | if (!bit_posn_valid(hyst->val_bit, "hysteresis value", clock_name)) | ||
284 | return false; | ||
285 | |||
286 | return true; | ||
287 | } | ||
288 | |||
264 | /* | 289 | /* |
265 | * A selector bitfield must be valid. Its parent_sel array must | 290 | * A selector bitfield must be valid. Its parent_sel array must |
266 | * also be reasonable for the field. | 291 | * also be reasonable for the field. |
@@ -379,6 +404,7 @@ peri_clk_data_valid(struct kona_clk *bcm_clk) | |||
379 | struct peri_clk_data *peri; | 404 | struct peri_clk_data *peri; |
380 | struct bcm_clk_policy *policy; | 405 | struct bcm_clk_policy *policy; |
381 | struct bcm_clk_gate *gate; | 406 | struct bcm_clk_gate *gate; |
407 | struct bcm_clk_hyst *hyst; | ||
382 | struct bcm_clk_sel *sel; | 408 | struct bcm_clk_sel *sel; |
383 | struct bcm_clk_div *div; | 409 | struct bcm_clk_div *div; |
384 | struct bcm_clk_div *pre_div; | 410 | struct bcm_clk_div *pre_div; |
@@ -406,6 +432,10 @@ peri_clk_data_valid(struct kona_clk *bcm_clk) | |||
406 | if (gate_exists(gate) && !gate_valid(gate, "gate", name)) | 432 | if (gate_exists(gate) && !gate_valid(gate, "gate", name)) |
407 | return false; | 433 | return false; |
408 | 434 | ||
435 | hyst = &peri->hyst; | ||
436 | if (hyst_exists(hyst) && !hyst_valid(hyst, name)) | ||
437 | return false; | ||
438 | |||
409 | sel = &peri->sel; | 439 | sel = &peri->sel; |
410 | if (selector_exists(sel)) { | 440 | if (selector_exists(sel)) { |
411 | if (!sel_valid(sel, "selector", name)) | 441 | if (!sel_valid(sel, "selector", name)) |