From: Angelo Dureghello <adureghello@baylibre.com>
To: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Angelo Dureghello <adureghello@baylibre.com>
Subject: [PATCH v2] iio: dac: ad3552r-hs: add debugfs reg access
Date: Wed, 19 Mar 2025 14:30:28 +0100 [thread overview]
Message-ID: <20250319-wip-bl-ad3552r-fixes-v2-1-2656bdd6778e@baylibre.com> (raw)
From: Angelo Dureghello <adureghello@baylibre.com>
Add debugfs register access.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
Changes in v2:
- set reg size setup as inline.
- Link to v1: https://lore.kernel.org/r/20250319-wip-bl-ad3552r-fixes-v1-1-cf10d6fae52a@baylibre.com
---
drivers/iio/dac/ad3552r-hs.c | 26 ++++++++++++++++++++++++++
drivers/iio/dac/ad3552r.h | 2 ++
2 files changed, 28 insertions(+)
diff --git a/drivers/iio/dac/ad3552r-hs.c b/drivers/iio/dac/ad3552r-hs.c
index cd8dabb60c5548780f0fce5d1b68c494cd71321d..fdea9984547ae338a51c4671024133be82ed854f 100644
--- a/drivers/iio/dac/ad3552r-hs.c
+++ b/drivers/iio/dac/ad3552r-hs.c
@@ -7,6 +7,7 @@
*/
#include <linux/bitfield.h>
+#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/iio/backend.h>
@@ -464,6 +465,30 @@ static int ad3552r_hs_setup_custom_gain(struct ad3552r_hs_state *st,
gain, 1);
}
+static int ad3552r_hs_reg_access(struct iio_dev *indio_dev, unsigned int reg,
+ unsigned int writeval, unsigned int *readval)
+{
+ struct ad3552r_hs_state *st = iio_priv(indio_dev);
+ int size_xfer, max_reg_addr;
+
+ max_reg_addr = (st->model_data->num_hw_channels == 2) ?
+ AD3552R_REG_ADDR_MAX : AD3551R_REG_ADDR_MAX;
+
+ if (reg > max_reg_addr)
+ return -EINVAL;
+
+ /*
+ * There is no 3 or 4 bytes r/w len possible in HDL, so keeping 2
+ * also for the 24bit area.
+ */
+ size_xfer = (reg > AD3552R_SECONDARY_REGION_START) ? 2 : 1;
+
+ if (readval)
+ return ad3552r_hs_reg_read(st, reg, readval, size_xfer);
+
+ return st->data->bus_reg_write(st->back, reg, writeval, size_xfer);
+}
+
static int ad3552r_hs_setup(struct ad3552r_hs_state *st)
{
u16 id;
@@ -639,6 +664,7 @@ static const struct iio_chan_spec ad3552r_hs_channels[] = {
static const struct iio_info ad3552r_hs_info = {
.read_raw = &ad3552r_hs_read_raw,
.write_raw = &ad3552r_hs_write_raw,
+ .debugfs_reg_access = &ad3552r_hs_reg_access,
};
static int ad3552r_hs_probe(struct platform_device *pdev)
diff --git a/drivers/iio/dac/ad3552r.h b/drivers/iio/dac/ad3552r.h
index 768fa264d39e9e6d517aeb4098382e072f153543..69ce96f132cdb353d2f140939c534586cb791aee 100644
--- a/drivers/iio/dac/ad3552r.h
+++ b/drivers/iio/dac/ad3552r.h
@@ -113,6 +113,8 @@
#define AD3552R_REG_ADDR_INPUT_PAGE_MASK_24B 0x44
#define AD3552R_REG_ADDR_SW_LDAC_24B 0x45
#define AD3552R_REG_ADDR_CH_INPUT_24B(ch) (0x4B - (1 - (ch)) * 3)
+#define AD3551R_REG_ADDR_MAX 0x46
+#define AD3552R_REG_ADDR_MAX 0x49
#define AD3552R_MAX_CH 2
#define AD3552R_MASK_CH(ch) BIT(ch)
---
base-commit: 6f9141cdd726e82d209b5fc6d6b5ea32ace339f1
change-id: 20250319-wip-bl-ad3552r-fixes-4fbbe9dd1d2b
Best regards,
--
Angelo Dureghello <adureghello@baylibre.com>
next reply other threads:[~2025-03-19 13:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 13:30 Angelo Dureghello [this message]
2025-03-19 14:10 ` David Lechner
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=20250319-wip-bl-ad3552r-fixes-v2-1-2656bdd6778e@baylibre.com \
--to=adureghello@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.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®