Searched refs:dpot (Results 1 - 1 of 1) sorted by relevance

/linux-4.1.27/drivers/misc/
H A Dad525x_dpot.c97 static inline int dpot_read_d8(struct dpot_data *dpot) dpot_read_d8() argument
99 return dpot->bdata.bops->read_d8(dpot->bdata.client); dpot_read_d8()
102 static inline int dpot_read_r8d8(struct dpot_data *dpot, u8 reg) dpot_read_r8d8() argument
104 return dpot->bdata.bops->read_r8d8(dpot->bdata.client, reg); dpot_read_r8d8()
107 static inline int dpot_read_r8d16(struct dpot_data *dpot, u8 reg) dpot_read_r8d16() argument
109 return dpot->bdata.bops->read_r8d16(dpot->bdata.client, reg); dpot_read_r8d16()
112 static inline int dpot_write_d8(struct dpot_data *dpot, u8 val) dpot_write_d8() argument
114 return dpot->bdata.bops->write_d8(dpot->bdata.client, val); dpot_write_d8()
117 static inline int dpot_write_r8d8(struct dpot_data *dpot, u8 reg, u16 val) dpot_write_r8d8() argument
119 return dpot->bdata.bops->write_r8d8(dpot->bdata.client, reg, val); dpot_write_r8d8()
122 static inline int dpot_write_r8d16(struct dpot_data *dpot, u8 reg, u16 val) dpot_write_r8d16() argument
124 return dpot->bdata.bops->write_r8d16(dpot->bdata.client, reg, val); dpot_write_r8d16()
127 static s32 dpot_read_spi(struct dpot_data *dpot, u8 reg) dpot_read_spi() argument
134 if (dpot->feat & F_RDACS_WONLY) dpot_read_spi()
135 return dpot->rdac_cache[reg & DPOT_RDAC_MASK]; dpot_read_spi()
136 if (dpot->uid == DPOT_UID(AD5291_ID) || dpot_read_spi()
137 dpot->uid == DPOT_UID(AD5292_ID) || dpot_read_spi()
138 dpot->uid == DPOT_UID(AD5293_ID)) { dpot_read_spi()
140 value = dpot_read_r8d8(dpot, dpot_read_spi()
143 if (dpot->uid == DPOT_UID(AD5291_ID)) dpot_read_spi()
147 } else if (dpot->uid == DPOT_UID(AD5270_ID) || dpot_read_spi()
148 dpot->uid == DPOT_UID(AD5271_ID)) { dpot_read_spi()
150 value = dpot_read_r8d8(dpot, dpot_read_spi()
156 if (dpot->uid == DPOT_UID(AD5271_ID)) dpot_read_spi()
167 if (dpot->feat & F_SPI_16BIT) dpot_read_spi()
168 return dpot_read_r8d8(dpot, ctrl); dpot_read_spi()
169 else if (dpot->feat & F_SPI_24BIT) dpot_read_spi()
170 return dpot_read_r8d16(dpot, ctrl); dpot_read_spi()
175 static s32 dpot_read_i2c(struct dpot_data *dpot, u8 reg) dpot_read_i2c() argument
180 switch (dpot->uid) { dpot_read_i2c()
183 return dpot_read_d8(dpot); dpot_read_i2c()
193 return dpot_read_r8d8(dpot, ctrl); dpot_read_i2c()
197 return dpot_read_d8(dpot); dpot_read_i2c()
202 return dpot_read_r8d8(dpot, ctrl); dpot_read_i2c()
205 dpot_write_r8d8(dpot, dpot_read_i2c()
208 value = dpot_read_r8d16(dpot, dpot_read_i2c()
219 if (dpot->uid == DPOT_UID(AD5271_ID)) dpot_read_i2c()
223 if ((reg & DPOT_REG_TOL) || (dpot->max_pos > 256)) dpot_read_i2c()
224 return dpot_read_r8d16(dpot, (reg & 0xF8) | dpot_read_i2c()
227 return dpot_read_r8d8(dpot, reg); dpot_read_i2c()
231 static s32 dpot_read(struct dpot_data *dpot, u8 reg) dpot_read() argument
233 if (dpot->feat & F_SPI) dpot_read()
234 return dpot_read_spi(dpot, reg); dpot_read()
236 return dpot_read_i2c(dpot, reg); dpot_read()
239 static s32 dpot_write_spi(struct dpot_data *dpot, u8 reg, u16 value) dpot_write_spi() argument
244 if (dpot->feat & F_RDACS_WONLY) dpot_write_spi()
245 dpot->rdac_cache[reg & DPOT_RDAC_MASK] = value; dpot_write_spi()
247 if (dpot->feat & F_AD_APPDATA) { dpot_write_spi()
248 if (dpot->feat & F_SPI_8BIT) { dpot_write_spi()
250 DPOT_MAX_POS(dpot->devid)) | dpot_write_spi()
252 return dpot_write_d8(dpot, val); dpot_write_spi()
253 } else if (dpot->feat & F_SPI_16BIT) { dpot_write_spi()
255 DPOT_MAX_POS(dpot->devid)) | dpot_write_spi()
257 return dpot_write_r8d8(dpot, val >> 8, dpot_write_spi()
262 if (dpot->uid == DPOT_UID(AD5291_ID) || dpot_write_spi()
263 dpot->uid == DPOT_UID(AD5292_ID) || dpot_write_spi()
264 dpot->uid == DPOT_UID(AD5293_ID)) { dpot_write_spi()
266 dpot_write_r8d8(dpot, DPOT_AD5291_CTRLREG << 2, dpot_write_spi()
269 if (dpot->uid == DPOT_UID(AD5291_ID)) dpot_write_spi()
272 return dpot_write_r8d8(dpot, dpot_write_spi()
275 } else if (dpot->uid == DPOT_UID(AD5270_ID) || dpot_write_spi()
276 dpot->uid == DPOT_UID(AD5271_ID)) { dpot_write_spi()
277 dpot_write_r8d8(dpot, dpot_write_spi()
281 if (dpot->uid == DPOT_UID(AD5271_ID)) dpot_write_spi()
284 return dpot_write_r8d8(dpot, dpot_write_spi()
308 if (dpot->uid == DPOT_UID(AD5291_ID) || dpot_write_spi()
309 dpot->uid == DPOT_UID(AD5292_ID)) { dpot_write_spi()
310 return dpot_write_r8d8(dpot, dpot_write_spi()
312 } else if (dpot->uid == DPOT_UID(AD5270_ID) || dpot_write_spi()
313 dpot->uid == DPOT_UID(AD5271_ID)) { dpot_write_spi()
314 return dpot_write_r8d8(dpot, dpot_write_spi()
320 if (dpot->feat & F_SPI_16BIT) dpot_write_spi()
321 return dpot_write_r8d8(dpot, val, value); dpot_write_spi()
322 else if (dpot->feat & F_SPI_24BIT) dpot_write_spi()
323 return dpot_write_r8d16(dpot, val, value); dpot_write_spi()
328 static s32 dpot_write_i2c(struct dpot_data *dpot, u8 reg, u16 value) dpot_write_i2c() argument
333 switch (dpot->uid) { dpot_write_i2c()
336 return dpot_write_d8(dpot, value); dpot_write_i2c()
347 return dpot_write_r8d8(dpot, ctrl, value); DPOT_UID()
351 tmp = dpot_read_d8(dpot); DPOT_UID()
356 return dpot_write_r8d8(dpot, ctrl, value);
362 tmp = dpot_read_r8d16(dpot, ctrl);
367 return dpot_write_r8d8(dpot, ctrl, value); DPOT_UID()
370 tmp = dpot_read_r8d16(dpot, tmp); DPOT_UID()
375 return dpot_write_r8d8(dpot, ctrl, value);
378 dpot_write_r8d8(dpot, DPOT_AD5270_1_2_4_CTRLREG << 2,
382 return dpot_write_r8d8(dpot,
385 if (dpot->uid == DPOT_UID(AD5274_ID))
388 return dpot_write_r8d8(dpot, (DPOT_AD5270_1_2_4_RDAC << 2) |
392 return dpot_write_d8(dpot, reg);
394 if (dpot->max_pos > 256)
395 return dpot_write_r8d16(dpot, (reg & 0xF8) |
399 return dpot_write_r8d8(dpot, reg, value);
403 static s32 dpot_write(struct dpot_data *dpot, u8 reg, u16 value) dpot_write() argument
405 if (dpot->feat & F_SPI) dpot_write()
406 return dpot_write_spi(dpot, reg, value); dpot_write()
408 return dpot_write_i2c(dpot, reg, value); dpot_write()

Completed in 90 milliseconds