From: Alisa-Dariana Roman <alisadariana@gmail.com>
To: "Alisa-Dariana Roman" <alisa.roman@analog.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
"David Lechner" <dlechner@baylibre.com>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Subject: [PATCH v1 1/3] iio: adc: ad_sigma_delta: Add CS assert function
Date: Sat, 21 Dec 2024 17:56:00 +0200 [thread overview]
Message-ID: <20241221155926.81954-2-alisa.roman@analog.com> (raw)
In-Reply-To: <20241221155926.81954-1-alisa.roman@analog.com>
Some sigma-delta ADCs, such as AD7191 and AD7780, have no registers and
start conversion when CS is asserted. Add helper function to support
this use case by allowing devices to assert CS without performing
register operations.
This function can be used by drivers through their set_mode callback.
Signed-off-by: Alisa-Dariana Roman <alisa.roman@analog.com>
---
drivers/iio/adc/ad_sigma_delta.c | 24 ++++++++++++++++++++++++
include/linux/iio/adc/ad_sigma_delta.h | 1 +
2 files changed, 25 insertions(+)
diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index 0f355dac7813..c0f33d4baddf 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -48,6 +48,30 @@ void ad_sd_set_comm(struct ad_sigma_delta *sigma_delta, uint8_t comm)
}
EXPORT_SYMBOL_NS_GPL(ad_sd_set_comm, "IIO_AD_SIGMA_DELTA");
+/**
+ * ad_sd_assert_cs() - Assert chip select line
+ *
+ * @sigma_delta: The sigma delta device
+ *
+ * Returns 0 on success, an error code otherwise.
+ **/
+int ad_sd_assert_cs(struct ad_sigma_delta *sigma_delta)
+{
+ struct spi_transfer t = {
+ .len = 0,
+ .cs_change = sigma_delta->keep_cs_asserted,
+ };
+ struct spi_message m;
+
+ spi_message_init(&m);
+ spi_message_add_tail(&t, &m);
+
+ if (sigma_delta->bus_locked)
+ return spi_sync_locked(sigma_delta->spi, &m);
+ return spi_sync(sigma_delta->spi, &m);
+}
+EXPORT_SYMBOL_NS_GPL(ad_sd_assert_cs, IIO_AD_SIGMA_DELTA);
+
/**
* ad_sd_write_reg() - Write a register
*
diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h
index 417073c52380..99ab56d04793 100644
--- a/include/linux/iio/adc/ad_sigma_delta.h
+++ b/include/linux/iio/adc/ad_sigma_delta.h
@@ -178,6 +178,7 @@ static inline int ad_sigma_delta_postprocess_sample(struct ad_sigma_delta *sd,
}
void ad_sd_set_comm(struct ad_sigma_delta *sigma_delta, uint8_t comm);
+int ad_sd_assert_cs(struct ad_sigma_delta *sigma_delta);
int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
unsigned int size, unsigned int val);
int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
--
2.43.0
next prev parent reply other threads:[~2024-12-21 15:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-21 15:55 [PATCH v0 0/3] Add support for AD7191 Alisa-Dariana Roman
2024-12-21 15:56 ` Alisa-Dariana Roman [this message]
2024-12-22 18:07 ` [PATCH v1 1/3] iio: adc: ad_sigma_delta: Add CS assert function Jonathan Cameron
2025-01-21 9:36 ` Alisa-Dariana Roman
2025-01-21 22:32 ` David Lechner
2025-01-22 12:26 ` Alisa-Dariana Roman
2024-12-21 15:56 ` [PATCH v1 2/3] dt-bindings: iio: adc: add AD7191 Alisa-Dariana Roman
2024-12-22 14:48 ` Conor Dooley
2024-12-22 18:18 ` Jonathan Cameron
2024-12-24 20:27 ` Conor Dooley
2024-12-27 8:53 ` Krzysztof Kozlowski
2024-12-21 15:56 ` [PATCH v1 3/3] iio: adc: ad7191: " Alisa-Dariana Roman
2024-12-22 18:54 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241221155926.81954-2-alisa.roman@analog.com \
--to=alisadariana@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=alisa.roman@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ukleinek@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®