diff options
author | Haojian Zhuang <haojian.zhuang@marvell.com> | 2011-03-07 10:43:16 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-03-23 05:42:07 -0400 |
commit | 09b034191acd1f95a749630fe366a84d3029930c (patch) | |
tree | 41a28ea82b39afc63f5d7500cee4ce3a1d15afe3 /drivers/mfd | |
parent | c9f560b3d0222f6a6e3faeda324e786e230e4f20 (diff) |
mfd: Append additional read write on 88pm860x
Append the additional read/write operation on 88pm860x for accessing
test page in 88PM860x.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/88pm860x-i2c.c | 103 |
1 files changed, 103 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 | } |
127 | EXPORT_SYMBOL(pm860x_set_bits); | 127 | EXPORT_SYMBOL(pm860x_set_bits); |
128 | 128 | ||
129 | int 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 | } | ||
148 | EXPORT_SYMBOL(pm860x_page_reg_read); | ||
149 | |||
150 | int 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 | } | ||
167 | EXPORT_SYMBOL(pm860x_page_reg_write); | ||
168 | |||
169 | int 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 | } | ||
186 | EXPORT_SYMBOL(pm860x_page_bulk_read); | ||
187 | |||
188 | int 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 | } | ||
205 | EXPORT_SYMBOL(pm860x_page_bulk_write); | ||
206 | |||
207 | int 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); | ||
225 | out: | ||
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 | } | ||
231 | EXPORT_SYMBOL(pm860x_page_set_bits); | ||
129 | 232 | ||
130 | static const struct i2c_device_id pm860x_id_table[] = { | 233 | static const struct i2c_device_id pm860x_id_table[] = { |
131 | { "88PM860x", 0 }, | 234 | { "88PM860x", 0 }, |