Lines Matching +full:interrupt +full:- +full:clk
1 // SPDX-License-Identifier: GPL-2.0-only
7 #include <linux/clk.h>
8 #include <linux/interrupt.h>
14 #include "timer-of.h"
17 * timer_of_irq_exit - Release the interrupt
26 struct clock_event_device *clkevt = &to->clkevt; in timer_of_irq_exit()
28 if (of_irq->percpu) in timer_of_irq_exit()
29 free_percpu_irq(of_irq->irq, clkevt); in timer_of_irq_exit()
31 free_irq(of_irq->irq, clkevt); in timer_of_irq_exit()
35 * timer_of_irq_init - Request the interrupt
39 * Get the interrupt number from the DT from its definition and
40 * request it. The interrupt is gotten by falling back the following way:
42 * - Get interrupt number by name
43 * - Get interrupt number by index
45 * When the interrupt is per CPU, 'request_percpu_irq()' is called,
55 struct clock_event_device *clkevt = &to->clkevt; in timer_of_irq_init()
57 if (of_irq->name) { in timer_of_irq_init()
58 of_irq->irq = ret = of_irq_get_byname(np, of_irq->name); in timer_of_irq_init()
60 pr_err("Failed to get interrupt %s for %pOF\n", in timer_of_irq_init()
61 of_irq->name, np); in timer_of_irq_init()
65 of_irq->irq = irq_of_parse_and_map(np, of_irq->index); in timer_of_irq_init()
67 if (!of_irq->irq) { in timer_of_irq_init()
68 pr_err("Failed to map interrupt for %pOF\n", np); in timer_of_irq_init()
69 return -EINVAL; in timer_of_irq_init()
72 ret = of_irq->percpu ? in timer_of_irq_init()
73 request_percpu_irq(of_irq->irq, of_irq->handler, in timer_of_irq_init()
74 np->full_name, clkevt) : in timer_of_irq_init()
75 request_irq(of_irq->irq, of_irq->handler, in timer_of_irq_init()
76 of_irq->flags ? of_irq->flags : IRQF_TIMER, in timer_of_irq_init()
77 np->full_name, clkevt); in timer_of_irq_init()
79 pr_err("Failed to request irq %d for %pOF\n", of_irq->irq, np); in timer_of_irq_init()
83 clkevt->irq = of_irq->irq; in timer_of_irq_init()
89 * timer_of_clk_exit - Release the clock resources
92 * Disables and releases the refcount on the clk
96 of_clk->rate = 0; in timer_of_clk_exit()
97 clk_disable_unprepare(of_clk->clk); in timer_of_clk_exit()
98 clk_put(of_clk->clk); in timer_of_clk_exit()
102 * timer_of_clk_init - Initialize the clock resources
115 of_clk->clk = of_clk->name ? of_clk_get_by_name(np, of_clk->name) : in timer_of_clk_init()
116 of_clk_get(np, of_clk->index); in timer_of_clk_init()
117 if (IS_ERR(of_clk->clk)) { in timer_of_clk_init()
118 ret = PTR_ERR(of_clk->clk); in timer_of_clk_init()
119 if (ret != -EPROBE_DEFER) in timer_of_clk_init()
124 ret = clk_prepare_enable(of_clk->clk); in timer_of_clk_init()
130 of_clk->rate = clk_get_rate(of_clk->clk); in timer_of_clk_init()
131 if (!of_clk->rate) { in timer_of_clk_init()
132 ret = -EINVAL; in timer_of_clk_init()
137 of_clk->period = DIV_ROUND_UP(of_clk->rate, HZ); in timer_of_clk_init()
142 clk_disable_unprepare(of_clk->clk); in timer_of_clk_init()
144 clk_put(of_clk->clk); in timer_of_clk_init()
151 iounmap(of_base->base); in timer_of_base_exit()
157 of_base->base = of_base->name ? in timer_of_base_init()
158 of_io_request_and_map(np, of_base->index, of_base->name) : in timer_of_base_init()
159 of_iomap(np, of_base->index); in timer_of_base_init()
160 if (IS_ERR_OR_NULL(of_base->base)) { in timer_of_base_init()
161 pr_err("Failed to iomap (%s:%s)\n", np->name, of_base->name); in timer_of_base_init()
162 return of_base->base ? PTR_ERR(of_base->base) : -ENOMEM; in timer_of_base_init()
170 int ret = -EINVAL; in timer_of_init()
173 if (to->flags & TIMER_OF_BASE) { in timer_of_init()
174 ret = timer_of_base_init(np, &to->of_base); in timer_of_init()
180 if (to->flags & TIMER_OF_CLOCK) { in timer_of_init()
181 ret = timer_of_clk_init(np, &to->of_clk); in timer_of_init()
187 if (to->flags & TIMER_OF_IRQ) { in timer_of_init()
188 ret = timer_of_irq_init(np, &to->of_irq); in timer_of_init()
194 if (!to->clkevt.name) in timer_of_init()
195 to->clkevt.name = np->full_name; in timer_of_init()
197 to->np = np; in timer_of_init()
203 timer_of_irq_exit(&to->of_irq); in timer_of_init()
206 timer_of_clk_exit(&to->of_clk); in timer_of_init()
209 timer_of_base_exit(&to->of_base); in timer_of_init()
214 * timer_of_cleanup - release timer_of resources
222 if (to->flags & TIMER_OF_IRQ) in timer_of_cleanup()
223 timer_of_irq_exit(&to->of_irq); in timer_of_cleanup()
225 if (to->flags & TIMER_OF_CLOCK) in timer_of_cleanup()
226 timer_of_clk_exit(&to->of_clk); in timer_of_cleanup()
228 if (to->flags & TIMER_OF_BASE) in timer_of_cleanup()
229 timer_of_base_exit(&to->of_base); in timer_of_cleanup()