mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH 1/3] aiodev: rockchip_saradc: Add reset control support
Date: Thu, 16 Jan 2025 20:01:52 +0300	[thread overview]
Message-ID: <20250116170154.104253-1-eagle.alexander923@gmail.com> (raw)

This adds reset control support for the Rockchip ADC driver.

Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
 drivers/aiodev/rockchip_saradc.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/aiodev/rockchip_saradc.c b/drivers/aiodev/rockchip_saradc.c
index 3c5c0e94da..b31804fc39 100644
--- a/drivers/aiodev/rockchip_saradc.c
+++ b/drivers/aiodev/rockchip_saradc.c
@@ -8,8 +8,9 @@
 
 #include <common.h>
 #include <aiodev.h>
-#include <linux/clk.h>
 #include <regulator.h>
+#include <linux/clk.h>
+#include <linux/reset.h>
 
 #define SARADC_DATA	       0x00
 
@@ -37,6 +38,7 @@ struct rockchip_saradc_data {
 	struct clk *pclk;
 	struct aiodevice aiodev;
 	struct aiochannel *channels;
+	struct reset_control *reset;
 };
 
 static inline void rockchip_saradc_reg_wr(struct rockchip_saradc_data *data,
@@ -51,6 +53,13 @@ static inline u32 rockchip_saradc_reg_rd(struct rockchip_saradc_data *data,
 	return readl(data->base + reg);
 }
 
+static void rockchip_saradc_reset_controller(struct reset_control *reset)
+{
+	reset_control_assert(reset);
+	udelay(20);
+	reset_control_deassert(reset);
+}
+
 static int rockchip_saradc_read(struct aiochannel *chan, int *val)
 {
 	struct rockchip_saradc_data *data;
@@ -163,14 +172,20 @@ static int rockchip_saradc_probe(struct device *dev)
 
 	rockchip_saradc_reg_wr(data, 0, SARADC_CTRL);
 
+	data->reset = reset_control_get(dev, "saradc-apb");
+
 	ret = aiodevice_register(&data->aiodev);
 	if (ret)
 		goto fail_channels;
 
+	rockchip_saradc_reset_controller(data->reset);
+
 	dev_info(dev, "registered as %s\n", dev_name(&data->aiodev.dev));
+
 	return 0;
 
 fail_channels:
+	reset_control_put(data->reset);
 	kfree(data->channels);
 	kfree(data->aiodev.channels);
 
-- 
2.38.2




             reply	other threads:[~2025-01-16 17:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 17:01 Alexander Shiyan [this message]
2025-01-16 17:01 ` [PATCH 2/3] aiodev: rockchip_saradc: Prepare driver to add support for other SARADC variants Alexander Shiyan
2025-01-16 17:01 ` [PATCH 3/3] aiodev: rockchip_saradc: Add support for RK3588 Alexander Shiyan
2025-01-21  8:27 ` [PATCH 1/3] aiodev: rockchip_saradc: Add reset control support Sascha Hauer

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=20250116170154.104253-1-eagle.alexander923@gmail.com \
    --to=eagle.alexander923@gmail.com \
    --cc=barebox@lists.infradead.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