1 From 0df27f96fd160ee4d2eb516c3e12fa218995cf58 Mon Sep 17 00:00:00 2001
2 From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
3 Date: Wed, 16 Sep 2015 23:47:39 +0200
4 Subject: [PATCH 311/366] clk: at91: remove IRQ handling and use polling
6 The AT91 clock drivers make use of IRQs to avoid polling when waiting for
7 some clocks to be enabled. Unfortunately, this leads to a crash when those
8 IRQs are threaded (which happens when using preempt-rt) because they are
9 registered before thread creation is possible.
11 Use polling on those clocks instead to avoid the problem.
13 Acked-by: Stephen Boyd <sboyd@codeaurora.org>
14 Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
15 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
17 drivers/clk/at91/clk-main.c | 138 +++++-----------------------------------
18 drivers/clk/at91/clk-master.c | 46 ++------------
19 drivers/clk/at91/clk-pll.c | 47 ++------------
20 drivers/clk/at91/clk-system.c | 56 ++--------------
21 drivers/clk/at91/clk-utmi.c | 49 ++------------
22 drivers/clk/at91/pmc.c | 144 +-----------------------------------------
23 drivers/clk/at91/pmc.h | 3 -
24 7 files changed, 37 insertions(+), 446 deletions(-)
26 diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
27 index c1f1197..4bfc94d 100644
28 --- a/drivers/clk/at91/clk-main.c
29 +++ b/drivers/clk/at91/clk-main.c
31 #include <linux/clk/at91_pmc.h>
32 #include <linux/delay.h>
34 -#include <linux/of_address.h>
35 -#include <linux/of_irq.h>
36 -#include <linux/io.h>
37 -#include <linux/interrupt.h>
38 -#include <linux/irq.h>
39 #include <linux/mfd/syscon.h>
40 #include <linux/regmap.h>
41 -#include <linux/sched.h>
42 -#include <linux/wait.h>
49 struct regmap *regmap;
51 - wait_queue_head_t wait;
54 #define to_clk_main_osc(hw) container_of(hw, struct clk_main_osc, hw)
55 @@ -46,8 +37,6 @@ struct clk_main_osc {
56 struct clk_main_rc_osc {
58 struct regmap *regmap;
60 - wait_queue_head_t wait;
61 unsigned long frequency;
62 unsigned long accuracy;
64 @@ -64,23 +53,11 @@ struct clk_rm9200_main {
65 struct clk_sam9x5_main {
67 struct regmap *regmap;
69 - wait_queue_head_t wait;
73 #define to_clk_sam9x5_main(hw) container_of(hw, struct clk_sam9x5_main, hw)
75 -static irqreturn_t clk_main_osc_irq_handler(int irq, void *dev_id)
77 - struct clk_main_osc *osc = dev_id;
79 - wake_up(&osc->wait);
80 - disable_irq_nosync(osc->irq);
85 static inline bool clk_main_osc_ready(struct regmap *regmap)
88 @@ -107,11 +84,8 @@ static int clk_main_osc_prepare(struct clk_hw *hw)
89 regmap_write(regmap, AT91_CKGR_MOR, tmp);
92 - while (!clk_main_osc_ready(regmap)) {
93 - enable_irq(osc->irq);
94 - wait_event(osc->wait,
95 - clk_main_osc_ready(regmap));
97 + while (!clk_main_osc_ready(regmap))
102 @@ -156,17 +130,15 @@ static const struct clk_ops main_osc_ops = {
104 static struct clk * __init
105 at91_clk_register_main_osc(struct regmap *regmap,
108 const char *parent_name,
112 struct clk_main_osc *osc;
113 struct clk *clk = NULL;
114 struct clk_init_data init;
116 - if (!irq || !name || !parent_name)
117 + if (!name || !parent_name)
118 return ERR_PTR(-EINVAL);
120 osc = kzalloc(sizeof(*osc), GFP_KERNEL);
121 @@ -181,16 +153,6 @@ at91_clk_register_main_osc(struct regmap *regmap,
123 osc->hw.init = &init;
124 osc->regmap = regmap;
127 - init_waitqueue_head(&osc->wait);
128 - irq_set_status_flags(osc->irq, IRQ_NOAUTOEN);
129 - ret = request_irq(osc->irq, clk_main_osc_irq_handler,
130 - IRQF_TRIGGER_HIGH, name, osc);
133 - return ERR_PTR(ret);
137 regmap_update_bits(regmap,
138 @@ -199,10 +161,8 @@ at91_clk_register_main_osc(struct regmap *regmap,
139 AT91_PMC_OSCBYPASS | AT91_PMC_KEY);
141 clk = clk_register(NULL, &osc->hw);
143 - free_irq(irq, osc);
150 @@ -210,7 +170,6 @@ at91_clk_register_main_osc(struct regmap *regmap,
151 static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
155 const char *name = np->name;
156 const char *parent_name;
157 struct regmap *regmap;
158 @@ -224,11 +183,7 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
162 - irq = irq_of_parse_and_map(np, 0);
166 - clk = at91_clk_register_main_osc(regmap, irq, name, parent_name, bypass);
167 + clk = at91_clk_register_main_osc(regmap, name, parent_name, bypass);
171 @@ -237,16 +192,6 @@ static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np)
172 CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc",
173 of_at91rm9200_clk_main_osc_setup);
175 -static irqreturn_t clk_main_rc_osc_irq_handler(int irq, void *dev_id)
177 - struct clk_main_rc_osc *osc = dev_id;
179 - wake_up(&osc->wait);
180 - disable_irq_nosync(osc->irq);
182 - return IRQ_HANDLED;
185 static bool clk_main_rc_osc_ready(struct regmap *regmap)
188 @@ -269,11 +214,8 @@ static int clk_main_rc_osc_prepare(struct clk_hw *hw)
189 MOR_KEY_MASK | AT91_PMC_MOSCRCEN,
190 AT91_PMC_MOSCRCEN | AT91_PMC_KEY);
192 - while (!clk_main_rc_osc_ready(regmap)) {
193 - enable_irq(osc->irq);
194 - wait_event(osc->wait,
195 - clk_main_rc_osc_ready(regmap));
197 + while (!clk_main_rc_osc_ready(regmap))
202 @@ -331,11 +273,9 @@ static const struct clk_ops main_rc_osc_ops = {
204 static struct clk * __init
205 at91_clk_register_main_rc_osc(struct regmap *regmap,
208 u32 frequency, u32 accuracy)
211 struct clk_main_rc_osc *osc;
212 struct clk *clk = NULL;
213 struct clk_init_data init;
214 @@ -355,22 +295,12 @@ at91_clk_register_main_rc_osc(struct regmap *regmap,
216 osc->hw.init = &init;
217 osc->regmap = regmap;
219 osc->frequency = frequency;
220 osc->accuracy = accuracy;
222 - init_waitqueue_head(&osc->wait);
223 - irq_set_status_flags(osc->irq, IRQ_NOAUTOEN);
224 - ret = request_irq(osc->irq, clk_main_rc_osc_irq_handler,
225 - IRQF_TRIGGER_HIGH, name, osc);
227 - return ERR_PTR(ret);
229 clk = clk_register(NULL, &osc->hw);
231 - free_irq(irq, osc);
238 @@ -378,7 +308,6 @@ at91_clk_register_main_rc_osc(struct regmap *regmap,
239 static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np)
245 const char *name = np->name;
246 @@ -388,16 +317,11 @@ static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np)
247 of_property_read_u32(np, "clock-frequency", &frequency);
248 of_property_read_u32(np, "clock-accuracy", &accuracy);
250 - irq = irq_of_parse_and_map(np, 0);
254 regmap = syscon_node_to_regmap(of_get_parent(np));
258 - clk = at91_clk_register_main_rc_osc(regmap, irq, name, frequency,
260 + clk = at91_clk_register_main_rc_osc(regmap, name, frequency, accuracy);
264 @@ -529,16 +453,6 @@ static void __init of_at91rm9200_clk_main_setup(struct device_node *np)
265 CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main",
266 of_at91rm9200_clk_main_setup);
268 -static irqreturn_t clk_sam9x5_main_irq_handler(int irq, void *dev_id)
270 - struct clk_sam9x5_main *clkmain = dev_id;
272 - wake_up(&clkmain->wait);
273 - disable_irq_nosync(clkmain->irq);
275 - return IRQ_HANDLED;
278 static inline bool clk_sam9x5_main_ready(struct regmap *regmap)
281 @@ -553,11 +467,8 @@ static int clk_sam9x5_main_prepare(struct clk_hw *hw)
282 struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw);
283 struct regmap *regmap = clkmain->regmap;
285 - while (!clk_sam9x5_main_ready(regmap)) {
286 - enable_irq(clkmain->irq);
287 - wait_event(clkmain->wait,
288 - clk_sam9x5_main_ready(regmap));
290 + while (!clk_sam9x5_main_ready(regmap))
293 return clk_main_probe_frequency(regmap);
295 @@ -594,11 +505,8 @@ static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index)
296 else if (!index && (tmp & AT91_PMC_MOSCSEL))
297 regmap_write(regmap, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL);
299 - while (!clk_sam9x5_main_ready(regmap)) {
300 - enable_irq(clkmain->irq);
301 - wait_event(clkmain->wait,
302 - clk_sam9x5_main_ready(regmap));
304 + while (!clk_sam9x5_main_ready(regmap))
309 @@ -623,12 +531,10 @@ static const struct clk_ops sam9x5_main_ops = {
311 static struct clk * __init
312 at91_clk_register_sam9x5_main(struct regmap *regmap,
315 const char **parent_names,
319 struct clk_sam9x5_main *clkmain;
320 struct clk *clk = NULL;
321 struct clk_init_data init;
322 @@ -652,21 +558,12 @@ at91_clk_register_sam9x5_main(struct regmap *regmap,
324 clkmain->hw.init = &init;
325 clkmain->regmap = regmap;
326 - clkmain->irq = irq;
327 regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status);
328 clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0;
329 - init_waitqueue_head(&clkmain->wait);
330 - irq_set_status_flags(clkmain->irq, IRQ_NOAUTOEN);
331 - ret = request_irq(clkmain->irq, clk_sam9x5_main_irq_handler,
332 - IRQF_TRIGGER_HIGH, name, clkmain);
334 - return ERR_PTR(ret);
336 clk = clk_register(NULL, &clkmain->hw);
338 - free_irq(clkmain->irq, clkmain);
345 @@ -676,7 +573,6 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
347 const char *parent_names[2];
350 const char *name = np->name;
351 struct regmap *regmap;
353 @@ -691,11 +587,7 @@ static void __init of_at91sam9x5_clk_main_setup(struct device_node *np)
355 of_property_read_string(np, "clock-output-names", &name);
357 - irq = irq_of_parse_and_map(np, 0);
361 - clk = at91_clk_register_sam9x5_main(regmap, irq, name, parent_names,
362 + clk = at91_clk_register_sam9x5_main(regmap, name, parent_names,
366 diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
367 index 8d94ddfc..7d4a186 100644
368 --- a/drivers/clk/at91/clk-master.c
369 +++ b/drivers/clk/at91/clk-master.c
371 #include <linux/clkdev.h>
372 #include <linux/clk/at91_pmc.h>
373 #include <linux/of.h>
374 -#include <linux/of_address.h>
375 -#include <linux/of_irq.h>
376 -#include <linux/io.h>
377 -#include <linux/wait.h>
378 -#include <linux/sched.h>
379 -#include <linux/interrupt.h>
380 -#include <linux/irq.h>
381 #include <linux/mfd/syscon.h>
382 #include <linux/regmap.h>
384 @@ -47,22 +40,10 @@ struct clk_master_layout {
387 struct regmap *regmap;
389 - wait_queue_head_t wait;
390 const struct clk_master_layout *layout;
391 const struct clk_master_characteristics *characteristics;
394 -static irqreturn_t clk_master_irq_handler(int irq, void *dev_id)
396 - struct clk_master *master = (struct clk_master *)dev_id;
398 - wake_up(&master->wait);
399 - disable_irq_nosync(master->irq);
401 - return IRQ_HANDLED;
404 static inline bool clk_master_ready(struct regmap *regmap)
407 @@ -76,11 +57,8 @@ static int clk_master_prepare(struct clk_hw *hw)
409 struct clk_master *master = to_clk_master(hw);
411 - while (!clk_master_ready(master->regmap)) {
412 - enable_irq(master->irq);
413 - wait_event(master->wait,
414 - clk_master_ready(master->regmap));
416 + while (!clk_master_ready(master->regmap))
421 @@ -143,13 +121,12 @@ static const struct clk_ops master_ops = {
424 static struct clk * __init
425 -at91_clk_register_master(struct regmap *regmap, unsigned int irq,
426 +at91_clk_register_master(struct regmap *regmap,
427 const char *name, int num_parents,
428 const char **parent_names,
429 const struct clk_master_layout *layout,
430 const struct clk_master_characteristics *characteristics)
433 struct clk_master *master;
434 struct clk *clk = NULL;
435 struct clk_init_data init;
436 @@ -171,19 +148,9 @@ at91_clk_register_master(struct regmap *regmap, unsigned int irq,
437 master->layout = layout;
438 master->characteristics = characteristics;
439 master->regmap = regmap;
441 - init_waitqueue_head(&master->wait);
442 - irq_set_status_flags(master->irq, IRQ_NOAUTOEN);
443 - ret = request_irq(master->irq, clk_master_irq_handler,
444 - IRQF_TRIGGER_HIGH, "clk-master", master);
447 - return ERR_PTR(ret);
450 clk = clk_register(NULL, &master->hw);
452 - free_irq(master->irq, master);
456 @@ -233,7 +200,6 @@ of_at91_clk_master_setup(struct device_node *np,
461 const char *parent_names[MASTER_SOURCE_MAX];
462 const char *name = np->name;
463 struct clk_master_characteristics *characteristics;
464 @@ -255,11 +221,7 @@ of_at91_clk_master_setup(struct device_node *np,
468 - irq = irq_of_parse_and_map(np, 0);
470 - goto out_free_characteristics;
472 - clk = at91_clk_register_master(regmap, irq, name, num_parents,
473 + clk = at91_clk_register_master(regmap, name, num_parents,
474 parent_names, layout,
477 diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c
478 index 5f4c6ce..fb2e0b5 100644
479 --- a/drivers/clk/at91/clk-pll.c
480 +++ b/drivers/clk/at91/clk-pll.c
482 #include <linux/clkdev.h>
483 #include <linux/clk/at91_pmc.h>
484 #include <linux/of.h>
485 -#include <linux/of_address.h>
486 -#include <linux/of_irq.h>
487 -#include <linux/io.h>
488 -#include <linux/kernel.h>
489 -#include <linux/wait.h>
490 -#include <linux/sched.h>
491 -#include <linux/interrupt.h>
492 -#include <linux/irq.h>
493 #include <linux/mfd/syscon.h>
494 #include <linux/regmap.h>
496 @@ -61,8 +53,6 @@ struct clk_pll_layout {
499 struct regmap *regmap;
501 - wait_queue_head_t wait;
505 @@ -71,16 +61,6 @@ struct clk_pll {
506 const struct clk_pll_characteristics *characteristics;
509 -static irqreturn_t clk_pll_irq_handler(int irq, void *dev_id)
511 - struct clk_pll *pll = (struct clk_pll *)dev_id;
513 - wake_up(&pll->wait);
514 - disable_irq_nosync(pll->irq);
516 - return IRQ_HANDLED;
519 static inline bool clk_pll_ready(struct regmap *regmap, int id)
522 @@ -127,11 +107,8 @@ static int clk_pll_prepare(struct clk_hw *hw)
523 (out << PLL_OUT_SHIFT) |
524 ((pll->mul & layout->mul_mask) << layout->mul_shift));
526 - while (!clk_pll_ready(regmap, pll->id)) {
527 - enable_irq(pll->irq);
528 - wait_event(pll->wait,
529 - clk_pll_ready(regmap, pll->id));
531 + while (!clk_pll_ready(regmap, pll->id))
536 @@ -320,7 +297,7 @@ static const struct clk_ops pll_ops = {
539 static struct clk * __init
540 -at91_clk_register_pll(struct regmap *regmap, unsigned int irq, const char *name,
541 +at91_clk_register_pll(struct regmap *regmap, const char *name,
542 const char *parent_name, u8 id,
543 const struct clk_pll_layout *layout,
544 const struct clk_pll_characteristics *characteristics)
545 @@ -328,7 +305,6 @@ at91_clk_register_pll(struct regmap *regmap, unsigned int irq, const char *name,
547 struct clk *clk = NULL;
548 struct clk_init_data init;
550 int offset = PLL_REG(id);
553 @@ -350,22 +326,12 @@ at91_clk_register_pll(struct regmap *regmap, unsigned int irq, const char *name,
554 pll->layout = layout;
555 pll->characteristics = characteristics;
556 pll->regmap = regmap;
558 regmap_read(regmap, offset, &pllr);
559 pll->div = PLL_DIV(pllr);
560 pll->mul = PLL_MUL(pllr, layout);
561 - init_waitqueue_head(&pll->wait);
562 - irq_set_status_flags(pll->irq, IRQ_NOAUTOEN);
563 - ret = request_irq(pll->irq, clk_pll_irq_handler, IRQF_TRIGGER_HIGH,
564 - id ? "clk-pllb" : "clk-plla", pll);
567 - return ERR_PTR(ret);
570 clk = clk_register(NULL, &pll->hw);
572 - free_irq(pll->irq, pll);
576 @@ -499,7 +465,6 @@ of_at91_clk_pll_setup(struct device_node *np,
577 const struct clk_pll_layout *layout)
582 struct regmap *regmap;
583 const char *parent_name;
584 @@ -521,11 +486,7 @@ of_at91_clk_pll_setup(struct device_node *np,
585 if (!characteristics)
588 - irq = irq_of_parse_and_map(np, 0);
592 - clk = at91_clk_register_pll(regmap, irq, name, parent_name, id, layout,
593 + clk = at91_clk_register_pll(regmap, name, parent_name, id, layout,
596 goto out_free_characteristics;
597 diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c
598 index 0593adf..8f35d81 100644
599 --- a/drivers/clk/at91/clk-system.c
600 +++ b/drivers/clk/at91/clk-system.c
602 #include <linux/clkdev.h>
603 #include <linux/clk/at91_pmc.h>
604 #include <linux/of.h>
605 -#include <linux/of_address.h>
606 -#include <linux/io.h>
607 -#include <linux/irq.h>
608 -#include <linux/of_irq.h>
609 -#include <linux/interrupt.h>
610 -#include <linux/wait.h>
611 -#include <linux/sched.h>
612 #include <linux/mfd/syscon.h>
613 #include <linux/regmap.h>
618 struct regmap *regmap;
620 - wait_queue_head_t wait;
624 @@ -41,15 +32,6 @@ static inline int is_pck(int id)
626 return (id >= 8) && (id <= 15);
628 -static irqreturn_t clk_system_irq_handler(int irq, void *dev_id)
630 - struct clk_system *sys = (struct clk_system *)dev_id;
632 - wake_up(&sys->wait);
633 - disable_irq_nosync(sys->irq);
635 - return IRQ_HANDLED;
638 static inline bool clk_system_ready(struct regmap *regmap, int id)
640 @@ -69,15 +51,9 @@ static int clk_system_prepare(struct clk_hw *hw)
641 if (!is_pck(sys->id))
644 - while (!clk_system_ready(sys->regmap, sys->id)) {
646 - enable_irq(sys->irq);
647 - wait_event(sys->wait,
648 - clk_system_ready(sys->regmap, sys->id));
653 + while (!clk_system_ready(sys->regmap, sys->id))
659 @@ -114,12 +90,11 @@ static const struct clk_ops system_ops = {
661 static struct clk * __init
662 at91_clk_register_system(struct regmap *regmap, const char *name,
663 - const char *parent_name, u8 id, int irq)
664 + const char *parent_name, u8 id)
666 struct clk_system *sys;
667 struct clk *clk = NULL;
668 struct clk_init_data init;
671 if (!parent_name || id > SYSTEM_MAX_ID)
672 return ERR_PTR(-EINVAL);
673 @@ -137,24 +112,10 @@ at91_clk_register_system(struct regmap *regmap, const char *name,
675 sys->hw.init = &init;
676 sys->regmap = regmap;
679 - init_waitqueue_head(&sys->wait);
680 - irq_set_status_flags(sys->irq, IRQ_NOAUTOEN);
681 - ret = request_irq(sys->irq, clk_system_irq_handler,
682 - IRQF_TRIGGER_HIGH, name, sys);
685 - return ERR_PTR(ret);
689 clk = clk_register(NULL, &sys->hw);
692 - free_irq(sys->irq, sys);
699 @@ -162,7 +123,6 @@ at91_clk_register_system(struct regmap *regmap, const char *name,
700 static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
707 @@ -185,13 +145,9 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
708 if (of_property_read_string(np, "clock-output-names", &name))
709 name = sysclknp->name;
712 - irq = irq_of_parse_and_map(sysclknp, 0);
714 parent_name = of_clk_get_parent_name(sysclknp, 0);
716 - clk = at91_clk_register_system(regmap, name, parent_name, id,
718 + clk = at91_clk_register_system(regmap, name, parent_name, id);
722 diff --git a/drivers/clk/at91/clk-utmi.c b/drivers/clk/at91/clk-utmi.c
723 index 58a310e..61fcf39 100644
724 --- a/drivers/clk/at91/clk-utmi.c
725 +++ b/drivers/clk/at91/clk-utmi.c
727 #include <linux/clk-provider.h>
728 #include <linux/clkdev.h>
729 #include <linux/clk/at91_pmc.h>
730 -#include <linux/interrupt.h>
731 -#include <linux/irq.h>
732 #include <linux/of.h>
733 -#include <linux/of_address.h>
734 -#include <linux/of_irq.h>
735 -#include <linux/io.h>
736 -#include <linux/sched.h>
737 -#include <linux/wait.h>
738 #include <linux/mfd/syscon.h>
739 #include <linux/regmap.h>
744 struct regmap *regmap;
746 - wait_queue_head_t wait;
749 #define to_clk_utmi(hw) container_of(hw, struct clk_utmi, hw)
751 -static irqreturn_t clk_utmi_irq_handler(int irq, void *dev_id)
753 - struct clk_utmi *utmi = (struct clk_utmi *)dev_id;
755 - wake_up(&utmi->wait);
756 - disable_irq_nosync(utmi->irq);
758 - return IRQ_HANDLED;
761 static inline bool clk_utmi_ready(struct regmap *regmap)
764 @@ -62,11 +43,8 @@ static int clk_utmi_prepare(struct clk_hw *hw)
766 regmap_update_bits(utmi->regmap, AT91_CKGR_UCKR, uckr, uckr);
768 - while (!clk_utmi_ready(utmi->regmap)) {
769 - enable_irq(utmi->irq);
770 - wait_event(utmi->wait,
771 - clk_utmi_ready(utmi->regmap));
773 + while (!clk_utmi_ready(utmi->regmap))
778 @@ -100,10 +78,9 @@ static const struct clk_ops utmi_ops = {
781 static struct clk * __init
782 -at91_clk_register_utmi(struct regmap *regmap, unsigned int irq,
783 +at91_clk_register_utmi(struct regmap *regmap,
784 const char *name, const char *parent_name)
787 struct clk_utmi *utmi;
788 struct clk *clk = NULL;
789 struct clk_init_data init;
790 @@ -120,28 +97,16 @@ at91_clk_register_utmi(struct regmap *regmap, unsigned int irq,
792 utmi->hw.init = &init;
793 utmi->regmap = regmap;
795 - init_waitqueue_head(&utmi->wait);
796 - irq_set_status_flags(utmi->irq, IRQ_NOAUTOEN);
797 - ret = request_irq(utmi->irq, clk_utmi_irq_handler,
798 - IRQF_TRIGGER_HIGH, "clk-utmi", utmi);
801 - return ERR_PTR(ret);
804 clk = clk_register(NULL, &utmi->hw);
806 - free_irq(utmi->irq, utmi);
814 static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
818 const char *parent_name;
819 const char *name = np->name;
820 @@ -151,15 +116,11 @@ static void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np)
822 of_property_read_string(np, "clock-output-names", &name);
824 - irq = irq_of_parse_and_map(np, 0);
828 regmap = syscon_node_to_regmap(of_get_parent(np));
832 - clk = at91_clk_register_utmi(regmap, irq, name, parent_name);
833 + clk = at91_clk_register_utmi(regmap, name, parent_name);
837 diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
838 index 295b17b..f17a2a1 100644
839 --- a/drivers/clk/at91/pmc.c
840 +++ b/drivers/clk/at91/pmc.c
842 #include <linux/clk/at91_pmc.h>
843 #include <linux/of.h>
844 #include <linux/of_address.h>
845 -#include <linux/io.h>
846 -#include <linux/interrupt.h>
847 -#include <linux/irq.h>
848 -#include <linux/irqchip/chained_irq.h>
849 -#include <linux/irqdomain.h>
850 -#include <linux/of_irq.h>
851 #include <linux/mfd/syscon.h>
852 #include <linux/regmap.h>
854 @@ -67,118 +61,6 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname,
856 EXPORT_SYMBOL_GPL(of_at91_get_clk_range);
858 -static void pmc_irq_mask(struct irq_data *d)
860 - struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
862 - regmap_write(pmc->regmap, AT91_PMC_IDR, 1 << d->hwirq);
865 -static void pmc_irq_unmask(struct irq_data *d)
867 - struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
869 - regmap_write(pmc->regmap, AT91_PMC_IER, 1 << d->hwirq);
872 -static int pmc_irq_set_type(struct irq_data *d, unsigned type)
874 - if (type != IRQ_TYPE_LEVEL_HIGH) {
875 - pr_warn("PMC: type not supported (support only IRQ_TYPE_LEVEL_HIGH type)\n");
882 -static void pmc_irq_suspend(struct irq_data *d)
884 - struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
886 - regmap_read(pmc->regmap, AT91_PMC_IMR, &pmc->imr);
887 - regmap_write(pmc->regmap, AT91_PMC_IDR, pmc->imr);
890 -static void pmc_irq_resume(struct irq_data *d)
892 - struct at91_pmc *pmc = irq_data_get_irq_chip_data(d);
894 - regmap_write(pmc->regmap, AT91_PMC_IER, pmc->imr);
897 -static struct irq_chip pmc_irq = {
899 - .irq_disable = pmc_irq_mask,
900 - .irq_mask = pmc_irq_mask,
901 - .irq_unmask = pmc_irq_unmask,
902 - .irq_set_type = pmc_irq_set_type,
903 - .irq_suspend = pmc_irq_suspend,
904 - .irq_resume = pmc_irq_resume,
907 -static struct lock_class_key pmc_lock_class;
909 -static int pmc_irq_map(struct irq_domain *h, unsigned int virq,
910 - irq_hw_number_t hw)
912 - struct at91_pmc *pmc = h->host_data;
914 - irq_set_lockdep_class(virq, &pmc_lock_class);
916 - irq_set_chip_and_handler(virq, &pmc_irq,
918 - irq_set_chip_data(virq, pmc);
923 -static int pmc_irq_domain_xlate(struct irq_domain *d,
924 - struct device_node *ctrlr,
925 - const u32 *intspec, unsigned int intsize,
926 - irq_hw_number_t *out_hwirq,
927 - unsigned int *out_type)
929 - struct at91_pmc *pmc = d->host_data;
930 - const struct at91_pmc_caps *caps = pmc->caps;
932 - if (WARN_ON(intsize < 1))
935 - *out_hwirq = intspec[0];
937 - if (!(caps->available_irqs & (1 << *out_hwirq)))
940 - *out_type = IRQ_TYPE_LEVEL_HIGH;
945 -static const struct irq_domain_ops pmc_irq_ops = {
946 - .map = pmc_irq_map,
947 - .xlate = pmc_irq_domain_xlate,
950 -static irqreturn_t pmc_irq_handler(int irq, void *data)
952 - struct at91_pmc *pmc = (struct at91_pmc *)data;
953 - unsigned int tmpsr, imr;
957 - regmap_read(pmc->regmap, AT91_PMC_SR, &tmpsr);
958 - regmap_read(pmc->regmap, AT91_PMC_IMR, &imr);
964 - for_each_set_bit(n, &sr, BITS_PER_LONG)
965 - generic_handle_irq(irq_find_mapping(pmc->irqdomain, n));
967 - return IRQ_HANDLED;
970 static const struct at91_pmc_caps at91rm9200_caps = {
971 .available_irqs = AT91_PMC_MOSCS | AT91_PMC_LOCKA | AT91_PMC_LOCKB |
972 AT91_PMC_MCKRDY | AT91_PMC_PCK0RDY |
973 @@ -230,12 +112,12 @@ static const struct at91_pmc_caps sama5d3_caps = {
975 static struct at91_pmc *__init at91_pmc_init(struct device_node *np,
976 struct regmap *regmap,
977 - void __iomem *regbase, int virq,
978 + void __iomem *regbase,
979 const struct at91_pmc_caps *caps)
981 struct at91_pmc *pmc;
983 - if (!regbase || !virq || !caps)
984 + if (!regbase || !caps)
987 at91_pmc_base = regbase;
988 @@ -245,26 +127,11 @@ static struct at91_pmc *__init at91_pmc_init(struct device_node *np,
991 pmc->regmap = regmap;
995 - pmc->irqdomain = irq_domain_add_linear(np, 32, &pmc_irq_ops, pmc);
996 - if (!pmc->irqdomain)
999 regmap_write(pmc->regmap, AT91_PMC_IDR, 0xffffffff);
1000 - if (request_irq(pmc->virq, pmc_irq_handler,
1001 - IRQF_SHARED | IRQF_COND_SUSPEND, "pmc", pmc))
1002 - goto out_remove_irqdomain;
1006 -out_remove_irqdomain:
1007 - irq_domain_remove(pmc->irqdomain);
1014 static void __init of_at91_pmc_setup(struct device_node *np,
1015 @@ -273,17 +140,12 @@ static void __init of_at91_pmc_setup(struct device_node *np,
1016 struct at91_pmc *pmc;
1017 void __iomem *regbase = of_iomap(np, 0);
1018 struct regmap *regmap;
1021 regmap = syscon_node_to_regmap(np);
1023 panic("Could not retrieve syscon regmap");
1025 - virq = irq_of_parse_and_map(np, 0);
1029 - pmc = at91_pmc_init(np, regmap, regbase, virq, caps);
1030 + pmc = at91_pmc_init(np, regmap, regbase, caps);
1034 diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
1035 index e160cb6..b06a332 100644
1036 --- a/drivers/clk/at91/pmc.h
1037 +++ b/drivers/clk/at91/pmc.h
1038 @@ -32,10 +32,7 @@ struct at91_pmc_caps {
1041 struct regmap *regmap;
1043 const struct at91_pmc_caps *caps;
1044 - struct irq_domain *irqdomain;
1048 int of_at91_get_clk_range(struct device_node *np, const char *propname,