Symbol: hx711_data
drivers/iio/adc/hx711.c
104
static int hx711_cycle(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
114
gpiod_set_value(hx711_data->gpiod_pd_sck, 1);
drivers/iio/adc/hx711.c
121
ndelay(hx711_data->data_ready_delay_ns);
drivers/iio/adc/hx711.c
129
gpiod_set_value(hx711_data->gpiod_pd_sck, 0);
drivers/iio/adc/hx711.c
136
ndelay(hx711_data->data_ready_delay_ns);
drivers/iio/adc/hx711.c
139
return gpiod_get_value(hx711_data->gpiod_dout);
drivers/iio/adc/hx711.c
142
static int hx711_read(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
146
int val = gpiod_get_value(hx711_data->gpiod_dout);
drivers/iio/adc/hx711.c
154
ret = hx711_cycle(hx711_data);
drivers/iio/adc/hx711.c
161
for (i = 0; i < hx711_get_gain_to_pulse(hx711_data->gain_set); i++)
drivers/iio/adc/hx711.c
162
hx711_cycle(hx711_data);
drivers/iio/adc/hx711.c
167
static int hx711_wait_for_ready(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
177
val = gpiod_get_value(hx711_data->gpiod_dout);
drivers/iio/adc/hx711.c
189
static int hx711_reset(struct hx711_data *hx711_data)
drivers/iio/adc/hx711.c
191
int val = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
203
gpiod_set_value(hx711_data->gpiod_pd_sck, 1);
drivers/iio/adc/hx711.c
205
gpiod_set_value(hx711_data->gpiod_pd_sck, 0);
drivers/iio/adc/hx711.c
207
val = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
210
hx711_data->gain_set = HX711_RESET_GAIN;
drivers/iio/adc/hx711.c
216
static int hx711_set_gain_for_channel(struct hx711_data *hx711_data, int chan)
drivers/iio/adc/hx711.c
221
if (hx711_data->gain_set == 32) {
drivers/iio/adc/hx711.c
222
hx711_data->gain_set = hx711_data->gain_chan_a;
drivers/iio/adc/hx711.c
224
ret = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
228
ret = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
233
if (hx711_data->gain_set != 32) {
drivers/iio/adc/hx711.c
234
hx711_data->gain_set = 32;
drivers/iio/adc/hx711.c
236
ret = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
240
ret = hx711_wait_for_ready(hx711_data);
drivers/iio/adc/hx711.c
249
static int hx711_reset_read(struct hx711_data *hx711_data, int chan)
drivers/iio/adc/hx711.c
258
if (hx711_reset(hx711_data)) {
drivers/iio/adc/hx711.c
259
dev_err(hx711_data->dev, "reset failed!");
drivers/iio/adc/hx711.c
263
ret = hx711_set_gain_for_channel(hx711_data, chan);
drivers/iio/adc/hx711.c
267
val = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
276
struct hx711_data *hx711_data = iio_priv(indio_dev);
drivers/iio/adc/hx711.c
280
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
282
*val = hx711_reset_read(hx711_data, chan->channel);
drivers/iio/adc/hx711.c
284
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
291
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
293
*val2 = hx711_get_gain_to_scale(hx711_data->gain_set);
drivers/iio/adc/hx711.c
295
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
309
struct hx711_data *hx711_data = iio_priv(indio_dev);
drivers/iio/adc/hx711.c
322
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
326
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
330
if (gain != hx711_data->gain_set) {
drivers/iio/adc/hx711.c
331
hx711_data->gain_set = gain;
drivers/iio/adc/hx711.c
333
hx711_data->gain_chan_a = gain;
drivers/iio/adc/hx711.c
335
ret = hx711_read(hx711_data);
drivers/iio/adc/hx711.c
337
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
342
mutex_unlock(&hx711_data->lock);
drivers/iio/adc/hx711.c
362
struct hx711_data *hx711_data = iio_priv(indio_dev);
drivers/iio/adc/hx711.c
365
mutex_lock(&hx711_data->lock);
drivers/iio/adc/hx711.c
367
memset(&hx711_data->buffer, 0, sizeof(hx711_data->buffer));
drivers/iio/adc/hx711.c
370
hx711_data->buffer.channel[j] = hx711_reset_read(hx711_data,
drivers/iio/adc/hx711.c
375
iio_push_to_buffers_with_timestamp(indio_dev, &hx711_data->buffer,
drivers/iio/adc/hx711.c
378
mutex_unlock(&hx711_data->lock);
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
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;