aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/omap_device.c
diff options
context:
space:
mode:
authorPartha Basak <p-basak2@ti.com>2010-09-21 13:23:04 -0400
committerPaul Walmsley <paul@pwsan.com>2010-09-22 11:19:54 -0400
commit4ef7aca895b2d06c07ff9d5f378af84bbf757e43 (patch)
tree1d2b64960a1c93649b7a8f82cc99b4a08b0c7772 /arch/arm/plat-omap/omap_device.c
parent9980ce53c97392a3dbdc9d1ac3e455d79b4167ed (diff)
OMAP: hwmod: Handle opt clocks node using clk_add_alias
For every optional clock present per hwmod per omap-device, this function adds an entry in the clocks list of the form <dev-id=dev_name, con-id=role>, if an entry is already present in the list of the form <dev-id=NULL, con-id=role>. The function is called from within the framework inside omap_device_build_ss(), after omap_device_register. This allows drivers to get a pointer to its optional clocks based on its role by calling clk_get(<dev*>, <role>). Link to discussions related to this patch: http://www.spinics.net/lists/linux-omap/msg34809.html Signed-off-by: Charulatha V <charu@ti.com> Signed-off-by: Partha Basak <p-basak2@ti.com> Signed-off-by: Benoit Cousson <b-cousson@ti.com> Signed-off-by: Rajendra Nayak <rnayak@ti.com> [paul@pwsan.com: simplified loop iterator; removed the superfluous clk_get(), using the clk_get() in clk_add_alias() instead] Signed-off-by: Paul Walmsley <paul@pwsan.com> Acked-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/plat-omap/omap_device.c')
-rw-r--r--arch/arm/plat-omap/omap_device.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index d2b160942ccc..ceba58a47595 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -82,6 +82,7 @@
82#include <linux/slab.h> 82#include <linux/slab.h>
83#include <linux/err.h> 83#include <linux/err.h>
84#include <linux/io.h> 84#include <linux/io.h>
85#include <linux/clk.h>
85 86
86#include <plat/omap_device.h> 87#include <plat/omap_device.h>
87#include <plat/omap_hwmod.h> 88#include <plat/omap_hwmod.h>
@@ -243,6 +244,44 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
243 return container_of(pdev, struct omap_device, pdev); 244 return container_of(pdev, struct omap_device, pdev);
244} 245}
245 246
247/**
248 * _add_optional_clock_alias - Add clock alias for hwmod optional clocks
249 * @od: struct omap_device *od
250 *
251 * For every optional clock present per hwmod per omap_device, this function
252 * adds an entry in the clocks list of the form <dev-id=dev_name, con-id=role>
253 * if an entry is already present in it with the form <dev-id=NULL, con-id=role>
254 *
255 * The function is called from inside omap_device_build_ss(), after
256 * omap_device_register.
257 *
258 * This allows drivers to get a pointer to its optional clocks based on its role
259 * by calling clk_get(<dev*>, <role>).
260 *
261 * No return value.
262 */
263static void _add_optional_clock_alias(struct omap_device *od,
264 struct omap_hwmod *oh)
265{
266 int i;
267
268 for (i = 0; i < oh->opt_clks_cnt; i++) {
269 struct omap_hwmod_opt_clk *oc;
270 int r;
271
272 oc = &oh->opt_clks[i];
273
274 if (!oc->_clk)
275 continue;
276
277 r = clk_add_alias(oc->role, dev_name(&od->pdev.dev),
278 (char *)oc->clk, &od->pdev.dev);
279 if (r)
280 pr_err("omap_device: %s: clk_add_alias for %s failed\n",
281 dev_name(&od->pdev.dev), oc->role);
282 }
283}
284
246 285
247/* Public functions for use by core code */ 286/* Public functions for use by core code */
248 287
@@ -421,8 +460,10 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
421 else 460 else
422 ret = omap_device_register(od); 461 ret = omap_device_register(od);
423 462
424 for (i = 0; i < oh_cnt; i++) 463 for (i = 0; i < oh_cnt; i++) {
425 hwmods[i]->od = od; 464 hwmods[i]->od = od;
465 _add_optional_clock_alias(od, hwmods[i]);
466 }
426 467
427 if (ret) 468 if (ret)
428 goto odbs_exit4; 469 goto odbs_exit4;