Lines Matching refs:dpot

96 static inline int dpot_read_d8(struct dpot_data *dpot)  in dpot_read_d8()  argument
98 return dpot->bdata.bops->read_d8(dpot->bdata.client); in dpot_read_d8()
101 static inline int dpot_read_r8d8(struct dpot_data *dpot, u8 reg) in dpot_read_r8d8() argument
103 return dpot->bdata.bops->read_r8d8(dpot->bdata.client, reg); in dpot_read_r8d8()
106 static inline int dpot_read_r8d16(struct dpot_data *dpot, u8 reg) in dpot_read_r8d16() argument
108 return dpot->bdata.bops->read_r8d16(dpot->bdata.client, reg); in dpot_read_r8d16()
111 static inline int dpot_write_d8(struct dpot_data *dpot, u8 val) in dpot_write_d8() argument
113 return dpot->bdata.bops->write_d8(dpot->bdata.client, val); in dpot_write_d8()
116 static inline int dpot_write_r8d8(struct dpot_data *dpot, u8 reg, u16 val) in dpot_write_r8d8() argument
118 return dpot->bdata.bops->write_r8d8(dpot->bdata.client, reg, val); in dpot_write_r8d8()
121 static inline int dpot_write_r8d16(struct dpot_data *dpot, u8 reg, u16 val) in dpot_write_r8d16() argument
123 return dpot->bdata.bops->write_r8d16(dpot->bdata.client, reg, val); in dpot_write_r8d16()
126 static s32 dpot_read_spi(struct dpot_data *dpot, u8 reg) in dpot_read_spi() argument
133 if (dpot->feat & F_RDACS_WONLY) in dpot_read_spi()
134 return dpot->rdac_cache[reg & DPOT_RDAC_MASK]; in dpot_read_spi()
135 if (dpot->uid == DPOT_UID(AD5291_ID) || in dpot_read_spi()
136 dpot->uid == DPOT_UID(AD5292_ID) || in dpot_read_spi()
137 dpot->uid == DPOT_UID(AD5293_ID)) { in dpot_read_spi()
139 value = dpot_read_r8d8(dpot, in dpot_read_spi()
142 if (dpot->uid == DPOT_UID(AD5291_ID)) in dpot_read_spi()
146 } else if (dpot->uid == DPOT_UID(AD5270_ID) || in dpot_read_spi()
147 dpot->uid == DPOT_UID(AD5271_ID)) { in dpot_read_spi()
149 value = dpot_read_r8d8(dpot, in dpot_read_spi()
155 if (dpot->uid == DPOT_UID(AD5271_ID)) in dpot_read_spi()
166 if (dpot->feat & F_SPI_16BIT) in dpot_read_spi()
167 return dpot_read_r8d8(dpot, ctrl); in dpot_read_spi()
168 else if (dpot->feat & F_SPI_24BIT) in dpot_read_spi()
169 return dpot_read_r8d16(dpot, ctrl); in dpot_read_spi()
174 static s32 dpot_read_i2c(struct dpot_data *dpot, u8 reg) in dpot_read_i2c() argument
179 switch (dpot->uid) { in dpot_read_i2c()
182 return dpot_read_d8(dpot); in dpot_read_i2c()
192 return dpot_read_r8d8(dpot, ctrl); in dpot_read_i2c()
196 return dpot_read_d8(dpot); in dpot_read_i2c()
201 return dpot_read_r8d8(dpot, ctrl); in dpot_read_i2c()
204 dpot_write_r8d8(dpot, in dpot_read_i2c()
207 value = dpot_read_r8d16(dpot, DPOT_AD5270_1_2_4_RDAC << 2); in dpot_read_i2c()
216 if (dpot->uid == DPOT_UID(AD5274_ID)) in dpot_read_i2c()
220 if ((reg & DPOT_REG_TOL) || (dpot->max_pos > 256)) in dpot_read_i2c()
221 return dpot_read_r8d16(dpot, (reg & 0xF8) | in dpot_read_i2c()
224 return dpot_read_r8d8(dpot, reg); in dpot_read_i2c()
228 static s32 dpot_read(struct dpot_data *dpot, u8 reg) in dpot_read() argument
230 if (dpot->feat & F_SPI) in dpot_read()
231 return dpot_read_spi(dpot, reg); in dpot_read()
233 return dpot_read_i2c(dpot, reg); in dpot_read()
236 static s32 dpot_write_spi(struct dpot_data *dpot, u8 reg, u16 value) in dpot_write_spi() argument
241 if (dpot->feat & F_RDACS_WONLY) in dpot_write_spi()
242 dpot->rdac_cache[reg & DPOT_RDAC_MASK] = value; in dpot_write_spi()
244 if (dpot->feat & F_AD_APPDATA) { in dpot_write_spi()
245 if (dpot->feat & F_SPI_8BIT) { in dpot_write_spi()
247 DPOT_MAX_POS(dpot->devid)) | in dpot_write_spi()
249 return dpot_write_d8(dpot, val); in dpot_write_spi()
250 } else if (dpot->feat & F_SPI_16BIT) { in dpot_write_spi()
252 DPOT_MAX_POS(dpot->devid)) | in dpot_write_spi()
254 return dpot_write_r8d8(dpot, val >> 8, in dpot_write_spi()
259 if (dpot->uid == DPOT_UID(AD5291_ID) || in dpot_write_spi()
260 dpot->uid == DPOT_UID(AD5292_ID) || in dpot_write_spi()
261 dpot->uid == DPOT_UID(AD5293_ID)) { in dpot_write_spi()
263 dpot_write_r8d8(dpot, DPOT_AD5291_CTRLREG << 2, in dpot_write_spi()
266 if (dpot->uid == DPOT_UID(AD5291_ID)) in dpot_write_spi()
269 return dpot_write_r8d8(dpot, in dpot_write_spi()
272 } else if (dpot->uid == DPOT_UID(AD5270_ID) || in dpot_write_spi()
273 dpot->uid == DPOT_UID(AD5271_ID)) { in dpot_write_spi()
274 dpot_write_r8d8(dpot, in dpot_write_spi()
278 if (dpot->uid == DPOT_UID(AD5271_ID)) in dpot_write_spi()
281 return dpot_write_r8d8(dpot, in dpot_write_spi()
305 if (dpot->uid == DPOT_UID(AD5291_ID) || in dpot_write_spi()
306 dpot->uid == DPOT_UID(AD5292_ID)) { in dpot_write_spi()
307 return dpot_write_r8d8(dpot, in dpot_write_spi()
309 } else if (dpot->uid == DPOT_UID(AD5270_ID) || in dpot_write_spi()
310 dpot->uid == DPOT_UID(AD5271_ID)) { in dpot_write_spi()
311 return dpot_write_r8d8(dpot, in dpot_write_spi()
317 if (dpot->feat & F_SPI_16BIT) in dpot_write_spi()
318 return dpot_write_r8d8(dpot, val, value); in dpot_write_spi()
319 else if (dpot->feat & F_SPI_24BIT) in dpot_write_spi()
320 return dpot_write_r8d16(dpot, val, value); in dpot_write_spi()
325 static s32 dpot_write_i2c(struct dpot_data *dpot, u8 reg, u16 value) in dpot_write_i2c() argument
330 switch (dpot->uid) { in dpot_write_i2c()
333 return dpot_write_d8(dpot, value); in dpot_write_i2c()
344 return dpot_write_r8d8(dpot, ctrl, value); in dpot_write_i2c()
348 tmp = dpot_read_d8(dpot); in dpot_write_i2c()
353 return dpot_write_r8d8(dpot, ctrl, value); in dpot_write_i2c()
359 tmp = dpot_read_r8d16(dpot, ctrl); in dpot_write_i2c()
364 return dpot_write_r8d8(dpot, ctrl, value); in dpot_write_i2c()
367 tmp = dpot_read_r8d16(dpot, tmp); in dpot_write_i2c()
372 return dpot_write_r8d8(dpot, ctrl, value); in dpot_write_i2c()
375 dpot_write_r8d8(dpot, DPOT_AD5270_1_2_4_CTRLREG << 2, in dpot_write_i2c()
379 return dpot_write_r8d8(dpot, in dpot_write_i2c()
382 if (dpot->uid == DPOT_UID(AD5274_ID)) in dpot_write_i2c()
385 return dpot_write_r8d8(dpot, (DPOT_AD5270_1_2_4_RDAC << 2) | in dpot_write_i2c()
389 return dpot_write_d8(dpot, reg); in dpot_write_i2c()
391 if (dpot->max_pos > 256) in dpot_write_i2c()
392 return dpot_write_r8d16(dpot, (reg & 0xF8) | in dpot_write_i2c()
396 return dpot_write_r8d8(dpot, reg, value); in dpot_write_i2c()
400 static s32 dpot_write(struct dpot_data *dpot, u8 reg, u16 value) in dpot_write() argument
402 if (dpot->feat & F_SPI) in dpot_write()
403 return dpot_write_spi(dpot, reg, value); in dpot_write()
405 return dpot_write_i2c(dpot, reg, value); in dpot_write()