From: Jammy Huang <jammy_huang@aspeedtech.com>
To: <eajames@linux.ibm.com>, <mchehab@kernel.org>, <joel@jms.id.au>,
<andrew@aj.id.au>, <linux-media@vger.kernel.org>,
<openbmc@lists.ozlabs.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-aspeed@lists.ozlabs.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] media: aspeed: use reset to replace clk off/on
Date: Wed, 3 Nov 2021 13:43:16 +0800 [thread overview]
Message-ID: <20211103054316.25272-1-jammy_huang@aspeedtech.com> (raw)
reset should be more proper than clk off/on to bring HW back to good
state.
Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
---
drivers/media/platform/aspeed-video.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index fea5e4d0927e..10d182139809 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -23,6 +23,7 @@
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <linux/ktime.h>
+#include <linux/reset.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
@@ -220,6 +221,7 @@ struct aspeed_video {
void __iomem *base;
struct clk *eclk;
struct clk *vclk;
+ struct reset_control *reset;
struct device *dev;
struct v4l2_ctrl_handler ctrl_handler;
@@ -554,6 +556,13 @@ static void aspeed_video_on(struct aspeed_video *video)
set_bit(VIDEO_CLOCKS_ON, &video->flags);
}
+static void aspeed_video_reset(struct aspeed_video *v)
+{
+ reset_control_assert(v->reset);
+ udelay(100);
+ reset_control_deassert(v->reset);
+}
+
static void aspeed_video_bufs_done(struct aspeed_video *video,
enum vb2_buffer_state state)
{
@@ -574,7 +583,9 @@ static void aspeed_video_irq_res_change(struct aspeed_video *video, ulong delay)
set_bit(VIDEO_RES_CHANGE, &video->flags);
clear_bit(VIDEO_FRAME_INPRG, &video->flags);
- aspeed_video_off(video);
+ aspeed_video_write(video, VE_INTERRUPT_CTRL, 0);
+ aspeed_video_write(video, VE_INTERRUPT_STATUS, 0xffffffff);
+ aspeed_video_reset(video);
aspeed_video_bufs_done(video, VB2_BUF_STATE_ERROR);
schedule_delayed_work(&video->res_work, delay);
@@ -1507,8 +1518,7 @@ static void aspeed_video_stop_streaming(struct vb2_queue *q)
* Need to force stop any DMA and try and get HW into a good
* state for future calls to start streaming again.
*/
- aspeed_video_off(video);
- aspeed_video_on(video);
+ aspeed_video_reset(video);
aspeed_video_init_regs(video);
@@ -1715,6 +1725,12 @@ static int aspeed_video_init(struct aspeed_video *video)
return rc;
}
+ video->reset = devm_reset_control_get(dev, NULL);
+ if (IS_ERR(video->reset)) {
+ dev_err(dev, "Unable to get reset\n");
+ return PTR_ERR(video->reset);
+ }
+
video->eclk = devm_clk_get(dev, "eclk");
if (IS_ERR(video->eclk)) {
dev_err(dev, "Unable to get ECLK\n");
--
2.25.1
next reply other threads:[~2021-11-03 5:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 5:43 Jammy Huang [this message]
2021-11-04 15:54 ` Jae Hyun Yoo
2021-11-05 1:27 ` Jammy Huang
2021-11-08 8:53 ` Hans Verkuil
2021-11-09 1:05 ` Jammy Huang
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=20211103054316.25272-1-jammy_huang@aspeedtech.com \
--to=jammy_huang@aspeedtech.com \
--cc=andrew@aj.id.au \
--cc=eajames@linux.ibm.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=openbmc@lists.ozlabs.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®