Symbol: hx711_data
drivers/iio/adc/hx711.c
102
static int hx711_cycle(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
112
gpiod_set_value(hx711_data->gpiod_pd_sck, 1);
drivers/iio/adc/hx711.c
119
ndelay(hx711_data->data_ready_delay_ns);
drivers/iio/adc/hx711.c
127
gpiod_set_value(hx711_data->gpiod_pd_sck, 0);
drivers/iio/adc/hx711.c
134
ndelay(hx711_data->data_ready_delay_ns);
drivers/iio/adc/hx711.c
137
return gpiod_get_value(hx711_data->gpiod_dout);
drivers/iio/adc/hx711.c
140
static int hx711_read(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
144
int val = gpiod_get_value(hx711_data->gpiod_dout);
drivers/iio/adc/hx711.c
152
ret = hx711_cycle(hx711_data);
drivers/iio/adc/hx711.c
159
for (i = 0; i < hx711_get_gain_to_pulse(hx711_data->gain_set); i++)
drivers/iio/adc/hx711.c
160
hx711_cycle(hx711_data);
drivers/iio/adc/hx711.c
165
static int hx711_wait_for_ready(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
175
val = gpiod_get_value(hx711_data->gpiod_dout);
drivers/iio/adc/hx711.c
187
static int hx711_reset(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
189
int val = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
201
gpiod_set_value(hx711_data->gpiod_pd_sck, 1);
drivers/iio/adc/hx711.c
203
gpiod_set_value(hx711_data->gpiod_pd_sck, 0);
drivers/iio/adc/hx711.c
205
val = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
208
hx711_data->gain_set = HX711_RESET_GAIN;
drivers/iio/adc/hx711.c
214
static int hx711_set_gain_for_channel(struct hx711_data *hx711_data, int chan)
drivers/iio/adc/hx711.c
219
if (hx711_data->gain_set == 32) {
drivers/iio/adc/hx711.c
220
hx711_data->gain_set = hx711_data->gain_chan_a;
drivers/iio/adc/hx711.c
222
ret = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
226
ret = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
231
if (hx711_data->gain_set != 32) {
drivers/iio/adc/hx711.c
232
hx711_data->gain_set = 32;
drivers/iio/adc/hx711.c
234
ret = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
238
ret = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
247
static int hx711_reset_read(struct hx711_data *hx711_data, int chan)
drivers/iio/adc/hx711.c
256
if (hx711_reset(hx711_data)) {
drivers/iio/adc/hx711.c
257
dev_err(hx711_data->dev, "reset failed!");
drivers/iio/adc/hx711.c
261
ret = hx711_set_gain_for_channel(hx711_data, chan);
drivers/iio/adc/hx711.c
265
val = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
274
struct hx711_data *hx711_data = iio_priv(indio_dev);
drivers/iio/adc/hx711.c
278
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
280
*val = hx711_reset_read(hx711_data, chan->channel);
drivers/iio/adc/hx711.c
282
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
289
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
291
*val2 = hx711_get_gain_to_scale(hx711_data->gain_scale,
drivers/iio/adc/hx711.c
292
hx711_data->gain_set);
drivers/iio/adc/hx711.c
294
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
308
struct hx711_data *hx711_data = iio_priv(indio_dev);
drivers/iio/adc/hx711.c
321
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
323
gain = hx711_get_scale_to_gain(hx711_data->gain_scale, val2);
drivers/iio/adc/hx711.c
325
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
329
if (gain != hx711_data->gain_set) {
drivers/iio/adc/hx711.c
330
hx711_data->gain_set = gain;
drivers/iio/adc/hx711.c
332
hx711_data->gain_chan_a = gain;
drivers/iio/adc/hx711.c
334
ret = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
336
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
341
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
361
struct hx711_data *hx711_data = iio_priv(indio_dev);
drivers/iio/adc/hx711.c
364
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
366
memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer));
drivers/iio/adc/hx711.c
369
hx711_data->buffer.channel[j] = hx711_reset_read(hx711_data,
drivers/iio/adc/hx711.c
374
iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer,
drivers/iio/adc/hx711.c
377
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
388
struct hx711_data *hx711_data = iio_priv(dev_to_iio_dev(dev));
drivers/iio/adc/hx711.c
396
hx711_data->gain_scale[i]);
drivers/iio/adc/hx711.c
461
struct hx711_data *hx711_data;
drivers/iio/adc/hx711.c
466
indio_dev = devm_iio_device_alloc(dev, sizeof(struct hx711_data));
drivers/iio/adc/hx711.c
470
hx711_data = iio_priv(indio_dev);
drivers/iio/adc/hx711.c
471
hx711_data->dev = dev;
drivers/iio/adc/hx711.c
473
mutex_init(&hx711_data->lock);
drivers/iio/adc/hx711.c
479
hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW);
drivers/iio/adc/hx711.c
480
if (IS_ERR(hx711_data->gpiod_pd_sck))
drivers/iio/adc/hx711.c
481
return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_pd_sck),
drivers/iio/adc/hx711.c
488
hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN);
drivers/iio/adc/hx711.c
489
if (IS_ERR(hx711_data->gpiod_dout))
drivers/iio/adc/hx711.c
490
return dev_err_probe(dev, PTR_ERR(hx711_data->gpiod_dout),
drivers/iio/adc/hx711.c
514
hx711_data->gain_scale[i] =
drivers/iio/adc/hx711.c
517
hx711_data->gain_set = 128;
drivers/iio/adc/hx711.c
518
hx711_data->gain_chan_a = 128;
drivers/iio/adc/hx711.c
520
hx711_data->clock_frequency = 400000;
drivers/iio/adc/hx711.c
522
&hx711_data->clock_frequency);
drivers/iio/adc/hx711.c
528
if (hx711_data->clock_frequency < 20000) {
drivers/iio/adc/hx711.c
530
hx711_data->clock_frequency = 400000;
drivers/iio/adc/hx711.c
533
hx711_data->data_ready_delay_ns =
drivers/iio/adc/hx711.c
534
1000000000 / hx711_data->clock_frequency;