diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-07 18:53:48 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-07 19:00:13 -0400 |
commit | 3ff1ec27e9f567824e73316025a9025528494506 (patch) | |
tree | 3d57d47caf0c733159d0d8dc774e95126b83e8b9 /sound | |
parent | 90c6ce0d5482ee52b0a427115e185d488783164b (diff) |
ASoC: wm2000: Always use a 4s timeout for the firmware
Rather than having varying timeouts depending on the transition always
use a 4s timeout. This provides better diagnostics for clocking errors
and ensures compatibility with current calibration firmwares.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/wm2000.c | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index a75c3766aede..0418fa11e6bd 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c | |||
@@ -99,8 +99,9 @@ static void wm2000_reset(struct wm2000_priv *wm2000) | |||
99 | } | 99 | } |
100 | 100 | ||
101 | static int wm2000_poll_bit(struct i2c_client *i2c, | 101 | static int wm2000_poll_bit(struct i2c_client *i2c, |
102 | unsigned int reg, u8 mask, int timeout) | 102 | unsigned int reg, u8 mask) |
103 | { | 103 | { |
104 | int timeout = 4000; | ||
104 | int val; | 105 | int val; |
105 | 106 | ||
106 | val = wm2000_read(i2c, reg); | 107 | val = wm2000_read(i2c, reg); |
@@ -119,7 +120,7 @@ static int wm2000_poll_bit(struct i2c_client *i2c, | |||
119 | static int wm2000_power_up(struct i2c_client *i2c, int analogue) | 120 | static int wm2000_power_up(struct i2c_client *i2c, int analogue) |
120 | { | 121 | { |
121 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 122 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
122 | int ret, timeout; | 123 | int ret; |
123 | 124 | ||
124 | BUG_ON(wm2000->anc_mode != ANC_OFF); | 125 | BUG_ON(wm2000->anc_mode != ANC_OFF); |
125 | 126 | ||
@@ -140,13 +141,13 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue) | |||
140 | 141 | ||
141 | /* Wait for ANC engine to become ready */ | 142 | /* Wait for ANC engine to become ready */ |
142 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, | 143 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, |
143 | WM2000_ANC_ENG_IDLE, 1)) { | 144 | WM2000_ANC_ENG_IDLE)) { |
144 | dev_err(&i2c->dev, "ANC engine failed to reset\n"); | 145 | dev_err(&i2c->dev, "ANC engine failed to reset\n"); |
145 | return -ETIMEDOUT; | 146 | return -ETIMEDOUT; |
146 | } | 147 | } |
147 | 148 | ||
148 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, | 149 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, |
149 | WM2000_STATUS_BOOT_COMPLETE, 1)) { | 150 | WM2000_STATUS_BOOT_COMPLETE)) { |
150 | dev_err(&i2c->dev, "ANC engine failed to initialise\n"); | 151 | dev_err(&i2c->dev, "ANC engine failed to initialise\n"); |
151 | return -ETIMEDOUT; | 152 | return -ETIMEDOUT; |
152 | } | 153 | } |
@@ -173,16 +174,13 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue) | |||
173 | dev_dbg(&i2c->dev, "Download complete\n"); | 174 | dev_dbg(&i2c->dev, "Download complete\n"); |
174 | 175 | ||
175 | if (analogue) { | 176 | if (analogue) { |
176 | timeout = 248; | 177 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PU_TIME, 248 / 4); |
177 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PU_TIME, timeout / 4); | ||
178 | 178 | ||
179 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 179 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
180 | WM2000_MODE_ANA_SEQ_INCLUDE | | 180 | WM2000_MODE_ANA_SEQ_INCLUDE | |
181 | WM2000_MODE_MOUSE_ENABLE | | 181 | WM2000_MODE_MOUSE_ENABLE | |
182 | WM2000_MODE_THERMAL_ENABLE); | 182 | WM2000_MODE_THERMAL_ENABLE); |
183 | } else { | 183 | } else { |
184 | timeout = 10; | ||
185 | |||
186 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 184 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
187 | WM2000_MODE_MOUSE_ENABLE | | 185 | WM2000_MODE_MOUSE_ENABLE | |
188 | WM2000_MODE_THERMAL_ENABLE); | 186 | WM2000_MODE_THERMAL_ENABLE); |
@@ -201,9 +199,8 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue) | |||
201 | wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); | 199 | wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); |
202 | 200 | ||
203 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, | 201 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, |
204 | WM2000_STATUS_MOUSE_ACTIVE, timeout)) { | 202 | WM2000_STATUS_MOUSE_ACTIVE)) { |
205 | dev_err(&i2c->dev, "Timed out waiting for device after %dms\n", | 203 | dev_err(&i2c->dev, "Timed out waiting for device\n"); |
206 | timeout * 10); | ||
207 | return -ETIMEDOUT; | 204 | return -ETIMEDOUT; |
208 | } | 205 | } |
209 | 206 | ||
@@ -218,28 +215,25 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue) | |||
218 | static int wm2000_power_down(struct i2c_client *i2c, int analogue) | 215 | static int wm2000_power_down(struct i2c_client *i2c, int analogue) |
219 | { | 216 | { |
220 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 217 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
221 | int timeout; | ||
222 | 218 | ||
223 | if (analogue) { | 219 | if (analogue) { |
224 | timeout = 248; | 220 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4); |
225 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, timeout / 4); | ||
226 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 221 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
227 | WM2000_MODE_ANA_SEQ_INCLUDE | | 222 | WM2000_MODE_ANA_SEQ_INCLUDE | |
228 | WM2000_MODE_POWER_DOWN); | 223 | WM2000_MODE_POWER_DOWN); |
229 | } else { | 224 | } else { |
230 | timeout = 10; | ||
231 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 225 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
232 | WM2000_MODE_POWER_DOWN); | 226 | WM2000_MODE_POWER_DOWN); |
233 | } | 227 | } |
234 | 228 | ||
235 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, | 229 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, |
236 | WM2000_STATUS_POWER_DOWN_COMPLETE, timeout)) { | 230 | WM2000_STATUS_POWER_DOWN_COMPLETE)) { |
237 | dev_err(&i2c->dev, "Timeout waiting for ANC power down\n"); | 231 | dev_err(&i2c->dev, "Timeout waiting for ANC power down\n"); |
238 | return -ETIMEDOUT; | 232 | return -ETIMEDOUT; |
239 | } | 233 | } |
240 | 234 | ||
241 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, | 235 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, |
242 | WM2000_ANC_ENG_IDLE, 1)) { | 236 | WM2000_ANC_ENG_IDLE)) { |
243 | dev_err(&i2c->dev, "Timeout waiting for ANC engine idle\n"); | 237 | dev_err(&i2c->dev, "Timeout waiting for ANC engine idle\n"); |
244 | return -ETIMEDOUT; | 238 | return -ETIMEDOUT; |
245 | } | 239 | } |
@@ -268,13 +262,13 @@ static int wm2000_enter_bypass(struct i2c_client *i2c, int analogue) | |||
268 | } | 262 | } |
269 | 263 | ||
270 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, | 264 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, |
271 | WM2000_STATUS_ANC_DISABLED, 10)) { | 265 | WM2000_STATUS_ANC_DISABLED)) { |
272 | dev_err(&i2c->dev, "Timeout waiting for ANC disable\n"); | 266 | dev_err(&i2c->dev, "Timeout waiting for ANC disable\n"); |
273 | return -ETIMEDOUT; | 267 | return -ETIMEDOUT; |
274 | } | 268 | } |
275 | 269 | ||
276 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, | 270 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, |
277 | WM2000_ANC_ENG_IDLE, 1)) { | 271 | WM2000_ANC_ENG_IDLE)) { |
278 | dev_err(&i2c->dev, "Timeout waiting for ANC engine idle\n"); | 272 | dev_err(&i2c->dev, "Timeout waiting for ANC engine idle\n"); |
279 | return -ETIMEDOUT; | 273 | return -ETIMEDOUT; |
280 | } | 274 | } |
@@ -311,7 +305,7 @@ static int wm2000_exit_bypass(struct i2c_client *i2c, int analogue) | |||
311 | wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); | 305 | wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); |
312 | 306 | ||
313 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, | 307 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, |
314 | WM2000_STATUS_MOUSE_ACTIVE, 10)) { | 308 | WM2000_STATUS_MOUSE_ACTIVE)) { |
315 | dev_err(&i2c->dev, "Timed out waiting for MOUSE\n"); | 309 | dev_err(&i2c->dev, "Timed out waiting for MOUSE\n"); |
316 | return -ETIMEDOUT; | 310 | return -ETIMEDOUT; |
317 | } | 311 | } |
@@ -325,38 +319,32 @@ static int wm2000_exit_bypass(struct i2c_client *i2c, int analogue) | |||
325 | static int wm2000_enter_standby(struct i2c_client *i2c, int analogue) | 319 | static int wm2000_enter_standby(struct i2c_client *i2c, int analogue) |
326 | { | 320 | { |
327 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 321 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
328 | int timeout; | ||
329 | 322 | ||
330 | BUG_ON(wm2000->anc_mode != ANC_ACTIVE); | 323 | BUG_ON(wm2000->anc_mode != ANC_ACTIVE); |
331 | 324 | ||
332 | if (analogue) { | 325 | if (analogue) { |
333 | timeout = 248; | 326 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, 248 / 4); |
334 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PD_TIME, timeout / 4); | ||
335 | 327 | ||
336 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 328 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
337 | WM2000_MODE_ANA_SEQ_INCLUDE | | 329 | WM2000_MODE_ANA_SEQ_INCLUDE | |
338 | WM2000_MODE_THERMAL_ENABLE | | 330 | WM2000_MODE_THERMAL_ENABLE | |
339 | WM2000_MODE_STANDBY_ENTRY); | 331 | WM2000_MODE_STANDBY_ENTRY); |
340 | } else { | 332 | } else { |
341 | timeout = 10; | ||
342 | |||
343 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 333 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
344 | WM2000_MODE_THERMAL_ENABLE | | 334 | WM2000_MODE_THERMAL_ENABLE | |
345 | WM2000_MODE_STANDBY_ENTRY); | 335 | WM2000_MODE_STANDBY_ENTRY); |
346 | } | 336 | } |
347 | 337 | ||
348 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, | 338 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, |
349 | WM2000_STATUS_ANC_DISABLED, timeout)) { | 339 | WM2000_STATUS_ANC_DISABLED)) { |
350 | dev_err(&i2c->dev, | 340 | dev_err(&i2c->dev, |
351 | "Timed out waiting for ANC disable after 1ms\n"); | 341 | "Timed out waiting for ANC disable after 1ms\n"); |
352 | return -ETIMEDOUT; | 342 | return -ETIMEDOUT; |
353 | } | 343 | } |
354 | 344 | ||
355 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, WM2000_ANC_ENG_IDLE, | 345 | if (!wm2000_poll_bit(i2c, WM2000_REG_ANC_STAT, WM2000_ANC_ENG_IDLE)) { |
356 | 1)) { | ||
357 | dev_err(&i2c->dev, | 346 | dev_err(&i2c->dev, |
358 | "Timed out waiting for standby after %dms\n", | 347 | "Timed out waiting for standby\n"); |
359 | timeout * 10); | ||
360 | return -ETIMEDOUT; | 348 | return -ETIMEDOUT; |
361 | } | 349 | } |
362 | 350 | ||
@@ -374,23 +362,19 @@ static int wm2000_enter_standby(struct i2c_client *i2c, int analogue) | |||
374 | static int wm2000_exit_standby(struct i2c_client *i2c, int analogue) | 362 | static int wm2000_exit_standby(struct i2c_client *i2c, int analogue) |
375 | { | 363 | { |
376 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); | 364 | struct wm2000_priv *wm2000 = dev_get_drvdata(&i2c->dev); |
377 | int timeout; | ||
378 | 365 | ||
379 | BUG_ON(wm2000->anc_mode != ANC_STANDBY); | 366 | BUG_ON(wm2000->anc_mode != ANC_STANDBY); |
380 | 367 | ||
381 | wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); | 368 | wm2000_write(i2c, WM2000_REG_SYS_CTL1, 0); |
382 | 369 | ||
383 | if (analogue) { | 370 | if (analogue) { |
384 | timeout = 248; | 371 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PU_TIME, 248 / 4); |
385 | wm2000_write(i2c, WM2000_REG_ANA_VMID_PU_TIME, timeout / 4); | ||
386 | 372 | ||
387 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 373 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
388 | WM2000_MODE_ANA_SEQ_INCLUDE | | 374 | WM2000_MODE_ANA_SEQ_INCLUDE | |
389 | WM2000_MODE_THERMAL_ENABLE | | 375 | WM2000_MODE_THERMAL_ENABLE | |
390 | WM2000_MODE_MOUSE_ENABLE); | 376 | WM2000_MODE_MOUSE_ENABLE); |
391 | } else { | 377 | } else { |
392 | timeout = 10; | ||
393 | |||
394 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, | 378 | wm2000_write(i2c, WM2000_REG_SYS_MODE_CNTRL, |
395 | WM2000_MODE_THERMAL_ENABLE | | 379 | WM2000_MODE_THERMAL_ENABLE | |
396 | WM2000_MODE_MOUSE_ENABLE); | 380 | WM2000_MODE_MOUSE_ENABLE); |
@@ -400,9 +384,8 @@ static int wm2000_exit_standby(struct i2c_client *i2c, int analogue) | |||
400 | wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); | 384 | wm2000_write(i2c, WM2000_REG_SYS_CTL2, WM2000_ANC_INT_N_CLR); |
401 | 385 | ||
402 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, | 386 | if (!wm2000_poll_bit(i2c, WM2000_REG_SYS_STATUS, |
403 | WM2000_STATUS_MOUSE_ACTIVE, timeout)) { | 387 | WM2000_STATUS_MOUSE_ACTIVE)) { |
404 | dev_err(&i2c->dev, "Timed out waiting for MOUSE after %dms\n", | 388 | dev_err(&i2c->dev, "Timed out waiting for MOUSE\n"); |
405 | timeout * 10); | ||
406 | return -ETIMEDOUT; | 389 | return -ETIMEDOUT; |
407 | } | 390 | } |
408 | 391 | ||