blob: ef1a7cdecfd9b03e4c6f7fa6c5ba5445bf7aafb9 [file] [log] [blame]
Tero Kristoa8acecc2013-07-18 11:52:33 +03001/*
2 * TI clock support
3 *
4 * Copyright (C) 2013 Texas Instruments, Inc.
5 *
6 * Tero Kristo <t-kristo@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <linux/clk-provider.h>
19#include <linux/clkdev.h>
20#include <linux/clk/ti.h>
21#include <linux/of.h>
22
23#undef pr_fmt
24#define pr_fmt(fmt) "%s: " fmt, __func__
25
26/**
27 * ti_dt_clocks_register - register DT alias clocks during boot
28 * @oclks: list of clocks to register
29 *
30 * Register alias or non-standard DT clock entries during boot. By
31 * default, DT clocks are found based on their node name. If any
32 * additional con-id / dev-id -> clock mapping is required, use this
33 * function to list these.
34 */
35void __init ti_dt_clocks_register(struct ti_dt_clk oclks[])
36{
37 struct ti_dt_clk *c;
38 struct device_node *node;
39 struct clk *clk;
40 struct of_phandle_args clkspec;
41
42 for (c = oclks; c->node_name != NULL; c++) {
43 node = of_find_node_by_name(NULL, c->node_name);
44 clkspec.np = node;
45 clk = of_clk_get_from_provider(&clkspec);
46
47 if (!IS_ERR(clk)) {
48 c->lk.clk = clk;
49 clkdev_add(&c->lk);
50 } else {
51 pr_warn("failed to lookup clock node %s\n",
52 c->node_name);
53 }
54 }
55}