1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * drivers/clk/at91/clk-slow.c
8 #include <linux/clk-provider.h>
9 #include <linux/clkdev.h>
10 #include <linux/clk/at91_pmc.h>
12 #include <linux/mfd/syscon.h>
13 #include <linux/regmap.h>
17 struct clk_sam9260_slow {
19 struct regmap *regmap;
22 #define to_clk_sam9260_slow(hw) container_of(hw, struct clk_sam9260_slow, hw)
24 static u8 clk_sam9260_slow_get_parent(struct clk_hw *hw)
26 struct clk_sam9260_slow *slowck = to_clk_sam9260_slow(hw);
29 regmap_read(slowck->regmap, AT91_PMC_SR, &status);
31 return status & AT91_PMC_OSCSEL ? 1 : 0;
34 static const struct clk_ops sam9260_slow_ops = {
35 .get_parent = clk_sam9260_slow_get_parent,
38 struct clk_hw * __init
39 at91_clk_register_sam9260_slow(struct regmap *regmap,
41 const char **parent_names,
44 struct clk_sam9260_slow *slowck;
46 struct clk_init_data init;
50 return ERR_PTR(-EINVAL);
52 if (!parent_names || !num_parents)
53 return ERR_PTR(-EINVAL);
55 slowck = kzalloc(sizeof(*slowck), GFP_KERNEL);
57 return ERR_PTR(-ENOMEM);
60 init.ops = &sam9260_slow_ops;
61 init.parent_names = parent_names;
62 init.num_parents = num_parents;
65 slowck->hw.init = &init;
66 slowck->regmap = regmap;
69 ret = clk_hw_register(NULL, &slowck->hw);