diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2015-09-16 17:47:39 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2016-02-17 11:52:59 -0500 |
commit | 99a81706526fb167029a940ef1f7bfbe882abd3e (patch) | |
tree | f35afa9e90b6a0825bf3f527160482fda286e91c | |
parent | 1bdf02326b71eae7e9b4b335b881856aaf9d1af6 (diff) |
clk: at91: remove IRQ handling and use polling
The AT91 clock drivers make use of IRQs to avoid polling when waiting for
some clocks to be enabled. Unfortunately, this leads to a crash when those
IRQs are threaded (which happens when using preempt-rt) because they are
registered before thread creation is possible.
Use polling on those clocks instead to avoid the problem.
Acked-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r-- | drivers/clk/at91/clk-main.c | 138 | ||||
-rw-r--r-- | drivers/clk/at91/clk-master.c | 46 | ||||
-rw-r--r-- | drivers/clk/at91/clk-pll.c | 47 | ||||
-rw-r--r-- | drivers/clk/at91/clk-system.c | 56 | ||||
-rw-r--r-- | drivers/clk/at91/clk-utmi.c | 49 | ||||
-rw-r--r-- | drivers/clk/at91/pmc.c | 144 | ||||
-rw-r--r-- | drivers/clk/at91/pmc.h | 3 |
7 files changed, 37 insertions, 446 deletions
diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c index c1f119748bdc..4bfc94d6c26e 100644 --- a/drivers/clk/at91/clk-main.c +++ b/drivers/clk/at91/clk-main.c | |||
@@ -13,15 +13,8 @@ | |||
13 | #include <linux/clk/at91_pmc.h> | 13 | #include <linux/clk/at91_pmc.h> |
14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
15 | #include <linux/of.h> | 15 | #include <linux/of.h> |
16 | #include <linux/of_address.h> | ||
17 | #include <linux/of_irq.h> | ||
18 | #include <linux/io.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/irq.h> | ||
21 | #include <linux/mfd/syscon.h> | 16 | #include <linux/mfd/syscon.h> |
22 | #include <linux/regmap.h> | 17 | #include <linux/regmap.h> |
23 | #include <linux/sched.h> | ||
24 | #include <linux/wait.h> | ||
25 | 18 | ||
26 | #include "pmc.h" | 19 | #include "pmc.h" |
27 | 20 | ||
@@ -37,8 +30,6 @@ | |||
37 | struct clk_main_osc { | 30 | struct clk_main_osc { |
38 | struct clk_hw hw; | 31 | struct clk_hw hw; |
39 | struct regmap *regmap; | 32 | struct regmap *regmap; |
40 | unsigned int irq; | ||
41 | wait_queue_head_t wait; | ||
42 | }; | 33 | }; |
43 | 34 | ||
44 | #define to_clk_main_osc(hw) container_of(hw, struct clk_main_osc, hw) | 35 | #define to_clk_main_osc(hw) container_of(hw, struct clk_main_osc, hw) |
@@ -46,8 +37,6 @@ struct clk_main_osc { | |||
46 | struct clk_main_rc_osc { | 37 | struct clk_main_rc_osc { |
47 | struct clk_hw hw; | 38 | struct clk_hw hw; |
48 | struct regmap *regmap; | 39 | struct regmap *regmap; |
49 | unsigned int irq; | ||
50 | wait_queue_head_t wait; | ||
51 | unsigned long frequency; | 40 | unsigned long frequency; |
52 | unsigned long accuracy; | 41 | unsigned long accuracy; |
53 | }; | 42 | }; |
@@ -64,23 +53,11 @@ struct clk_rm9200_main { | |||
64 | struct clk_sam9x5_main { | 53 | struct clk_sam9x5_main { |
65 | struct clk_hw hw; | 54 | struct clk_hw hw; |
66 | struct regmap *regmap; | 55 | struct regmap *regmap; |
67 | unsigned int irq; | ||
68 | wait_queue_head_t wait; | ||
69 | u8 parent; | 56 | u8 parent; |
70 | }; | 57 | }; |
71 | 58 | ||
72 | #define to_clk_sam9x5_main(hw) container_of(hw, struct clk_sam9x5_main, hw) | 59 | #define to_clk_sam9x5_main(hw) container_of(hw, struct clk_sam9x5_main, hw) |
73 | 60 | ||
74 | static irqreturn_t clk_main_osc_irq_handler(int irq, void *dev_id) | ||
75 | { | ||
76 | struct clk_main_osc *osc = dev_id; | ||
77 | |||
78 | wake_up(&osc->wait); | ||
79 | disable_irq_nosync(osc->irq); | ||
80 | |||
81 | return IRQ_HANDLED; | ||
82 | } | ||
83 | |||
84 | static inline bool clk_main_osc_ready(struct regmap *regmap) | 61 | static inline bool clk_main_osc_ready(struct regmap *regmap) |
85 | { | 62 | { |
86 | unsigned int status; | 63 | unsigned int status; |
@@ -107,11 +84,8 @@ static int clk_main_osc_prepare(struct clk_hw *hw) | |||
107 | regmap_write(regmap, AT91_CKGR_MOR, tmp); | 84 | regmap_write(regmap, AT91_CKGR_MOR, tmp); |
108 | } | 85 | } |
109 | 86 | ||
110 | while (!clk_main_osc_ready(regmap)) { | 87 | while (!clk_main_osc_ready(regmap)) |
111 | enable_irq(osc->irq); | 88 | cpu_relax(); |
112 | wait_event(osc->wait, | ||
113 | clk_main_osc_ready(regmap)); | ||
114 | } | ||
115 | 89 | ||
116 | return 0; | 90 | return 0; |
117 | } | 91 | } |
@@ -156,17 +130,15 @@ static const struct clk_ops main_osc_ops = { | |||
156 | 130 | ||
157 | static struct clk * __init | 131 | static struct clk * __init |
158 | at91_clk_register_main_osc(struct regmap *regmap, | 132 | at91_clk_register_main_osc(struct regmap *regmap, |
159 | unsigned int irq, | ||
160 | const char *name, | 133 | const char *name, |
161 | const char *parent_name, | 134 | const char *parent_name, |
162 | bool bypass) | 135 | bool bypass) |
163 | { | 136 | { |
164 | int ret; | ||
165 | struct clk_main_osc *osc; | 137 | struct clk_main_osc *osc; |
166 | struct clk *clk = NULL; | 138 | struct clk *clk = NULL; |
167 | struct clk_init_data init; | 139 | struct clk_init_data init; |
168 | 140 | ||
169 | if (!irq || !name || !parent_name) | 141 | if (!name || !parent_name) |
170 | return ERR_PTR(-EINVAL); | 142 | return ERR_PTR(-EINVAL); |
171 | 143 | ||
172 | osc = kzalloc(sizeof(*osc), GFP_KERNEL); | 144 | osc = kzalloc(sizeof(*osc), GFP_KERNEL); |
@@ -181,16 +153,6 @@ at91_clk_register_main_osc(struct regmap *regmap, | |||
181 | 153 | ||
182 | osc->hw.init = &init; | 154 | osc->hw.init = &init; |
183 | osc->regmap = regmap; | 155 | osc->regmap = regmap; |
184 | osc->irq = irq; | ||
185 | |||
186 | init_waitqueue_head(&osc->wait); | ||
187 | irq_set_status_flags(osc->irq, IRQ_NOAUTOEN); | ||
188 | ret = request_irq(osc->irq, clk_main_osc_irq_handler, | ||
189 | IRQF_TRIGGER_HIGH, name, osc); | ||
190 | if (ret) { | ||
191 | kfree(osc); | ||
192 | return ERR_PTR(ret); | ||
193 | } | ||
194 | 156 | ||
195 | if (bypass) | 157 | if (bypass) |
196 | regmap_update_bits(regmap, | 158 | regmap_update_bits(regmap, |
@@ -199,10 +161,8 @@ at91_clk_register_main_osc(struct regmap *regmap, | |||
199 | AT91_PMC_OSCBYPASS | AT91_PMC_KEY); | 161 | AT91_PMC_OSCBYPASS | AT91_PMC_KEY); |
200 | 162 | ||
201 | clk = clk_register(NULL, &osc->hw); | 163 | clk = clk_register(NULL, &osc->hw); |
202 | if (IS_ERR(clk)) { | 164 | if (IS_ERR(clk)) |
203 | free_irq(irq, osc); | ||
204 | kfree(osc); | 165 | kfree(osc); |
205 | } | ||
206 | 166 | ||
207 | return clk; | 167 | return clk; |
208 | } | 168 | } |
@@ -210,7 +170,6 @@ at91_clk_register_main_osc(struct regmap *regmap, | |||
210 | static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) | 170 | static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) |
211 | { | 171 | { |
212 | struct clk *clk; | 172 | struct clk *clk; |
213 | unsigned int irq; | ||
214 | const char *name = np->name; | 173 | const char *name = np->name; |
215 | const char *parent_name; | 174 | const char *parent_name; |
216 | struct regmap *regmap; | 175 | struct regmap *regmap; |
@@ -224,11 +183,7 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) | |||
224 | if (IS_ERR(regmap)) | 183 | if (IS_ERR(regmap)) |
225 | return; | 184 | return; |
226 | 185 | ||
227 | irq = irq_of_parse_and_map(np, 0); | 186 | clk = at91_clk_register_main_osc(regmap, name, parent_name, bypass); |
228 | if (!irq) | ||
229 | return; | ||
230 | |||
231 | clk = at91_clk_register_main_osc(regmap, irq, name, parent_name, bypass); | ||
232 | if (IS_ERR(clk)) | 187 | if (IS_ERR(clk)) |
233 | return; | 188 | return; |
234 | 189 | ||
@@ -237,16 +192,6 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) | |||
237 | CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc", | 192 | CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc", |
238 | of_at91rm9200_clk_main_osc_setup); | 193 | of_at91rm9200_clk_main_osc_setup); |
239 | 194 | ||
240 | static irqreturn_t clk_main_rc_osc_irq_handler(int irq, void *dev_id) | ||
241 | { | ||
242 | struct clk_main_rc_osc *osc = dev_id; | ||
243 | |||
244 | wake_up(&osc->wait); | ||
245 | disable_irq_nosync(osc->irq); | ||
246 | |||
247 | return IRQ_HANDLED; | ||
248 | } | ||
249 | |||
250 | static bool clk_main_rc_osc_ready(struct regmap *regmap) | 195 | static bool clk_main_rc_osc_ready(struct regmap *regmap) |
251 | { | 196 | { |
252 | unsigned int status; | 197 | unsigned int status; |
@@ -269,11 +214,8 @@ static int clk_main_rc_osc_prepare(struct clk_hw *hw) | |||
269 | MOR_KEY_MASK | AT91_PMC_MOSCRCEN, | 214 | MOR_KEY_MASK | AT91_PMC_MOSCRCEN, |
270 | AT91_PMC_MOSCRCEN | AT91_PMC_KEY); | 215 | AT91_PMC_MOSCRCEN | AT91_PMC_KEY); |
271 | 216 | ||
272 | while (!clk_main_rc_osc_ready(regmap)) { | 217 | while (!clk_main_rc_osc_ready(regmap)) |
273 | enable_irq(osc->irq); | 218 | cpu_relax(); |
274 | wait_event(osc->wait, | ||
275 | clk_main_rc_osc_ready(regmap)); | ||
276 | } | ||
277 | 219 | ||
278 | return 0; | 220 | return 0; |
279 | } | 221 | } |
@@ -331,11 +273,9 @@ static const struct clk_ops main_rc_osc_ops = { | |||
331 | 273 | ||
332 | static struct clk * __init | 274 | static struct clk * __init |
333 | at91_clk_register_main_rc_osc(struct regmap *regmap, | 275 | at91_clk_register_main_rc_osc(struct regmap *regmap, |
334 | unsigned int irq, | ||
335 | const char *name, | 276 | const char *name, |
336 | u32 frequency, u32 accuracy) | 277 | u32 frequency, u32 accuracy) |
337 | { | 278 | { |
338 | int ret; | ||
339 | struct clk_main_rc_osc *osc; | 279 | struct clk_main_rc_osc *osc; |
340 | struct clk *clk = NULL; | 280 | struct clk *clk = NULL; |
341 | struct clk_init_data init; | 281 | struct clk_init_data init; |
@@ -355,22 +295,12 @@ at91_clk_register_main_rc_osc(struct regmap *regmap, | |||
355 | 295 | ||
356 | osc->hw.init = &init; | 296 | osc->hw.init = &init; |
357 | osc->regmap = regmap; | 297 | osc->regmap = regmap; |
358 | osc->irq = irq; | ||
359 | osc->frequency = frequency; | 298 | osc->frequency = frequency; |
360 | osc->accuracy = accuracy; | 299 | osc->accuracy = accuracy; |
361 | 300 | ||
362 | init_waitqueue_head(&osc->wait); | ||
363 | irq_set_status_flags(osc->irq, IRQ_NOAUTOEN); | ||
364 | ret = request_irq(osc->irq, clk_main_rc_osc_irq_handler, | ||
365 | IRQF_TRIGGER_HIGH, name, osc); | ||
366 | if (ret) | ||
367 | return ERR_PTR(ret); | ||
368 | |||
369 | clk = clk_register(NULL, &osc->hw); | 301 | clk = clk_register(NULL, &osc->hw); |
370 | if (IS_ERR(clk)) { | 302 | if (IS_ERR(clk)) |
371 | free_irq(irq, osc); | ||
372 | kfree(osc); | 303 | kfree(osc); |
373 | } | ||
374 | 304 | ||
375 | return clk; | 305 | return clk; |
376 | } | 306 | } |
@@ -378,7 +308,6 @@ at91_clk_register_main_rc_osc(struct regmap *regmap, | |||
378 | static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np) | 308 | static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np) |
379 | { | 309 | { |
380 | struct clk *clk; | 310 | struct clk *clk; |
381 | unsigned int irq; | ||
382 | u32 frequency = 0; | 311 | u32 frequency = 0; |
383 | u32 accuracy = 0; | 312 | u32 accuracy = 0; |
384 | const char *name = np->name; | 313 | const char *name = np->name; |
@@ -388,16 +317,11 @@ static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np) | |||
388 | of_property_read_u32(np, "clock-frequency", &frequency); | 317 | of_property_read_u32(np, "clock-frequency", &frequency); |
389 | of_property_read_u32(np, "clock-accuracy", &accuracy); | 318 | of_property_read_u32(np, "clock-accuracy", &accuracy); |
390 | 319 | ||
391 | irq = irq_of_parse_and_map(np, 0); | ||
392 | if (!irq) | ||
393 | return; | ||
394 | |||
395 | regmap = syscon_node_to_regmap(of_get_parent(np)); | 320 | regmap = syscon_node_to_regmap(of_get_parent(np)); |
396 | if (IS_ERR(regmap)) | 321 | if (IS_ERR(regmap)) |
397 | return; | 322 | return; |
398 | 323 | ||
399 | clk = at91_clk_register_main_rc_osc(regmap, irq, name, frequency, | 324 | clk = at91_clk_register_main_rc_osc(regmap, name, frequency, accuracy); |
400 | accuracy); | ||
401 | if (IS_ERR(clk)) | 325 | if (IS_ERR(clk)) |
402 | return; | 326 | return; |
403 | 327 | ||
@@ -529,16 +453,6 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np) | |||
529 | CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main", | 453 | CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main", |
530 | of_at91rm9200_clk_main_setup); | 454 | of_at91rm9200_clk_main_setup); |
531 | 455 | ||
532 | static irqreturn_t clk_sam9x5_main_irq_handler(int irq, void *dev_id) | ||
533 | { | ||
534 | struct clk_sam9x5_main *clkmain = dev_id; | ||
535 | |||
536 | wake_up(&clkmain->wait); | ||
537 | disable_irq_nosync(clkmain->irq); | ||
538 | |||
539 | return IRQ_HANDLED; | ||
540 | } | ||
541 | |||
542 | static inline bool clk_sam9x5_main_ready(struct regmap *regmap) | 456 | static inline bool clk_sam9x5_main_ready(struct regmap *regmap) |
543 | { | 457 | { |
544 | unsigned int status; | 458 | unsigned int status; |
@@ -553,11 +467,8 @@ static int clk_sam9x5_main_prepare(struct clk_hw *hw) | |||
553 | struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); | 467 | struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); |
554 | struct regmap *regmap = clkmain->regmap; | 468 | struct regmap *regmap = clkmain->regmap; |
555 | 469 | ||
556 | while (!clk_sam9x5_main_ready(regmap)) { | 470 | while (!clk_sam9x5_main_ready(regmap)) |
557 | enable_irq(clkmain->irq); | 471 | cpu_relax(); |
558 | wait_event(clkmain->wait, | ||
559 | clk_sam9x5_main_ready(regmap)); | ||
560 | } | ||
561 | 472 | ||
562 | return clk_main_probe_frequency(regmap); | 473 | return clk_main_probe_frequency(regmap); |
563 | } | 474 | } |
@@ -594,11 +505,8 @@ static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index) | |||
594 | else if (!index && (tmp & AT91_PMC_MOSCSEL)) | 505 | else if (!index && (tmp & AT91_PMC_MOSCSEL)) |
595 | regmap_write(regmap, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL); | 506 | regmap_write(regmap, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL); |
596 | 507 | ||
597 | while (!clk_sam9x5_main_ready(regmap)) { | 508 | while (!clk_sam9x5_main_ready(regmap)) |
598 | enable_irq(clkmain->irq); | 509 | cpu_relax(); |
599 | wait_event(clkmain->wait, | ||
600 | clk_sam9x5_main_ready(regmap)); | ||
601 | } | ||
602 | 510 | ||
603 | return 0; | 511 | return 0; |
604 | } | 512 | } |
@@ -623,12 +531,10 @@ static const struct clk_ops sam9x5_main_ops = { | |||
623 | 531 | ||
624 | static struct clk * __init | 532 | static struct clk * __init |
625 | at91_clk_register_sam9x5_main(struct regmap *regmap, | 533 | at91_clk_register_sam9x5_main(struct regmap *regmap, |
626 | unsigned int irq, | ||
627 | const char *name, | 534 | const char *name, |
628 | const char **parent_names, | 535 | const char **parent_names, |
629 | int num_parents) | 536 | int num_parents) |
630 | { | 537 | { |
631 | int ret; | ||
632 | struct clk_sam9x5_main *clkmain; | 538 | struct clk_sam9x5_main *clkmain; |
633 | struct clk *clk = NULL; | 539 | struct clk *clk = NULL; |
634 | struct clk_init_data init; | 540 | struct clk_init_data init; |
@@ -652,21 +558,12 @@ at91_clk_register_sam9x5_main(struct regmap *regmap, | |||
652 | 558 | ||
653 | clkmain->hw.init = &init; | 559 | clkmain->hw.init = &init; |
654 | clkmain->regmap = regmap; | 560 | clkmain->regmap = regmap; |
655 | clkmain->irq = irq; | ||
656 | regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status); | 561 | regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status); |
657 | clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0; | 562 | clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0; |
658 | init_waitqueue_head(&clkmain->wait); | ||
659 | irq_set_status_flags(clkmain->irq, IRQ_NOAUTOEN); | ||
660 | ret = request_irq(clkmain->irq, clk_sam9x5_main_irq_handler, | ||
661 | IRQF_TRIGGER_HIGH, name, clkmain); | ||
662 | if (ret) | ||
663 | return ERR_PTR(ret); | ||
664 | 563 | ||
665 | clk = clk_register(NULL, &clkmain->hw); | 564 | clk = clk_register(NULL, &clkmain->hw); |
666 | if (IS_ERR(clk)) { | 565 | if (IS_ERR(clk)) |
667 | free_irq(clkmain->irq, clkmain); | ||
668 | kfree(clkmain); | 566 | kfree(clkmain); |
669 | } | ||
670 | 567 | ||
671 | return clk; | 568 | return clk; |
672 | } | 569 | } |
@@ -676,7 +573,6 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np) | |||
676 | struct clk *clk; | 573 | struct clk *clk; |
677 | const char *parent_names[2]; | 574 | const char *parent_names[2]; |
678 | int num_parents; | 575 | int num_parents; |
679 | unsigned int irq; | ||
680 | const char *name = np->name; | 576 | const char *name = np->name; |
681 | struct regmap *regmap; | 577 | struct regmap *regmap; |
682 | 578 | ||
@@ -691,11 +587,7 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np) | |||
691 | 587 | ||
692 | of_property_read_string(np, "clock-output-names", &name); | 588 | of_property_read_string(np, "clock-output-names", &name); |
693 | 589 | ||
694 | irq = irq_of_parse_and_map(np, 0); | 590 | clk = at91_clk_register_sam9x5_main(regmap, name, parent_names, |
695 | if (!irq) | ||
696 | return; | ||
697 | |||
698 | clk = at91_clk_register_sam9x5_main(regmap, irq, name, parent_names, | ||
699 | num_parents); | 591 | num_parents); |
700 | if (IS_ERR(clk)) | 592 | if (IS_ERR(clk)) |
701 | return; | 593 | return; |
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c index 8d94ddfc9c72..7d4a1864ea7c 100644 --- a/drivers/clk/at91/clk-master.c +++ b/drivers/clk/at91/clk-master.c | |||
@@ -12,13 +12,6 @@ | |||
12 | #include <linux/clkdev.h> | 12 | #include <linux/clkdev.h> |
13 | #include <linux/clk/at91_pmc.h> | 13 | #include <linux/clk/at91_pmc.h> |
14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
15 | #include <linux/of_address.h> | ||
16 | #include <linux/of_irq.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/wait.h> | ||
19 | #include <linux/sched.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/irq.h> | ||
22 | #include <linux/mfd/syscon.h> | 15 | #include <linux/mfd/syscon.h> |
23 | #include <linux/regmap.h> | 16 | #include <linux/regmap.h> |
24 | 17 | ||
@@ -47,22 +40,10 @@ struct clk_master_layout { | |||
47 | struct clk_master { | 40 | struct clk_master { |
48 | struct clk_hw hw; | 41 | struct clk_hw hw; |
49 | struct regmap *regmap; | 42 | struct regmap *regmap; |
50 | unsigned int irq; | ||
51 | wait_queue_head_t wait; | ||
52 | const struct clk_master_layout *layout; | 43 | const struct clk_master_layout *layout; |
53 | const struct clk_master_characteristics *characteristics; | 44 | const struct clk_master_characteristics *characteristics; |
54 | }; | 45 | }; |
55 | 46 | ||
56 | static irqreturn_t clk_master_irq_handler(int irq, void *dev_id) | ||
57 | { | ||
58 | struct clk_master *master = (struct clk_master *)dev_id; | ||
59 | |||
60 | wake_up(&master->wait); | ||
61 | disable_irq_nosync(master->irq); | ||
62 | |||
63 | return IRQ_HANDLED; | ||
64 | } | ||
65 | |||
66 | static inline bool clk_master_ready(struct regmap *regmap) | 47 | static inline bool clk_master_ready(struct regmap *regmap) |
67 | { | 48 | { |
68 | unsigned int status; | 49 | unsigned int status; |
@@ -76,11 +57,8 @@ static int clk_master_prepare(struct clk_hw *hw) | |||
76 | { | 57 | { |
77 | struct clk_master *master = to_clk_master(hw); | 58 | struct clk_master *master = to_clk_master(hw); |
78 | 59 | ||
79 | while (!clk_master_ready(master->regmap)) { | 60 | while (!clk_master_ready(master->regmap)) |
80 | enable_irq(master->irq); | 61 | cpu_relax(); |
81 | wait_event(master->wait, | ||
82 | clk_master_ready(master->regmap)); | ||
83 | } | ||
84 | 62 | ||
85 | return 0; | 63 | return 0; |
86 | } | 64 | } |
@@ -143,13 +121,12 @@ static const struct clk_ops master_ops = { | |||
143 | }; | 121 | }; |
144 | 122 | ||
145 | static struct clk * __init | 123 | static struct clk * __init |
146 | at91_clk_register_master(struct regmap *regmap, unsigned int irq, | 124 | at91_clk_register_master(struct regmap *regmap, |
147 | const char *name, int num_parents, | 125 | const char *name, int num_parents, |
148 | const char **parent_names, | 126 | const char **parent_names, |
149 | const struct clk_master_layout *layout, | 127 | const struct clk_master_layout *layout, |
150 | const struct clk_master_characteristics *characteristics) | 128 | const struct clk_master_characteristics *characteristics) |
151 | { | 129 | { |
152 | int ret; | ||
153 | struct clk_master *master; | 130 | struct clk_master *master; |
154 | struct clk *clk = NULL; | 131 | struct clk *clk = NULL; |
155 | struct clk_init_data init; | 132 | struct clk_init_data init; |
@@ -171,19 +148,9 @@ at91_clk_register_master(struct regmap *regmap, unsigned int irq, | |||
171 | master->layout = layout; | 148 | master->layout = layout; |
172 | master->characteristics = characteristics; | 149 | master->characteristics = characteristics; |
173 | master->regmap = regmap; | 150 | master->regmap = regmap; |
174 | master->irq = irq; | ||
175 | init_waitqueue_head(&master->wait); | ||
176 | irq_set_status_flags(master->irq, IRQ_NOAUTOEN); | ||
177 | ret = request_irq(master->irq, clk_master_irq_handler, | ||
178 | IRQF_TRIGGER_HIGH, "clk-master", master); | ||
179 | if (ret) { | ||
180 | kfree(master); | ||
181 | return ERR_PTR(ret); | ||
182 | } | ||
183 | 151 | ||
184 | clk = clk_register(NULL, &master->hw); | 152 | clk = clk_register(NULL, &master->hw); |
185 | if (IS_ERR(clk)) { | 153 | if (IS_ERR(clk)) { |
186 | free_irq(master->irq, master); | ||
187 | kfree(master); | 154 | kfree(master); |
188 | } | 155 | } |
189 | 156 | ||
@@ -233,7 +200,6 @@ of_at91_clk_master_setup(struct device_node *np, | |||
233 | { | 200 | { |
234 | struct clk *clk; | 201 | struct clk *clk; |
235 | int num_parents; | 202 | int num_parents; |
236 | unsigned int irq; | ||
237 | const char *parent_names[MASTER_SOURCE_MAX]; | 203 | const char *parent_names[MASTER_SOURCE_MAX]; |
238 | const char *name = np->name; | 204 | const char *name = np->name; |
239 | struct clk_master_characteristics *characteristics; | 205 | struct clk_master_characteristics *characteristics; |
@@ -255,11 +221,7 @@ of_at91_clk_master_setup(struct device_node *np, | |||
255 | if (IS_ERR(regmap)) | 221 | if (IS_ERR(regmap)) |
256 | return; | 222 | return; |
257 | 223 | ||
258 | irq = irq_of_parse_and_map(np, 0); | 224 | clk = at91_clk_register_master(regmap, name, num_parents, |
259 | if (!irq) | ||
260 | goto out_free_characteristics; | ||
261 | |||
262 | clk = at91_clk_register_master(regmap, irq, name, num_parents, | ||
263 | parent_names, layout, | 225 | parent_names, layout, |
264 | characteristics); | 226 | characteristics); |
265 | if (IS_ERR(clk)) | 227 | if (IS_ERR(clk)) |
diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c index 5f4c6ce628e0..fb2e0b56d4b7 100644 --- a/drivers/clk/at91/clk-pll.c +++ b/drivers/clk/at91/clk-pll.c | |||
@@ -12,14 +12,6 @@ | |||
12 | #include <linux/clkdev.h> | 12 | #include <linux/clkdev.h> |
13 | #include <linux/clk/at91_pmc.h> | 13 | #include <linux/clk/at91_pmc.h> |
14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
15 | #include <linux/of_address.h> | ||
16 | #include <linux/of_irq.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/wait.h> | ||
20 | #include <linux/sched.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | #include <linux/irq.h> | ||
23 | #include <linux/mfd/syscon.h> | 15 | #include <linux/mfd/syscon.h> |
24 | #include <linux/regmap.h> | 16 | #include <linux/regmap.h> |
25 | 17 | ||
@@ -61,8 +53,6 @@ struct clk_pll_layout { | |||
61 | struct clk_pll { | 53 | struct clk_pll { |
62 | struct clk_hw hw; | 54 | struct clk_hw hw; |
63 | struct regmap *regmap; | 55 | struct regmap *regmap; |
64 | unsigned int irq; | ||
65 | wait_queue_head_t wait; | ||
66 | u8 id; | 56 | u8 id; |
67 | u8 div; | 57 | u8 div; |
68 | u8 range; | 58 | u8 range; |
@@ -71,16 +61,6 @@ struct clk_pll { | |||
71 | const struct clk_pll_characteristics *characteristics; | 61 | const struct clk_pll_characteristics *characteristics; |
72 | }; | 62 | }; |
73 | 63 | ||
74 | static irqreturn_t clk_pll_irq_handler(int irq, void *dev_id) | ||
75 | { | ||
76 | struct clk_pll *pll = (struct clk_pll *)dev_id; | ||
77 | |||
78 | wake_up(&pll->wait); | ||
79 | disable_irq_nosync(pll->irq); | ||
80 | |||
81 | return IRQ_HANDLED; | ||
82 | } | ||
83 | |||
84 | static inline bool clk_pll_ready(struct regmap *regmap, int id) | 64 | static inline bool clk_pll_ready(struct regmap *regmap, int id) |
85 | { | 65 | { |
86 | unsigned int status; | 66 | unsigned int status; |
@@ -127,11 +107,8 @@ static int clk_pll_prepare(struct clk_hw *hw) | |||
127 | (out << PLL_OUT_SHIFT) | | 107 | (out << PLL_OUT_SHIFT) | |
128 | ((pll->mul & layout->mul_mask) << layout->mul_shift)); | 108 | ((pll->mul & layout->mul_mask) << layout->mul_shift)); |
129 | 109 | ||
130 | while (!clk_pll_ready(regmap, pll->id)) { | 110 | while (!clk_pll_ready(regmap, pll->id)) |
131 | enable_irq(pll->irq); | 111 | cpu_relax(); |
132 | wait_event(pll->wait, | ||
133 | clk_pll_ready(regmap, pll->id)); | ||
134 | } | ||
135 | 112 | ||
136 | return 0; | 113 | return 0; |
137 | } | 114 | } |
@@ -320,7 +297,7 @@ static const struct clk_ops pll_ops = { | |||
320 | }; | 297 | }; |
321 | 298 | ||
322 | static struct clk * __init | 299 | static struct clk * __init |
323 | at91_clk_register_pll(struct regmap *regmap, unsigned int irq, const char *name, | 300 | at91_clk_register_pll(struct regmap *regmap, const char *name, |
324 | const char *parent_name, u8 id, | 301 | const char *parent_name, u8 id, |
325 | const struct clk_pll_layout *layout, | 302 | const struct clk_pll_layout *layout, |
326 | const struct clk_pll_characteristics *characteristics) | 303 | const struct clk_pll_characteristics *characteristics) |
@@ -328,7 +305,6 @@ at91_clk_register_pll(struct regmap *regmap, unsigned int irq, const char *name, | |||
328 | struct clk_pll *pll; | 305 | struct clk_pll *pll; |
329 | struct clk *clk = NULL; | 306 | struct clk *clk = NULL; |
330 | struct clk_init_data init; | 307 | struct clk_init_data init; |
331 | int ret; | ||
332 | int offset = PLL_REG(id); | 308 | int offset = PLL_REG(id); |
333 | unsigned int pllr; | 309 | unsigned int pllr; |
334 | 310 | ||
@@ -350,22 +326,12 @@ at91_clk_register_pll(struct regmap *regmap, unsigned int irq, const char *name, | |||
350 | pll->layout = layout; | 326 | pll->layout = layout; |
351 | pll->characteristics = characteristics; | 327 | pll->characteristics = characteristics; |
352 | pll->regmap = regmap; | 328 | pll->regmap = regmap; |
353 | pll->irq = irq; | ||
354 | regmap_read(regmap, offset, &pllr); | 329 | regmap_read(regmap, offset, &pllr); |
355 | pll->div = PLL_DIV(pllr); | 330 | pll->div = PLL_DIV(pllr); |
356 | pll->mul = PLL_MUL(pllr, layout); | 331 | pll->mul = PLL_MUL(pllr, layout); |
357 | init_waitqueue_head(&pll->wait); | ||
358 | irq_set_status_flags(pll->irq, IRQ_NOAUTOEN); | ||
359 | ret = request_irq(pll->irq, clk_pll_irq_handler, IRQF_TRIGGER_HIGH, | ||
360 | id ? "clk-pllb" : "clk-plla", pll); | ||
361 | if (ret) { | ||
362 | kfree(pll); | ||
363 | return ERR_PTR(ret); | ||
364 | } | ||
365 | 332 | ||
366 | clk = clk_register(NULL, &pll->hw); | 333 | clk = clk_register(NULL, &pll->hw); |
367 | if (IS_ERR(clk)) { | 334 | if (IS_ERR(clk)) { |
368 | free_irq(pll->irq, pll); | ||
369 | kfree(pll); | 335 | kfree(pll); |
370 | } | 336 | } |
371 | 337 | ||
@@ -499,7 +465,6 @@ of_at91_clk_pll_setup(struct device_node *np, | |||
499 | const struct clk_pll_layout *layout) | 465 | const struct clk_pll_layout *layout) |
500 | { | 466 | { |
501 | u32 id; | 467 | u32 id; |
502 | unsigned int irq; | ||
503 | struct clk *clk; | 468 | struct clk *clk; |
504 | struct regmap *regmap; | 469 | struct regmap *regmap; |
505 | const char *parent_name; | 470 | const char *parent_name; |
@@ -521,11 +486,7 @@ of_at91_clk_pll_setup(struct device_node *np, | |||
521 | if (!characteristics) | 486 | if (!characteristics) |
522 | return; | 487 | return; |
523 | 488 | ||
524 | irq = irq_of_parse_and_map(np, 0); | 489 | clk = at91_clk_register_pll(regmap, name, parent_name, id, layout, |
525 | if (!irq) | ||
526 | return; | ||
527 | |||
528 | clk = at91_clk_register_pll(regmap, irq, name, parent_name, id, layout, | ||
529 | characteristics); | 490 | characteristics); |
530 | if (IS_ERR(clk)) | 491 | if (IS_ERR(clk)) |
531 | goto out_free_characteristics; | 492 | goto out_free_characteristics; |
diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c index 0593adf1bf4b..8f35d8172909 100644 --- a/drivers/clk/at91/clk-system.c +++ b/drivers/clk/at91/clk-system.c | |||
@@ -12,13 +12,6 @@ | |||
12 | #include <linux/clkdev.h> | 12 | #include <linux/clkdev.h> |
13 | #include <linux/clk/at91_pmc.h> | 13 | #include <linux/clk/at91_pmc.h> |
14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
15 | #include <linux/of_address.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/irq.h> | ||
18 | #include <linux/of_irq.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/wait.h> | ||
21 | #include <linux/sched.h> | ||
22 | #include <linux/mfd/syscon.h> | 15 | #include <linux/mfd/syscon.h> |
23 | #include <linux/regmap.h> | 16 | #include <linux/regmap.h> |
24 | 17 | ||
@@ -32,8 +25,6 @@ | |||
32 | struct clk_system { | 25 | struct clk_system { |
33 | struct clk_hw hw; | 26 | struct clk_hw hw; |
34 | struct regmap *regmap; | 27 | struct regmap *regmap; |
35 | unsigned int irq; | ||
36 | wait_queue_head_t wait; | ||
37 | u8 id; | 28 | u8 id; |
38 | }; | 29 | }; |
39 | 30 | ||
@@ -41,15 +32,6 @@ static inline int is_pck(int id) | |||
41 | { | 32 | { |
42 | return (id >= 8) && (id <= 15); | 33 | return (id >= 8) && (id <= 15); |
43 | } | 34 | } |
44 | static irqreturn_t clk_system_irq_handler(int irq, void *dev_id) | ||
45 | { | ||
46 | struct clk_system *sys = (struct clk_system *)dev_id; | ||
47 | |||
48 | wake_up(&sys->wait); | ||
49 | disable_irq_nosync(sys->irq); | ||
50 | |||
51 | return IRQ_HANDLED; | ||
52 | } | ||
53 | 35 | ||
54 | static inline bool clk_system_ready(struct regmap *regmap, int id) | 36 | static inline bool clk_system_ready(struct regmap *regmap, int id) |
55 | { | 37 | { |
@@ -69,15 +51,9 @@ static int clk_system_prepare(struct clk_hw *hw) | |||
69 | if (!is_pck(sys->id)) | 51 | if (!is_pck(sys->id)) |
70 | return 0; | 52 | return 0; |
71 | 53 | ||
72 | while (!clk_system_ready(sys->regmap, sys->id)) { | 54 | while (!clk_system_ready(sys->regmap, sys->id)) |
73 | if (sys->irq) { | 55 | cpu_relax(); |
74 | enable_irq(sys->irq); | 56 | |
75 | wait_event(sys->wait, | ||
76 | clk_system_ready(sys->regmap, sys->id)); | ||
77 | } else { | ||
78 | cpu_relax(); | ||
79 | } | ||
80 | } | ||
81 | return 0; | 57 | return 0; |
82 | } | 58 | } |
83 | 59 | ||
@@ -114,12 +90,11 @@ static const struct clk_ops system_ops = { | |||
114 | 90 | ||
115 | static struct clk * __init | 91 | static struct clk * __init |
116 | at91_clk_register_system(struct regmap *regmap, const char *name, | 92 | at91_clk_register_system(struct regmap *regmap, const char *name, |
117 | const char *parent_name, u8 id, int irq) | 93 | const char *parent_name, u8 id) |
118 | { | 94 | { |
119 | struct clk_system *sys; | 95 | struct clk_system *sys; |
120 | struct clk *clk = NULL; | 96 | struct clk *clk = NULL; |
121 | struct clk_init_data init; | 97 | struct clk_init_data init; |
122 | int ret; | ||
123 | 98 | ||
124 | if (!parent_name || id > SYSTEM_MAX_ID) | 99 | if (!parent_name || id > SYSTEM_MAX_ID) |
125 | return ERR_PTR(-EINVAL); | 100 | return ERR_PTR(-EINVAL); |
@@ -137,24 +112,10 @@ at91_clk_register_system(struct regmap *regmap, const char *name, | |||
137 | sys->id = id; | 112 | sys->id = id; |
138 | sys->hw.init = &init; | 113 | sys->hw.init = &init; |
139 | sys->regmap = regmap; | 114 | sys->regmap = regmap; |
140 | sys->irq = irq; | ||
141 | if (irq) { | ||
142 | init_waitqueue_head(&sys->wait); | ||
143 | irq_set_status_flags(sys->irq, IRQ_NOAUTOEN); | ||
144 | ret = request_irq(sys->irq, clk_system_irq_handler, | ||
145 | IRQF_TRIGGER_HIGH, name, sys); | ||
146 | if (ret) { | ||
147 | kfree(sys); | ||
148 | return ERR_PTR(ret); | ||
149 | } | ||
150 | } | ||
151 | 115 | ||
152 | clk = clk_register(NULL, &sys->hw); | 116 | clk = clk_register(NULL, &sys->hw); |
153 | if (IS_ERR(clk)) { | 117 | if (IS_ERR(clk)) |
154 | if (irq) | ||
155 | free_irq(sys->irq, sys); | ||
156 | kfree(sys); | 118 | kfree(sys); |
157 | } | ||
158 | 119 | ||
159 | return clk; | 120 | return clk; |
160 | } | 121 | } |
@@ -162,7 +123,6 @@ at91_clk_register_system(struct regmap *regmap, const char *name, | |||
162 | static void __init of_at91rm9200_clk_sys_setup(struct device_node *np) | 123 | static void __init of_at91rm9200_clk_sys_setup(struct device_node *np) |
163 | { | 124 | { |
164 | int num; | 125 | int num; |
165 | int irq = 0; | ||
166 | u32 id; | 126 | u32 id; |
167 | struct clk *clk; | 127 | struct clk *clk; |
168 | const char *name; | 128 | const char *name; |
@@ -185,13 +145,9 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np) | |||
185 | if (of_property_read_string(np, "clock-output-names", &name)) | 145 | if (of_property_read_string(np, "clock-output-names", &name)) |
186 | name = sysclknp->name; | 146 | name = sysclknp->name; |
187 | 147 | ||
188 | if (is_pck(id)) | ||
189 | irq = irq_of_parse_and_map(sysclknp, 0); | ||
190 | |||
191 | parent_name = of_clk_get_parent_name(sysclknp, 0); | 148 | parent_name = of_clk_get_parent_name(sysclknp, 0); |
192 | 149 | ||
193 | clk = at91_clk_register_system(regmap, name, parent_name, id, | 150 | clk = at91_clk_register_system(regmap, name, parent_name, id); |
194 | irq); | ||
195 | if (IS_ERR(clk)) | 151 | if (IS_ERR(clk)) |
196 | continue; | 152 | continue; |
197 | 153 | ||
diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c index 58a310e5768c..61fcf399e58c 100644 --- a/drivers/clk/at91/clk-utmi.c +++ b/drivers/clk/at91/clk-utmi.c | |||
@@ -11,14 +11,7 @@ | |||
11 | #include <linux/clk-provider.h> | 11 | #include <linux/clk-provider.h> |
12 | #include <linux/clkdev.h> | 12 | #include <linux/clkdev.h> |
13 | #include <linux/clk/at91_pmc.h> | 13 | #include <linux/clk/at91_pmc.h> |
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/irq.h> | ||
16 | #include <linux/of.h> | 14 | #include <linux/of.h> |
17 | #include <linux/of_address.h> | ||
18 | #include <linux/of_irq.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <linux/sched.h> | ||
21 | #include <linux/wait.h> | ||
22 | #include <linux/mfd/syscon.h> | 15 | #include <linux/mfd/syscon.h> |
23 | #include <linux/regmap.h> | 16 | #include <linux/regmap.h> |
24 | 17 | ||
@@ -29,22 +22,10 @@ | |||
29 | struct clk_utmi { | 22 | struct clk_utmi { |
30 | struct clk_hw hw; | 23 | struct clk_hw hw; |
31 | struct regmap *regmap; | 24 | struct regmap *regmap; |
32 | unsigned int irq; | ||
33 | wait_queue_head_t wait; | ||
34 | }; | 25 | }; |
35 | 26 | ||
36 | #define to_clk_utmi(hw) container_of(hw, struct clk_utmi, hw) | 27 | #define to_clk_utmi(hw) container_of(hw, struct clk_utmi, hw) |
37 | 28 | ||
38 | static irqreturn_t clk_utmi_irq_handler(int irq, void *dev_id) | ||
39 | { | ||
40 | struct clk_utmi *utmi = (struct clk_utmi *)dev_id; | ||
41 | |||
42 | wake_up(&utmi->wait); | ||
43 | disable_irq_nosync(utmi->irq); | ||
44 | |||
45 | return IRQ_HANDLED; | ||
46 | } | ||
47 | |||
48 | static inline bool clk_utmi_ready(struct regmap *regmap) | 29 | static inline bool clk_utmi_ready(struct regmap *regmap) |
49 | { | 30 | { |
50 | unsigned int status; | 31 | unsigned int status; |
@@ -62,11 +43,8 @@ static int clk_utmi_prepare(struct clk_hw *hw) | |||
62 | 43 | ||
63 | regmap_update_bits(utmi->regmap, AT91_CKGR_UCKR, uckr, uckr); | 44 | regmap_update_bits(utmi->regmap, AT91_CKGR_UCKR, uckr, uckr); |
64 | 45 | ||
65 | while (!clk_utmi_ready(utmi->regmap)) { | 46 | while (!clk_utmi_ready(utmi->regmap)) |
66 | enable_irq(utmi->irq); | 47 | cpu_relax(); |
67 | wait_event(utmi->wait, | ||
68 | clk_utmi_ready(utmi->regmap)); | ||
69 | } | ||
70 | 48 | ||
71 | return 0; | 49 | return 0; |
72 | } | 50 | } |
@@ -100,10 +78,9 @@ static const struct clk_ops utmi_ops = { | |||
100 | }; | 78 | }; |
101 | 79 | ||
102 | static struct clk * __init | 80 | static struct clk * __init |
103 | at91_clk_register_utmi(struct regmap *regmap, unsigned int irq, | 81 | at91_clk_register_utmi(struct regmap *regmap, |
104 | const char *name, const char *parent_name) | 82 | const char *name, const char *parent_name) |
105 | { | 83 | { |
106 | int ret; | ||
107 | struct clk_utmi *utmi; | 84 | struct clk_utmi *utmi; |
108 | struct clk *clk = NULL; | 85 | struct clk *clk = NULL; |
109 | struct clk_init_data init; | 86 | struct clk_init_data init; |
@@ -120,28 +97,16 @@ at91_clk_register_utmi(struct regmap *regmap, unsigned int irq, | |||
120 | 97 | ||
121 | utmi->hw.init = &init; | 98 | utmi->hw.init = &init; |
122 | utmi->regmap = regmap; | 99 | utmi->regmap = regmap; |
123 | utmi->irq = irq; | ||
124 | init_waitqueue_head(&utmi->wait); | ||
125 | irq_set_status_flags(utmi->irq, IRQ_NOAUTOEN); | ||
126 | ret = request_irq(utmi->irq, clk_utmi_irq_handler, | ||
127 | IRQF_TRIGGER_HIGH, "clk-utmi", utmi); | ||
128 | if (ret) { | ||
129 | kfree(utmi); | ||
130 | return ERR_PTR(ret); | ||
131 | } | ||
132 | 100 | ||
133 | clk = clk_register(NULL, &utmi->hw); | 101 | clk = clk_register(NULL, &utmi->hw); |
134 | if (IS_ERR(clk)) { | 102 | if (IS_ERR(clk)) |
135 | free_irq(utmi->irq, utmi); | ||
136 | kfree(utmi); | 103 | kfree(utmi); |
137 | } | ||
138 | 104 | ||
139 | return clk; | 105 | return clk; |
140 | } | 106 | } |
141 | 107 | ||
142 | static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np) | 108 | static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np) |
143 | { | 109 | { |
144 | unsigned int irq; | ||
145 | struct clk *clk; | 110 | struct clk *clk; |
146 | const char *parent_name; | 111 | const char *parent_name; |
147 | const char *name = np->name; | 112 | const char *name = np->name; |
@@ -151,15 +116,11 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np) | |||
151 | 116 | ||
152 | of_property_read_string(np, "clock-output-names", &name); | 117 | of_property_read_string(np, "clock-output-names", &name); |
153 | 118 | ||
154 | irq = irq_of_parse_and_map(np, 0); | ||
155 | if (!irq) | ||
156 | return; | ||
157 | |||
158 | regmap = syscon_node_to_regmap(of_get_parent(np)); | 119 | regmap = syscon_node_to_regmap(of_get_parent(np)); |
159 | if (IS_ERR(regmap)) | 120 | if (IS_ERR(regmap)) |
160 | return; | 121 | return; |
161 | 122 | ||
162 | clk = at91_clk_register_utmi(regmap, irq, name, parent_name); | 123 | clk = at91_clk_register_utmi(regmap, name, parent_name); |
163 | if (IS_ERR(clk)) | 124 | if (IS_ERR(clk)) |
164 | return; | 125 | return; |
165 | 126 | ||
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 295b17b9c689..f17a2a1f1e85 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c | |||
@@ -13,12 +13,6 @@ | |||
13 | #include <linux/clk/at91_pmc.h> | 13 | #include <linux/clk/at91_pmc.h> |
14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
15 | #include <linux/of_address.h> | 15 | #include <linux/of_address.h> |
16 | #include <linux/io.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/irq.h> | ||
19 | #include <linux/irqchip/chained_irq.h> | ||
20 | #include <linux/irqdomain.h> | ||
21 | #include <linux/of_irq.h> | ||
22 | #include <linux/mfd/syscon.h> | 16 | #include <linux/mfd/syscon.h> |
23 | #include <linux/regmap.h> | 17 | #include <linux/regmap.h> |
24 | 18 | ||
@@ -67,118 +61,6 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname, | |||
67 | } | 61 | } |
68 | EXPORT_SYMBOL_GPL(of_at91_get_clk_range); | 62 | EXPORT_SYMBOL_GPL(of_at91_get_clk_range); |
69 | 63 | ||
70 | static void pmc_irq_mask(struct irq_data *d) | ||
71 | { | ||
72 | struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); | ||
73 | |||
74 | regmap_write(pmc->regmap, AT91_PMC_IDR, 1 << d->hwirq); | ||
75 | } | ||
76 | |||
77 | static void pmc_irq_unmask(struct irq_data *d) | ||
78 | { | ||
79 | struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); | ||
80 | |||
81 | regmap_write(pmc->regmap, AT91_PMC_IER, 1 << d->hwirq); | ||
82 | } | ||
83 | |||
84 | static int pmc_irq_set_type(struct irq_data *d, unsigned type) | ||
85 | { | ||
86 | if (type != IRQ_TYPE_LEVEL_HIGH) { | ||
87 | pr_warn("PMC: type not supported (support only IRQ_TYPE_LEVEL_HIGH type)\n"); | ||
88 | return -EINVAL; | ||
89 | } | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static void pmc_irq_suspend(struct irq_data *d) | ||
95 | { | ||
96 | struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); | ||
97 | |||
98 | regmap_read(pmc->regmap, AT91_PMC_IMR, &pmc->imr); | ||
99 | regmap_write(pmc->regmap, AT91_PMC_IDR, pmc->imr); | ||
100 | } | ||
101 | |||
102 | static void pmc_irq_resume(struct irq_data *d) | ||
103 | { | ||
104 | struct at91_pmc *pmc = irq_data_get_irq_chip_data(d); | ||
105 | |||
106 | regmap_write(pmc->regmap, AT91_PMC_IER, pmc->imr); | ||
107 | } | ||
108 | |||
109 | static struct irq_chip pmc_irq = { | ||
110 | .name = "PMC", | ||
111 | .irq_disable = pmc_irq_mask, | ||
112 | .irq_mask = pmc_irq_mask, | ||
113 | .irq_unmask = pmc_irq_unmask, | ||
114 | .irq_set_type = pmc_irq_set_type, | ||
115 | .irq_suspend = pmc_irq_suspend, | ||
116 | .irq_resume = pmc_irq_resume, | ||
117 | }; | ||
118 | |||
119 | static struct lock_class_key pmc_lock_class; | ||
120 | |||
121 | static int pmc_irq_map(struct irq_domain *h, unsigned int virq, | ||
122 | irq_hw_number_t hw) | ||
123 | { | ||
124 | struct at91_pmc *pmc = h->host_data; | ||
125 | |||
126 | irq_set_lockdep_class(virq, &pmc_lock_class); | ||
127 | |||
128 | irq_set_chip_and_handler(virq, &pmc_irq, | ||
129 | handle_level_irq); | ||
130 | irq_set_chip_data(virq, pmc); | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static int pmc_irq_domain_xlate(struct irq_domain *d, | ||
136 | struct device_node *ctrlr, | ||
137 | const u32 *intspec, unsigned int intsize, | ||
138 | irq_hw_number_t *out_hwirq, | ||
139 | unsigned int *out_type) | ||
140 | { | ||
141 | struct at91_pmc *pmc = d->host_data; | ||
142 | const struct at91_pmc_caps *caps = pmc->caps; | ||
143 | |||
144 | if (WARN_ON(intsize < 1)) | ||
145 | return -EINVAL; | ||
146 | |||
147 | *out_hwirq = intspec[0]; | ||
148 | |||
149 | if (!(caps->available_irqs & (1 << *out_hwirq))) | ||
150 | return -EINVAL; | ||
151 | |||
152 | *out_type = IRQ_TYPE_LEVEL_HIGH; | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static const struct irq_domain_ops pmc_irq_ops = { | ||
158 | .map = pmc_irq_map, | ||
159 | .xlate = pmc_irq_domain_xlate, | ||
160 | }; | ||
161 | |||
162 | static irqreturn_t pmc_irq_handler(int irq, void *data) | ||
163 | { | ||
164 | struct at91_pmc *pmc = (struct at91_pmc *)data; | ||
165 | unsigned int tmpsr, imr; | ||
166 | unsigned long sr; | ||
167 | int n; | ||
168 | |||
169 | regmap_read(pmc->regmap, AT91_PMC_SR, &tmpsr); | ||
170 | regmap_read(pmc->regmap, AT91_PMC_IMR, &imr); | ||
171 | |||
172 | sr = tmpsr & imr; | ||
173 | if (!sr) | ||
174 | return IRQ_NONE; | ||
175 | |||
176 | for_each_set_bit(n, &sr, BITS_PER_LONG) | ||
177 | generic_handle_irq(irq_find_mapping(pmc->irqdomain, n)); | ||
178 | |||
179 | return IRQ_HANDLED; | ||
180 | } | ||
181 | |||
182 | static const struct at91_pmc_caps at91rm9200_caps = { | 64 | static const struct at91_pmc_caps at91rm9200_caps = { |
183 | .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_LOCKB | | 65 | .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_LOCKB | |
184 | AT91_PMC_MCKRDY | AT91_PMC_PCK0RDY | | 66 | AT91_PMC_MCKRDY | AT91_PMC_PCK0RDY | |
@@ -230,12 +112,12 @@ static const struct at91_pmc_caps sama5d3_caps = { | |||
230 | 112 | ||
231 | static struct at91_pmc *__init at91_pmc_init(struct device_node *np, | 113 | static struct at91_pmc *__init at91_pmc_init(struct device_node *np, |
232 | struct regmap *regmap, | 114 | struct regmap *regmap, |
233 | void __iomem *regbase, int virq, | 115 | void __iomem *regbase, |
234 | const struct at91_pmc_caps *caps) | 116 | const struct at91_pmc_caps *caps) |
235 | { | 117 | { |
236 | struct at91_pmc *pmc; | 118 | struct at91_pmc *pmc; |
237 | 119 | ||
238 | if (!regbase || !virq || !caps) | 120 | if (!regbase || !caps) |
239 | return NULL; | 121 | return NULL; |
240 | 122 | ||
241 | at91_pmc_base = regbase; | 123 | at91_pmc_base = regbase; |
@@ -245,26 +127,11 @@ static struct at91_pmc *__init at91_pmc_init(struct device_node *np, | |||
245 | return NULL; | 127 | return NULL; |
246 | 128 | ||
247 | pmc->regmap = regmap; | 129 | pmc->regmap = regmap; |
248 | pmc->virq = virq; | ||
249 | pmc->caps = caps; | 130 | pmc->caps = caps; |
250 | 131 | ||
251 | pmc->irqdomain = irq_domain_add_linear(np, 32, &pmc_irq_ops, pmc); | ||
252 | if (!pmc->irqdomain) | ||
253 | goto out_free_pmc; | ||
254 | |||
255 | regmap_write(pmc->regmap, AT91_PMC_IDR, 0xffffffff); | 132 | regmap_write(pmc->regmap, AT91_PMC_IDR, 0xffffffff); |
256 | if (request_irq(pmc->virq, pmc_irq_handler, | ||
257 | IRQF_SHARED | IRQF_COND_SUSPEND, "pmc", pmc)) | ||
258 | goto out_remove_irqdomain; | ||
259 | 133 | ||
260 | return pmc; | 134 | return pmc; |
261 | |||
262 | out_remove_irqdomain: | ||
263 | irq_domain_remove(pmc->irqdomain); | ||
264 | out_free_pmc: | ||
265 | kfree(pmc); | ||
266 | |||
267 | return NULL; | ||
268 | } | 135 | } |
269 | 136 | ||
270 | static void __init of_at91_pmc_setup(struct device_node *np, | 137 | static void __init of_at91_pmc_setup(struct device_node *np, |
@@ -273,17 +140,12 @@ static void __init of_at91_pmc_setup(struct device_node *np, | |||
273 | struct at91_pmc *pmc; | 140 | struct at91_pmc *pmc; |
274 | void __iomem *regbase = of_iomap(np, 0); | 141 | void __iomem *regbase = of_iomap(np, 0); |
275 | struct regmap *regmap; | 142 | struct regmap *regmap; |
276 | int virq; | ||
277 | 143 | ||
278 | regmap = syscon_node_to_regmap(np); | 144 | regmap = syscon_node_to_regmap(np); |
279 | if (IS_ERR(regmap)) | 145 | if (IS_ERR(regmap)) |
280 | panic("Could not retrieve syscon regmap"); | 146 | panic("Could not retrieve syscon regmap"); |
281 | 147 | ||
282 | virq = irq_of_parse_and_map(np, 0); | 148 | pmc = at91_pmc_init(np, regmap, regbase, caps); |
283 | if (!virq) | ||
284 | return; | ||
285 | |||
286 | pmc = at91_pmc_init(np, regmap, regbase, virq, caps); | ||
287 | if (!pmc) | 149 | if (!pmc) |
288 | return; | 150 | return; |
289 | } | 151 | } |
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index e160cb640e4a..b06a332b056a 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h | |||
@@ -32,10 +32,7 @@ struct at91_pmc_caps { | |||
32 | 32 | ||
33 | struct at91_pmc { | 33 | struct at91_pmc { |
34 | struct regmap *regmap; | 34 | struct regmap *regmap; |
35 | int virq; | ||
36 | const struct at91_pmc_caps *caps; | 35 | const struct at91_pmc_caps *caps; |
37 | struct irq_domain *irqdomain; | ||
38 | u32 imr; | ||
39 | }; | 36 | }; |
40 | 37 | ||
41 | int of_at91_get_clk_range(struct device_node *np, const char *propname, | 38 | int of_at91_get_clk_range(struct device_node *np, const char *propname, |