diff options
author | Benoit Cousson <b-cousson@ti.com> | 2011-07-10 07:54:12 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2011-07-10 07:54:12 -0400 |
commit | bf1e0776cf5e4ef2622de3a4b63f84175b5b48ab (patch) | |
tree | df9b0b1c02f1f7c4774464bf5ca58d6ca791db9b /arch/arm/plat-omap | |
parent | c84584139aaeef7631df152e13cbf319d8e55950 (diff) |
OMAP: omap_device: Create clkdev entry for hwmod main_clk
Extend the existing function to create clkdev for every optional
clocks to add a well one "fck" alias for the main_clk of the
omap_hwmod.
It will allow to remove these static clkdev entries from the
clockXXX_data.c file.
Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Todd Poynor <toddpoynor@google.com>
[paul@pwsan.com: remove all of the "fck" role clkdev aliases from the
clock data files; fixed error message]
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r-- | arch/arm/plat-omap/omap_device.c | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index c8b9cd1716ba..be45147651cb 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c | |||
@@ -236,56 +236,71 @@ static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat) | |||
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | 238 | ||
239 | static void _add_clkdev(struct omap_device *od, const char *clk_alias, | ||
240 | const char *clk_name) | ||
241 | { | ||
242 | struct clk *r; | ||
243 | struct clk_lookup *l; | ||
244 | |||
245 | if (!clk_alias || !clk_name) | ||
246 | return; | ||
247 | |||
248 | pr_debug("omap_device: %s: Creating %s -> %s\n", | ||
249 | dev_name(&od->pdev.dev), clk_alias, clk_name); | ||
250 | |||
251 | r = clk_get_sys(dev_name(&od->pdev.dev), clk_alias); | ||
252 | if (!IS_ERR(r)) { | ||
253 | pr_warning("omap_device: %s: alias %s already exists\n", | ||
254 | dev_name(&od->pdev.dev), clk_alias); | ||
255 | clk_put(r); | ||
256 | return; | ||
257 | } | ||
258 | |||
259 | r = omap_clk_get_by_name(clk_name); | ||
260 | if (IS_ERR(r)) { | ||
261 | pr_err("omap_device: %s: omap_clk_get_by_name for %s failed\n", | ||
262 | dev_name(&od->pdev.dev), clk_name); | ||
263 | return; | ||
264 | } | ||
265 | |||
266 | l = clkdev_alloc(r, clk_alias, dev_name(&od->pdev.dev)); | ||
267 | if (!l) { | ||
268 | pr_err("omap_device: %s: clkdev_alloc for %s failed\n", | ||
269 | dev_name(&od->pdev.dev), clk_alias); | ||
270 | return; | ||
271 | } | ||
272 | |||
273 | clkdev_add(l); | ||
274 | } | ||
275 | |||
239 | /** | 276 | /** |
240 | * _add_optional_clock_clkdev - Add clkdev entry for hwmod optional clocks | 277 | * _add_hwmod_clocks_clkdev - Add clkdev entry for hwmod optional clocks |
278 | * and main clock | ||
241 | * @od: struct omap_device *od | 279 | * @od: struct omap_device *od |
280 | * @oh: struct omap_hwmod *oh | ||
242 | * | 281 | * |
243 | * For every optional clock present per hwmod per omap_device, this function | 282 | * For the main clock and every optional clock present per hwmod per |
244 | * adds an entry in the clkdev table of the form <dev-id=dev_name, con-id=role> | 283 | * omap_device, this function adds an entry in the clkdev table of the |
245 | * if it does not exist already. | 284 | * form <dev-id=dev_name, con-id=role> if it does not exist already. |
246 | * | 285 | * |
247 | * The function is called from inside omap_device_build_ss(), after | 286 | * The function is called from inside omap_device_build_ss(), after |
248 | * omap_device_register. | 287 | * omap_device_register. |
249 | * | 288 | * |
250 | * This allows drivers to get a pointer to its optional clocks based on its role | 289 | * This allows drivers to get a pointer to its optional clocks based on its role |
251 | * by calling clk_get(<dev*>, <role>). | 290 | * by calling clk_get(<dev*>, <role>). |
291 | * In the case of the main clock, a "fck" alias is used. | ||
252 | * | 292 | * |
253 | * No return value. | 293 | * No return value. |
254 | */ | 294 | */ |
255 | static void _add_optional_clock_clkdev(struct omap_device *od, | 295 | static void _add_hwmod_clocks_clkdev(struct omap_device *od, |
256 | struct omap_hwmod *oh) | 296 | struct omap_hwmod *oh) |
257 | { | 297 | { |
258 | int i; | 298 | int i; |
259 | 299 | ||
260 | for (i = 0; i < oh->opt_clks_cnt; i++) { | 300 | _add_clkdev(od, "fck", oh->main_clk); |
261 | struct omap_hwmod_opt_clk *oc; | ||
262 | struct clk *r; | ||
263 | struct clk_lookup *l; | ||
264 | |||
265 | oc = &oh->opt_clks[i]; | ||
266 | |||
267 | if (!oc->_clk) | ||
268 | continue; | ||
269 | |||
270 | r = clk_get_sys(dev_name(&od->pdev.dev), oc->role); | ||
271 | if (!IS_ERR(r)) | ||
272 | continue; /* clkdev entry exists */ | ||
273 | 301 | ||
274 | r = omap_clk_get_by_name((char *)oc->clk); | 302 | for (i = 0; i < oh->opt_clks_cnt; i++) |
275 | if (IS_ERR(r)) { | 303 | _add_clkdev(od, oh->opt_clks[i].role, oh->opt_clks[i].clk); |
276 | pr_err("omap_device: %s: omap_clk_get_by_name for %s failed\n", | ||
277 | dev_name(&od->pdev.dev), oc->clk); | ||
278 | continue; | ||
279 | } | ||
280 | |||
281 | l = clkdev_alloc(r, oc->role, dev_name(&od->pdev.dev)); | ||
282 | if (!l) { | ||
283 | pr_err("omap_device: %s: clkdev_alloc for %s failed\n", | ||
284 | dev_name(&od->pdev.dev), oc->role); | ||
285 | return; | ||
286 | } | ||
287 | clkdev_add(l); | ||
288 | } | ||
289 | } | 304 | } |
290 | 305 | ||
291 | 306 | ||
@@ -492,7 +507,7 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id, | |||
492 | 507 | ||
493 | for (i = 0; i < oh_cnt; i++) { | 508 | for (i = 0; i < oh_cnt; i++) { |
494 | hwmods[i]->od = od; | 509 | hwmods[i]->od = od; |
495 | _add_optional_clock_clkdev(od, hwmods[i]); | 510 | _add_hwmod_clocks_clkdev(od, hwmods[i]); |
496 | } | 511 | } |
497 | 512 | ||
498 | if (ret) | 513 | if (ret) |