blob: 69abb08cf146513b0307a4a78449b2e5da971282 [file] [log] [blame]
Boris BREZILLON0ad61252013-12-02 15:07:02 +01001/*
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
19struct clk_range {
20 unsigned long min;
21 unsigned long max;
22};
23
24#define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,}
25
26struct at91_pmc_caps {
27 u32 available_irqs;
28};
29
30struct 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;
Boris BREZILLON947f5b12015-03-02 10:18:16 +010036 u32 imr;
Boris BREZILLON0ad61252013-12-02 15:07:02 +010037};
38
39static inline void pmc_lock(struct at91_pmc *pmc)
40{
41 spin_lock(&pmc->lock);
42}
43
44static inline void pmc_unlock(struct at91_pmc *pmc)
45{
46 spin_unlock(&pmc->lock);
47}
48
49static inline u32 pmc_read(struct at91_pmc *pmc, int offset)
50{
51 return readl(pmc->regbase + offset);
52}
53
54static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
55{
56 writel(value, pmc->regbase + offset);
57}
58
59int of_at91_get_clk_range(struct device_node *np, const char *propname,
60 struct clk_range *range);
61
Boris BREZILLON80eded62014-05-07 18:02:15 +020062extern void __init of_at91sam9260_clk_slow_setup(struct device_node *np,
63 struct at91_pmc *pmc);
64
Boris BREZILLON27cb1c22014-05-07 18:00:08 +020065extern void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np,
66 struct at91_pmc *pmc);
67extern void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np,
68 struct at91_pmc *pmc);
Boris BREZILLON38d34c32013-10-11 10:44:49 +020069extern void __init of_at91rm9200_clk_main_setup(struct device_node *np,
70 struct at91_pmc *pmc);
Boris BREZILLON27cb1c22014-05-07 18:00:08 +020071extern void __init of_at91sam9x5_clk_main_setup(struct device_node *np,
72 struct at91_pmc *pmc);
Boris BREZILLON38d34c32013-10-11 10:44:49 +020073
Boris BREZILLON1a748d22013-10-11 10:48:26 +020074extern void __init of_at91rm9200_clk_pll_setup(struct device_node *np,
75 struct at91_pmc *pmc);
76extern void __init of_at91sam9g45_clk_pll_setup(struct device_node *np,
77 struct at91_pmc *pmc);
78extern void __init of_at91sam9g20_clk_pllb_setup(struct device_node *np,
79 struct at91_pmc *pmc);
80extern void __init of_sama5d3_clk_pll_setup(struct device_node *np,
81 struct at91_pmc *pmc);
82extern void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np,
83 struct at91_pmc *pmc);
84
Boris BREZILLONe442d232013-10-11 10:51:23 +020085extern void __init of_at91rm9200_clk_master_setup(struct device_node *np,
86 struct at91_pmc *pmc);
87extern void __init of_at91sam9x5_clk_master_setup(struct device_node *np,
88 struct at91_pmc *pmc);
89
Boris BREZILLON5fba62e2013-10-11 11:41:41 +020090extern void __init of_at91rm9200_clk_sys_setup(struct device_node *np,
91 struct at91_pmc *pmc);
92
Boris BREZILLON61140672013-10-11 11:44:36 +020093extern void __init of_at91rm9200_clk_periph_setup(struct device_node *np,
94 struct at91_pmc *pmc);
95extern void __init of_at91sam9x5_clk_periph_setup(struct device_node *np,
96 struct at91_pmc *pmc);
97
Boris BREZILLON1f22f8b2013-10-11 11:57:04 +020098extern void __init of_at91rm9200_clk_prog_setup(struct device_node *np,
99 struct at91_pmc *pmc);
100extern void __init of_at91sam9g45_clk_prog_setup(struct device_node *np,
101 struct at91_pmc *pmc);
102extern void __init of_at91sam9x5_clk_prog_setup(struct device_node *np,
103 struct at91_pmc *pmc);
Boris BREZILLON1f22f8b2013-10-11 11:57:04 +0200104
Boris BREZILLONf090fb32013-10-11 12:22:06 +0200105#if defined(CONFIG_HAVE_AT91_UTMI)
106extern void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np,
107 struct at91_pmc *pmc);
108#endif
109
Boris BREZILLONc84a61d2013-10-17 18:55:41 +0200110#if defined(CONFIG_HAVE_AT91_USB_CLK)
111extern void __init of_at91rm9200_clk_usb_setup(struct device_node *np,
112 struct at91_pmc *pmc);
113extern void __init of_at91sam9x5_clk_usb_setup(struct device_node *np,
114 struct at91_pmc *pmc);
115extern void __init of_at91sam9n12_clk_usb_setup(struct device_node *np,
116 struct at91_pmc *pmc);
117#endif
118
Boris BREZILLONa9c06882013-10-11 13:27:06 +0200119#if defined(CONFIG_HAVE_AT91_SMD)
120extern void __init of_at91sam9x5_clk_smd_setup(struct device_node *np,
121 struct at91_pmc *pmc);
122#endif
123
Alexandre Bellonibcc5fd42014-09-15 18:15:53 +0200124#if defined(CONFIG_HAVE_AT91_SMD)
125extern void __init of_sama5d4_clk_h32mx_setup(struct device_node *np,
126 struct at91_pmc *pmc);
127#endif
128
Boris BREZILLON0ad61252013-12-02 15:07:02 +0100129#endif /* __PMC_H_ */