• Home
  • Raw
  • Download

Lines Matching +full:two +full:- +full:wire

2  * ds2482.c - provides i2c to w1-master bridge(s)
6 * It is a I2C to 1-wire bridge.
7 * There are two variations: -100 and -800, which have 1 or 8 1-wire ports.
9 * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4382
29 * The APU bit controls whether an active pullup (controlled slew-rate
31 * a 1-Wire line from low to high. When APU = 0, active pullup is disabled
33 * only a single slave on the 1-Wire line.
38 "0-disable, 1-enable (default)");
41 * The DS2482 registers - there are 3 registers that are addressed by a read
48 #define DS2482_CMD_CHANNEL_SELECT 0xC3 /* Param: Channel byte - DS2482-800 only */
60 #define DS2482_PTR_CODE_CHANNEL 0xD2 /* DS2482-800 only */
68 #define DS2482_REG_CFG_1WS 0x08 /* 1-wire speed */
69 #define DS2482_REG_CFG_SPU 0x04 /* strong pull-up */
71 #define DS2482_REG_CFG_APU 0x01 /* active pull-up */
73 /* extra configurations - e.g. 1WS */
77 * Write and verify codes for the CHANNEL_SELECT command (DS2482-800 only).
115 /* 1-wire interface(s) */
119 /* per-device values */
144 * @return -1 on failure, 0 on success
148 if (pdev->read_prt != read_ptr) { in ds2482_select_register()
149 if (i2c_smbus_write_byte_data(pdev->client, in ds2482_select_register()
152 return -1; in ds2482_select_register()
154 pdev->read_prt = read_ptr; in ds2482_select_register()
165 * @return -1 on failure, 0 on success
169 if (i2c_smbus_write_byte(pdev->client, cmd) < 0) in ds2482_send_cmd()
170 return -1; in ds2482_send_cmd()
172 pdev->read_prt = DS2482_PTR_CODE_STATUS; in ds2482_send_cmd()
184 * @return -1 on failure, 0 on success
189 if (i2c_smbus_write_byte_data(pdev->client, cmd, byte) < 0) in ds2482_send_cmd_data()
190 return -1; in ds2482_send_cmd_data()
193 pdev->read_prt = (cmd != DS2482_CMD_WRITE_CONFIG) ? in ds2482_send_cmd_data()
200 * 1-Wire interface code
206 * Waits until the 1-wire interface is idle (not busy)
209 * @return the last value read from status or -1 (failure)
213 int temp = -1; in ds2482_wait_1wire_idle()
218 temp = i2c_smbus_read_byte(pdev->client); in ds2482_wait_1wire_idle()
225 __func__, pdev->channel); in ds2482_wait_1wire_idle()
232 * The 1-wire interface must be idle before calling this function.
235 * @param channel 0-7
236 * @return -1 (failure) or 0 (success)
240 if (i2c_smbus_write_byte_data(pdev->client, DS2482_CMD_CHANNEL_SELECT, in ds2482_set_channel()
242 return -1; in ds2482_set_channel()
244 pdev->read_prt = DS2482_PTR_CODE_CHANNEL; in ds2482_set_channel()
245 pdev->channel = -1; in ds2482_set_channel()
246 if (i2c_smbus_read_byte(pdev->client) == ds2482_chan_rd[channel]) { in ds2482_set_channel()
247 pdev->channel = channel; in ds2482_set_channel()
250 return -1; in ds2482_set_channel()
255 * Performs the touch-bit function, which writes a 0 or 1 and reads the level.
258 * @param bit The level to write: 0 or non-zero
264 struct ds2482_data *pdev = pchan->pdev; in ds2482_w1_touch_bit()
265 int status = -1; in ds2482_w1_touch_bit()
267 mutex_lock(&pdev->access_lock); in ds2482_w1_touch_bit()
271 if (pdev->w1_count > 1) in ds2482_w1_touch_bit()
272 ds2482_set_channel(pdev, pchan->channel); in ds2482_w1_touch_bit()
279 mutex_unlock(&pdev->access_lock); in ds2482_w1_touch_bit()
285 * Performs the triplet function, which reads two bits and writes a bit.
286 * The bit written is determined by the two reads:
296 struct ds2482_data *pdev = pchan->pdev; in ds2482_w1_triplet()
299 mutex_lock(&pdev->access_lock); in ds2482_w1_triplet()
303 if (pdev->w1_count > 1) in ds2482_w1_triplet()
304 ds2482_set_channel(pdev, pchan->channel); in ds2482_w1_triplet()
311 mutex_unlock(&pdev->access_lock); in ds2482_w1_triplet()
326 struct ds2482_data *pdev = pchan->pdev; in ds2482_w1_write_byte()
328 mutex_lock(&pdev->access_lock); in ds2482_w1_write_byte()
332 if (pdev->w1_count > 1) in ds2482_w1_write_byte()
333 ds2482_set_channel(pdev, pchan->channel); in ds2482_w1_write_byte()
338 mutex_unlock(&pdev->access_lock); in ds2482_w1_write_byte()
350 struct ds2482_data *pdev = pchan->pdev; in ds2482_w1_read_byte()
353 mutex_lock(&pdev->access_lock); in ds2482_w1_read_byte()
357 if (pdev->w1_count > 1) in ds2482_w1_read_byte()
358 ds2482_set_channel(pdev, pchan->channel); in ds2482_w1_read_byte()
370 result = i2c_smbus_read_byte(pdev->client); in ds2482_w1_read_byte()
372 mutex_unlock(&pdev->access_lock); in ds2482_w1_read_byte()
379 * Sends a reset on the 1-wire interface
387 struct ds2482_data *pdev = pchan->pdev; in ds2482_w1_reset_bus()
391 mutex_lock(&pdev->access_lock); in ds2482_w1_reset_bus()
395 if (pdev->w1_count > 1) in ds2482_w1_reset_bus()
396 ds2482_set_channel(pdev, pchan->channel); in ds2482_w1_reset_bus()
405 /* If the chip did reset since detect, re-config it */ in ds2482_w1_reset_bus()
411 mutex_unlock(&pdev->access_lock); in ds2482_w1_reset_bus()
419 struct ds2482_data *pdev = pchan->pdev; in ds2482_w1_set_pullup()
422 /* if delay is non-zero activate the pullup, in ds2482_w1_set_pullup()
446 int err = -ENODEV; in ds2482_probe()
450 if (!i2c_check_functionality(client->adapter, in ds2482_probe()
453 return -ENODEV; in ds2482_probe()
456 err = -ENOMEM; in ds2482_probe()
460 data->client = client; in ds2482_probe()
465 dev_warn(&client->dev, "DS2482 reset failed.\n"); in ds2482_probe()
472 /* Read the status byte - only reset bit and line should be set */ in ds2482_probe()
475 dev_warn(&client->dev, "DS2482 reset status " in ds2482_probe()
476 "0x%02X - not a DS2482\n", temp1); in ds2482_probe()
480 /* Detect the 8-port version */ in ds2482_probe()
481 data->w1_count = 1; in ds2482_probe()
483 data->w1_count = 8; in ds2482_probe()
489 mutex_init(&data->access_lock); in ds2482_probe()
491 /* Register 1-wire interface(s) */ in ds2482_probe()
492 for (idx = 0; idx < data->w1_count; idx++) { in ds2482_probe()
493 data->w1_ch[idx].pdev = data; in ds2482_probe()
494 data->w1_ch[idx].channel = idx; in ds2482_probe()
497 data->w1_ch[idx].w1_bm.data = &data->w1_ch[idx]; in ds2482_probe()
498 data->w1_ch[idx].w1_bm.read_byte = ds2482_w1_read_byte; in ds2482_probe()
499 data->w1_ch[idx].w1_bm.write_byte = ds2482_w1_write_byte; in ds2482_probe()
500 data->w1_ch[idx].w1_bm.touch_bit = ds2482_w1_touch_bit; in ds2482_probe()
501 data->w1_ch[idx].w1_bm.triplet = ds2482_w1_triplet; in ds2482_probe()
502 data->w1_ch[idx].w1_bm.reset_bus = ds2482_w1_reset_bus; in ds2482_probe()
503 data->w1_ch[idx].w1_bm.set_pullup = ds2482_w1_set_pullup; in ds2482_probe()
505 err = w1_add_master_device(&data->w1_ch[idx].w1_bm); in ds2482_probe()
507 data->w1_ch[idx].pdev = NULL; in ds2482_probe()
515 for (idx = 0; idx < data->w1_count; idx++) { in ds2482_probe()
516 if (data->w1_ch[idx].pdev != NULL) in ds2482_probe()
517 w1_remove_master_device(&data->w1_ch[idx].w1_bm); in ds2482_probe()
530 /* Unregister the 1-wire bridge(s) */ in ds2482_remove()
531 for (idx = 0; idx < data->w1_count; idx++) { in ds2482_remove()
532 if (data->w1_ch[idx].pdev != NULL) in ds2482_remove()
533 w1_remove_master_device(&data->w1_ch[idx].w1_bm); in ds2482_remove()