22
22
#ifndef __W1_H
23
23
#define __W1_H
24
24
25
- struct w1_reg_num
26
- {
25
+ struct w1_reg_num {
27
26
#if defined(__LITTLE_ENDIAN_BITFIELD )
28
- __u64 family :8 ,
29
- id :48 ,
30
- crc :8 ;
27
+ __u64 family :8 , id :48 , crc :8 ;
31
28
#elif defined(__BIG_ENDIAN_BITFIELD )
32
- __u64 crc :8 ,
33
- id :48 ,
34
- family :8 ;
29
+ __u64 crc :8 , id :48 , family :8 ;
35
30
#else
36
31
#error "Please fix <asm/byteorder.h>"
37
32
#endif
@@ -59,26 +54,24 @@ struct w1_reg_num
59
54
60
55
#define W1_SLAVE_ACTIVE 0
61
56
62
- struct w1_slave
63
- {
64
- struct module * owner ;
65
- unsigned char name [W1_MAXNAMELEN ];
66
- struct list_head w1_slave_entry ;
67
- struct w1_reg_num reg_num ;
68
- atomic_t refcnt ;
69
- u8 rom [9 ];
70
- u32 flags ;
71
- int ttl ;
72
-
73
- struct w1_master * master ;
74
- struct w1_family * family ;
75
- void * family_data ;
76
- struct device dev ;
77
- struct completion released ;
57
+ struct w1_slave {
58
+ struct module * owner ;
59
+ unsigned char name [W1_MAXNAMELEN ];
60
+ struct list_head w1_slave_entry ;
61
+ struct w1_reg_num reg_num ;
62
+ atomic_t refcnt ;
63
+ u8 rom [9 ];
64
+ u32 flags ;
65
+ int ttl ;
66
+
67
+ struct w1_master * master ;
68
+ struct w1_family * family ;
69
+ void * family_data ;
70
+ struct device dev ;
71
+ struct completion released ;
78
72
};
79
73
80
- typedef void (* w1_slave_found_callback )(struct w1_master * , u64 );
81
-
74
+ typedef void (* w1_slave_found_callback ) (struct w1_master * , u64 );
82
75
83
76
/**
84
77
* Note: read_bit and write_bit are very low level functions and should only
@@ -87,19 +80,18 @@ typedef void (*w1_slave_found_callback)(struct w1_master *, u64);
87
80
* Either define read_bit and write_bit OR define, at minimum, touch_bit and
88
81
* reset_bus.
89
82
*/
90
- struct w1_bus_master
91
- {
83
+ struct w1_bus_master {
92
84
/** the first parameter in all the functions below */
93
- void * data ;
85
+ void * data ;
94
86
95
87
/**
96
88
* Sample the line level
97
89
* @return the level read (0 or 1)
98
90
*/
99
- u8 (* read_bit )(void * );
91
+ u8 (* read_bit ) (void * );
100
92
101
93
/** Sets the line level */
102
- void (* write_bit )(void * , u8 );
94
+ void (* write_bit ) (void * , u8 );
103
95
104
96
/**
105
97
* touch_bit is the lowest-level function for devices that really
@@ -108,96 +100,103 @@ struct w1_bus_master
108
100
* touch_bit(1) = write-1 / read cycle
109
101
* @return the bit read (0 or 1)
110
102
*/
111
- u8 (* touch_bit )(void * , u8 );
103
+ u8 (* touch_bit ) (void * , u8 );
112
104
113
105
/**
114
106
* Reads a bytes. Same as 8 touch_bit(1) calls.
115
107
* @return the byte read
116
108
*/
117
- u8 (* read_byte )(void * );
109
+ u8 (* read_byte ) (void * );
118
110
119
111
/**
120
112
* Writes a byte. Same as 8 touch_bit(x) calls.
121
113
*/
122
- void (* write_byte )(void * , u8 );
114
+ void (* write_byte ) (void * , u8 );
123
115
124
116
/**
125
117
* Same as a series of read_byte() calls
126
118
* @return the number of bytes read
127
119
*/
128
- u8 (* read_block )(void * , u8 * , int );
120
+ u8 (* read_block ) (void * , u8 * , int );
129
121
130
122
/** Same as a series of write_byte() calls */
131
- void (* write_block )(void * , const u8 * , int );
123
+ void (* write_block ) (void * , const u8 * , int );
132
124
133
125
/**
134
126
* Combines two reads and a smart write for ROM searches
135
127
* @return bit0=Id bit1=comp_id bit2=dir_taken
136
128
*/
137
- u8 (* triplet )(void * , u8 );
129
+ u8 (* triplet ) (void * , u8 );
138
130
139
131
/**
140
132
* long write-0 with a read for the presence pulse detection
141
133
* @return -1=Error, 0=Device present, 1=No device present
142
134
*/
143
- u8 (* reset_bus )(void * );
135
+ u8 (* reset_bus ) (void * );
144
136
145
137
/**
146
138
* Put out a strong pull-up pulse of the specified duration.
147
139
* @return -1=Error, 0=completed
148
140
*/
149
- u8 (* set_pullup )(void * , int );
141
+ u8 (* set_pullup ) (void * , int );
142
+
143
+ /**
144
+ * Turns the pullup on/off in bitbanging mode, takes an on/off argument.
145
+ * @return -1=Error, 0=completed
146
+ */
147
+ void (* bitbang_pullup ) (void * , u8 );
150
148
151
149
/** Really nice hardware can handles the different types of ROM search
152
150
* w1_master* is passed to the slave found callback.
153
151
*/
154
- void (* search )(void * , struct w1_master * ,
155
- u8 , w1_slave_found_callback );
152
+ void (* search ) (void * , struct w1_master * ,
153
+ u8 , w1_slave_found_callback );
156
154
};
157
155
158
- struct w1_master
159
- {
160
- struct list_head w1_master_entry ;
161
- struct module * owner ;
162
- unsigned char name [W1_MAXNAMELEN ];
163
- struct list_head slist ;
164
- int max_slave_count , slave_count ;
165
- unsigned long attempts ;
166
- int slave_ttl ;
167
- int initialized ;
168
- u32 id ;
169
- int search_count ;
170
-
171
- atomic_t refcnt ;
172
-
173
- void * priv ;
174
- int priv_size ;
156
+ struct w1_master {
157
+ struct list_head w1_master_entry ;
158
+ struct module * owner ;
159
+ unsigned char name [W1_MAXNAMELEN ];
160
+ struct list_head slist ;
161
+ int max_slave_count , slave_count ;
162
+ unsigned long attempts ;
163
+ int slave_ttl ;
164
+ int initialized ;
165
+ u32 id ;
166
+ int search_count ;
167
+
168
+ atomic_t refcnt ;
169
+
170
+ void * priv ;
171
+ int priv_size ;
175
172
176
173
/** 5V strong pullup enabled flag, 1 enabled, zero disabled. */
177
- int enable_pullup ;
174
+ int enable_pullup ;
178
175
/** 5V strong pullup duration in milliseconds, zero disabled. */
179
- int pullup_duration ;
176
+ int pullup_duration ;
180
177
181
- struct task_struct * thread ;
182
- struct mutex mutex ;
183
- struct mutex bus_mutex ;
178
+ struct task_struct * thread ;
179
+ struct mutex mutex ;
180
+ struct mutex bus_mutex ;
184
181
185
- struct device_driver * driver ;
186
- struct device dev ;
182
+ struct device_driver * driver ;
183
+ struct device dev ;
187
184
188
- struct w1_bus_master * bus_master ;
185
+ struct w1_bus_master * bus_master ;
189
186
190
- u32 seq ;
187
+ u32 seq ;
191
188
};
192
189
193
190
int w1_create_master_attributes (struct w1_master * );
194
191
void w1_destroy_master_attributes (struct w1_master * master );
195
- void w1_search (struct w1_master * dev , u8 search_type , w1_slave_found_callback cb );
196
- void w1_search_devices (struct w1_master * dev , u8 search_type , w1_slave_found_callback cb );
192
+ void w1_search (struct w1_master * dev , u8 search_type ,
193
+ w1_slave_found_callback cb );
194
+ void w1_search_devices (struct w1_master * dev , u8 search_type ,
195
+ w1_slave_found_callback cb );
197
196
struct w1_slave * w1_search_slave (struct w1_reg_num * id );
198
197
void w1_slave_found (struct w1_master * dev , u64 rn );
199
198
void w1_search_process_cb (struct w1_master * dev , u8 search_type ,
200
- w1_slave_found_callback cb );
199
+ w1_slave_found_callback cb );
201
200
struct w1_master * w1_search_master_id (u32 id );
202
201
203
202
/* Disconnect and reconnect devices in the given family. Used for finding
@@ -220,17 +219,17 @@ int w1_reset_select_slave(struct w1_slave *sl);
220
219
int w1_reset_resume_command (struct w1_master * );
221
220
void w1_next_pullup (struct w1_master * , int );
222
221
223
- static inline struct w1_slave * dev_to_w1_slave (struct device * dev )
222
+ static inline struct w1_slave * dev_to_w1_slave (struct device * dev )
224
223
{
225
224
return container_of (dev , struct w1_slave , dev );
226
225
}
227
226
228
- static inline struct w1_slave * kobj_to_w1_slave (struct kobject * kobj )
227
+ static inline struct w1_slave * kobj_to_w1_slave (struct kobject * kobj )
229
228
{
230
229
return dev_to_w1_slave (container_of (kobj , struct device , kobj ));
231
230
}
232
231
233
- static inline struct w1_master * dev_to_w1_master (struct device * dev )
232
+ static inline struct w1_master * dev_to_w1_master (struct device * dev )
234
233
{
235
234
return container_of (dev , struct w1_master , dev );
236
235
}
0 commit comments