diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/w1/slaves/w1_ds2408.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/w1/slaves/w1_ds2408.c b/drivers/w1/slaves/w1_ds2408.c index 91cc2cdf02c0..cb8a8e5d9573 100644 --- a/drivers/w1/slaves/w1_ds2408.c +++ b/drivers/w1/slaves/w1_ds2408.c | |||
@@ -302,7 +302,33 @@ error: | |||
302 | return -EIO; | 302 | return -EIO; |
303 | } | 303 | } |
304 | 304 | ||
305 | /* | ||
306 | * This is a special sequence we must do to ensure the P0 output is not stuck | ||
307 | * in test mode. This is described in rev 2 of the ds2408's datasheet | ||
308 | * (http://datasheets.maximintegrated.com/en/ds/DS2408.pdf) under | ||
309 | * "APPLICATION INFORMATION/Power-up timing". | ||
310 | */ | ||
311 | static int w1_f29_disable_test_mode(struct w1_slave *sl) | ||
312 | { | ||
313 | int res; | ||
314 | u8 magic[10] = {0x96, }; | ||
315 | u64 rn = le64_to_cpu(*((u64*)&sl->reg_num)); | ||
316 | |||
317 | memcpy(&magic[1], &rn, 8); | ||
318 | magic[9] = 0x3C; | ||
319 | |||
320 | mutex_lock(&sl->master->bus_mutex); | ||
305 | 321 | ||
322 | res = w1_reset_bus(sl->master); | ||
323 | if (res) | ||
324 | goto out; | ||
325 | w1_write_block(sl->master, magic, ARRAY_SIZE(magic)); | ||
326 | |||
327 | res = w1_reset_bus(sl->master); | ||
328 | out: | ||
329 | mutex_unlock(&sl->master->bus_mutex); | ||
330 | return res; | ||
331 | } | ||
306 | 332 | ||
307 | static struct bin_attribute w1_f29_sysfs_bin_files[] = { | 333 | static struct bin_attribute w1_f29_sysfs_bin_files[] = { |
308 | { | 334 | { |
@@ -363,6 +389,10 @@ static int w1_f29_add_slave(struct w1_slave *sl) | |||
363 | int err = 0; | 389 | int err = 0; |
364 | int i; | 390 | int i; |
365 | 391 | ||
392 | err = w1_f29_disable_test_mode(sl); | ||
393 | if (err) | ||
394 | return err; | ||
395 | |||
366 | for (i = 0; i < ARRAY_SIZE(w1_f29_sysfs_bin_files) && !err; ++i) | 396 | for (i = 0; i < ARRAY_SIZE(w1_f29_sysfs_bin_files) && !err; ++i) |
367 | err = sysfs_create_bin_file( | 397 | err = sysfs_create_bin_file( |
368 | &sl->dev.kobj, | 398 | &sl->dev.kobj, |