Skip to contentSkip to conversation

iio: dac: add backend debugfs direct_reg_access

PATCH Applied Nuno Sa 2 participants 4 messages Aug 6, 2024

Subsystems (4)
lore
Share & tools
lore

Nuno Sa

author maintainer
#0 lore raw

cover iio: dac: add backend debugfs direct_reg_access

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á

author maintainer
#1 lore raw

PATCH 1/2 iio: dac: adi-axi-dac: support debugfs direct_reg_access

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

---
 drivers/iio/dac/adi-axi-dac.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/iio/dac/adi-axi-dac.c +12 -0
index 9655705b158b..0cb00f3bec04 100644
@@ -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 = {
Signature · 1 line
2.45.2
author maintainer
#2 lore raw

PATCH 2/2 iio: dac: ad9739a: add backend debugfs interface

In reply to Nuno Sa

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

---
 drivers/iio/dac/ad9739a.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/iio/dac/ad9739a.c +7 -1
index 799387f21b9f..615d1a196db3 100644
@@ -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[] = {
Signature · 1 line
2.45.2
maintainer Applied
#3 lore raw
In reply to Nuno Sa
Quoted 3 lines · On Tue, 06 Aug 2024 15:35:05 +0200 Nuno Sa via B4 Relay…

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