Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp32297pxb; Tue, 2 Nov 2021 22:43:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT1Kxzs63s1y+BNUxmYKi19zWqrQNf9iB+CMCBKNfnRf4bVMDrD6UiqepG4ttdlvmgP3jC X-Received: by 2002:a05:6602:1592:: with SMTP id e18mr5721967iow.58.1635918238388; Tue, 02 Nov 2021 22:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635918238; cv=none; d=google.com; s=arc-20160816; b=T7m1DBXJ8u5NbVGYGGoLg9jwDAtgm9/YmKJuASBi0p+2LnFdiM6jMywKYm2foJ8wsM KE9aikbTvEl5Gb3qGLB5o1ucmiuqOSihTvqqq7GaJT8x/RAm7JURGIq3N9ggMIUsVsHw fQN/B4e8szqL6wDw47Z6bRlymXj5b0a2xkuXEPJqBYPFYOtbVGwfeSIWxVrlKrym0R37 sRetmRw5XLJoHUPDWnXAmfhVu12cM76wpFxKBE8UbrlYazOS2sMDgPVz+Co3bNVD1FLz hC2ZXfIUdx+jEyXF2wgGjjvCSpUaQ57Cc2plDyL1k+Mtn3D/AKTLKgae0IxgOWPMO7zB PY+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=95NO/rgGZc+PnHRcYAntGA8KelOtr51ooBhSaIeM+oI=; b=C36bsnjzcgVesbT57qRUw84c3yBW6/LpBwXdCMh1d2sceLJCx488iuZ1W98J4Ae75U R9E+IfoI9Lk0OzEw8GhvLkBDDPIvAF+7G2T4qxh7Ikv1IhylmWCKZIIsaoUoEaCmC6yn drUrJ16sahhXtWJhNeWR5vqCSYBTuW07xjy2ga2VqQGXhVhyOMqc4XYhkKdw2jDiovc9 rm0fiLB0om99GtEKwyT/K3qK8cn0aoaTPFVAjIDxiB//AL3UoRB9tbSmXNRLJfmYf/KY 2g2SDDVP88axKgInrgsJNCnIJiB+nzQ6JtSXnG3mW2rcoJytYsvWspp4jtXSe7fSrhuM sQ3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si2111570ili.174.2021.11.02.22.43.46; Tue, 02 Nov 2021 22:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231254AbhKCFpW (ORCPT + 99 others); Wed, 3 Nov 2021 01:45:22 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:11088 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbhKCFpV (ORCPT ); Wed, 3 Nov 2021 01:45:21 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1A35Jl9W075146; Wed, 3 Nov 2021 13:19:47 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from JammyHuang-PC.aspeed.com (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 3 Nov 2021 13:42:38 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH] media: aspeed: use reset to replace clk off/on Date: Wed, 3 Nov 2021 13:43:16 +0800 Message-ID: <20211103054316.25272-1-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 1A35Jl9W075146 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org reset should be more proper than clk off/on to bring HW back to good state. Signed-off-by: Jammy Huang --- 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 #include #include +#include #include #include #include @@ -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