31 #include <linux/module.h>
34 #include <linux/slab.h>
35 #include <linux/poll.h>
37 #include <asm/div64.h>
38 #include <linux/pci.h>
48 static int ngene_command_i2c_read(
struct ngene *
dev,
u8 adr,
54 com.cmd.hdr.Length = outlen + 3;
55 com.cmd.I2CRead.Device = adr << 1;
56 memcpy(com.cmd.I2CRead.Data, out, outlen);
58 com.cmd.I2CRead.Data[outlen + 1] = 0;
59 com.in_len = outlen + 3;
60 com.out_len = inlen + 1;
65 if ((com.cmd.raw8[0] >> 1) != adr)
69 memcpy(in, com.cmd.raw8, inlen + 1);
71 memcpy(in, com.cmd.raw8 + 1, inlen);
75 static int ngene_command_i2c_write(
struct ngene *dev,
u8 adr,
82 com.cmd.hdr.Length = outlen + 1;
83 com.cmd.I2CRead.Device = adr << 1;
84 memcpy(com.cmd.I2CRead.Data, out, outlen);
85 com.in_len = outlen + 1;
91 if (com.cmd.raw8[0] == 1)
97 static void ngene_i2c_set_bus(
struct ngene *dev,
int bus)
126 ngene_i2c_set_bus(dev, chan->
number);
129 if (!ngene_command_i2c_read(dev, msg[0].
addr,
130 msg[0].
buf, msg[0].len,
131 msg[1].buf, msg[1].len, 0))
134 if (num == 1 && !(msg[0].
flags & I2C_M_RD))
135 if (!ngene_command_i2c_write(dev, msg[0].addr,
136 msg[0].buf, msg[0].len))
138 if (num == 1 && (msg[0].
flags & I2C_M_RD))
139 if (!ngene_command_i2c_read(dev, msg[0].addr,
NULL, 0,
140 msg[0].buf, msg[0].len, 0))
158 .master_xfer = ngene_i2c_master_xfer,
159 .functionality = ngene_i2c_functionality,
166 i2c_set_adapdata(adap, &(dev->
channel[dev_nr]));
170 adap->
algo = &ngene_i2c_algo;