xref: /linux/drivers/clk/at91/sckc.c (revision ca55b2fef3a9373fcfc30f82fd26bc7fccbda732)
1 /*
2  * drivers/clk/at91/sckc.c
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 
13 #include <linux/clk-provider.h>
14 #include <linux/clkdev.h>
15 #include <linux/of.h>
16 #include <linux/of_address.h>
17 #include <linux/io.h>
18 
19 #include "sckc.h"
20 
21 static const struct of_device_id sckc_clk_ids[] __initconst = {
22 	/* Slow clock */
23 	{
24 		.compatible = "atmel,at91sam9x5-clk-slow-osc",
25 		.data = of_at91sam9x5_clk_slow_osc_setup,
26 	},
27 	{
28 		.compatible = "atmel,at91sam9x5-clk-slow-rc-osc",
29 		.data = of_at91sam9x5_clk_slow_rc_osc_setup,
30 	},
31 	{
32 		.compatible = "atmel,at91sam9x5-clk-slow",
33 		.data = of_at91sam9x5_clk_slow_setup,
34 	},
35 	{ /*sentinel*/ }
36 };
37 
38 static void __init of_at91sam9x5_sckc_setup(struct device_node *np)
39 {
40 	struct device_node *childnp;
41 	void (*clk_setup)(struct device_node *, void __iomem *);
42 	const struct of_device_id *clk_id;
43 	void __iomem *regbase = of_iomap(np, 0);
44 
45 	if (!regbase)
46 		return;
47 
48 	for_each_child_of_node(np, childnp) {
49 		clk_id = of_match_node(sckc_clk_ids, childnp);
50 		if (!clk_id)
51 			continue;
52 		clk_setup = clk_id->data;
53 		clk_setup(childnp, regbase);
54 	}
55 }
56 CLK_OF_DECLARE(at91sam9x5_clk_sckc, "atmel,at91sam9x5-sckc",
57 	       of_at91sam9x5_sckc_setup);
58