Lines Matching refs:afe

141 	struct afe4403_data *afe = iio_priv(indio_dev);  in afe440x_show_register()  local
147 ret = regmap_field_read(afe->fields[afe440x_attr->field], &reg_val); in afe440x_show_register()
165 struct afe4403_data *afe = iio_priv(indio_dev); in afe440x_store_register() local
180 ret = regmap_field_write(afe->fields[afe440x_attr->field], val); in afe440x_store_register()
217 static int afe4403_read(struct afe4403_data *afe, unsigned int reg, u32 *val) in afe4403_read() argument
224 ret = spi_write_then_read(afe->spi, tx, 4, NULL, 0); in afe4403_read()
228 ret = spi_write_then_read(afe->spi, &reg, 1, rx, sizeof(rx)); in afe4403_read()
236 ret = spi_write_then_read(afe->spi, tx, 4, NULL, 0); in afe4403_read()
247 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_read_raw() local
256 ret = afe4403_read(afe, reg, val); in afe4403_read_raw()
266 ret = regmap_field_read(afe->fields[field], val); in afe4403_read_raw()
287 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_write_raw() local
294 return regmap_field_write(afe->fields[field], val); in afe4403_write_raw()
314 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_trigger_handler() local
320 ret = spi_write_then_read(afe->spi, tx, 4, NULL, 0); in afe4403_trigger_handler()
325 ret = spi_write_then_read(afe->spi, in afe4403_trigger_handler()
331 afe->buffer[i++] = get_unaligned_be24(&rx[0]); in afe4403_trigger_handler()
336 ret = spi_write_then_read(afe->spi, tx, 4, NULL, 0); in afe4403_trigger_handler()
340 iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer, in afe4403_trigger_handler()
421 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_suspend() local
424 ret = regmap_set_bits(afe->regmap, AFE440X_CONTROL2, in afe4403_suspend()
429 ret = regulator_disable(afe->regulator); in afe4403_suspend()
441 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_resume() local
444 ret = regulator_enable(afe->regulator); in afe4403_resume()
450 ret = regmap_clear_bits(afe->regmap, AFE440X_CONTROL2, in afe4403_resume()
464 struct afe4403_data *afe; in afe4403_probe() local
467 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*afe)); in afe4403_probe()
471 afe = iio_priv(indio_dev); in afe4403_probe()
474 afe->dev = &spi->dev; in afe4403_probe()
475 afe->spi = spi; in afe4403_probe()
476 afe->irq = spi->irq; in afe4403_probe()
478 afe->regmap = devm_regmap_init_spi(spi, &afe4403_regmap_config); in afe4403_probe()
479 if (IS_ERR(afe->regmap)) { in afe4403_probe()
480 dev_err(afe->dev, "Unable to allocate register map\n"); in afe4403_probe()
481 return PTR_ERR(afe->regmap); in afe4403_probe()
485 afe->fields[i] = devm_regmap_field_alloc(afe->dev, afe->regmap, in afe4403_probe()
487 if (IS_ERR(afe->fields[i])) { in afe4403_probe()
488 dev_err(afe->dev, "Unable to allocate regmap fields\n"); in afe4403_probe()
489 return PTR_ERR(afe->fields[i]); in afe4403_probe()
493 afe->regulator = devm_regulator_get(afe->dev, "tx_sup"); in afe4403_probe()
494 if (IS_ERR(afe->regulator)) in afe4403_probe()
495 return dev_err_probe(afe->dev, PTR_ERR(afe->regulator), in afe4403_probe()
498 ret = regulator_enable(afe->regulator); in afe4403_probe()
500 dev_err(afe->dev, "Unable to enable regulator\n"); in afe4403_probe()
503 ret = devm_add_action_or_reset(afe->dev, afe4403_regulator_disable, afe->regulator); in afe4403_probe()
505 dev_err(afe->dev, "Unable to add regulator disable action\n"); in afe4403_probe()
509 ret = regmap_write(afe->regmap, AFE440X_CONTROL0, in afe4403_probe()
512 dev_err(afe->dev, "Unable to reset device\n"); in afe4403_probe()
516 ret = regmap_multi_reg_write(afe->regmap, afe4403_reg_sequences, in afe4403_probe()
519 dev_err(afe->dev, "Unable to set register defaults\n"); in afe4403_probe()
529 if (afe->irq > 0) { in afe4403_probe()
530 afe->trig = devm_iio_trigger_alloc(afe->dev, in afe4403_probe()
534 if (!afe->trig) { in afe4403_probe()
535 dev_err(afe->dev, "Unable to allocate IIO trigger\n"); in afe4403_probe()
539 iio_trigger_set_drvdata(afe->trig, indio_dev); in afe4403_probe()
541 ret = devm_iio_trigger_register(afe->dev, afe->trig); in afe4403_probe()
543 dev_err(afe->dev, "Unable to register IIO trigger\n"); in afe4403_probe()
547 ret = devm_request_threaded_irq(afe->dev, afe->irq, in afe4403_probe()
551 afe->trig); in afe4403_probe()
553 dev_err(afe->dev, "Unable to request IRQ\n"); in afe4403_probe()
558 ret = devm_iio_triggered_buffer_setup(afe->dev, indio_dev, in afe4403_probe()
562 dev_err(afe->dev, "Unable to setup buffer\n"); in afe4403_probe()
566 ret = devm_iio_device_register(afe->dev, indio_dev); in afe4403_probe()
568 dev_err(afe->dev, "Unable to register IIO device\n"); in afe4403_probe()