aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/omap_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-omap/omap_device.c')
-rw-r--r--arch/arm/plat-omap/omap_device.c61
1 files changed, 51 insertions, 10 deletions
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index 5195dbb1a397..590435894848 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -90,6 +90,8 @@
90#define IGNORE_WAKEUP_LAT 1 90#define IGNORE_WAKEUP_LAT 1
91 91
92 92
93#define OMAP_DEVICE_MAGIC 0xf00dcafe
94
93/* Private functions */ 95/* Private functions */
94 96
95/** 97/**
@@ -305,6 +307,7 @@ int omap_device_fill_resources(struct omap_device *od, struct resource *res)
305 * @pdata_len: amount of memory pointed to by @pdata 307 * @pdata_len: amount of memory pointed to by @pdata
306 * @pm_lats: pointer to a omap_device_pm_latency array for this device 308 * @pm_lats: pointer to a omap_device_pm_latency array for this device
307 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats 309 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
310 * @is_early_device: should the device be registered as an early device or not
308 * 311 *
309 * Convenience function for building and registering a single 312 * Convenience function for building and registering a single
310 * omap_device record, which in turn builds and registers a 313 * omap_device record, which in turn builds and registers a
@@ -316,7 +319,7 @@ struct omap_device *omap_device_build(const char *pdev_name, int pdev_id,
316 struct omap_hwmod *oh, void *pdata, 319 struct omap_hwmod *oh, void *pdata,
317 int pdata_len, 320 int pdata_len,
318 struct omap_device_pm_latency *pm_lats, 321 struct omap_device_pm_latency *pm_lats,
319 int pm_lats_cnt) 322 int pm_lats_cnt, int is_early_device)
320{ 323{
321 struct omap_hwmod *ohs[] = { oh }; 324 struct omap_hwmod *ohs[] = { oh };
322 325
@@ -324,7 +327,8 @@ struct omap_device *omap_device_build(const char *pdev_name, int pdev_id,
324 return ERR_PTR(-EINVAL); 327 return ERR_PTR(-EINVAL);
325 328
326 return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata, 329 return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata,
327 pdata_len, pm_lats, pm_lats_cnt); 330 pdata_len, pm_lats, pm_lats_cnt,
331 is_early_device);
328} 332}
329 333
330/** 334/**
@@ -336,6 +340,7 @@ struct omap_device *omap_device_build(const char *pdev_name, int pdev_id,
336 * @pdata_len: amount of memory pointed to by @pdata 340 * @pdata_len: amount of memory pointed to by @pdata
337 * @pm_lats: pointer to a omap_device_pm_latency array for this device 341 * @pm_lats: pointer to a omap_device_pm_latency array for this device
338 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats 342 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
343 * @is_early_device: should the device be registered as an early device or not
339 * 344 *
340 * Convenience function for building and registering an omap_device 345 * Convenience function for building and registering an omap_device
341 * subsystem record. Subsystem records consist of multiple 346 * subsystem record. Subsystem records consist of multiple
@@ -347,7 +352,7 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
347 struct omap_hwmod **ohs, int oh_cnt, 352 struct omap_hwmod **ohs, int oh_cnt,
348 void *pdata, int pdata_len, 353 void *pdata, int pdata_len,
349 struct omap_device_pm_latency *pm_lats, 354 struct omap_device_pm_latency *pm_lats,
350 int pm_lats_cnt) 355 int pm_lats_cnt, int is_early_device)
351{ 356{
352 int ret = -ENOMEM; 357 int ret = -ENOMEM;
353 struct omap_device *od; 358 struct omap_device *od;
@@ -403,7 +408,13 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
403 od->pm_lats = pm_lats; 408 od->pm_lats = pm_lats;
404 od->pm_lats_cnt = pm_lats_cnt; 409 od->pm_lats_cnt = pm_lats_cnt;
405 410
406 ret = omap_device_register(od); 411 od->magic = OMAP_DEVICE_MAGIC;
412
413 if (is_early_device)
414 ret = omap_early_device_register(od);
415 else
416 ret = omap_device_register(od);
417
407 if (ret) 418 if (ret)
408 goto odbs_exit4; 419 goto odbs_exit4;
409 420
@@ -424,6 +435,24 @@ odbs_exit1:
424} 435}
425 436
426/** 437/**
438 * omap_early_device_register - register an omap_device as an early platform
439 * device.
440 * @od: struct omap_device * to register
441 *
442 * Register the omap_device structure. This currently just calls
443 * platform_early_add_device() on the underlying platform_device.
444 * Returns 0 by default.
445 */
446int omap_early_device_register(struct omap_device *od)
447{
448 struct platform_device *devices[1];
449
450 devices[0] = &(od->pdev);
451 early_platform_add_devices(devices, 1);
452 return 0;
453}
454
455/**
427 * omap_device_register - register an omap_device with one omap_hwmod 456 * omap_device_register - register an omap_device with one omap_hwmod
428 * @od: struct omap_device * to register 457 * @od: struct omap_device * to register
429 * 458 *
@@ -462,8 +491,8 @@ int omap_device_enable(struct platform_device *pdev)
462 od = _find_by_pdev(pdev); 491 od = _find_by_pdev(pdev);
463 492
464 if (od->_state == OMAP_DEVICE_STATE_ENABLED) { 493 if (od->_state == OMAP_DEVICE_STATE_ENABLED) {
465 WARN(1, "omap_device: %s.%d: omap_device_enable() called from " 494 WARN(1, "omap_device: %s.%d: %s() called from invalid state %d\n",
466 "invalid state\n", od->pdev.name, od->pdev.id); 495 od->pdev.name, od->pdev.id, __func__, od->_state);
467 return -EINVAL; 496 return -EINVAL;
468 } 497 }
469 498
@@ -501,8 +530,8 @@ int omap_device_idle(struct platform_device *pdev)
501 od = _find_by_pdev(pdev); 530 od = _find_by_pdev(pdev);
502 531
503 if (od->_state != OMAP_DEVICE_STATE_ENABLED) { 532 if (od->_state != OMAP_DEVICE_STATE_ENABLED) {
504 WARN(1, "omap_device: %s.%d: omap_device_idle() called from " 533 WARN(1, "omap_device: %s.%d: %s() called from invalid state %d\n",
505 "invalid state\n", od->pdev.name, od->pdev.id); 534 od->pdev.name, od->pdev.id, __func__, od->_state);
506 return -EINVAL; 535 return -EINVAL;
507 } 536 }
508 537
@@ -534,8 +563,8 @@ int omap_device_shutdown(struct platform_device *pdev)
534 563
535 if (od->_state != OMAP_DEVICE_STATE_ENABLED && 564 if (od->_state != OMAP_DEVICE_STATE_ENABLED &&
536 od->_state != OMAP_DEVICE_STATE_IDLE) { 565 od->_state != OMAP_DEVICE_STATE_IDLE) {
537 WARN(1, "omap_device: %s.%d: omap_device_shutdown() called " 566 WARN(1, "omap_device: %s.%d: %s() called from invalid state %d\n",
538 "from invalid state\n", od->pdev.name, od->pdev.id); 567 od->pdev.name, od->pdev.id, __func__, od->_state);
539 return -EINVAL; 568 return -EINVAL;
540 } 569 }
541 570
@@ -589,6 +618,18 @@ int omap_device_align_pm_lat(struct platform_device *pdev,
589} 618}
590 619
591/** 620/**
621 * omap_device_is_valid - Check if pointer is a valid omap_device
622 * @od: struct omap_device *
623 *
624 * Return whether struct omap_device pointer @od points to a valid
625 * omap_device.
626 */
627bool omap_device_is_valid(struct omap_device *od)
628{
629 return (od && od->magic == OMAP_DEVICE_MAGIC);
630}
631
632/**
592 * omap_device_get_pwrdm - return the powerdomain * associated with @od 633 * omap_device_get_pwrdm - return the powerdomain * associated with @od
593 * @od: struct omap_device * 634 * @od: struct omap_device *
594 * 635 *