aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/88pm860x-i2c.c103
-rw-r--r--include/linux/mfd/88pm860x.h8
2 files changed, 111 insertions, 0 deletions
diff --git a/drivers/mfd/88pm860x-i2c.c b/drivers/mfd/88pm860x-i2c.c
index bc02e6b21608..e017dc88622a 100644
--- a/drivers/mfd/88pm860x-i2c.c
+++ b/drivers/mfd/88pm860x-i2c.c
@@ -126,6 +126,109 @@ out:
126} 126}
127EXPORT_SYMBOL(pm860x_set_bits); 127EXPORT_SYMBOL(pm860x_set_bits);
128 128
129int pm860x_page_reg_read(struct i2c_client *i2c, int reg)
130{
131 struct pm860x_chip *chip = i2c_get_clientdata(i2c);
132 unsigned char zero = 0;
133 unsigned char data;
134 int ret;
135
136 mutex_lock(&chip->io_lock);
137 pm860x_write_device(i2c, 0xFA, 0, &zero);
138 pm860x_write_device(i2c, 0xFB, 0, &zero);
139 pm860x_write_device(i2c, 0xFF, 0, &zero);
140 ret = pm860x_read_device(i2c, reg, 1, &data);
141 if (ret >= 0)
142 ret = (int)data;
143 pm860x_write_device(i2c, 0xFE, 0, &zero);
144 pm860x_write_device(i2c, 0xFC, 0, &zero);
145 mutex_unlock(&chip->io_lock);
146 return ret;
147}
148EXPORT_SYMBOL(pm860x_page_reg_read);
149
150int pm860x_page_reg_write(struct i2c_client *i2c, int reg,
151 unsigned char data)
152{
153 struct pm860x_chip *chip = i2c_get_clientdata(i2c);
154 unsigned char zero;
155 int ret;
156
157 mutex_lock(&chip->io_lock);
158 pm860x_write_device(i2c, 0xFA, 0, &zero);
159 pm860x_write_device(i2c, 0xFB, 0, &zero);
160 pm860x_write_device(i2c, 0xFF, 0, &zero);
161 ret = pm860x_write_device(i2c, reg, 1, &data);
162 pm860x_write_device(i2c, 0xFE, 0, &zero);
163 pm860x_write_device(i2c, 0xFC, 0, &zero);
164 mutex_unlock(&chip->io_lock);
165 return ret;
166}
167EXPORT_SYMBOL(pm860x_page_reg_write);
168
169int pm860x_page_bulk_read(struct i2c_client *i2c, int reg,
170 int count, unsigned char *buf)
171{
172 struct pm860x_chip *chip = i2c_get_clientdata(i2c);
173 unsigned char zero = 0;
174 int ret;
175
176 mutex_lock(&chip->io_lock);
177 pm860x_write_device(i2c, 0xFA, 0, &zero);
178 pm860x_write_device(i2c, 0xFB, 0, &zero);
179 pm860x_write_device(i2c, 0xFF, 0, &zero);
180 ret = pm860x_read_device(i2c, reg, count, buf);
181 pm860x_write_device(i2c, 0xFE, 0, &zero);
182 pm860x_write_device(i2c, 0xFC, 0, &zero);
183 mutex_unlock(&chip->io_lock);
184 return ret;
185}
186EXPORT_SYMBOL(pm860x_page_bulk_read);
187
188int pm860x_page_bulk_write(struct i2c_client *i2c, int reg,
189 int count, unsigned char *buf)
190{
191 struct pm860x_chip *chip = i2c_get_clientdata(i2c);
192 unsigned char zero = 0;
193 int ret;
194
195 mutex_lock(&chip->io_lock);
196 pm860x_write_device(i2c, 0xFA, 0, &zero);
197 pm860x_write_device(i2c, 0xFB, 0, &zero);
198 pm860x_write_device(i2c, 0xFF, 0, &zero);
199 ret = pm860x_write_device(i2c, reg, count, buf);
200 pm860x_write_device(i2c, 0xFE, 0, &zero);
201 pm860x_write_device(i2c, 0xFC, 0, &zero);
202 mutex_unlock(&chip->io_lock);
203 return ret;
204}
205EXPORT_SYMBOL(pm860x_page_bulk_write);
206
207int pm860x_page_set_bits(struct i2c_client *i2c, int reg,
208 unsigned char mask, unsigned char data)
209{
210 struct pm860x_chip *chip = i2c_get_clientdata(i2c);
211 unsigned char zero;
212 unsigned char value;
213 int ret;
214
215 mutex_lock(&chip->io_lock);
216 pm860x_write_device(i2c, 0xFA, 0, &zero);
217 pm860x_write_device(i2c, 0xFB, 0, &zero);
218 pm860x_write_device(i2c, 0xFF, 0, &zero);
219 ret = pm860x_read_device(i2c, reg, 1, &value);
220 if (ret < 0)
221 goto out;
222 value &= ~mask;
223 value |= data;
224 ret = pm860x_write_device(i2c, reg, 1, &value);
225out:
226 pm860x_write_device(i2c, 0xFE, 0, &zero);
227 pm860x_write_device(i2c, 0xFC, 0, &zero);
228 mutex_unlock(&chip->io_lock);
229 return ret;
230}
231EXPORT_SYMBOL(pm860x_page_set_bits);
129 232
130static const struct i2c_device_id pm860x_id_table[] = { 233static const struct i2c_device_id pm860x_id_table[] = {
131 { "88PM860x", 0 }, 234 { "88PM860x", 0 },
diff --git a/include/linux/mfd/88pm860x.h b/include/linux/mfd/88pm860x.h
index a6f6f81efece..8fba7972ff5f 100644
--- a/include/linux/mfd/88pm860x.h
+++ b/include/linux/mfd/88pm860x.h
@@ -368,6 +368,14 @@ extern int pm860x_bulk_read(struct i2c_client *, int, int, unsigned char *);
368extern int pm860x_bulk_write(struct i2c_client *, int, int, unsigned char *); 368extern int pm860x_bulk_write(struct i2c_client *, int, int, unsigned char *);
369extern int pm860x_set_bits(struct i2c_client *, int, unsigned char, 369extern int pm860x_set_bits(struct i2c_client *, int, unsigned char,
370 unsigned char); 370 unsigned char);
371extern int pm860x_page_reg_read(struct i2c_client *, int);
372extern int pm860x_page_reg_write(struct i2c_client *, int, unsigned char);
373extern int pm860x_page_bulk_read(struct i2c_client *, int, int,
374 unsigned char *);
375extern int pm860x_page_bulk_write(struct i2c_client *, int, int,
376 unsigned char *);
377extern int pm860x_page_set_bits(struct i2c_client *, int, unsigned char,
378 unsigned char);
371 379
372extern int pm860x_device_init(struct pm860x_chip *chip, 380extern int pm860x_device_init(struct pm860x_chip *chip,
373 struct pm860x_platform_data *pdata) __devinit ; 381 struct pm860x_platform_data *pdata) __devinit ;