diff options
author | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2018-10-16 10:21:47 -0400 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2018-10-17 13:44:33 -0400 |
commit | d387ff5427be6b93e11986c6ab6d7a8e6031e976 (patch) | |
tree | d50a8f3a189a1c88824b853dac032682c43a7646 | |
parent | d425ad81eacda2df98f063c4ca93b0f5a4690206 (diff) |
clk: at91: add new DT lookup function
Add a new DT lookup function to lookup for PMC clocks.
Note that the #ifndef AT91_PMC_MOSCS section will be removed once all the
platforms are converted.
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
-rw-r--r-- | drivers/clk/at91/pmc.c | 34 | ||||
-rw-r--r-- | include/dt-bindings/clock/at91.h | 15 |
2 files changed, 49 insertions, 0 deletions
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 0f8b3add1b04..db24539d5740 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c | |||
@@ -19,6 +19,8 @@ | |||
19 | 19 | ||
20 | #include <asm/proc-fns.h> | 20 | #include <asm/proc-fns.h> |
21 | 21 | ||
22 | #include <dt-bindings/clock/at91.h> | ||
23 | |||
22 | #include "pmc.h" | 24 | #include "pmc.h" |
23 | 25 | ||
24 | #define PMC_MAX_IDS 128 | 26 | #define PMC_MAX_IDS 128 |
@@ -47,6 +49,38 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname, | |||
47 | } | 49 | } |
48 | EXPORT_SYMBOL_GPL(of_at91_get_clk_range); | 50 | EXPORT_SYMBOL_GPL(of_at91_get_clk_range); |
49 | 51 | ||
52 | struct clk_hw *of_clk_hw_pmc_get(struct of_phandle_args *clkspec, void *data) | ||
53 | { | ||
54 | unsigned int type = clkspec->args[0]; | ||
55 | unsigned int idx = clkspec->args[1]; | ||
56 | struct pmc_data *pmc_data = data; | ||
57 | |||
58 | switch (type) { | ||
59 | case PMC_TYPE_CORE: | ||
60 | if (idx < pmc_data->ncore) | ||
61 | return pmc_data->chws[idx]; | ||
62 | break; | ||
63 | case PMC_TYPE_SYSTEM: | ||
64 | if (idx < pmc_data->nsystem) | ||
65 | return pmc_data->shws[idx]; | ||
66 | break; | ||
67 | case PMC_TYPE_PERIPHERAL: | ||
68 | if (idx < pmc_data->nperiph) | ||
69 | return pmc_data->phws[idx]; | ||
70 | break; | ||
71 | case PMC_TYPE_GCK: | ||
72 | if (idx < pmc_data->ngck) | ||
73 | return pmc_data->ghws[idx]; | ||
74 | break; | ||
75 | default: | ||
76 | break; | ||
77 | } | ||
78 | |||
79 | pr_err("%s: invalid type (%u) or index (%u)\n", __func__, type, idx); | ||
80 | |||
81 | return ERR_PTR(-EINVAL); | ||
82 | } | ||
83 | |||
50 | void pmc_data_free(struct pmc_data *pmc_data) | 84 | void pmc_data_free(struct pmc_data *pmc_data) |
51 | { | 85 | { |
52 | kfree(pmc_data->chws); | 86 | kfree(pmc_data->chws); |
diff --git a/include/dt-bindings/clock/at91.h b/include/dt-bindings/clock/at91.h index ab3ee241d10c..ed30da28d820 100644 --- a/include/dt-bindings/clock/at91.h +++ b/include/dt-bindings/clock/at91.h | |||
@@ -9,6 +9,20 @@ | |||
9 | #ifndef _DT_BINDINGS_CLK_AT91_H | 9 | #ifndef _DT_BINDINGS_CLK_AT91_H |
10 | #define _DT_BINDINGS_CLK_AT91_H | 10 | #define _DT_BINDINGS_CLK_AT91_H |
11 | 11 | ||
12 | #define PMC_TYPE_CORE 0 | ||
13 | #define PMC_TYPE_SYSTEM 1 | ||
14 | #define PMC_TYPE_PERIPHERAL 2 | ||
15 | #define PMC_TYPE_GCK 3 | ||
16 | |||
17 | #define PMC_SLOW 0 | ||
18 | #define PMC_MCK 1 | ||
19 | #define PMC_UTMI 2 | ||
20 | #define PMC_MAIN 3 | ||
21 | #define PMC_MCK2 4 | ||
22 | #define PMC_I2S0_MUX 5 | ||
23 | #define PMC_I2S1_MUX 6 | ||
24 | |||
25 | #ifndef AT91_PMC_MOSCS | ||
12 | #define AT91_PMC_MOSCS 0 /* MOSCS Flag */ | 26 | #define AT91_PMC_MOSCS 0 /* MOSCS Flag */ |
13 | #define AT91_PMC_LOCKA 1 /* PLLA Lock */ | 27 | #define AT91_PMC_LOCKA 1 /* PLLA Lock */ |
14 | #define AT91_PMC_LOCKB 2 /* PLLB Lock */ | 28 | #define AT91_PMC_LOCKB 2 /* PLLB Lock */ |
@@ -19,5 +33,6 @@ | |||
19 | #define AT91_PMC_MOSCRCS 17 /* Main On-Chip RC */ | 33 | #define AT91_PMC_MOSCRCS 17 /* Main On-Chip RC */ |
20 | #define AT91_PMC_CFDEV 18 /* Clock Failure Detector Event */ | 34 | #define AT91_PMC_CFDEV 18 /* Clock Failure Detector Event */ |
21 | #define AT91_PMC_GCKRDY 24 /* Generated Clocks */ | 35 | #define AT91_PMC_GCKRDY 24 /* Generated Clocks */ |
36 | #endif | ||
22 | 37 | ||
23 | #endif | 38 | #endif |