diff options
Diffstat (limited to 'drivers/w1/w1.h')
-rw-r--r-- | drivers/w1/w1.h | 87 |
1 files changed, 67 insertions, 20 deletions
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 44dfb92e55cd..3cfdd08d32fc 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h | |||
@@ -25,9 +25,9 @@ | |||
25 | struct w1_reg_num | 25 | struct w1_reg_num |
26 | { | 26 | { |
27 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 27 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
28 | __u64 family:8, | 28 | __u64 family:8, |
29 | id:48, | 29 | id:48, |
30 | crc:8; | 30 | crc:8; |
31 | #elif defined(__BIG_ENDIAN_BITFIELD) | 31 | #elif defined(__BIG_ENDIAN_BITFIELD) |
32 | __u64 crc:8, | 32 | __u64 crc:8, |
33 | id:48, | 33 | id:48, |
@@ -84,24 +84,71 @@ struct w1_slave | |||
84 | 84 | ||
85 | typedef void (* w1_slave_found_callback)(unsigned long, u64); | 85 | typedef void (* w1_slave_found_callback)(unsigned long, u64); |
86 | 86 | ||
87 | |||
88 | /** | ||
89 | * Note: read_bit and write_bit are very low level functions and should only | ||
90 | * be used with hardware that doesn't really support 1-wire operations, | ||
91 | * like a parallel/serial port. | ||
92 | * Either define read_bit and write_bit OR define, at minimum, touch_bit and | ||
93 | * reset_bus. | ||
94 | */ | ||
87 | struct w1_bus_master | 95 | struct w1_bus_master |
88 | { | 96 | { |
89 | unsigned long data; | 97 | /** the first parameter in all the functions below */ |
90 | 98 | unsigned long data; | |
91 | u8 (*read_bit)(unsigned long); | 99 | |
92 | void (*write_bit)(unsigned long, u8); | 100 | /** |
93 | 101 | * Sample the line level | |
94 | u8 (*read_byte)(unsigned long); | 102 | * @return the level read (0 or 1) |
95 | void (*write_byte)(unsigned long, u8); | 103 | */ |
96 | 104 | u8 (*read_bit)(unsigned long); | |
97 | u8 (*read_block)(unsigned long, u8 *, int); | 105 | |
98 | void (*write_block)(unsigned long, u8 *, int); | 106 | /** Sets the line level */ |
99 | 107 | void (*write_bit)(unsigned long, u8); | |
100 | u8 (*touch_bit)(unsigned long, u8); | 108 | |
101 | 109 | /** | |
102 | u8 (*reset_bus)(unsigned long); | 110 | * touch_bit is the lowest-level function for devices that really |
103 | 111 | * support the 1-wire protocol. | |
104 | void (*search)(unsigned long, w1_slave_found_callback); | 112 | * touch_bit(0) = write-0 cycle |
113 | * touch_bit(1) = write-1 / read cycle | ||
114 | * @return the bit read (0 or 1) | ||
115 | */ | ||
116 | u8 (*touch_bit)(unsigned long, u8); | ||
117 | |||
118 | /** | ||
119 | * Reads a bytes. Same as 8 touch_bit(1) calls. | ||
120 | * @return the byte read | ||
121 | */ | ||
122 | u8 (*read_byte)(unsigned long); | ||
123 | |||
124 | /** | ||
125 | * Writes a byte. Same as 8 touch_bit(x) calls. | ||
126 | */ | ||
127 | void (*write_byte)(unsigned long, u8); | ||
128 | |||
129 | /** | ||
130 | * Same as a series of read_byte() calls | ||
131 | * @return the number of bytes read | ||
132 | */ | ||
133 | u8 (*read_block)(unsigned long, u8 *, int); | ||
134 | |||
135 | /** Same as a series of write_byte() calls */ | ||
136 | void (*write_block)(unsigned long, const u8 *, int); | ||
137 | |||
138 | /** | ||
139 | * Combines two reads and a smart write for ROM searches | ||
140 | * @return bit0=Id bit1=comp_id bit2=dir_taken | ||
141 | */ | ||
142 | u8 (*triplet)(unsigned long, u8); | ||
143 | |||
144 | /** | ||
145 | * long write-0 with a read for the presence pulse detection | ||
146 | * @return -1=Error, 0=Device present, 1=No device present | ||
147 | */ | ||
148 | u8 (*reset_bus)(unsigned long); | ||
149 | |||
150 | /** Really nice hardware can handles the ROM searches */ | ||
151 | void (*search)(unsigned long, w1_slave_found_callback); | ||
105 | }; | 152 | }; |
106 | 153 | ||
107 | struct w1_master | 154 | struct w1_master |
@@ -137,7 +184,7 @@ struct w1_master | |||
137 | }; | 184 | }; |
138 | 185 | ||
139 | int w1_create_master_attributes(struct w1_master *); | 186 | int w1_create_master_attributes(struct w1_master *); |
140 | void w1_search(struct w1_master *dev); | 187 | void w1_search(struct w1_master *dev, w1_slave_found_callback cb); |
141 | 188 | ||
142 | #endif /* __KERNEL__ */ | 189 | #endif /* __KERNEL__ */ |
143 | 190 | ||