Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | */ |
| 10 | |
| 11 | #include <linux/clk-provider.h> |
| 12 | #include <linux/clkdev.h> |
| 13 | #include <linux/clk/at91_pmc.h> |
| 14 | #include <linux/delay.h> |
| 15 | #include <linux/of.h> |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 16 | #include <linux/mfd/syscon.h> |
| 17 | #include <linux/regmap.h> |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 18 | |
| 19 | #include "pmc.h" |
| 20 | |
| 21 | #define SLOW_CLOCK_FREQ 32768 |
| 22 | #define MAINF_DIV 16 |
| 23 | #define MAINFRDY_TIMEOUT (((MAINF_DIV + 1) * USEC_PER_SEC) / \ |
| 24 | SLOW_CLOCK_FREQ) |
| 25 | #define MAINF_LOOP_MIN_WAIT (USEC_PER_SEC / SLOW_CLOCK_FREQ) |
| 26 | #define MAINF_LOOP_MAX_WAIT MAINFRDY_TIMEOUT |
| 27 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 28 | #define MOR_KEY_MASK (0xff << 16) |
| 29 | |
| 30 | struct clk_main_osc { |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 31 | struct clk_hw hw; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 32 | struct regmap *regmap; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 33 | }; |
| 34 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 35 | #define to_clk_main_osc(hw) container_of(hw, struct clk_main_osc, hw) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 36 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 37 | struct clk_main_rc_osc { |
| 38 | struct clk_hw hw; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 39 | struct regmap *regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 40 | unsigned long frequency; |
| 41 | unsigned long accuracy; |
| 42 | }; |
| 43 | |
| 44 | #define to_clk_main_rc_osc(hw) container_of(hw, struct clk_main_rc_osc, hw) |
| 45 | |
| 46 | struct clk_rm9200_main { |
| 47 | struct clk_hw hw; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 48 | struct regmap *regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | #define to_clk_rm9200_main(hw) container_of(hw, struct clk_rm9200_main, hw) |
| 52 | |
| 53 | struct clk_sam9x5_main { |
| 54 | struct clk_hw hw; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 55 | struct regmap *regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 56 | u8 parent; |
| 57 | }; |
| 58 | |
| 59 | #define to_clk_sam9x5_main(hw) container_of(hw, struct clk_sam9x5_main, hw) |
| 60 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 61 | static inline bool clk_main_osc_ready(struct regmap *regmap) |
| 62 | { |
| 63 | unsigned int status; |
| 64 | |
| 65 | regmap_read(regmap, AT91_PMC_SR, &status); |
| 66 | |
| 67 | return status & AT91_PMC_MOSCS; |
| 68 | } |
| 69 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 70 | static int clk_main_osc_prepare(struct clk_hw *hw) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 71 | { |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 72 | struct clk_main_osc *osc = to_clk_main_osc(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 73 | struct regmap *regmap = osc->regmap; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 74 | u32 tmp; |
| 75 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 76 | regmap_read(regmap, AT91_CKGR_MOR, &tmp); |
| 77 | tmp &= ~MOR_KEY_MASK; |
| 78 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 79 | if (tmp & AT91_PMC_OSCBYPASS) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 80 | return 0; |
| 81 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 82 | if (!(tmp & AT91_PMC_MOSCEN)) { |
| 83 | tmp |= AT91_PMC_MOSCEN | AT91_PMC_KEY; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 84 | regmap_write(regmap, AT91_CKGR_MOR, tmp); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 85 | } |
| 86 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 87 | while (!clk_main_osc_ready(regmap)) |
| 88 | cpu_relax(); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 93 | static void clk_main_osc_unprepare(struct clk_hw *hw) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 94 | { |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 95 | struct clk_main_osc *osc = to_clk_main_osc(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 96 | struct regmap *regmap = osc->regmap; |
| 97 | u32 tmp; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 98 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 99 | regmap_read(regmap, AT91_CKGR_MOR, &tmp); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 100 | if (tmp & AT91_PMC_OSCBYPASS) |
| 101 | return; |
| 102 | |
| 103 | if (!(tmp & AT91_PMC_MOSCEN)) |
| 104 | return; |
| 105 | |
| 106 | tmp &= ~(AT91_PMC_KEY | AT91_PMC_MOSCEN); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 107 | regmap_write(regmap, AT91_CKGR_MOR, tmp | AT91_PMC_KEY); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 108 | } |
| 109 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 110 | static int clk_main_osc_is_prepared(struct clk_hw *hw) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 111 | { |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 112 | struct clk_main_osc *osc = to_clk_main_osc(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 113 | struct regmap *regmap = osc->regmap; |
| 114 | u32 tmp, status; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 115 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 116 | regmap_read(regmap, AT91_CKGR_MOR, &tmp); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 117 | if (tmp & AT91_PMC_OSCBYPASS) |
| 118 | return 1; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 119 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 120 | regmap_read(regmap, AT91_PMC_SR, &status); |
| 121 | |
| 122 | return (status & AT91_PMC_MOSCS) && (tmp & AT91_PMC_MOSCEN); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 123 | } |
| 124 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 125 | static const struct clk_ops main_osc_ops = { |
| 126 | .prepare = clk_main_osc_prepare, |
| 127 | .unprepare = clk_main_osc_unprepare, |
| 128 | .is_prepared = clk_main_osc_is_prepared, |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | static struct clk * __init |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 132 | at91_clk_register_main_osc(struct regmap *regmap, |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 133 | const char *name, |
| 134 | const char *parent_name, |
| 135 | bool bypass) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 136 | { |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 137 | struct clk_main_osc *osc; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 138 | struct clk *clk = NULL; |
| 139 | struct clk_init_data init; |
| 140 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 141 | if (!name || !parent_name) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 142 | return ERR_PTR(-EINVAL); |
| 143 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 144 | osc = kzalloc(sizeof(*osc), GFP_KERNEL); |
| 145 | if (!osc) |
| 146 | return ERR_PTR(-ENOMEM); |
| 147 | |
| 148 | init.name = name; |
| 149 | init.ops = &main_osc_ops; |
| 150 | init.parent_names = &parent_name; |
| 151 | init.num_parents = 1; |
| 152 | init.flags = CLK_IGNORE_UNUSED; |
| 153 | |
| 154 | osc->hw.init = &init; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 155 | osc->regmap = regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 156 | |
| 157 | if (bypass) |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 158 | regmap_update_bits(regmap, |
| 159 | AT91_CKGR_MOR, MOR_KEY_MASK | |
| 160 | AT91_PMC_MOSCEN, |
| 161 | AT91_PMC_OSCBYPASS | AT91_PMC_KEY); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 162 | |
| 163 | clk = clk_register(NULL, &osc->hw); |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 164 | if (IS_ERR(clk)) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 165 | kfree(osc); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 166 | |
| 167 | return clk; |
| 168 | } |
| 169 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 170 | static void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 171 | { |
| 172 | struct clk *clk; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 173 | const char *name = np->name; |
| 174 | const char *parent_name; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 175 | struct regmap *regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 176 | bool bypass; |
| 177 | |
| 178 | of_property_read_string(np, "clock-output-names", &name); |
| 179 | bypass = of_property_read_bool(np, "atmel,osc-bypass"); |
| 180 | parent_name = of_clk_get_parent_name(np, 0); |
| 181 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 182 | regmap = syscon_node_to_regmap(of_get_parent(np)); |
| 183 | if (IS_ERR(regmap)) |
| 184 | return; |
| 185 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 186 | clk = at91_clk_register_main_osc(regmap, name, parent_name, bypass); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 187 | if (IS_ERR(clk)) |
| 188 | return; |
| 189 | |
| 190 | of_clk_add_provider(np, of_clk_src_simple_get, clk); |
| 191 | } |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 192 | CLK_OF_DECLARE(at91rm9200_clk_main_osc, "atmel,at91rm9200-clk-main-osc", |
| 193 | of_at91rm9200_clk_main_osc_setup); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 194 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 195 | static bool clk_main_rc_osc_ready(struct regmap *regmap) |
| 196 | { |
| 197 | unsigned int status; |
| 198 | |
| 199 | regmap_read(regmap, AT91_PMC_SR, &status); |
| 200 | |
| 201 | return status & AT91_PMC_MOSCRCS; |
| 202 | } |
| 203 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 204 | static int clk_main_rc_osc_prepare(struct clk_hw *hw) |
| 205 | { |
| 206 | struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 207 | struct regmap *regmap = osc->regmap; |
| 208 | unsigned int mor; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 209 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 210 | regmap_read(regmap, AT91_CKGR_MOR, &mor); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 211 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 212 | if (!(mor & AT91_PMC_MOSCRCEN)) |
| 213 | regmap_update_bits(regmap, AT91_CKGR_MOR, |
| 214 | MOR_KEY_MASK | AT91_PMC_MOSCRCEN, |
| 215 | AT91_PMC_MOSCRCEN | AT91_PMC_KEY); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 216 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 217 | while (!clk_main_rc_osc_ready(regmap)) |
| 218 | cpu_relax(); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 219 | |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | static void clk_main_rc_osc_unprepare(struct clk_hw *hw) |
| 224 | { |
| 225 | struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 226 | struct regmap *regmap = osc->regmap; |
| 227 | unsigned int mor; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 228 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 229 | regmap_read(regmap, AT91_CKGR_MOR, &mor); |
| 230 | |
| 231 | if (!(mor & AT91_PMC_MOSCRCEN)) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 232 | return; |
| 233 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 234 | regmap_update_bits(regmap, AT91_CKGR_MOR, |
| 235 | MOR_KEY_MASK | AT91_PMC_MOSCRCEN, AT91_PMC_KEY); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | static int clk_main_rc_osc_is_prepared(struct clk_hw *hw) |
| 239 | { |
| 240 | struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 241 | struct regmap *regmap = osc->regmap; |
| 242 | unsigned int mor, status; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 243 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 244 | regmap_read(regmap, AT91_CKGR_MOR, &mor); |
| 245 | regmap_read(regmap, AT91_PMC_SR, &status); |
| 246 | |
| 247 | return (mor & AT91_PMC_MOSCRCEN) && (status & AT91_PMC_MOSCRCS); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | static unsigned long clk_main_rc_osc_recalc_rate(struct clk_hw *hw, |
| 251 | unsigned long parent_rate) |
| 252 | { |
| 253 | struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); |
| 254 | |
| 255 | return osc->frequency; |
| 256 | } |
| 257 | |
| 258 | static unsigned long clk_main_rc_osc_recalc_accuracy(struct clk_hw *hw, |
| 259 | unsigned long parent_acc) |
| 260 | { |
| 261 | struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw); |
| 262 | |
| 263 | return osc->accuracy; |
| 264 | } |
| 265 | |
| 266 | static const struct clk_ops main_rc_osc_ops = { |
| 267 | .prepare = clk_main_rc_osc_prepare, |
| 268 | .unprepare = clk_main_rc_osc_unprepare, |
| 269 | .is_prepared = clk_main_rc_osc_is_prepared, |
| 270 | .recalc_rate = clk_main_rc_osc_recalc_rate, |
| 271 | .recalc_accuracy = clk_main_rc_osc_recalc_accuracy, |
| 272 | }; |
| 273 | |
| 274 | static struct clk * __init |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 275 | at91_clk_register_main_rc_osc(struct regmap *regmap, |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 276 | const char *name, |
| 277 | u32 frequency, u32 accuracy) |
| 278 | { |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 279 | struct clk_main_rc_osc *osc; |
| 280 | struct clk *clk = NULL; |
| 281 | struct clk_init_data init; |
| 282 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 283 | if (!name || !frequency) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 284 | return ERR_PTR(-EINVAL); |
| 285 | |
| 286 | osc = kzalloc(sizeof(*osc), GFP_KERNEL); |
| 287 | if (!osc) |
| 288 | return ERR_PTR(-ENOMEM); |
| 289 | |
| 290 | init.name = name; |
| 291 | init.ops = &main_rc_osc_ops; |
| 292 | init.parent_names = NULL; |
| 293 | init.num_parents = 0; |
| 294 | init.flags = CLK_IS_ROOT | CLK_IGNORE_UNUSED; |
| 295 | |
| 296 | osc->hw.init = &init; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 297 | osc->regmap = regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 298 | osc->frequency = frequency; |
| 299 | osc->accuracy = accuracy; |
| 300 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 301 | clk = clk_register(NULL, &osc->hw); |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 302 | if (IS_ERR(clk)) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 303 | kfree(osc); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 304 | |
| 305 | return clk; |
| 306 | } |
| 307 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 308 | static void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 309 | { |
| 310 | struct clk *clk; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 311 | u32 frequency = 0; |
| 312 | u32 accuracy = 0; |
| 313 | const char *name = np->name; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 314 | struct regmap *regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 315 | |
| 316 | of_property_read_string(np, "clock-output-names", &name); |
| 317 | of_property_read_u32(np, "clock-frequency", &frequency); |
| 318 | of_property_read_u32(np, "clock-accuracy", &accuracy); |
| 319 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 320 | regmap = syscon_node_to_regmap(of_get_parent(np)); |
| 321 | if (IS_ERR(regmap)) |
| 322 | return; |
| 323 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 324 | clk = at91_clk_register_main_rc_osc(regmap, name, frequency, accuracy); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 325 | if (IS_ERR(clk)) |
| 326 | return; |
| 327 | |
| 328 | of_clk_add_provider(np, of_clk_src_simple_get, clk); |
| 329 | } |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 330 | CLK_OF_DECLARE(at91sam9x5_clk_main_rc_osc, "atmel,at91sam9x5-clk-main-rc-osc", |
| 331 | of_at91sam9x5_clk_main_rc_osc_setup); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 332 | |
| 333 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 334 | static int clk_main_probe_frequency(struct regmap *regmap) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 335 | { |
| 336 | unsigned long prep_time, timeout; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 337 | unsigned int mcfr; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 338 | |
| 339 | timeout = jiffies + usecs_to_jiffies(MAINFRDY_TIMEOUT); |
| 340 | do { |
| 341 | prep_time = jiffies; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 342 | regmap_read(regmap, AT91_CKGR_MCFR, &mcfr); |
| 343 | if (mcfr & AT91_PMC_MAINRDY) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 344 | return 0; |
| 345 | usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT); |
| 346 | } while (time_before(prep_time, timeout)); |
| 347 | |
| 348 | return -ETIMEDOUT; |
| 349 | } |
| 350 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 351 | static unsigned long clk_main_recalc_rate(struct regmap *regmap, |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 352 | unsigned long parent_rate) |
| 353 | { |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 354 | unsigned int mcfr; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 355 | |
| 356 | if (parent_rate) |
| 357 | return parent_rate; |
| 358 | |
Alexandre Belloni | 4da66b6 | 2014-07-01 16:12:12 +0200 | [diff] [blame] | 359 | pr_warn("Main crystal frequency not set, using approximate value\n"); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 360 | regmap_read(regmap, AT91_CKGR_MCFR, &mcfr); |
| 361 | if (!(mcfr & AT91_PMC_MAINRDY)) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 362 | return 0; |
| 363 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 364 | return ((mcfr & AT91_PMC_MAINF) * SLOW_CLOCK_FREQ) / MAINF_DIV; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | static int clk_rm9200_main_prepare(struct clk_hw *hw) |
| 368 | { |
| 369 | struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw); |
| 370 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 371 | return clk_main_probe_frequency(clkmain->regmap); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | static int clk_rm9200_main_is_prepared(struct clk_hw *hw) |
| 375 | { |
| 376 | struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 377 | unsigned int status; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 378 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 379 | regmap_read(clkmain->regmap, AT91_CKGR_MCFR, &status); |
| 380 | |
| 381 | return status & AT91_PMC_MAINRDY ? 1 : 0; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | static unsigned long clk_rm9200_main_recalc_rate(struct clk_hw *hw, |
| 385 | unsigned long parent_rate) |
| 386 | { |
| 387 | struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw); |
| 388 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 389 | return clk_main_recalc_rate(clkmain->regmap, parent_rate); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | static const struct clk_ops rm9200_main_ops = { |
| 393 | .prepare = clk_rm9200_main_prepare, |
| 394 | .is_prepared = clk_rm9200_main_is_prepared, |
| 395 | .recalc_rate = clk_rm9200_main_recalc_rate, |
| 396 | }; |
| 397 | |
| 398 | static struct clk * __init |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 399 | at91_clk_register_rm9200_main(struct regmap *regmap, |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 400 | const char *name, |
| 401 | const char *parent_name) |
| 402 | { |
| 403 | struct clk_rm9200_main *clkmain; |
| 404 | struct clk *clk = NULL; |
| 405 | struct clk_init_data init; |
| 406 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 407 | if (!name) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 408 | return ERR_PTR(-EINVAL); |
| 409 | |
| 410 | if (!parent_name) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 411 | return ERR_PTR(-EINVAL); |
| 412 | |
| 413 | clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL); |
| 414 | if (!clkmain) |
| 415 | return ERR_PTR(-ENOMEM); |
| 416 | |
| 417 | init.name = name; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 418 | init.ops = &rm9200_main_ops; |
| 419 | init.parent_names = &parent_name; |
| 420 | init.num_parents = 1; |
| 421 | init.flags = 0; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 422 | |
| 423 | clkmain->hw.init = &init; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 424 | clkmain->regmap = regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 425 | |
| 426 | clk = clk_register(NULL, &clkmain->hw); |
| 427 | if (IS_ERR(clk)) |
| 428 | kfree(clkmain); |
| 429 | |
| 430 | return clk; |
| 431 | } |
| 432 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 433 | static void __init of_at91rm9200_clk_main_setup(struct device_node *np) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 434 | { |
| 435 | struct clk *clk; |
| 436 | const char *parent_name; |
| 437 | const char *name = np->name; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 438 | struct regmap *regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 439 | |
| 440 | parent_name = of_clk_get_parent_name(np, 0); |
| 441 | of_property_read_string(np, "clock-output-names", &name); |
| 442 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 443 | regmap = syscon_node_to_regmap(of_get_parent(np)); |
| 444 | if (IS_ERR(regmap)) |
| 445 | return; |
| 446 | |
| 447 | clk = at91_clk_register_rm9200_main(regmap, name, parent_name); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 448 | if (IS_ERR(clk)) |
| 449 | return; |
| 450 | |
| 451 | of_clk_add_provider(np, of_clk_src_simple_get, clk); |
| 452 | } |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 453 | CLK_OF_DECLARE(at91rm9200_clk_main, "atmel,at91rm9200-clk-main", |
| 454 | of_at91rm9200_clk_main_setup); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 455 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 456 | static inline bool clk_sam9x5_main_ready(struct regmap *regmap) |
| 457 | { |
| 458 | unsigned int status; |
| 459 | |
| 460 | regmap_read(regmap, AT91_PMC_SR, &status); |
| 461 | |
| 462 | return status & AT91_PMC_MOSCSELS ? 1 : 0; |
| 463 | } |
| 464 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 465 | static int clk_sam9x5_main_prepare(struct clk_hw *hw) |
| 466 | { |
| 467 | struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 468 | struct regmap *regmap = clkmain->regmap; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 469 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 470 | while (!clk_sam9x5_main_ready(regmap)) |
| 471 | cpu_relax(); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 472 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 473 | return clk_main_probe_frequency(regmap); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | static int clk_sam9x5_main_is_prepared(struct clk_hw *hw) |
| 477 | { |
| 478 | struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); |
| 479 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 480 | return clk_sam9x5_main_ready(clkmain->regmap); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | static unsigned long clk_sam9x5_main_recalc_rate(struct clk_hw *hw, |
| 484 | unsigned long parent_rate) |
| 485 | { |
| 486 | struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); |
| 487 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 488 | return clk_main_recalc_rate(clkmain->regmap, parent_rate); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index) |
| 492 | { |
| 493 | struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 494 | struct regmap *regmap = clkmain->regmap; |
| 495 | unsigned int tmp; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 496 | |
| 497 | if (index > 1) |
| 498 | return -EINVAL; |
| 499 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 500 | regmap_read(regmap, AT91_CKGR_MOR, &tmp); |
| 501 | tmp &= ~MOR_KEY_MASK; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 502 | |
| 503 | if (index && !(tmp & AT91_PMC_MOSCSEL)) |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 504 | regmap_write(regmap, AT91_CKGR_MOR, tmp | AT91_PMC_MOSCSEL); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 505 | else if (!index && (tmp & AT91_PMC_MOSCSEL)) |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 506 | regmap_write(regmap, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 507 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 508 | while (!clk_sam9x5_main_ready(regmap)) |
| 509 | cpu_relax(); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 510 | |
| 511 | return 0; |
| 512 | } |
| 513 | |
| 514 | static u8 clk_sam9x5_main_get_parent(struct clk_hw *hw) |
| 515 | { |
| 516 | struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 517 | unsigned int status; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 518 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 519 | regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status); |
| 520 | |
| 521 | return status & AT91_PMC_MOSCEN ? 1 : 0; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | static const struct clk_ops sam9x5_main_ops = { |
| 525 | .prepare = clk_sam9x5_main_prepare, |
| 526 | .is_prepared = clk_sam9x5_main_is_prepared, |
| 527 | .recalc_rate = clk_sam9x5_main_recalc_rate, |
| 528 | .set_parent = clk_sam9x5_main_set_parent, |
| 529 | .get_parent = clk_sam9x5_main_get_parent, |
| 530 | }; |
| 531 | |
| 532 | static struct clk * __init |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 533 | at91_clk_register_sam9x5_main(struct regmap *regmap, |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 534 | const char *name, |
| 535 | const char **parent_names, |
| 536 | int num_parents) |
| 537 | { |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 538 | struct clk_sam9x5_main *clkmain; |
| 539 | struct clk *clk = NULL; |
| 540 | struct clk_init_data init; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 541 | unsigned int status; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 542 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 543 | if (!name) |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 544 | return ERR_PTR(-EINVAL); |
| 545 | |
| 546 | if (!parent_names || !num_parents) |
| 547 | return ERR_PTR(-EINVAL); |
| 548 | |
| 549 | clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL); |
| 550 | if (!clkmain) |
| 551 | return ERR_PTR(-ENOMEM); |
| 552 | |
| 553 | init.name = name; |
| 554 | init.ops = &sam9x5_main_ops; |
| 555 | init.parent_names = parent_names; |
| 556 | init.num_parents = num_parents; |
| 557 | init.flags = CLK_SET_PARENT_GATE; |
| 558 | |
| 559 | clkmain->hw.init = &init; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 560 | clkmain->regmap = regmap; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 561 | regmap_read(clkmain->regmap, AT91_CKGR_MOR, &status); |
| 562 | clkmain->parent = status & AT91_PMC_MOSCEN ? 1 : 0; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 563 | |
| 564 | clk = clk_register(NULL, &clkmain->hw); |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 565 | if (IS_ERR(clk)) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 566 | kfree(clkmain); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 567 | |
| 568 | return clk; |
| 569 | } |
| 570 | |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 571 | static void __init of_at91sam9x5_clk_main_setup(struct device_node *np) |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 572 | { |
| 573 | struct clk *clk; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 574 | const char *parent_names[2]; |
| 575 | int num_parents; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 576 | const char *name = np->name; |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 577 | struct regmap *regmap; |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 578 | |
Geert Uytterhoeven | 51a43be | 2015-05-29 11:25:45 +0200 | [diff] [blame] | 579 | num_parents = of_clk_get_parent_count(np); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 580 | if (num_parents <= 0 || num_parents > 2) |
| 581 | return; |
| 582 | |
Dinh Nguyen | f0557fb | 2015-07-06 22:59:01 -0500 | [diff] [blame] | 583 | of_clk_parent_fill(np, parent_names, num_parents); |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 584 | regmap = syscon_node_to_regmap(of_get_parent(np)); |
| 585 | if (IS_ERR(regmap)) |
| 586 | return; |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 587 | |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 588 | of_property_read_string(np, "clock-output-names", &name); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 589 | |
Alexandre Belloni | 99a8170 | 2015-09-16 23:47:39 +0200 | [diff] [blame^] | 590 | clk = at91_clk_register_sam9x5_main(regmap, name, parent_names, |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame] | 591 | num_parents); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 592 | if (IS_ERR(clk)) |
| 593 | return; |
| 594 | |
| 595 | of_clk_add_provider(np, of_clk_src_simple_get, clk); |
| 596 | } |
Boris Brezillon | 1bdf023 | 2014-09-07 08:14:29 +0200 | [diff] [blame] | 597 | CLK_OF_DECLARE(at91sam9x5_clk_main, "atmel,at91sam9x5-clk-main", |
| 598 | of_at91sam9x5_clk_main_setup); |