16 #include <linux/module.h>
18 #include <linux/slab.h>
19 #include <linux/i2c.h>
21 #include <asm/delay.h>
24 #include "../w1_int.h"
32 #define DS2482_CMD_RESET 0xF0
33 #define DS2482_CMD_SET_READ_PTR 0xE1
34 #define DS2482_CMD_CHANNEL_SELECT 0xC3
35 #define DS2482_CMD_WRITE_CONFIG 0xD2
36 #define DS2482_CMD_1WIRE_RESET 0xB4
37 #define DS2482_CMD_1WIRE_SINGLE_BIT 0x87
38 #define DS2482_CMD_1WIRE_WRITE_BYTE 0xA5
39 #define DS2482_CMD_1WIRE_READ_BYTE 0x96
41 #define DS2482_CMD_1WIRE_TRIPLET 0x78
44 #define DS2482_PTR_CODE_STATUS 0xF0
45 #define DS2482_PTR_CODE_DATA 0xE1
46 #define DS2482_PTR_CODE_CHANNEL 0xD2
47 #define DS2482_PTR_CODE_CONFIG 0xC3
54 #define DS2482_REG_CFG_1WS 0x08
55 #define DS2482_REG_CFG_SPU 0x04
56 #define DS2482_REG_CFG_PPM 0x02
57 #define DS2482_REG_CFG_APU 0x01
65 static const u8 ds2482_chan_wr[8] =
66 { 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87 };
67 static const u8 ds2482_chan_rd[8] =
68 { 0xB8, 0xB1, 0xAA, 0xA3, 0x9C, 0x95, 0x8E, 0x87 };
74 #define DS2482_REG_STS_DIR 0x80
75 #define DS2482_REG_STS_TSB 0x40
76 #define DS2482_REG_STS_SBR 0x20
77 #define DS2482_REG_STS_RST 0x10
78 #define DS2482_REG_STS_LL 0x08
79 #define DS2482_REG_STS_SD 0x04
80 #define DS2482_REG_STS_PPD 0x02
81 #define DS2482_REG_STS_1WB 0x01
102 .probe = ds2482_probe,
103 .remove = ds2482_remove,
104 .id_table = ds2482_id,
180 static inline int ds2482_send_cmd_data(
struct ds2482_data *pdev,
197 #define DS2482_WAIT_IDLE_TIMEOUT 100
205 static int ds2482_wait_1wire_idle(
struct ds2482_data *pdev)
235 ds2482_chan_wr[channel]) < 0)
264 ds2482_wait_1wire_idle(pdev);
266 ds2482_set_channel(pdev, pchan->
channel);
271 status = ds2482_wait_1wire_idle(pdev);
287 static u8 ds2482_w1_triplet(
void *data,
u8 dbit)
291 int status = (3 << 5);
296 ds2482_wait_1wire_idle(pdev);
298 ds2482_set_channel(pdev, pchan->
channel);
303 status = ds2482_wait_1wire_idle(pdev);
308 return (status >> 5);
317 static void ds2482_w1_write_byte(
void *data,
u8 byte)
325 ds2482_wait_1wire_idle(pdev);
327 ds2482_set_channel(pdev, pchan->
channel);
341 static u8 ds2482_w1_read_byte(
void *data)
350 ds2482_wait_1wire_idle(pdev);
352 ds2482_set_channel(pdev, pchan->
channel);
358 ds2482_wait_1wire_idle(pdev);
378 static u8 ds2482_w1_reset_bus(
void *data)
388 ds2482_wait_1wire_idle(pdev);
390 ds2482_set_channel(pdev, pchan->
channel);
396 err = ds2482_wait_1wire_idle(pdev);
419 if (!i2c_check_functionality(client->
adapter,
430 i2c_set_clientdata(client, data);
445 "0x%02X - not a DS2482\n", temp1);
451 if (ds2482_set_channel(data, 7) == 0)
460 for (idx = 0; idx < data->
w1_count; idx++) {
466 data->
w1_ch[
idx].w1_bm.read_byte = ds2482_w1_read_byte;
467 data->
w1_ch[
idx].w1_bm.write_byte = ds2482_w1_write_byte;
468 data->
w1_ch[
idx].w1_bm.touch_bit = ds2482_w1_touch_bit;
469 data->
w1_ch[
idx].w1_bm.triplet = ds2482_w1_triplet;
470 data->
w1_ch[
idx].w1_bm.reset_bus = ds2482_w1_reset_bus;
482 for (idx = 0; idx < data->
w1_count; idx++) {
492 static int ds2482_remove(
struct i2c_client *client)
494 struct ds2482_data *data = i2c_get_clientdata(client);
498 for (idx = 0; idx < data->
w1_count; idx++) {
508 static int __init sensors_ds2482_init(
void)
510 return i2c_add_driver(&ds2482_driver);
513 static void __exit sensors_ds2482_exit(
void)