diff options
author | Rajendra Nayak <rnayak@ti.com> | 2011-02-25 17:40:21 -0500 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2011-03-01 18:36:38 -0500 |
commit | da0653fe01cd4c6ed402a94752b78be62cb39282 (patch) | |
tree | 3d981c94727963b7a52ab038f7a791418d7d851c /arch/arm/plat-omap/omap_device.c | |
parent | dd9c1549edef02290edced639f67b54a25abbe0e (diff) |
OMAP2+: omap_device/clock: Do not expect an entry in clkdev for opt_clks
The _add_optional_clock_alias function expects an entry
already existing in the clkdev table in the form of
<dev-id=NULL, con-id=role> which might not be the case
always.
Instead, just check if an entry already exists in clkdev
in the <dev-id=dev_name, con-id=role> form, else go ahead
and add one.
Remove any assumption of an entry already existing in clkdev
table in any form.
Since this means, adding a new entry in clkdev if it does
not already exist, and not really adding an 'alias',
also rename the function name
(s/_add_optional_clock_alias/_add_optional_clock_clkdev)
to reflect this.
Signed-off-by: Rajendra Nayak <rnayak@ti.com>
Reported-by: Sumit Semwal <sumit.semwal@ti.com>
Cc: Sumit Semwal <sumit.semwal@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Partha Basak <p-basak2@ti.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/plat-omap/omap_device.c')
-rw-r--r-- | arch/arm/plat-omap/omap_device.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 57adb270767b..9bbda9acb73b 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c | |||
@@ -83,9 +83,11 @@ | |||
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 | #include <linux/clk.h> |
86 | #include <linux/clkdev.h> | ||
86 | 87 | ||
87 | #include <plat/omap_device.h> | 88 | #include <plat/omap_device.h> |
88 | #include <plat/omap_hwmod.h> | 89 | #include <plat/omap_hwmod.h> |
90 | #include <plat/clock.h> | ||
89 | 91 | ||
90 | /* These parameters are passed to _omap_device_{de,}activate() */ | 92 | /* These parameters are passed to _omap_device_{de,}activate() */ |
91 | #define USE_WAKEUP_LAT 0 | 93 | #define USE_WAKEUP_LAT 0 |
@@ -239,12 +241,12 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev) | |||
239 | } | 241 | } |
240 | 242 | ||
241 | /** | 243 | /** |
242 | * _add_optional_clock_alias - Add clock alias for hwmod optional clocks | 244 | * _add_optional_clock_clkdev - Add clkdev entry for hwmod optional clocks |
243 | * @od: struct omap_device *od | 245 | * @od: struct omap_device *od |
244 | * | 246 | * |
245 | * For every optional clock present per hwmod per omap_device, this function | 247 | * For every optional clock present per hwmod per omap_device, this function |
246 | * adds an entry in the clocks list of the form <dev-id=dev_name, con-id=role> | 248 | * adds an entry in the clkdev table of the form <dev-id=dev_name, con-id=role> |
247 | * if an entry is already present in it with the form <dev-id=NULL, con-id=role> | 249 | * if it does not exist already. |
248 | * | 250 | * |
249 | * The function is called from inside omap_device_build_ss(), after | 251 | * The function is called from inside omap_device_build_ss(), after |
250 | * omap_device_register. | 252 | * omap_device_register. |
@@ -254,25 +256,39 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev) | |||
254 | * | 256 | * |
255 | * No return value. | 257 | * No return value. |
256 | */ | 258 | */ |
257 | static void _add_optional_clock_alias(struct omap_device *od, | 259 | static void _add_optional_clock_clkdev(struct omap_device *od, |
258 | struct omap_hwmod *oh) | 260 | struct omap_hwmod *oh) |
259 | { | 261 | { |
260 | int i; | 262 | int i; |
261 | 263 | ||
262 | for (i = 0; i < oh->opt_clks_cnt; i++) { | 264 | for (i = 0; i < oh->opt_clks_cnt; i++) { |
263 | struct omap_hwmod_opt_clk *oc; | 265 | struct omap_hwmod_opt_clk *oc; |
264 | int r; | 266 | struct clk *r; |
267 | struct clk_lookup *l; | ||
265 | 268 | ||
266 | oc = &oh->opt_clks[i]; | 269 | oc = &oh->opt_clks[i]; |
267 | 270 | ||
268 | if (!oc->_clk) | 271 | if (!oc->_clk) |
269 | continue; | 272 | continue; |
270 | 273 | ||
271 | r = clk_add_alias(oc->role, dev_name(&od->pdev.dev), | 274 | r = clk_get_sys(dev_name(&od->pdev.dev), oc->role); |
272 | (char *)oc->clk, &od->pdev.dev); | 275 | if (!IS_ERR(r)) |
273 | if (r) | 276 | continue; /* clkdev entry exists */ |
274 | pr_err("omap_device: %s: clk_add_alias for %s failed\n", | 277 | |
278 | r = omap_clk_get_by_name((char *)oc->clk); | ||
279 | if (IS_ERR(r)) { | ||
280 | pr_err("omap_device: %s: omap_clk_get_by_name for %s failed\n", | ||
281 | dev_name(&od->pdev.dev), oc->clk); | ||
282 | continue; | ||
283 | } | ||
284 | |||
285 | l = clkdev_alloc(r, oc->role, dev_name(&od->pdev.dev)); | ||
286 | if (!l) { | ||
287 | pr_err("omap_device: %s: clkdev_alloc for %s failed\n", | ||
275 | dev_name(&od->pdev.dev), oc->role); | 288 | dev_name(&od->pdev.dev), oc->role); |
289 | return; | ||
290 | } | ||
291 | clkdev_add(l); | ||
276 | } | 292 | } |
277 | } | 293 | } |
278 | 294 | ||
@@ -480,7 +496,7 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id, | |||
480 | 496 | ||
481 | for (i = 0; i < oh_cnt; i++) { | 497 | for (i = 0; i < oh_cnt; i++) { |
482 | hwmods[i]->od = od; | 498 | hwmods[i]->od = od; |
483 | _add_optional_clock_alias(od, hwmods[i]); | 499 | _add_optional_clock_clkdev(od, hwmods[i]); |
484 | } | 500 | } |
485 | 501 | ||
486 | if (ret) | 502 | if (ret) |