aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1
diff options
context:
space:
mode:
authorDavid Fries <david@fries.net>2008-10-16 01:05:03 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:50 -0400
commit1f4ec2d7f6c4560a9d0c1abab2e8effe9ba93921 (patch)
tree10e0ab98846a7bd0bb7f8a68a4c104675109256a /drivers/w1
parent95cfaebf61dff28612bd280d89efc6e2c6716dfa (diff)
W1: ds2490.c add support for strong pullup
Add strong pullup support for ds2490 driver, also drop mdelay(750), which busy waits, usage in favour of msleep for long delays. Now with msleep only being called when the strong pullup is active, one wire bus operations are only taking minimal system overhead. The new set_pullup will only enable the strong pullup when requested, which is expected to be the only write operation that will benefit from a strong pullup. Signed-off-by: David Fries <david@fries.net> Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/w1')
-rw-r--r--drivers/w1/masters/ds2490.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index c8365fb20b4f..6b188e8008e4 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -98,11 +98,6 @@
98#define BRANCH_MAIN 0xCC 98#define BRANCH_MAIN 0xCC
99#define BRANCH_AUX 0x33 99#define BRANCH_AUX 0x33
100 100
101/*
102 * Duration of the strong pull-up pulse in milliseconds.
103 */
104#define PULLUP_PULSE_DURATION 750
105
106/* Status flags */ 101/* Status flags */
107#define ST_SPUA 0x01 /* Strong Pull-up is active */ 102#define ST_SPUA 0x01 /* Strong Pull-up is active */
108#define ST_PRGA 0x02 /* 12V programming pulse is being generated */ 103#define ST_PRGA 0x02 /* 12V programming pulse is being generated */
@@ -131,6 +126,11 @@ struct ds_device
131 126
132 int ep[NUM_EP]; 127 int ep[NUM_EP];
133 128
129 /* Strong PullUp
130 * 0: pullup not active, else duration in milliseconds
131 */
132 int spu_sleep;
133
134 struct w1_bus_master master; 134 struct w1_bus_master master;
135}; 135};
136 136
@@ -192,7 +192,7 @@ static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index)
192 192
193 return err; 193 return err;
194} 194}
195#if 0 195
196static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) 196static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index)
197{ 197{
198 int err; 198 int err;
@@ -207,7 +207,7 @@ static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index)
207 207
208 return err; 208 return err;
209} 209}
210#endif 210
211static int ds_send_control(struct ds_device *dev, u16 value, u16 index) 211static int ds_send_control(struct ds_device *dev, u16 value, u16 index)
212{ 212{
213 int err; 213 int err;
@@ -294,14 +294,6 @@ static int ds_recv_status(struct ds_device *dev, struct ds_status *st)
294 if (count < 0) 294 if (count < 0)
295 return err; 295 return err;
296 } 296 }
297#if 0
298 if (st->status & ST_IDLE) {
299 printk(KERN_INFO "Resetting pulse after ST_IDLE.\n");
300 err = ds_start_pulse(dev, PULLUP_PULSE_DURATION);
301 if (err)
302 return err;
303 }
304#endif
305 297
306 return err; 298 return err;
307} 299}
@@ -472,32 +464,26 @@ static int ds_set_speed(struct ds_device *dev, int speed)
472} 464}
473#endif /* 0 */ 465#endif /* 0 */
474 466
475static int ds_start_pulse(struct ds_device *dev, int delay) 467static int ds_set_pullup(struct ds_device *dev, int delay)
476{ 468{
477 int err; 469 int err;
478 u8 del = 1 + (u8)(delay >> 4); 470 u8 del = 1 + (u8)(delay >> 4);
479 struct ds_status st;
480
481#if 0
482 err = ds_stop_pulse(dev, 10);
483 if (err)
484 return err;
485
486 err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE);
487 if (err)
488 return err;
489#endif
490 err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM, del);
491 if (err)
492 return err;
493 471
494 err = ds_send_control(dev, COMM_PULSE | COMM_IM | COMM_F, 0); 472 dev->spu_sleep = 0;
473 err = ds_send_control_mode(dev, MOD_PULSE_EN, delay ? PULSE_SPUE : 0);
495 if (err) 474 if (err)
496 return err; 475 return err;
497 476
498 mdelay(delay); 477 if (delay) {
478 err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM, del);
479 if (err)
480 return err;
499 481
500 ds_wait_status(dev, &st); 482 /* Just storing delay would not get the trunication and
483 * roundup.
484 */
485 dev->spu_sleep = del<<4;
486 }
501 487
502 return err; 488 return err;
503} 489}
@@ -558,6 +544,9 @@ static int ds_write_byte(struct ds_device *dev, u8 byte)
558 if (err) 544 if (err)
559 return err; 545 return err;
560 546
547 if (dev->spu_sleep)
548 msleep(dev->spu_sleep);
549
561 err = ds_wait_status(dev, &st); 550 err = ds_wait_status(dev, &st);
562 if (err) 551 if (err)
563 return err; 552 return err;
@@ -566,8 +555,6 @@ static int ds_write_byte(struct ds_device *dev, u8 byte)
566 if (err < 0) 555 if (err < 0)
567 return err; 556 return err;
568 557
569 ds_start_pulse(dev, PULLUP_PULSE_DURATION);
570
571 return !(byte == rbyte); 558 return !(byte == rbyte);
572} 559}
573 560
@@ -603,7 +590,7 @@ static int ds_read_block(struct ds_device *dev, u8 *buf, int len)
603 if (err < 0) 590 if (err < 0)
604 return err; 591 return err;
605 592
606 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); 593 err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM, len);
607 if (err) 594 if (err)
608 return err; 595 return err;
609 596
@@ -630,14 +617,15 @@ static int ds_write_block(struct ds_device *dev, u8 *buf, int len)
630 if (err) 617 if (err)
631 return err; 618 return err;
632 619
620 if (dev->spu_sleep)
621 msleep(dev->spu_sleep);
622
633 ds_wait_status(dev, &st); 623 ds_wait_status(dev, &st);
634 624
635 err = ds_recv_data(dev, buf, len); 625 err = ds_recv_data(dev, buf, len);
636 if (err < 0) 626 if (err < 0)
637 return err; 627 return err;
638 628
639 ds_start_pulse(dev, PULLUP_PULSE_DURATION);
640
641 return !(err == len); 629 return !(err == len);
642} 630}
643 631
@@ -803,6 +791,16 @@ static u8 ds9490r_reset(void *data)
803 return 0; 791 return 0;
804} 792}
805 793
794static u8 ds9490r_set_pullup(void *data, int delay)
795{
796 struct ds_device *dev = data;
797
798 if (ds_set_pullup(dev, delay))
799 return 1;
800
801 return 0;
802}
803
806static int ds_w1_init(struct ds_device *dev) 804static int ds_w1_init(struct ds_device *dev)
807{ 805{
808 memset(&dev->master, 0, sizeof(struct w1_bus_master)); 806 memset(&dev->master, 0, sizeof(struct w1_bus_master));
@@ -816,6 +814,7 @@ static int ds_w1_init(struct ds_device *dev)
816 dev->master.read_block = &ds9490r_read_block; 814 dev->master.read_block = &ds9490r_read_block;
817 dev->master.write_block = &ds9490r_write_block; 815 dev->master.write_block = &ds9490r_write_block;
818 dev->master.reset_bus = &ds9490r_reset; 816 dev->master.reset_bus = &ds9490r_reset;
817 dev->master.set_pullup = &ds9490r_set_pullup;
819 818
820 return w1_add_master_device(&dev->master); 819 return w1_add_master_device(&dev->master);
821} 820}
@@ -839,6 +838,7 @@ static int ds_probe(struct usb_interface *intf,
839 printk(KERN_INFO "Failed to allocate new DS9490R structure.\n"); 838 printk(KERN_INFO "Failed to allocate new DS9490R structure.\n");
840 return -ENOMEM; 839 return -ENOMEM;
841 } 840 }
841 dev->spu_sleep = 0;
842 dev->udev = usb_get_dev(udev); 842 dev->udev = usb_get_dev(udev);
843 if (!dev->udev) { 843 if (!dev->udev) {
844 err = -ENOMEM; 844 err = -ENOMEM;