-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLK: TI: add DT alias clock registration mechanism
Some devices require their clocks to be available with a specific dev-id con-id mapping. With DT, the clocks can be found by default only with their name, or alternatively through the device node of the consumer. With drivers, that don't support DT fully yet, add mechanism to register specific clock names. Signed-off-by: Tero Kristo <t-kristo@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
- Loading branch information
Tero Kristo
authored and
Mike Turquette
committed
Jan 17, 2014
1 parent
68b9f60
commit a8acecc
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ifneq ($(CONFIG_OF),) | ||
obj-y += clk.o | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* TI clock support | ||
* | ||
* Copyright (C) 2013 Texas Instruments, Inc. | ||
* | ||
* Tero Kristo <t-kristo@ti.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
* kind, whether express or implied; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
#include <linux/clk-provider.h> | ||
#include <linux/clkdev.h> | ||
#include <linux/clk/ti.h> | ||
#include <linux/of.h> | ||
|
||
#undef pr_fmt | ||
#define pr_fmt(fmt) "%s: " fmt, __func__ | ||
|
||
/** | ||
* ti_dt_clocks_register - register DT alias clocks during boot | ||
* @oclks: list of clocks to register | ||
* | ||
* Register alias or non-standard DT clock entries during boot. By | ||
* default, DT clocks are found based on their node name. If any | ||
* additional con-id / dev-id -> clock mapping is required, use this | ||
* function to list these. | ||
*/ | ||
void __init ti_dt_clocks_register(struct ti_dt_clk oclks[]) | ||
{ | ||
struct ti_dt_clk *c; | ||
struct device_node *node; | ||
struct clk *clk; | ||
struct of_phandle_args clkspec; | ||
|
||
for (c = oclks; c->node_name != NULL; c++) { | ||
node = of_find_node_by_name(NULL, c->node_name); | ||
clkspec.np = node; | ||
clk = of_clk_get_from_provider(&clkspec); | ||
|
||
if (!IS_ERR(clk)) { | ||
c->lk.clk = clk; | ||
clkdev_add(&c->lk); | ||
} else { | ||
pr_warn("failed to lookup clock node %s\n", | ||
c->node_name); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* TI clock drivers support | ||
* | ||
* Copyright (C) 2013 Texas Instruments, Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
* kind, whether express or implied; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
#ifndef __LINUX_CLK_TI_H__ | ||
#define __LINUX_CLK_TI_H__ | ||
|
||
#include <linux/clkdev.h> | ||
|
||
/** | ||
* struct ti_dt_clk - OMAP DT clock alias declarations | ||
* @lk: clock lookup definition | ||
* @node_name: clock DT node to map to | ||
*/ | ||
struct ti_dt_clk { | ||
struct clk_lookup lk; | ||
char *node_name; | ||
}; | ||
|
||
#define DT_CLK(dev, con, name) \ | ||
{ \ | ||
.lk = { \ | ||
.dev_id = dev, \ | ||
.con_id = con, \ | ||
}, \ | ||
.node_name = name, \ | ||
} | ||
|
||
|
||
void ti_dt_clocks_register(struct ti_dt_clk *oclks); | ||
|
||
#endif |