aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc
diff options
context:
space:
mode:
authorPeter Meerwald <pmeerw@pmeerw.net>2014-12-06 00:54:00 -0500
committerJonathan Cameron <jic23@kernel.org>2014-07-13 16:57:35 -0400
commit0f7ddcc1bff1983d0be1573f971995371669fa4f (patch)
treec1702ce3ef24db0117f8360c0e604f8d0b3c22d2 /drivers/iio/adc
parent89ca79afe50e9e9608ad3315bf099fdbb82c4eb5 (diff)
iio:adc:ad799x: Write default config on probe and reset alert status on probe
writing ALERT_EN and BUSY_ALERT to the chip config register clears pending alerts, BUSY_ALERT is cleared when reading back the register Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/adc')
-rw-r--r--drivers/iio/adc/ad799x.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
index fe2a9b1170b0..84ce9b426a48 100644
--- a/drivers/iio/adc/ad799x.c
+++ b/drivers/iio/adc/ad799x.c
@@ -595,7 +595,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
595 AD799X_CHANNEL_WITH_EVENTS(1, 12), 595 AD799X_CHANNEL_WITH_EVENTS(1, 12),
596 IIO_CHAN_SOFT_TIMESTAMP(3), 596 IIO_CHAN_SOFT_TIMESTAMP(3),
597 }, 597 },
598 .default_config = AD7998_ALERT_EN, 598 .default_config = AD7998_ALERT_EN | AD7998_BUSY_ALERT,
599 .info = &ad7993_4_7_8_irq_info, 599 .info = &ad7993_4_7_8_irq_info,
600 }, 600 },
601 }, 601 },
@@ -619,7 +619,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
619 AD799X_CHANNEL_WITH_EVENTS(3, 10), 619 AD799X_CHANNEL_WITH_EVENTS(3, 10),
620 IIO_CHAN_SOFT_TIMESTAMP(4), 620 IIO_CHAN_SOFT_TIMESTAMP(4),
621 }, 621 },
622 .default_config = AD7998_ALERT_EN, 622 .default_config = AD7998_ALERT_EN | AD7998_BUSY_ALERT,
623 .info = &ad7993_4_7_8_irq_info, 623 .info = &ad7993_4_7_8_irq_info,
624 }, 624 },
625 }, 625 },
@@ -643,7 +643,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
643 AD799X_CHANNEL_WITH_EVENTS(3, 12), 643 AD799X_CHANNEL_WITH_EVENTS(3, 12),
644 IIO_CHAN_SOFT_TIMESTAMP(4), 644 IIO_CHAN_SOFT_TIMESTAMP(4),
645 }, 645 },
646 .default_config = AD7998_ALERT_EN, 646 .default_config = AD7998_ALERT_EN | AD7998_BUSY_ALERT,
647 .info = &ad7993_4_7_8_irq_info, 647 .info = &ad7993_4_7_8_irq_info,
648 }, 648 },
649 }, 649 },
@@ -675,7 +675,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
675 AD799X_CHANNEL(7, 10), 675 AD799X_CHANNEL(7, 10),
676 IIO_CHAN_SOFT_TIMESTAMP(8), 676 IIO_CHAN_SOFT_TIMESTAMP(8),
677 }, 677 },
678 .default_config = AD7998_ALERT_EN, 678 .default_config = AD7998_ALERT_EN | AD7998_BUSY_ALERT,
679 .info = &ad7993_4_7_8_irq_info, 679 .info = &ad7993_4_7_8_irq_info,
680 }, 680 },
681 }, 681 },
@@ -707,7 +707,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = {
707 AD799X_CHANNEL(7, 12), 707 AD799X_CHANNEL(7, 12),
708 IIO_CHAN_SOFT_TIMESTAMP(8), 708 IIO_CHAN_SOFT_TIMESTAMP(8),
709 }, 709 },
710 .default_config = AD7998_ALERT_EN, 710 .default_config = AD7998_ALERT_EN | AD7998_BUSY_ALERT,
711 .info = &ad7993_4_7_8_irq_info, 711 .info = &ad7993_4_7_8_irq_info,
712 }, 712 },
713 }, 713 },
@@ -735,7 +735,6 @@ static int ad799x_probe(struct i2c_client *client,
735 st->chip_config = &chip_info->irq_config; 735 st->chip_config = &chip_info->irq_config;
736 else 736 else
737 st->chip_config = &chip_info->noirq_config; 737 st->chip_config = &chip_info->noirq_config;
738 st->config = st->chip_config->default_config;
739 738
740 /* TODO: Add pdata options for filtering and bit delay */ 739 /* TODO: Add pdata options for filtering and bit delay */
741 740
@@ -764,6 +763,14 @@ static int ad799x_probe(struct i2c_client *client,
764 indio_dev->channels = st->chip_config->channel; 763 indio_dev->channels = st->chip_config->channel;
765 indio_dev->num_channels = chip_info->num_channels; 764 indio_dev->num_channels = chip_info->num_channels;
766 765
766 ret = ad799x_write_config(st, st->chip_config->default_config);
767 if (ret < 0)
768 goto error_disable_reg;
769 ret = ad799x_read_config(st);
770 if (ret < 0)
771 goto error_disable_reg;
772 st->config = ret;
773
767 ret = iio_triggered_buffer_setup(indio_dev, NULL, 774 ret = iio_triggered_buffer_setup(indio_dev, NULL,
768 &ad799x_trigger_handler, NULL); 775 &ad799x_trigger_handler, NULL);
769 if (ret) 776 if (ret)