Lines Matching refs:adc
95 static int mcp3422_update_config(struct mcp3422 *adc, u8 newconfig) in mcp3422_update_config() argument
99 ret = i2c_master_send(adc->i2c, &newconfig, 1); in mcp3422_update_config()
101 adc->config = newconfig; in mcp3422_update_config()
108 static int mcp3422_read(struct mcp3422 *adc, int *value, u8 *config) in mcp3422_read() argument
111 u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config); in mcp3422_read()
116 ret = i2c_master_recv(adc->i2c, buf, 4); in mcp3422_read()
120 ret = i2c_master_recv(adc->i2c, buf, 3); in mcp3422_read()
130 static int mcp3422_read_channel(struct mcp3422 *adc, in mcp3422_read_channel() argument
137 mutex_lock(&adc->lock); in mcp3422_read_channel()
139 if (req_channel != MCP3422_CHANNEL(adc->config)) { in mcp3422_read_channel()
140 config = adc->config; in mcp3422_read_channel()
144 config |= MCP3422_PGA_VALUE(adc->pga[req_channel]); in mcp3422_read_channel()
145 ret = mcp3422_update_config(adc, config); in mcp3422_read_channel()
147 mutex_unlock(&adc->lock); in mcp3422_read_channel()
150 msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]); in mcp3422_read_channel()
153 ret = mcp3422_read(adc, value, &config); in mcp3422_read_channel()
155 mutex_unlock(&adc->lock); in mcp3422_read_channel()
164 struct mcp3422 *adc = iio_priv(iio); in mcp3422_read_raw() local
167 u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config); in mcp3422_read_raw()
168 u8 pga = MCP3422_PGA(adc->config); in mcp3422_read_raw()
172 err = mcp3422_read_channel(adc, channel, val1); in mcp3422_read_raw()
184 *val1 = mcp3422_sample_rates[MCP3422_SAMPLE_RATE(adc->config)]; in mcp3422_read_raw()
198 struct mcp3422 *adc = iio_priv(iio); in mcp3422_write_raw() local
200 u8 config = adc->config; in mcp3422_write_raw()
212 adc->pga[req_channel] = i; in mcp3422_write_raw()
217 config |= MCP3422_PGA_VALUE(adc->pga[req_channel]); in mcp3422_write_raw()
219 return mcp3422_update_config(adc, config); in mcp3422_write_raw()
236 if (adc->id > 4) in mcp3422_write_raw()
249 return mcp3422_update_config(adc, config); in mcp3422_write_raw()
274 struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev)); in mcp3422_show_samp_freqs() local
276 if (adc->id > 4) in mcp3422_show_samp_freqs()
285 struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev)); in mcp3422_show_scales() local
286 u8 sample_rate = MCP3422_SAMPLE_RATE(adc->config); in mcp3422_show_scales()
337 struct mcp3422 *adc; in mcp3422_probe() local
344 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adc)); in mcp3422_probe()
348 adc = iio_priv(indio_dev); in mcp3422_probe()
349 adc->i2c = client; in mcp3422_probe()
350 adc->id = (u8)(id->driver_data); in mcp3422_probe()
352 mutex_init(&adc->lock); in mcp3422_probe()
358 switch (adc->id) { in mcp3422_probe()
383 err = mcp3422_update_config(adc, config); in mcp3422_probe()