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 free_irq(of_irq->irq, clkevt); in timer_of_irq_exit()
32 * timer_of_irq_init - Request the interrupt
36 * Get the interrupt number from the DT from its definition and
37 * request it. The interrupt is gotten by falling back the following way:
39 * - Get interrupt number by name
40 * - Get interrupt number by index
49 struct clock_event_device *clkevt = &to->clkevt; in timer_of_irq_init()
51 if (of_irq->name) { in timer_of_irq_init()
52 of_irq->irq = ret = of_irq_get_byname(np, of_irq->name); in timer_of_irq_init()
54 pr_err("Failed to get interrupt %s for %pOF\n", in timer_of_irq_init()
55 of_irq->name, np); in timer_of_irq_init()
59 of_irq->irq = irq_of_parse_and_map(np, of_irq->index); in timer_of_irq_init()
61 if (!of_irq->irq) { in timer_of_irq_init()
62 pr_err("Failed to map interrupt for %pOF\n", np); in timer_of_irq_init()
63 return -EINVAL; in timer_of_irq_init()
66 ret = request_irq(of_irq->irq, of_irq->handler, in timer_of_irq_init()
67 of_irq->flags ? of_irq->flags : IRQF_TIMER, in timer_of_irq_init()
68 np->full_name, clkevt); in timer_of_irq_init()
70 pr_err("Failed to request irq %d for %pOF\n", of_irq->irq, np); in timer_of_irq_init()
74 clkevt->irq = of_irq->irq; in timer_of_irq_init()
80 * timer_of_clk_exit - Release the clock resources
83 * Disables and releases the refcount on the clk
87 of_clk->rate = 0; in timer_of_clk_exit()
88 clk_disable_unprepare(of_clk->clk); in timer_of_clk_exit()
89 clk_put(of_clk->clk); in timer_of_clk_exit()
93 * timer_of_clk_init - Initialize the clock resources
106 of_clk->clk = of_clk->name ? of_clk_get_by_name(np, of_clk->name) : in timer_of_clk_init()
107 of_clk_get(np, of_clk->index); in timer_of_clk_init()
108 if (IS_ERR(of_clk->clk)) { in timer_of_clk_init()
109 ret = PTR_ERR(of_clk->clk); in timer_of_clk_init()
110 if (ret != -EPROBE_DEFER) in timer_of_clk_init()
115 ret = clk_prepare_enable(of_clk->clk); in timer_of_clk_init()
121 of_clk->rate = clk_get_rate(of_clk->clk); in timer_of_clk_init()
122 if (!of_clk->rate) { in timer_of_clk_init()
123 ret = -EINVAL; in timer_of_clk_init()
128 of_clk->period = DIV_ROUND_UP(of_clk->rate, HZ); in timer_of_clk_init()
133 clk_disable_unprepare(of_clk->clk); in timer_of_clk_init()
135 clk_put(of_clk->clk); in timer_of_clk_init()
142 iounmap(of_base->base); in timer_of_base_exit()
148 of_base->base = of_base->name ? in timer_of_base_init()
149 of_io_request_and_map(np, of_base->index, of_base->name) : in timer_of_base_init()
150 of_iomap(np, of_base->index); in timer_of_base_init()
151 if (IS_ERR_OR_NULL(of_base->base)) { in timer_of_base_init()
152 pr_err("Failed to iomap (%s:%s)\n", np->name, of_base->name); in timer_of_base_init()
153 return of_base->base ? PTR_ERR(of_base->base) : -ENOMEM; in timer_of_base_init()
161 int ret = -EINVAL; in timer_of_init()
164 if (to->flags & TIMER_OF_BASE) { in timer_of_init()
165 ret = timer_of_base_init(np, &to->of_base); in timer_of_init()
171 if (to->flags & TIMER_OF_CLOCK) { in timer_of_init()
172 ret = timer_of_clk_init(np, &to->of_clk); in timer_of_init()
178 if (to->flags & TIMER_OF_IRQ) { in timer_of_init()
179 ret = timer_of_irq_init(np, &to->of_irq); in timer_of_init()
185 if (!to->clkevt.name) in timer_of_init()
186 to->clkevt.name = np->full_name; in timer_of_init()
188 to->np = np; in timer_of_init()
194 timer_of_irq_exit(&to->of_irq); in timer_of_init()
197 timer_of_clk_exit(&to->of_clk); in timer_of_init()
200 timer_of_base_exit(&to->of_base); in timer_of_init()
205 * timer_of_cleanup - release timer_of resources
213 if (to->flags & TIMER_OF_IRQ) in timer_of_cleanup()
214 timer_of_irq_exit(&to->of_irq); in timer_of_cleanup()
216 if (to->flags & TIMER_OF_CLOCK) in timer_of_cleanup()
217 timer_of_clk_exit(&to->of_clk); in timer_of_cleanup()
219 if (to->flags & TIMER_OF_BASE) in timer_of_cleanup()
220 timer_of_base_exit(&to->of_base); in timer_of_cleanup()