diff options
author | Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 2006-03-23 11:11:58 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-22 14:22:50 -0400 |
commit | 81f6075ebcf3b0800321b7d81e4845d6ad9566d8 (patch) | |
tree | 48eb8a7a5f96813882402a211b8db9d91d2e7af5 /drivers/w1/masters | |
parent | f522d2396138e68bcb9cc5650aa368a81d7f7ff0 (diff) |
[PATCH] w1: Replace dscore and ds_w1_bridge with ds2490 driver.
Diffstat (limited to 'drivers/w1/masters')
-rw-r--r-- | drivers/w1/masters/Kconfig | 27 | ||||
-rw-r--r-- | drivers/w1/masters/Makefile | 7 | ||||
-rw-r--r-- | drivers/w1/masters/ds2490.c (renamed from drivers/w1/masters/dscore.c) | 434 | ||||
-rw-r--r-- | drivers/w1/masters/ds_w1_bridge.c | 174 | ||||
-rw-r--r-- | drivers/w1/masters/dscore.h | 166 |
5 files changed, 303 insertions, 505 deletions
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig index c6bad4dbdc64..2fb425536eae 100644 --- a/drivers/w1/masters/Kconfig +++ b/drivers/w1/masters/Kconfig | |||
@@ -15,24 +15,15 @@ config W1_MASTER_MATROX | |||
15 | This support is also available as a module. If so, the module | 15 | This support is also available as a module. If so, the module |
16 | will be called matrox_w1.ko. | 16 | will be called matrox_w1.ko. |
17 | 17 | ||
18 | config W1_MASTER_DS9490 | 18 | config W1_MASTER_DS2490 |
19 | tristate "DS9490R transport layer driver" | 19 | tristate "DS2490 USB <-> W1 transport layer for 1-wire" |
20 | depends on W1 && USB | 20 | depends on W1 && USB |
21 | help | 21 | help |
22 | Say Y here if you want to have a driver for DS9490R UWB <-> W1 bridge. | 22 | Say Y here if you want to have a driver for DS2490 based USB <-> W1 bridges, |
23 | 23 | for example DS9490*. | |
24 | This support is also available as a module. If so, the module | 24 | |
25 | will be called ds9490r.ko. | 25 | This support is also available as a module. If so, the module |
26 | 26 | will be called ds2490.ko. | |
27 | config W1_MASTER_DS9490_BRIDGE | ||
28 | tristate "DS9490R USB <-> W1 transport layer for 1-wire" | ||
29 | depends on W1_MASTER_DS9490 | ||
30 | help | ||
31 | Say Y here if you want to communicate with your 1-wire devices | ||
32 | using DS9490R USB bridge. | ||
33 | |||
34 | This support is also available as a module. If so, the module | ||
35 | will be called ds_w1_bridge.ko. | ||
36 | 27 | ||
37 | config W1_MASTER_DS2482 | 28 | config W1_MASTER_DS2482 |
38 | tristate "Maxim DS2482 I2C to 1-Wire bridge" | 29 | tristate "Maxim DS2482 I2C to 1-Wire bridge" |
diff --git a/drivers/w1/masters/Makefile b/drivers/w1/masters/Makefile index 1f3c8b983dc1..4cee256a8134 100644 --- a/drivers/w1/masters/Makefile +++ b/drivers/w1/masters/Makefile | |||
@@ -3,11 +3,6 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_W1_MASTER_MATROX) += matrox_w1.o | 5 | obj-$(CONFIG_W1_MASTER_MATROX) += matrox_w1.o |
6 | 6 | obj-$(CONFIG_W1_MASTER_DS2490) += ds2490.o | |
7 | obj-$(CONFIG_W1_MASTER_DS9490) += ds9490r.o | ||
8 | ds9490r-objs := dscore.o | ||
9 | |||
10 | obj-$(CONFIG_W1_MASTER_DS9490_BRIDGE) += ds_w1_bridge.o | ||
11 | |||
12 | obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o | 7 | obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o |
13 | 8 | ||
diff --git a/drivers/w1/masters/dscore.c b/drivers/w1/masters/ds2490.c index 2cf7776a7080..637677833da5 100644 --- a/drivers/w1/masters/dscore.c +++ b/drivers/w1/masters/ds2490.c | |||
@@ -24,7 +24,136 @@ | |||
24 | #include <linux/mod_devicetable.h> | 24 | #include <linux/mod_devicetable.h> |
25 | #include <linux/usb.h> | 25 | #include <linux/usb.h> |
26 | 26 | ||
27 | #include "dscore.h" | 27 | #include "../w1_int.h" |
28 | #include "../w1.h" | ||
29 | |||
30 | /* COMMAND TYPE CODES */ | ||
31 | #define CONTROL_CMD 0x00 | ||
32 | #define COMM_CMD 0x01 | ||
33 | #define MODE_CMD 0x02 | ||
34 | |||
35 | /* CONTROL COMMAND CODES */ | ||
36 | #define CTL_RESET_DEVICE 0x0000 | ||
37 | #define CTL_START_EXE 0x0001 | ||
38 | #define CTL_RESUME_EXE 0x0002 | ||
39 | #define CTL_HALT_EXE_IDLE 0x0003 | ||
40 | #define CTL_HALT_EXE_DONE 0x0004 | ||
41 | #define CTL_FLUSH_COMM_CMDS 0x0007 | ||
42 | #define CTL_FLUSH_RCV_BUFFER 0x0008 | ||
43 | #define CTL_FLUSH_XMT_BUFFER 0x0009 | ||
44 | #define CTL_GET_COMM_CMDS 0x000A | ||
45 | |||
46 | /* MODE COMMAND CODES */ | ||
47 | #define MOD_PULSE_EN 0x0000 | ||
48 | #define MOD_SPEED_CHANGE_EN 0x0001 | ||
49 | #define MOD_1WIRE_SPEED 0x0002 | ||
50 | #define MOD_STRONG_PU_DURATION 0x0003 | ||
51 | #define MOD_PULLDOWN_SLEWRATE 0x0004 | ||
52 | #define MOD_PROG_PULSE_DURATION 0x0005 | ||
53 | #define MOD_WRITE1_LOWTIME 0x0006 | ||
54 | #define MOD_DSOW0_TREC 0x0007 | ||
55 | |||
56 | /* COMMUNICATION COMMAND CODES */ | ||
57 | #define COMM_ERROR_ESCAPE 0x0601 | ||
58 | #define COMM_SET_DURATION 0x0012 | ||
59 | #define COMM_BIT_IO 0x0020 | ||
60 | #define COMM_PULSE 0x0030 | ||
61 | #define COMM_1_WIRE_RESET 0x0042 | ||
62 | #define COMM_BYTE_IO 0x0052 | ||
63 | #define COMM_MATCH_ACCESS 0x0064 | ||
64 | #define COMM_BLOCK_IO 0x0074 | ||
65 | #define COMM_READ_STRAIGHT 0x0080 | ||
66 | #define COMM_DO_RELEASE 0x6092 | ||
67 | #define COMM_SET_PATH 0x00A2 | ||
68 | #define COMM_WRITE_SRAM_PAGE 0x00B2 | ||
69 | #define COMM_WRITE_EPROM 0x00C4 | ||
70 | #define COMM_READ_CRC_PROT_PAGE 0x00D4 | ||
71 | #define COMM_READ_REDIRECT_PAGE_CRC 0x21E4 | ||
72 | #define COMM_SEARCH_ACCESS 0x00F4 | ||
73 | |||
74 | /* Communication command bits */ | ||
75 | #define COMM_TYPE 0x0008 | ||
76 | #define COMM_SE 0x0008 | ||
77 | #define COMM_D 0x0008 | ||
78 | #define COMM_Z 0x0008 | ||
79 | #define COMM_CH 0x0008 | ||
80 | #define COMM_SM 0x0008 | ||
81 | #define COMM_R 0x0008 | ||
82 | #define COMM_IM 0x0001 | ||
83 | |||
84 | #define COMM_PS 0x4000 | ||
85 | #define COMM_PST 0x4000 | ||
86 | #define COMM_CIB 0x4000 | ||
87 | #define COMM_RTS 0x4000 | ||
88 | #define COMM_DT 0x2000 | ||
89 | #define COMM_SPU 0x1000 | ||
90 | #define COMM_F 0x0800 | ||
91 | #define COMM_NTP 0x0400 | ||
92 | #define COMM_ICP 0x0200 | ||
93 | #define COMM_RST 0x0100 | ||
94 | |||
95 | #define PULSE_PROG 0x01 | ||
96 | #define PULSE_SPUE 0x02 | ||
97 | |||
98 | #define BRANCH_MAIN 0xCC | ||
99 | #define BRANCH_AUX 0x33 | ||
100 | |||
101 | /* | ||
102 | * Duration of the strong pull-up pulse in milliseconds. | ||
103 | */ | ||
104 | #define PULLUP_PULSE_DURATION 750 | ||
105 | |||
106 | /* Status flags */ | ||
107 | #define ST_SPUA 0x01 /* Strong Pull-up is active */ | ||
108 | #define ST_PRGA 0x02 /* 12V programming pulse is being generated */ | ||
109 | #define ST_12VP 0x04 /* external 12V programming voltage is present */ | ||
110 | #define ST_PMOD 0x08 /* DS2490 powered from USB and external sources */ | ||
111 | #define ST_HALT 0x10 /* DS2490 is currently halted */ | ||
112 | #define ST_IDLE 0x20 /* DS2490 is currently idle */ | ||
113 | #define ST_EPOF 0x80 | ||
114 | |||
115 | #define SPEED_NORMAL 0x00 | ||
116 | #define SPEED_FLEXIBLE 0x01 | ||
117 | #define SPEED_OVERDRIVE 0x02 | ||
118 | |||
119 | #define NUM_EP 4 | ||
120 | #define EP_CONTROL 0 | ||
121 | #define EP_STATUS 1 | ||
122 | #define EP_DATA_OUT 2 | ||
123 | #define EP_DATA_IN 3 | ||
124 | |||
125 | struct ds_device | ||
126 | { | ||
127 | struct list_head ds_entry; | ||
128 | |||
129 | struct usb_device *udev; | ||
130 | struct usb_interface *intf; | ||
131 | |||
132 | int ep[NUM_EP]; | ||
133 | |||
134 | struct w1_bus_master master; | ||
135 | }; | ||
136 | |||
137 | struct ds_status | ||
138 | { | ||
139 | u8 enable; | ||
140 | u8 speed; | ||
141 | u8 pullup_dur; | ||
142 | u8 ppuls_dur; | ||
143 | u8 pulldown_slew; | ||
144 | u8 write1_time; | ||
145 | u8 write0_time; | ||
146 | u8 reserved0; | ||
147 | u8 status; | ||
148 | u8 command0; | ||
149 | u8 command1; | ||
150 | u8 command_buffer_status; | ||
151 | u8 data_out_buffer_status; | ||
152 | u8 data_in_buffer_status; | ||
153 | u8 reserved1; | ||
154 | u8 reserved2; | ||
155 | |||
156 | }; | ||
28 | 157 | ||
29 | static struct usb_device_id ds_id_table [] = { | 158 | static struct usb_device_id ds_id_table [] = { |
30 | { USB_DEVICE(0x04fa, 0x2490) }, | 159 | { USB_DEVICE(0x04fa, 0x2490) }, |
@@ -35,21 +164,12 @@ MODULE_DEVICE_TABLE(usb, ds_id_table); | |||
35 | static int ds_probe(struct usb_interface *, const struct usb_device_id *); | 164 | static int ds_probe(struct usb_interface *, const struct usb_device_id *); |
36 | static void ds_disconnect(struct usb_interface *); | 165 | static void ds_disconnect(struct usb_interface *); |
37 | 166 | ||
38 | int ds_touch_bit(struct ds_device *, u8, u8 *); | ||
39 | int ds_read_byte(struct ds_device *, u8 *); | ||
40 | int ds_read_bit(struct ds_device *, u8 *); | ||
41 | int ds_write_byte(struct ds_device *, u8); | ||
42 | int ds_write_bit(struct ds_device *, u8); | ||
43 | static int ds_start_pulse(struct ds_device *, int); | ||
44 | int ds_reset(struct ds_device *, struct ds_status *); | ||
45 | struct ds_device * ds_get_device(void); | ||
46 | void ds_put_device(struct ds_device *); | ||
47 | |||
48 | static inline void ds_dump_status(unsigned char *, unsigned char *, int); | 167 | static inline void ds_dump_status(unsigned char *, unsigned char *, int); |
49 | static int ds_send_control(struct ds_device *, u16, u16); | 168 | static int ds_send_control(struct ds_device *, u16, u16); |
50 | static int ds_send_control_mode(struct ds_device *, u16, u16); | ||
51 | static int ds_send_control_cmd(struct ds_device *, u16, u16); | 169 | static int ds_send_control_cmd(struct ds_device *, u16, u16); |
52 | 170 | ||
171 | static LIST_HEAD(ds_devices); | ||
172 | static DECLARE_MUTEX(ds_mutex); | ||
53 | 173 | ||
54 | static struct usb_driver ds_driver = { | 174 | static struct usb_driver ds_driver = { |
55 | .name = "DS9490R", | 175 | .name = "DS9490R", |
@@ -58,20 +178,6 @@ static struct usb_driver ds_driver = { | |||
58 | .id_table = ds_id_table, | 178 | .id_table = ds_id_table, |
59 | }; | 179 | }; |
60 | 180 | ||
61 | static struct ds_device *ds_dev; | ||
62 | |||
63 | struct ds_device * ds_get_device(void) | ||
64 | { | ||
65 | if (ds_dev) | ||
66 | atomic_inc(&ds_dev->refcnt); | ||
67 | return ds_dev; | ||
68 | } | ||
69 | |||
70 | void ds_put_device(struct ds_device *dev) | ||
71 | { | ||
72 | atomic_dec(&dev->refcnt); | ||
73 | } | ||
74 | |||
75 | static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) | 181 | static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) |
76 | { | 182 | { |
77 | int err; | 183 | int err; |
@@ -86,7 +192,7 @@ static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) | |||
86 | 192 | ||
87 | return err; | 193 | return err; |
88 | } | 194 | } |
89 | 195 | #if 0 | |
90 | static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) | 196 | static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) |
91 | { | 197 | { |
92 | int err; | 198 | int err; |
@@ -101,7 +207,7 @@ static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) | |||
101 | 207 | ||
102 | return err; | 208 | return err; |
103 | } | 209 | } |
104 | 210 | #endif | |
105 | static int ds_send_control(struct ds_device *dev, u16 value, u16 index) | 211 | static int ds_send_control(struct ds_device *dev, u16 value, u16 index) |
106 | { | 212 | { |
107 | int err; | 213 | int err; |
@@ -324,7 +430,7 @@ static int ds_wait_status(struct ds_device *dev, struct ds_status *st) | |||
324 | return 0; | 430 | return 0; |
325 | } | 431 | } |
326 | 432 | ||
327 | int ds_reset(struct ds_device *dev, struct ds_status *st) | 433 | static int ds_reset(struct ds_device *dev, struct ds_status *st) |
328 | { | 434 | { |
329 | int err; | 435 | int err; |
330 | 436 | ||
@@ -345,7 +451,7 @@ int ds_reset(struct ds_device *dev, struct ds_status *st) | |||
345 | } | 451 | } |
346 | 452 | ||
347 | #if 0 | 453 | #if 0 |
348 | int ds_set_speed(struct ds_device *dev, int speed) | 454 | static int ds_set_speed(struct ds_device *dev, int speed) |
349 | { | 455 | { |
350 | int err; | 456 | int err; |
351 | 457 | ||
@@ -395,7 +501,7 @@ static int ds_start_pulse(struct ds_device *dev, int delay) | |||
395 | return err; | 501 | return err; |
396 | } | 502 | } |
397 | 503 | ||
398 | int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit) | 504 | static int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit) |
399 | { | 505 | { |
400 | int err, count; | 506 | int err, count; |
401 | struct ds_status st; | 507 | struct ds_status st; |
@@ -427,7 +533,7 @@ int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit) | |||
427 | return 0; | 533 | return 0; |
428 | } | 534 | } |
429 | 535 | ||
430 | int ds_write_bit(struct ds_device *dev, u8 bit) | 536 | static int ds_write_bit(struct ds_device *dev, u8 bit) |
431 | { | 537 | { |
432 | int err; | 538 | int err; |
433 | struct ds_status st; | 539 | struct ds_status st; |
@@ -441,7 +547,7 @@ int ds_write_bit(struct ds_device *dev, u8 bit) | |||
441 | return 0; | 547 | return 0; |
442 | } | 548 | } |
443 | 549 | ||
444 | int ds_write_byte(struct ds_device *dev, u8 byte) | 550 | static int ds_write_byte(struct ds_device *dev, u8 byte) |
445 | { | 551 | { |
446 | int err; | 552 | int err; |
447 | struct ds_status st; | 553 | struct ds_status st; |
@@ -464,26 +570,7 @@ int ds_write_byte(struct ds_device *dev, u8 byte) | |||
464 | return !(byte == rbyte); | 570 | return !(byte == rbyte); |
465 | } | 571 | } |
466 | 572 | ||
467 | int ds_read_bit(struct ds_device *dev, u8 *bit) | 573 | static int ds_read_byte(struct ds_device *dev, u8 *byte) |
468 | { | ||
469 | int err; | ||
470 | |||
471 | err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE); | ||
472 | if (err) | ||
473 | return err; | ||
474 | |||
475 | err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | COMM_SPU | COMM_D, 0); | ||
476 | if (err) | ||
477 | return err; | ||
478 | |||
479 | err = ds_recv_data(dev, bit, sizeof(*bit)); | ||
480 | if (err < 0) | ||
481 | return err; | ||
482 | |||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | int ds_read_byte(struct ds_device *dev, u8 *byte) | ||
487 | { | 574 | { |
488 | int err; | 575 | int err; |
489 | struct ds_status st; | 576 | struct ds_status st; |
@@ -501,7 +588,7 @@ int ds_read_byte(struct ds_device *dev, u8 *byte) | |||
501 | return 0; | 588 | return 0; |
502 | } | 589 | } |
503 | 590 | ||
504 | int ds_read_block(struct ds_device *dev, u8 *buf, int len) | 591 | static int ds_read_block(struct ds_device *dev, u8 *buf, int len) |
505 | { | 592 | { |
506 | struct ds_status st; | 593 | struct ds_status st; |
507 | int err; | 594 | int err; |
@@ -527,7 +614,7 @@ int ds_read_block(struct ds_device *dev, u8 *buf, int len) | |||
527 | return err; | 614 | return err; |
528 | } | 615 | } |
529 | 616 | ||
530 | int ds_write_block(struct ds_device *dev, u8 *buf, int len) | 617 | static int ds_write_block(struct ds_device *dev, u8 *buf, int len) |
531 | { | 618 | { |
532 | int err; | 619 | int err; |
533 | struct ds_status st; | 620 | struct ds_status st; |
@@ -555,7 +642,7 @@ int ds_write_block(struct ds_device *dev, u8 *buf, int len) | |||
555 | 642 | ||
556 | #if 0 | 643 | #if 0 |
557 | 644 | ||
558 | int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int conditional_search) | 645 | static int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int conditional_search) |
559 | { | 646 | { |
560 | int err; | 647 | int err; |
561 | u16 value, index; | 648 | u16 value, index; |
@@ -584,7 +671,7 @@ int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int condi | |||
584 | return err/8; | 671 | return err/8; |
585 | } | 672 | } |
586 | 673 | ||
587 | int ds_match_access(struct ds_device *dev, u64 init) | 674 | static int ds_match_access(struct ds_device *dev, u64 init) |
588 | { | 675 | { |
589 | int err; | 676 | int err; |
590 | struct ds_status st; | 677 | struct ds_status st; |
@@ -604,7 +691,7 @@ int ds_match_access(struct ds_device *dev, u64 init) | |||
604 | return 0; | 691 | return 0; |
605 | } | 692 | } |
606 | 693 | ||
607 | int ds_set_path(struct ds_device *dev, u64 init) | 694 | static int ds_set_path(struct ds_device *dev, u64 init) |
608 | { | 695 | { |
609 | int err; | 696 | int err; |
610 | struct ds_status st; | 697 | struct ds_status st; |
@@ -630,45 +717,156 @@ int ds_set_path(struct ds_device *dev, u64 init) | |||
630 | 717 | ||
631 | #endif /* 0 */ | 718 | #endif /* 0 */ |
632 | 719 | ||
720 | static u8 ds9490r_touch_bit(void *data, u8 bit) | ||
721 | { | ||
722 | u8 ret; | ||
723 | struct ds_device *dev = data; | ||
724 | |||
725 | if (ds_touch_bit(dev, bit, &ret)) | ||
726 | return 0; | ||
727 | |||
728 | return ret; | ||
729 | } | ||
730 | |||
731 | static void ds9490r_write_bit(void *data, u8 bit) | ||
732 | { | ||
733 | struct ds_device *dev = data; | ||
734 | |||
735 | ds_write_bit(dev, bit); | ||
736 | } | ||
737 | |||
738 | static void ds9490r_write_byte(void *data, u8 byte) | ||
739 | { | ||
740 | struct ds_device *dev = data; | ||
741 | |||
742 | ds_write_byte(dev, byte); | ||
743 | } | ||
744 | |||
745 | static u8 ds9490r_read_bit(void *data) | ||
746 | { | ||
747 | struct ds_device *dev = data; | ||
748 | int err; | ||
749 | u8 bit = 0; | ||
750 | |||
751 | err = ds_touch_bit(dev, 1, &bit); | ||
752 | if (err) | ||
753 | return 0; | ||
754 | |||
755 | return bit & 1; | ||
756 | } | ||
757 | |||
758 | static u8 ds9490r_read_byte(void *data) | ||
759 | { | ||
760 | struct ds_device *dev = data; | ||
761 | int err; | ||
762 | u8 byte = 0; | ||
763 | |||
764 | err = ds_read_byte(dev, &byte); | ||
765 | if (err) | ||
766 | return 0; | ||
767 | |||
768 | return byte; | ||
769 | } | ||
770 | |||
771 | static void ds9490r_write_block(void *data, const u8 *buf, int len) | ||
772 | { | ||
773 | struct ds_device *dev = data; | ||
774 | |||
775 | ds_write_block(dev, (u8 *)buf, len); | ||
776 | } | ||
777 | |||
778 | static u8 ds9490r_read_block(void *data, u8 *buf, int len) | ||
779 | { | ||
780 | struct ds_device *dev = data; | ||
781 | int err; | ||
782 | |||
783 | err = ds_read_block(dev, buf, len); | ||
784 | if (err < 0) | ||
785 | return 0; | ||
786 | |||
787 | return len; | ||
788 | } | ||
789 | |||
790 | static u8 ds9490r_reset(void *data) | ||
791 | { | ||
792 | struct ds_device *dev = data; | ||
793 | struct ds_status st; | ||
794 | int err; | ||
795 | |||
796 | memset(&st, 0, sizeof(st)); | ||
797 | |||
798 | err = ds_reset(dev, &st); | ||
799 | if (err) | ||
800 | return 1; | ||
801 | |||
802 | return 0; | ||
803 | } | ||
804 | |||
805 | static int ds_w1_init(struct ds_device *dev) | ||
806 | { | ||
807 | memset(&dev->master, 0, sizeof(struct w1_bus_master)); | ||
808 | |||
809 | dev->master.data = dev; | ||
810 | dev->master.touch_bit = &ds9490r_touch_bit; | ||
811 | dev->master.read_bit = &ds9490r_read_bit; | ||
812 | dev->master.write_bit = &ds9490r_write_bit; | ||
813 | dev->master.read_byte = &ds9490r_read_byte; | ||
814 | dev->master.write_byte = &ds9490r_write_byte; | ||
815 | dev->master.read_block = &ds9490r_read_block; | ||
816 | dev->master.write_block = &ds9490r_write_block; | ||
817 | dev->master.reset_bus = &ds9490r_reset; | ||
818 | |||
819 | return w1_add_master_device(&dev->master); | ||
820 | } | ||
821 | |||
822 | static void ds_w1_fini(struct ds_device *dev) | ||
823 | { | ||
824 | w1_remove_master_device(&dev->master); | ||
825 | } | ||
826 | |||
633 | static int ds_probe(struct usb_interface *intf, | 827 | static int ds_probe(struct usb_interface *intf, |
634 | const struct usb_device_id *udev_id) | 828 | const struct usb_device_id *udev_id) |
635 | { | 829 | { |
636 | struct usb_device *udev = interface_to_usbdev(intf); | 830 | struct usb_device *udev = interface_to_usbdev(intf); |
637 | struct usb_endpoint_descriptor *endpoint; | 831 | struct usb_endpoint_descriptor *endpoint; |
638 | struct usb_host_interface *iface_desc; | 832 | struct usb_host_interface *iface_desc; |
833 | struct ds_device *dev; | ||
639 | int i, err; | 834 | int i, err; |
640 | 835 | ||
641 | ds_dev = kmalloc(sizeof(struct ds_device), GFP_KERNEL); | 836 | dev = kmalloc(sizeof(struct ds_device), GFP_KERNEL); |
642 | if (!ds_dev) { | 837 | if (!dev) { |
643 | printk(KERN_INFO "Failed to allocate new DS9490R structure.\n"); | 838 | printk(KERN_INFO "Failed to allocate new DS9490R structure.\n"); |
644 | return -ENOMEM; | 839 | return -ENOMEM; |
645 | } | 840 | } |
841 | dev->udev = usb_get_dev(udev); | ||
842 | if (!dev->udev) { | ||
843 | err = -ENOMEM; | ||
844 | goto err_out_free; | ||
845 | } | ||
846 | memset(dev->ep, 0, sizeof(dev->ep)); | ||
646 | 847 | ||
647 | ds_dev->udev = usb_get_dev(udev); | 848 | usb_set_intfdata(intf, dev); |
648 | usb_set_intfdata(intf, ds_dev); | ||
649 | 849 | ||
650 | err = usb_set_interface(ds_dev->udev, intf->altsetting[0].desc.bInterfaceNumber, 3); | 850 | err = usb_set_interface(dev->udev, intf->altsetting[0].desc.bInterfaceNumber, 3); |
651 | if (err) { | 851 | if (err) { |
652 | printk(KERN_ERR "Failed to set alternative setting 3 for %d interface: err=%d.\n", | 852 | printk(KERN_ERR "Failed to set alternative setting 3 for %d interface: err=%d.\n", |
653 | intf->altsetting[0].desc.bInterfaceNumber, err); | 853 | intf->altsetting[0].desc.bInterfaceNumber, err); |
654 | return err; | 854 | goto err_out_clear; |
655 | } | 855 | } |
656 | 856 | ||
657 | err = usb_reset_configuration(ds_dev->udev); | 857 | err = usb_reset_configuration(dev->udev); |
658 | if (err) { | 858 | if (err) { |
659 | printk(KERN_ERR "Failed to reset configuration: err=%d.\n", err); | 859 | printk(KERN_ERR "Failed to reset configuration: err=%d.\n", err); |
660 | return err; | 860 | goto err_out_clear; |
661 | } | 861 | } |
662 | 862 | ||
663 | iface_desc = &intf->altsetting[0]; | 863 | iface_desc = &intf->altsetting[0]; |
664 | if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { | 864 | if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { |
665 | printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints); | 865 | printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints); |
666 | return -ENODEV; | 866 | err = -EINVAL; |
867 | goto err_out_clear; | ||
667 | } | 868 | } |
668 | 869 | ||
669 | atomic_set(&ds_dev->refcnt, 0); | ||
670 | memset(ds_dev->ep, 0, sizeof(ds_dev->ep)); | ||
671 | |||
672 | /* | 870 | /* |
673 | * This loop doesn'd show control 0 endpoint, | 871 | * This loop doesn'd show control 0 endpoint, |
674 | * so we will fill only 1-3 endpoints entry. | 872 | * so we will fill only 1-3 endpoints entry. |
@@ -676,54 +874,31 @@ static int ds_probe(struct usb_interface *intf, | |||
676 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 874 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { |
677 | endpoint = &iface_desc->endpoint[i].desc; | 875 | endpoint = &iface_desc->endpoint[i].desc; |
678 | 876 | ||
679 | ds_dev->ep[i+1] = endpoint->bEndpointAddress; | 877 | dev->ep[i+1] = endpoint->bEndpointAddress; |
680 | 878 | #if 0 | |
681 | printk("%d: addr=%x, size=%d, dir=%s, type=%x\n", | 879 | printk("%d: addr=%x, size=%d, dir=%s, type=%x\n", |
682 | i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), | 880 | i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), |
683 | (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", | 881 | (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", |
684 | endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); | 882 | endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); |
883 | #endif | ||
685 | } | 884 | } |
686 | 885 | ||
687 | #if 0 | 886 | err = ds_w1_init(dev); |
688 | { | 887 | if (err) |
689 | int err, i; | 888 | goto err_out_clear; |
690 | u64 buf[3]; | ||
691 | u64 init=0xb30000002078ee81ull; | ||
692 | struct ds_status st; | ||
693 | |||
694 | ds_reset(ds_dev, &st); | ||
695 | err = ds_search(ds_dev, init, buf, 3, 0); | ||
696 | if (err < 0) | ||
697 | return err; | ||
698 | for (i=0; i<err; ++i) | ||
699 | printk("%d: %llx\n", i, buf[i]); | ||
700 | |||
701 | printk("Resetting...\n"); | ||
702 | ds_reset(ds_dev, &st); | ||
703 | printk("Setting path for %llx.\n", init); | ||
704 | err = ds_set_path(ds_dev, init); | ||
705 | if (err) | ||
706 | return err; | ||
707 | printk("Calling MATCH_ACCESS.\n"); | ||
708 | err = ds_match_access(ds_dev, init); | ||
709 | if (err) | ||
710 | return err; | ||
711 | |||
712 | printk("Searching the bus...\n"); | ||
713 | err = ds_search(ds_dev, init, buf, 3, 0); | ||
714 | |||
715 | printk("ds_search() returned %d\n", err); | ||
716 | |||
717 | if (err < 0) | ||
718 | return err; | ||
719 | for (i=0; i<err; ++i) | ||
720 | printk("%d: %llx\n", i, buf[i]); | ||
721 | 889 | ||
722 | return 0; | 890 | down(&ds_mutex); |
723 | } | 891 | list_add_tail(&dev->ds_entry, &ds_devices); |
724 | #endif | 892 | up(&ds_mutex); |
725 | 893 | ||
726 | return 0; | 894 | return 0; |
895 | |||
896 | err_out_clear: | ||
897 | usb_set_intfdata(intf, NULL); | ||
898 | usb_put_dev(dev->udev); | ||
899 | err_out_free: | ||
900 | kfree(dev); | ||
901 | return err; | ||
727 | } | 902 | } |
728 | 903 | ||
729 | static void ds_disconnect(struct usb_interface *intf) | 904 | static void ds_disconnect(struct usb_interface *intf) |
@@ -731,19 +906,19 @@ static void ds_disconnect(struct usb_interface *intf) | |||
731 | struct ds_device *dev; | 906 | struct ds_device *dev; |
732 | 907 | ||
733 | dev = usb_get_intfdata(intf); | 908 | dev = usb_get_intfdata(intf); |
734 | usb_set_intfdata(intf, NULL); | 909 | if (!dev) |
910 | return; | ||
735 | 911 | ||
736 | while (atomic_read(&dev->refcnt)) { | 912 | down(&ds_mutex); |
737 | printk(KERN_INFO "Waiting for DS to become free: refcnt=%d.\n", | 913 | list_del(&dev->ds_entry); |
738 | atomic_read(&dev->refcnt)); | 914 | up(&ds_mutex); |
739 | 915 | ||
740 | if (msleep_interruptible(1000)) | 916 | ds_w1_fini(dev); |
741 | flush_signals(current); | 917 | |
742 | } | 918 | usb_set_intfdata(intf, NULL); |
743 | 919 | ||
744 | usb_put_dev(dev->udev); | 920 | usb_put_dev(dev->udev); |
745 | kfree(dev); | 921 | kfree(dev); |
746 | ds_dev = NULL; | ||
747 | } | 922 | } |
748 | 923 | ||
749 | static int ds_init(void) | 924 | static int ds_init(void) |
@@ -769,27 +944,4 @@ module_exit(ds_fini); | |||
769 | 944 | ||
770 | MODULE_LICENSE("GPL"); | 945 | MODULE_LICENSE("GPL"); |
771 | MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); | 946 | MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); |
772 | 947 | MODULE_DESCRIPTION("DS2490 USB <-> W1 bus master driver (DS9490*)"); | |
773 | EXPORT_SYMBOL(ds_touch_bit); | ||
774 | EXPORT_SYMBOL(ds_read_byte); | ||
775 | EXPORT_SYMBOL(ds_read_bit); | ||
776 | EXPORT_SYMBOL(ds_read_block); | ||
777 | EXPORT_SYMBOL(ds_write_byte); | ||
778 | EXPORT_SYMBOL(ds_write_bit); | ||
779 | EXPORT_SYMBOL(ds_write_block); | ||
780 | EXPORT_SYMBOL(ds_reset); | ||
781 | EXPORT_SYMBOL(ds_get_device); | ||
782 | EXPORT_SYMBOL(ds_put_device); | ||
783 | |||
784 | /* | ||
785 | * This functions can be used for EEPROM programming, | ||
786 | * when driver will be included into mainline this will | ||
787 | * require uncommenting. | ||
788 | */ | ||
789 | #if 0 | ||
790 | EXPORT_SYMBOL(ds_start_pulse); | ||
791 | EXPORT_SYMBOL(ds_set_speed); | ||
792 | EXPORT_SYMBOL(ds_detect); | ||
793 | EXPORT_SYMBOL(ds_stop_pulse); | ||
794 | EXPORT_SYMBOL(ds_search); | ||
795 | #endif | ||
diff --git a/drivers/w1/masters/ds_w1_bridge.c b/drivers/w1/masters/ds_w1_bridge.c deleted file mode 100644 index 5d30783a3eb6..000000000000 --- a/drivers/w1/masters/ds_w1_bridge.c +++ /dev/null | |||
@@ -1,174 +0,0 @@ | |||
1 | /* | ||
2 | * ds_w1_bridge.c | ||
3 | * | ||
4 | * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> | ||
5 | * | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/types.h> | ||
24 | |||
25 | #include "../w1.h" | ||
26 | #include "../w1_int.h" | ||
27 | #include "dscore.h" | ||
28 | |||
29 | static struct ds_device *ds_dev; | ||
30 | static struct w1_bus_master *ds_bus_master; | ||
31 | |||
32 | static u8 ds9490r_touch_bit(void *data, u8 bit) | ||
33 | { | ||
34 | u8 ret; | ||
35 | struct ds_device *dev = data; | ||
36 | |||
37 | if (ds_touch_bit(dev, bit, &ret)) | ||
38 | return 0; | ||
39 | |||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | static void ds9490r_write_bit(void *data, u8 bit) | ||
44 | { | ||
45 | struct ds_device *dev = data; | ||
46 | |||
47 | ds_write_bit(dev, bit); | ||
48 | } | ||
49 | |||
50 | static void ds9490r_write_byte(void *data, u8 byte) | ||
51 | { | ||
52 | struct ds_device *dev = data; | ||
53 | |||
54 | ds_write_byte(dev, byte); | ||
55 | } | ||
56 | |||
57 | static u8 ds9490r_read_bit(void *data) | ||
58 | { | ||
59 | struct ds_device *dev = data; | ||
60 | int err; | ||
61 | u8 bit = 0; | ||
62 | |||
63 | err = ds_touch_bit(dev, 1, &bit); | ||
64 | if (err) | ||
65 | return 0; | ||
66 | //err = ds_read_bit(dev, &bit); | ||
67 | //if (err) | ||
68 | // return 0; | ||
69 | |||
70 | return bit & 1; | ||
71 | } | ||
72 | |||
73 | static u8 ds9490r_read_byte(void *data) | ||
74 | { | ||
75 | struct ds_device *dev = data; | ||
76 | int err; | ||
77 | u8 byte = 0; | ||
78 | |||
79 | err = ds_read_byte(dev, &byte); | ||
80 | if (err) | ||
81 | return 0; | ||
82 | |||
83 | return byte; | ||
84 | } | ||
85 | |||
86 | static void ds9490r_write_block(void *data, const u8 *buf, int len) | ||
87 | { | ||
88 | struct ds_device *dev = data; | ||
89 | |||
90 | ds_write_block(dev, (u8 *)buf, len); | ||
91 | } | ||
92 | |||
93 | static u8 ds9490r_read_block(void *data, u8 *buf, int len) | ||
94 | { | ||
95 | struct ds_device *dev = data; | ||
96 | int err; | ||
97 | |||
98 | err = ds_read_block(dev, buf, len); | ||
99 | if (err < 0) | ||
100 | return 0; | ||
101 | |||
102 | return len; | ||
103 | } | ||
104 | |||
105 | static u8 ds9490r_reset(void *data) | ||
106 | { | ||
107 | struct ds_device *dev = data; | ||
108 | struct ds_status st; | ||
109 | int err; | ||
110 | |||
111 | memset(&st, 0, sizeof(st)); | ||
112 | |||
113 | err = ds_reset(dev, &st); | ||
114 | if (err) | ||
115 | return 1; | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static int __devinit ds_w1_init(void) | ||
121 | { | ||
122 | int err; | ||
123 | |||
124 | ds_bus_master = kmalloc(sizeof(*ds_bus_master), GFP_KERNEL); | ||
125 | if (!ds_bus_master) { | ||
126 | printk(KERN_ERR "Failed to allocate DS9490R USB<->W1 bus_master structure.\n"); | ||
127 | return -ENOMEM; | ||
128 | } | ||
129 | |||
130 | ds_dev = ds_get_device(); | ||
131 | if (!ds_dev) { | ||
132 | printk(KERN_ERR "DS9490R is not registered.\n"); | ||
133 | err = -ENODEV; | ||
134 | goto err_out_free_bus_master; | ||
135 | } | ||
136 | |||
137 | memset(ds_bus_master, 0, sizeof(*ds_bus_master)); | ||
138 | |||
139 | ds_bus_master->data = ds_dev; | ||
140 | ds_bus_master->touch_bit = &ds9490r_touch_bit; | ||
141 | ds_bus_master->read_bit = &ds9490r_read_bit; | ||
142 | ds_bus_master->write_bit = &ds9490r_write_bit; | ||
143 | ds_bus_master->read_byte = &ds9490r_read_byte; | ||
144 | ds_bus_master->write_byte = &ds9490r_write_byte; | ||
145 | ds_bus_master->read_block = &ds9490r_read_block; | ||
146 | ds_bus_master->write_block = &ds9490r_write_block; | ||
147 | ds_bus_master->reset_bus = &ds9490r_reset; | ||
148 | |||
149 | err = w1_add_master_device(ds_bus_master); | ||
150 | if (err) | ||
151 | goto err_out_put_device; | ||
152 | |||
153 | return 0; | ||
154 | |||
155 | err_out_put_device: | ||
156 | ds_put_device(ds_dev); | ||
157 | err_out_free_bus_master: | ||
158 | kfree(ds_bus_master); | ||
159 | |||
160 | return err; | ||
161 | } | ||
162 | |||
163 | static void __devexit ds_w1_fini(void) | ||
164 | { | ||
165 | w1_remove_master_device(ds_bus_master); | ||
166 | ds_put_device(ds_dev); | ||
167 | kfree(ds_bus_master); | ||
168 | } | ||
169 | |||
170 | module_init(ds_w1_init); | ||
171 | module_exit(ds_w1_fini); | ||
172 | |||
173 | MODULE_LICENSE("GPL"); | ||
174 | MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>"); | ||
diff --git a/drivers/w1/masters/dscore.h b/drivers/w1/masters/dscore.h deleted file mode 100644 index 6cf5671d6ebe..000000000000 --- a/drivers/w1/masters/dscore.h +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | /* | ||
2 | * dscore.h | ||
3 | * | ||
4 | * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> | ||
5 | * | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | */ | ||
21 | |||
22 | #ifndef __DSCORE_H | ||
23 | #define __DSCORE_H | ||
24 | |||
25 | #include <linux/usb.h> | ||
26 | #include <asm/atomic.h> | ||
27 | |||
28 | /* COMMAND TYPE CODES */ | ||
29 | #define CONTROL_CMD 0x00 | ||
30 | #define COMM_CMD 0x01 | ||
31 | #define MODE_CMD 0x02 | ||
32 | |||
33 | /* CONTROL COMMAND CODES */ | ||
34 | #define CTL_RESET_DEVICE 0x0000 | ||
35 | #define CTL_START_EXE 0x0001 | ||
36 | #define CTL_RESUME_EXE 0x0002 | ||
37 | #define CTL_HALT_EXE_IDLE 0x0003 | ||
38 | #define CTL_HALT_EXE_DONE 0x0004 | ||
39 | #define CTL_FLUSH_COMM_CMDS 0x0007 | ||
40 | #define CTL_FLUSH_RCV_BUFFER 0x0008 | ||
41 | #define CTL_FLUSH_XMT_BUFFER 0x0009 | ||
42 | #define CTL_GET_COMM_CMDS 0x000A | ||
43 | |||
44 | /* MODE COMMAND CODES */ | ||
45 | #define MOD_PULSE_EN 0x0000 | ||
46 | #define MOD_SPEED_CHANGE_EN 0x0001 | ||
47 | #define MOD_1WIRE_SPEED 0x0002 | ||
48 | #define MOD_STRONG_PU_DURATION 0x0003 | ||
49 | #define MOD_PULLDOWN_SLEWRATE 0x0004 | ||
50 | #define MOD_PROG_PULSE_DURATION 0x0005 | ||
51 | #define MOD_WRITE1_LOWTIME 0x0006 | ||
52 | #define MOD_DSOW0_TREC 0x0007 | ||
53 | |||
54 | /* COMMUNICATION COMMAND CODES */ | ||
55 | #define COMM_ERROR_ESCAPE 0x0601 | ||
56 | #define COMM_SET_DURATION 0x0012 | ||
57 | #define COMM_BIT_IO 0x0020 | ||
58 | #define COMM_PULSE 0x0030 | ||
59 | #define COMM_1_WIRE_RESET 0x0042 | ||
60 | #define COMM_BYTE_IO 0x0052 | ||
61 | #define COMM_MATCH_ACCESS 0x0064 | ||
62 | #define COMM_BLOCK_IO 0x0074 | ||
63 | #define COMM_READ_STRAIGHT 0x0080 | ||
64 | #define COMM_DO_RELEASE 0x6092 | ||
65 | #define COMM_SET_PATH 0x00A2 | ||
66 | #define COMM_WRITE_SRAM_PAGE 0x00B2 | ||
67 | #define COMM_WRITE_EPROM 0x00C4 | ||
68 | #define COMM_READ_CRC_PROT_PAGE 0x00D4 | ||
69 | #define COMM_READ_REDIRECT_PAGE_CRC 0x21E4 | ||
70 | #define COMM_SEARCH_ACCESS 0x00F4 | ||
71 | |||
72 | /* Communication command bits */ | ||
73 | #define COMM_TYPE 0x0008 | ||
74 | #define COMM_SE 0x0008 | ||
75 | #define COMM_D 0x0008 | ||
76 | #define COMM_Z 0x0008 | ||
77 | #define COMM_CH 0x0008 | ||
78 | #define COMM_SM 0x0008 | ||
79 | #define COMM_R 0x0008 | ||
80 | #define COMM_IM 0x0001 | ||
81 | |||
82 | #define COMM_PS 0x4000 | ||
83 | #define COMM_PST 0x4000 | ||
84 | #define COMM_CIB 0x4000 | ||
85 | #define COMM_RTS 0x4000 | ||
86 | #define COMM_DT 0x2000 | ||
87 | #define COMM_SPU 0x1000 | ||
88 | #define COMM_F 0x0800 | ||
89 | #define COMM_NTP 0x0400 | ||
90 | #define COMM_ICP 0x0200 | ||
91 | #define COMM_RST 0x0100 | ||
92 | |||
93 | #define PULSE_PROG 0x01 | ||
94 | #define PULSE_SPUE 0x02 | ||
95 | |||
96 | #define BRANCH_MAIN 0xCC | ||
97 | #define BRANCH_AUX 0x33 | ||
98 | |||
99 | /* | ||
100 | * Duration of the strong pull-up pulse in milliseconds. | ||
101 | */ | ||
102 | #define PULLUP_PULSE_DURATION 750 | ||
103 | |||
104 | /* Status flags */ | ||
105 | #define ST_SPUA 0x01 /* Strong Pull-up is active */ | ||
106 | #define ST_PRGA 0x02 /* 12V programming pulse is being generated */ | ||
107 | #define ST_12VP 0x04 /* external 12V programming voltage is present */ | ||
108 | #define ST_PMOD 0x08 /* DS2490 powered from USB and external sources */ | ||
109 | #define ST_HALT 0x10 /* DS2490 is currently halted */ | ||
110 | #define ST_IDLE 0x20 /* DS2490 is currently idle */ | ||
111 | #define ST_EPOF 0x80 | ||
112 | |||
113 | #define SPEED_NORMAL 0x00 | ||
114 | #define SPEED_FLEXIBLE 0x01 | ||
115 | #define SPEED_OVERDRIVE 0x02 | ||
116 | |||
117 | #define NUM_EP 4 | ||
118 | #define EP_CONTROL 0 | ||
119 | #define EP_STATUS 1 | ||
120 | #define EP_DATA_OUT 2 | ||
121 | #define EP_DATA_IN 3 | ||
122 | |||
123 | struct ds_device | ||
124 | { | ||
125 | struct usb_device *udev; | ||
126 | struct usb_interface *intf; | ||
127 | |||
128 | int ep[NUM_EP]; | ||
129 | |||
130 | atomic_t refcnt; | ||
131 | }; | ||
132 | |||
133 | struct ds_status | ||
134 | { | ||
135 | u8 enable; | ||
136 | u8 speed; | ||
137 | u8 pullup_dur; | ||
138 | u8 ppuls_dur; | ||
139 | u8 pulldown_slew; | ||
140 | u8 write1_time; | ||
141 | u8 write0_time; | ||
142 | u8 reserved0; | ||
143 | u8 status; | ||
144 | u8 command0; | ||
145 | u8 command1; | ||
146 | u8 command_buffer_status; | ||
147 | u8 data_out_buffer_status; | ||
148 | u8 data_in_buffer_status; | ||
149 | u8 reserved1; | ||
150 | u8 reserved2; | ||
151 | |||
152 | }; | ||
153 | |||
154 | int ds_touch_bit(struct ds_device *, u8, u8 *); | ||
155 | int ds_read_byte(struct ds_device *, u8 *); | ||
156 | int ds_read_bit(struct ds_device *, u8 *); | ||
157 | int ds_write_byte(struct ds_device *, u8); | ||
158 | int ds_write_bit(struct ds_device *, u8); | ||
159 | int ds_reset(struct ds_device *, struct ds_status *); | ||
160 | struct ds_device * ds_get_device(void); | ||
161 | void ds_put_device(struct ds_device *); | ||
162 | int ds_write_block(struct ds_device *, u8 *, int); | ||
163 | int ds_read_block(struct ds_device *, u8 *, int); | ||
164 | |||
165 | #endif /* __DSCORE_H */ | ||
166 | |||