Linux IIO development
 help / color / mirror / Atom feed
* [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access
@ 2024-08-06 13:35 Nuno Sa via B4 Relay
  2024-08-06 13:35 ` [PATCH 1/2] iio: dac: adi-axi-dac: support " Nuno Sa via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-06 13:35 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

Implement the direct_reg_access callback in the axi-dac backend driver.
On the ad9739a frontend, call iio_backend_debugfs_add() to add the
backend debugfs interface.

---
Nuno Sa (2):
      iio: dac: adi-axi-dac: support debugfs direct_reg_access
      iio: dac: ad9739a: add backend debugfs interface

 drivers/iio/dac/ad9739a.c     |  8 +++++++-
 drivers/iio/dac/adi-axi-dac.c | 12 ++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
---
base-commit: 593737c18ae789dc6e4b493510a0c00977972e2e
change-id: 20240806-dev-backend-dac-direct-reg-access-03f2d9036ae2
--

Thanks!
- Nuno Sá



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] iio: dac: adi-axi-dac: support debugfs direct_reg_access
  2024-08-06 13:35 [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access Nuno Sa via B4 Relay
@ 2024-08-06 13:35 ` Nuno Sa via B4 Relay
  2024-08-06 13:35 ` [PATCH 2/2] iio: dac: ad9739a: add backend debugfs interface Nuno Sa via B4 Relay
  2024-08-06 16:00 ` [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-06 13:35 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

From: Nuno Sa <nuno.sa@analog.com>

Make it possible to read/write registers on the backend using the
debugfs interface for it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/dac/adi-axi-dac.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
index 9655705b158b..0cb00f3bec04 100644
--- a/drivers/iio/dac/adi-axi-dac.c
+++ b/drivers/iio/dac/adi-axi-dac.c
@@ -507,6 +507,17 @@ static int axi_dac_set_sample_rate(struct iio_backend *back, unsigned int chan,
 	return 0;
 }
 
+static int axi_dac_reg_access(struct iio_backend *back, unsigned int reg,
+			      unsigned int writeval, unsigned int *readval)
+{
+	struct axi_dac_state *st = iio_backend_get_priv(back);
+
+	if (readval)
+		return regmap_read(st->regmap, reg, readval);
+
+	return regmap_write(st->regmap, reg, writeval);
+}
+
 static const struct iio_backend_ops axi_dac_generic_ops = {
 	.enable = axi_dac_enable,
 	.disable = axi_dac_disable,
@@ -517,6 +528,7 @@ static const struct iio_backend_ops axi_dac_generic_ops = {
 	.ext_info_get = axi_dac_ext_info_get,
 	.data_source_set = axi_dac_data_source_set,
 	.set_sample_rate = axi_dac_set_sample_rate,
+	.debugfs_reg_access = iio_backend_debugfs_ptr(axi_dac_reg_access),
 };
 
 static const struct iio_backend_info axi_dac_generic = {

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] iio: dac: ad9739a: add backend debugfs interface
  2024-08-06 13:35 [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access Nuno Sa via B4 Relay
  2024-08-06 13:35 ` [PATCH 1/2] iio: dac: adi-axi-dac: support " Nuno Sa via B4 Relay
@ 2024-08-06 13:35 ` Nuno Sa via B4 Relay
  2024-08-06 16:00 ` [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Nuno Sa via B4 Relay @ 2024-08-06 13:35 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Dragos Bogdan

From: Nuno Sa <nuno.sa@analog.com>

Call iio_backend_debugfs_add() to add (if available) the backend debug
interface.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/dac/ad9739a.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad9739a.c b/drivers/iio/dac/ad9739a.c
index 799387f21b9f..615d1a196db3 100644
--- a/drivers/iio/dac/ad9739a.c
+++ b/drivers/iio/dac/ad9739a.c
@@ -431,7 +431,13 @@ static int ad9739a_probe(struct spi_device *spi)
 	indio_dev->num_channels = ARRAY_SIZE(ad9739a_channels);
 	indio_dev->setup_ops = &ad9739a_buffer_setup_ops;
 
-	return devm_iio_device_register(&spi->dev, indio_dev);
+	ret = devm_iio_device_register(&spi->dev, indio_dev);
+	if (ret)
+		return ret;
+
+	iio_backend_debugfs_add(st->back, indio_dev);
+
+	return 0;
 }
 
 static const struct of_device_id ad9739a_of_match[] = {

-- 
2.45.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access
  2024-08-06 13:35 [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access Nuno Sa via B4 Relay
  2024-08-06 13:35 ` [PATCH 1/2] iio: dac: adi-axi-dac: support " Nuno Sa via B4 Relay
  2024-08-06 13:35 ` [PATCH 2/2] iio: dac: ad9739a: add backend debugfs interface Nuno Sa via B4 Relay
@ 2024-08-06 16:00 ` Jonathan Cameron
  2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-08-06 16:00 UTC (permalink / raw)
  To: Nuno Sa via B4 Relay
  Cc: nuno.sa, linux-iio, Lars-Peter Clausen, Michael Hennerich,
	Dragos Bogdan

On Tue, 06 Aug 2024 15:35:05 +0200
Nuno Sa via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:

> Implement the direct_reg_access callback in the axi-dac backend driver.
> On the ad9739a frontend, call iio_backend_debugfs_add() to add the
> backend debugfs interface.
Applied.

Thanks,

Jonathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-06 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-06 13:35 [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access Nuno Sa via B4 Relay
2024-08-06 13:35 ` [PATCH 1/2] iio: dac: adi-axi-dac: support " Nuno Sa via B4 Relay
2024-08-06 13:35 ` [PATCH 2/2] iio: dac: ad9739a: add backend debugfs interface Nuno Sa via B4 Relay
2024-08-06 16:00 ` [PATCH 0/2] iio: dac: add backend debugfs direct_reg_access Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox