11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/i2c.h>
73 unsigned char mask,
unsigned char data)
108 msgbuf0[0] = (
unsigned char)reg;
114 ret = adap->
algo->master_xfer(adap, msg, num);
115 memcpy(dest, msgbuf1, bytes);
121 static int write_device(
struct i2c_client *i2c,
int reg,
122 int bytes,
void *
src)
124 unsigned char buf[bytes + 1];
129 buf[0] = (
unsigned char)reg;
130 memcpy(&buf[1], src, bytes);
136 ret = adap->
algo->master_xfer(adap, &msg, 1);
144 unsigned char zero = 0;
149 read_device(i2c, 0xFA, 0, &zero);
150 read_device(i2c, 0xFB, 0, &zero);
151 read_device(i2c, 0xFF, 0, &zero);
152 ret = read_device(i2c, reg, 1, &data);
155 read_device(i2c, 0xFE, 0, &zero);
156 read_device(i2c, 0xFC, 0, &zero);
169 read_device(i2c, 0xFA, 0, &zero);
170 read_device(i2c, 0xFB, 0, &zero);
171 read_device(i2c, 0xFF, 0, &zero);
172 ret = write_device(i2c, reg, 1, &data);
173 read_device(i2c, 0xFE, 0, &zero);
174 read_device(i2c, 0xFC, 0, &zero);
181 int count,
unsigned char *buf)
183 unsigned char zero = 0;
187 read_device(i2c, 0xfa, 0, &zero);
188 read_device(i2c, 0xfb, 0, &zero);
189 read_device(i2c, 0xff, 0, &zero);
190 ret = read_device(i2c, reg, count, buf);
191 read_device(i2c, 0xFE, 0, &zero);
192 read_device(i2c, 0xFC, 0, &zero);
199 int count,
unsigned char *buf)
201 unsigned char zero = 0;
205 read_device(i2c, 0xFA, 0, &zero);
206 read_device(i2c, 0xFB, 0, &zero);
207 read_device(i2c, 0xFF, 0, &zero);
208 ret = write_device(i2c, reg, count, buf);
209 read_device(i2c, 0xFE, 0, &zero);
210 read_device(i2c, 0xFC, 0, &zero);
218 unsigned char mask,
unsigned char data)
225 read_device(i2c, 0xFA, 0, &zero);
226 read_device(i2c, 0xFB, 0, &zero);
227 read_device(i2c, 0xFF, 0, &zero);
228 ret = read_device(i2c, reg, 1, &value);
233 ret = write_device(i2c, reg, 1, &value);
235 read_device(i2c, 0xFE, 0, &zero);
236 read_device(i2c, 0xFC, 0, &zero);