Message ID | 1356619644-18565-10-git-send-email-pgaikwad@nvidia.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 12/27/2012 07:47 AM, Prashant Gaikwad wrote:
> Add support to initialize clock from DT.
Rather than require every separate clock driver to create a header in
include/linux/clk/$socname.h, would it make sense to create a single
function that can initialize any enable SoC's clocks, using a scheme
similar to:
https://lkml.org/lkml/2012/11/20/706
That's in linux-next as of today, and Thomas Petazzoni was working on
something similar for irqchips. It probably wouldn't be too hard to do
the same for clock initialization?
diff --git a/drivers/clk/tegra/clk.c b/drivers/clk/tegra/clk.c index cf023a9..314d5bd 100644 --- a/drivers/clk/tegra/clk.c +++ b/drivers/clk/tegra/clk.c @@ -67,3 +67,26 @@ void __init tegra_init_from_table(struct tegra_clk_init_table *tbl, } } } + +static const struct of_device_id tegra_dt_clk_match[] = { + { .compatible = "nvidia,tegra20-car", .data = tegra20_clock_init }, + { .compatible = "nvidia,tegra30-car", .data = tegra30_clock_init }, + { } +}; + +void __init tegra_dt_init_clk(void) +{ + struct device_node *np; + const struct of_device_id *match; + of_tegra_clk_init_func_t clk_init_func; + + np = of_find_matching_node(NULL, tegra_dt_clk_match); + if (!np) + return; + + match = of_match_node(tegra_dt_clk_match, np); + + clk_init_func = match->data; + + clk_init_func(np); +} diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h index f1ed1d0..ca1f0e4 100644 --- a/drivers/clk/tegra/clk.h +++ b/drivers/clk/tegra/clk.h @@ -20,6 +20,8 @@ #include <linux/clk-provider.h> #include <linux/clkdev.h> +typedef void (*of_tegra_clk_init_func_t)(struct device_node *); + /** * struct tegra_clk_sync_source - external clock source from codec * diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h index 0977f2a..a97e241 100644 --- a/include/linux/clk/tegra.h +++ b/include/linux/clk/tegra.h @@ -118,6 +118,7 @@ static inline void tegra_cpu_clock_resume(void) } #endif +void tegra_dt_init_clk(void); void tegra20_cpu_car_ops_init(void); void tegra30_cpu_car_ops_init(void);
Add support to initialize clock from DT. Signed-off-by: Prashant Gaikwad <pgaikwad@nvidia.com> --- drivers/clk/tegra/clk.c | 23 +++++++++++++++++++++++ drivers/clk/tegra/clk.h | 2 ++ include/linux/clk/tegra.h | 1 + 3 files changed, 26 insertions(+), 0 deletions(-)