connectTheSignalSlot.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * omap_device implementation
  3. *
  4. * Copyright (C) 2009-2010 Nokia Corporation
  5. * Paul Walmsley, Kevin Hilman
  6. *
  7. * Developed in collaboration with (alphabetical order): Benoit
  8. * Cousson, Thara Gopinath, Tony Lindgren, Rajendra Nayak, Vikram
  9. * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
  10. * Woodruff
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. *
  16. * This code provides a consistent interface for OMAP device drivers
  17. * to control power management and interconnect properties of their
  18. * devices.
  19. *
  20. * In the medium- to long-term, this code should either be
  21. * a) implemented via arch-specific pointers in platform_data
  22. * or
  23. * b) implemented as a proper omap_bus/omap_device in Linux, no more
  24. * platform_data func pointers
  25. *
  26. *
  27. * Guidelines for usage by driver authors:
  28. *
  29. * 1. These functions are intended to be used by device drivers via
  30. * function pointers in struct platform_data. As an example,
  31. * omap_device_enable() should be passed to the driver as
  32. *
  33. * struct foo_driver_platform_data {
  34. * ...
  35. * int (*device_enable)(struct platform_device *pdev);
  36. * ...
  37. * }
  38. *
  39. * Note that the generic "device_enable" name is used, rather than
  40. * "omap_device_enable". This is so other architectures can pass in their
  41. * own enable/disable functions here.
  42. *
  43. * This should be populated during device setup:
  44. *
  45. * ...
  46. * pdata->device_enable = omap_device_enable;
  47. * ...
  48. *
  49. * 2. Drivers should first check to ensure the function pointer is not null
  50. * before calling it, as in:
  51. *
  52. * if (pdata->device_enable)
  53. * pdata->device_enable(pdev);
  54. *
  55. * This allows other architectures that don't use similar device_enable()/
  56. * device_shutdown() functions to execute normally.
  57. *
  58. * ...
  59. *
  60. * Suggested usage by device drivers:
  61. *
  62. * During device initialization:
  63. * device_enable()
  64. *
  65. * During device idle:
  66. * (save remaining device context if necessary)
  67. * device_idle();
  68. *
  69. * During device resume:
  70. * device_enable();
  71. * (restore context if necessary)
  72. *
  73. * During device shutdown:
  74. * device_shutdown()
  75. * (device must be reinitialized at this point to use it again)
  76. *
  77. */
  78. #undef DEBUG
  79. #include <linux/kernel.h>
  80. #include <linux/export.h>
  81. #include <linux/platform_device.h>
  82. #include <linux/slab.h>
  83. #include <linux/err.h>
  84. #include <linux/io.h>
  85. #include <linux/clk.h>
  86. #include <linux/clkdev.h>
  87. #include <linux/pm_runtime.h>
  88. #include <linux/of.h>
  89. #include <linux/notifier.h>
  90. #include "omap_device.h"
  91. #include "omap_hwmod.h"
  92. /* These parameters are passed to _omap_device_{de,}activate() */
  93. #define USE_WAKEUP_LAT 0
  94. #define IGNORE_WAKEUP_LAT 1
  95. static int omap_early_device_register(struct platform_device *pdev);
  96. static struct omap_device_pm_latency omap_default_latency[] = {
  97. {
  98. .deactivate_func = omap_device_idle_hwmods,
  99. .activate_func = omap_device_enable_hwmods,
  100. .flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
  101. }
  102. };
  103. /* Private functions */
  104. /**
  105. * _omap_device_activate - increase device readiness
  106. * @od: struct omap_device *
  107. * @ignore_lat: increase to latency target (0) or full readiness (1)?
  108. *
  109. * Increase readiness of omap_device @od (thus decreasing device
  110. * wakeup latency, but consuming more power). If @ignore_lat is
  111. * IGNORE_WAKEUP_LAT, make the omap_device fully active. Otherwise,
  112. * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
  113. * latency is greater than the requested maximum wakeup latency, step
  114. * backwards in the omap_device_pm_latency table to ensure the
  115. * device's maximum wakeup latency is less than or equal to the
  116. * requested maximum wakeup latency. Returns 0.
  117. */
  118. static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
  119. {
  120. struct timespec a, b, c;
  121. dev_dbg(&od->pdev->dev, "omap_device: activating\n");
  122. while (od->pm_lat_level > 0) {
  123. struct omap_device_pm_latency *odpl;
  124. unsigned long long act_lat = 0;
  125. od->pm_lat_level--;
  126. odpl = od->pm_lats + od->pm_lat_level;
  127. if (!ignore_lat &&
  128. (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit))
  129. break;
  130. read_persistent_clock(&a);
  131. /* XXX check return code */
  132. odpl->activate_func(od);