clk: at91: add PMC base support
[deliverable/linux.git] / drivers / clk / at91 / pmc.h
1 /*
2 * drivers/clk/at91/pmc.h
3 *
4 * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12 #ifndef __PMC_H_
13 #define __PMC_H_
14
15 #include <linux/io.h>
16 #include <linux/irqdomain.h>
17 #include <linux/spinlock.h>
18
19 struct clk_range {
20 unsigned long min;
21 unsigned long max;
22 };
23
24 #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,}
25
26 struct at91_pmc_caps {
27 u32 available_irqs;
28 };
29
30 struct at91_pmc {
31 void __iomem *regbase;
32 int virq;
33 spinlock_t lock;
34 const struct at91_pmc_caps *caps;
35 struct irq_domain *irqdomain;
36 };
37
38 static inline void pmc_lock(struct at91_pmc *pmc)
39 {
40 spin_lock(&pmc->lock);
41 }
42
43 static inline void pmc_unlock(struct at91_pmc *pmc)
44 {
45 spin_unlock(&pmc->lock);
46 }
47
48 static inline u32 pmc_read(struct at91_pmc *pmc, int offset)
49 {
50 return readl(pmc->regbase + offset);
51 }
52
53 static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
54 {
55 writel(value, pmc->regbase + offset);
56 }
57
58 int of_at91_get_clk_range(struct device_node *np, const char *propname,
59 struct clk_range *range);
60
61 #endif /* __PMC_H_ */
This page took 0.032684 seconds and 6 git commands to generate.