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()
326 ret = spi_write_then_read(afe->spi, in afe4403_trigger_handler()
332 afe->buffer[i++] = get_unaligned_be24(&rx[0]); in afe4403_trigger_handler()
337 ret = spi_write_then_read(afe->spi, tx, 4, NULL, 0); in afe4403_trigger_handler()
341 iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer, in afe4403_trigger_handler()
415 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_suspend() local
418 ret = regmap_update_bits(afe->regmap, AFE440X_CONTROL2, in afe4403_suspend()
424 ret = regulator_disable(afe->regulator); in afe4403_suspend()
436 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_resume() local
439 ret = regulator_enable(afe->regulator); in afe4403_resume()
445 ret = regmap_update_bits(afe->regmap, AFE440X_CONTROL2, in afe4403_resume()
459 struct afe4403_data *afe; in afe4403_probe() local
462 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*afe)); in afe4403_probe()
466 afe = iio_priv(indio_dev); in afe4403_probe()
469 afe->dev = &spi->dev; in afe4403_probe()
470 afe->spi = spi; in afe4403_probe()
471 afe->irq = spi->irq; in afe4403_probe()
473 afe->regmap = devm_regmap_init_spi(spi, &afe4403_regmap_config); in afe4403_probe()
474 if (IS_ERR(afe->regmap)) { in afe4403_probe()
475 dev_err(afe->dev, "Unable to allocate register map\n"); in afe4403_probe()
476 return PTR_ERR(afe->regmap); in afe4403_probe()
480 afe->fields[i] = devm_regmap_field_alloc(afe->dev, afe->regmap, in afe4403_probe()
482 if (IS_ERR(afe->fields[i])) { in afe4403_probe()
483 dev_err(afe->dev, "Unable to allocate regmap fields\n"); in afe4403_probe()
484 return PTR_ERR(afe->fields[i]); in afe4403_probe()
488 afe->regulator = devm_regulator_get(afe->dev, "tx_sup"); in afe4403_probe()
489 if (IS_ERR(afe->regulator)) in afe4403_probe()
490 return dev_err_probe(afe->dev, PTR_ERR(afe->regulator), in afe4403_probe()
493 ret = regulator_enable(afe->regulator); in afe4403_probe()
495 dev_err(afe->dev, "Unable to enable regulator\n"); in afe4403_probe()
499 ret = regmap_write(afe->regmap, AFE440X_CONTROL0, in afe4403_probe()
502 dev_err(afe->dev, "Unable to reset device\n"); in afe4403_probe()
506 ret = regmap_multi_reg_write(afe->regmap, afe4403_reg_sequences, in afe4403_probe()
509 dev_err(afe->dev, "Unable to set register defaults\n"); in afe4403_probe()
519 if (afe->irq > 0) { in afe4403_probe()
520 afe->trig = devm_iio_trigger_alloc(afe->dev, in afe4403_probe()
524 if (!afe->trig) { in afe4403_probe()
525 dev_err(afe->dev, "Unable to allocate IIO trigger\n"); in afe4403_probe()
530 iio_trigger_set_drvdata(afe->trig, indio_dev); in afe4403_probe()
532 ret = iio_trigger_register(afe->trig); in afe4403_probe()
534 dev_err(afe->dev, "Unable to register IIO trigger\n"); in afe4403_probe()
538 ret = devm_request_threaded_irq(afe->dev, afe->irq, in afe4403_probe()
542 afe->trig); in afe4403_probe()
544 dev_err(afe->dev, "Unable to request IRQ\n"); in afe4403_probe()
552 dev_err(afe->dev, "Unable to setup buffer\n"); in afe4403_probe()
558 dev_err(afe->dev, "Unable to register IIO device\n"); in afe4403_probe()
567 if (afe->irq > 0) in afe4403_probe()
568 iio_trigger_unregister(afe->trig); in afe4403_probe()
570 regulator_disable(afe->regulator); in afe4403_probe()
578 struct afe4403_data *afe = iio_priv(indio_dev); in afe4403_remove() local
585 if (afe->irq > 0) in afe4403_remove()
586 iio_trigger_unregister(afe->trig); in afe4403_remove()
588 ret = regulator_disable(afe->regulator); in afe4403_remove()
590 dev_warn(afe->dev, "Unable to disable regulator\n"); in afe4403_remove()