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.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index 2c409fc6dd21..12513f493daf 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -103,21 +103,6 @@
103/* Private functions */ 103/* Private functions */
104 104
105/** 105/**
106 * _read_32ksynct - read the OMAP 32K sync timer
107 *
108 * Returns the current value of the 32KiHz synchronization counter.
109 * XXX this should be generalized to simply read the system clocksource.
110 * XXX this should be moved to a separate synctimer32k.c file
111 */
112static u32 _read_32ksynct(void)
113{
114 if (!cpu_class_is_omap2())
115 BUG();
116
117 return __raw_readl(OMAP2_IO_ADDRESS(OMAP_32KSYNCT_BASE + 0x010));
118}
119
120/**
121 * _omap_device_activate - increase device readiness 106 * _omap_device_activate - increase device readiness
122 * @od: struct omap_device * 107 * @od: struct omap_device *
123 * @ignore_lat: increase to latency target (0) or full readiness (1)? 108 * @ignore_lat: increase to latency target (0) or full readiness (1)?
@@ -133,13 +118,13 @@ static u32 _read_32ksynct(void)
133 */ 118 */
134static int _omap_device_activate(struct omap_device *od, u8 ignore_lat) 119static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
135{ 120{
136 u32 a, b; 121 struct timespec a, b, c;
137 122
138 pr_debug("omap_device: %s: activating\n", od->pdev.name); 123 pr_debug("omap_device: %s: activating\n", od->pdev.name);
139 124
140 while (od->pm_lat_level > 0) { 125 while (od->pm_lat_level > 0) {
141 struct omap_device_pm_latency *odpl; 126 struct omap_device_pm_latency *odpl;
142 int act_lat = 0; 127 unsigned long long act_lat = 0;
143 128
144 od->pm_lat_level--; 129 od->pm_lat_level--;
145 130
@@ -149,20 +134,22 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
149 (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit)) 134 (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit))
150 break; 135 break;
151 136
152 a = _read_32ksynct(); 137 getnstimeofday(&a);
153 138
154 /* XXX check return code */ 139 /* XXX check return code */
155 odpl->activate_func(od); 140 odpl->activate_func(od);
156 141
157 b = _read_32ksynct(); 142 getnstimeofday(&b);
158 143
159 act_lat = (b - a) >> 15; /* 32KiHz cycles to microseconds */ 144 c = timespec_sub(b, a);
145 act_lat = timespec_to_ns(&c) * NSEC_PER_USEC;
160 146
161 pr_debug("omap_device: %s: pm_lat %d: activate: elapsed time " 147 pr_debug("omap_device: %s: pm_lat %d: activate: elapsed time "
162 "%d usec\n", od->pdev.name, od->pm_lat_level, act_lat); 148 "%llu usec\n", od->pdev.name, od->pm_lat_level,
149 act_lat);
163 150
164 WARN(act_lat > odpl->activate_lat, "omap_device: %s.%d: " 151 WARN(act_lat > odpl->activate_lat, "omap_device: %s.%d: "
165 "activate step %d took longer than expected (%d > %d)\n", 152 "activate step %d took longer than expected (%llu > %d)\n",
166 od->pdev.name, od->pdev.id, od->pm_lat_level, 153 od->pdev.name, od->pdev.id, od->pm_lat_level,
167 act_lat, odpl->activate_lat); 154 act_lat, odpl->activate_lat);
168 155
@@ -188,13 +175,13 @@ static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
188 */ 175 */
189static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat) 176static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)
190{ 177{
191 u32 a, b; 178 struct timespec a, b, c;
192 179
193 pr_debug("omap_device: %s: deactivating\n", od->pdev.name); 180 pr_debug("omap_device: %s: deactivating\n", od->pdev.name);
194 181
195 while (od->pm_lat_level < od->pm_lats_cnt) { 182 while (od->pm_lat_level < od->pm_lats_cnt) {
196 struct omap_device_pm_latency *odpl; 183 struct omap_device_pm_latency *odpl;
197 int deact_lat = 0; 184 unsigned long long deact_lat = 0;
198 185
199 odpl = od->pm_lats + od->pm_lat_level; 186 odpl = od->pm_lats + od->pm_lat_level;
200 187
@@ -203,23 +190,24 @@ static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)
203 od->_dev_wakeup_lat_limit)) 190 od->_dev_wakeup_lat_limit))
204 break; 191 break;
205 192
206 a = _read_32ksynct(); 193 getnstimeofday(&a);
207 194
208 /* XXX check return code */ 195 /* XXX check return code */
209 odpl->deactivate_func(od); 196 odpl->deactivate_func(od);
210 197
211 b = _read_32ksynct(); 198 getnstimeofday(&b);
212 199
213 deact_lat = (b - a) >> 15; /* 32KiHz cycles to microseconds */ 200 c = timespec_sub(b, a);
201 deact_lat = timespec_to_ns(&c) * NSEC_PER_USEC;
214 202
215 pr_debug("omap_device: %s: pm_lat %d: deactivate: elapsed time " 203 pr_debug("omap_device: %s: pm_lat %d: deactivate: elapsed time "
216 "%d usec\n", od->pdev.name, od->pm_lat_level, 204 "%llu usec\n", od->pdev.name, od->pm_lat_level,
217 deact_lat); 205 deact_lat);
218 206
219 WARN(deact_lat > odpl->deactivate_lat, "omap_device: %s.%d: " 207 WARN(deact_lat > odpl->deactivate_lat, "omap_device: %s.%d: "
220 "deactivate step %d took longer than expected (%d > %d)\n", 208 "deactivate step %d took longer than expected "
221 od->pdev.name, od->pdev.id, od->pm_lat_level, 209 "(%llu > %d)\n", od->pdev.name, od->pdev.id,
222 deact_lat, odpl->deactivate_lat); 210 od->pm_lat_level, deact_lat, odpl->deactivate_lat);
223 211
224 od->dev_wakeup_lat += odpl->activate_lat; 212 od->dev_wakeup_lat += odpl->activate_lat;
225 213