Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp494062pxb; Mon, 8 Nov 2021 17:19:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJw88jQq3M4IIEB1cAtfxbIARK6zn+YiXXtK85DEPZ57SU8QYacATSPL8iNBynktfzpbY702 X-Received: by 2002:a17:907:2d87:: with SMTP id gt7mr4558563ejc.554.1636420740204; Mon, 08 Nov 2021 17:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636420740; cv=none; d=google.com; s=arc-20160816; b=Qag4PuF3BwNI6xTQYwooVisD7/mlwwNhsUH3+/ZK9SeCWVDbxOoz5AkBUNYPonbFi5 aFhqNUlvIGy1fOO+LH8lVAAnQwT3DCdPDNv8l+bO+XNdyvYtIzJXps0Ke4cSxvAukAtW Clob5AoExvr/jwA+iBssT75hjVFprSsXRUynKFaFtE0yDv1v/6lWIc89/HSpDU7tVSaz +ZNwfxryiLEb8LClMIOKaDO9FipIYeoLnfBtYT7e1OGxxD5J16qx2NzkOK4aX1Ustjc4 ZHrFyAeluNiXcc4F/Fxfj7+1I92qONzDmldTOHgMEvOZpLkTIjtWnaneqVtt5pr8u6I0 80kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=yLlLPUtE0yTjTB2NBw7ypx9c7Qetgw1+8Z3u1YmF5K4=; b=hB6OriiLf64GPEwN30HY+jnUJ4jpyf0RtZwz833MsHFMF5QmiURKaCft2oIn0dH1+d Vc4blAmfLmj0JY9Yk1peiLeMOth0PAxbhO+6BTDngv4bVpzWUkt7PBbdA0TacptkLmAO YxaYxRQdlFRhEjwwM3wX8ZMBI78dXKCOUxQ1Pt3c3UnehPCu5RgU7SFayXQV1ZYYaa0J xaVYWZiCqyNO2RHATF9u4Hv1lz+e8BxEbmzKHwxxrX9aQtWXrYgsN3QE95AiiwRnoMbr OLAJ/1n2o8U/bw48oPrZBMzt53x5EJadfUrqm6G1WupjiF3uN9QJ6FZt7UR4DWtP3WYC Yd8A== 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 24si26720447edv.504.2021.11.08.17.18.35; Mon, 08 Nov 2021 17:19:00 -0800 (PST) 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 S242661AbhKIBOF (ORCPT + 99 others); Mon, 8 Nov 2021 20:14:05 -0500 Received: from twspam01.aspeedtech.com ([211.20.114.71]:42080 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242136AbhKIBJm (ORCPT ); Mon, 8 Nov 2021 20:09:42 -0500 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 1A90gj1h050854; Tue, 9 Nov 2021 08:42:45 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from [192.168.2.115] (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 9 Nov 2021 09:05:59 +0800 Message-ID: Date: Tue, 9 Nov 2021 09:05:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] media: aspeed: use reset to replace clk off/on Content-Language: en-US To: Hans Verkuil , Jae Hyun Yoo , "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" References: <20211103054316.25272-1-jammy_huang@aspeedtech.com> <883dd517-7996-8c44-8cea-1c8838b367b6@linux.intel.com> <398d37a5-509f-b78b-360b-990d256bde63@xs4all.nl> From: Jammy Huang In-Reply-To: <398d37a5-509f-b78b-360b-990d256bde63@xs4all.nl> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit 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 1A90gj1h050854 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Hans, On 2021/11/8 下午 04:53, Hans Verkuil wrote: > Hi Jammy, > > On 05/11/2021 02:27, Jammy Huang wrote: >> Hi Jae, >> >> OK, I found it. >> Thanks for your help. > So just so I understand this correctly: this patch can be dropped, right? > > Regards, > > Hans Yes, aspeed clk driver will reset the related engine at clk-enabled. Thus, this modification isn't necessary. >> Regards, >> Jammy Huang >> >> Tel: 886-3-575-1185  ext.8630 >> >> ************* Email Confidentiality Notice ******************** >> DISCLAIMER: >> This message (and any attachments) may contain legally privileged and/or other confidential information. If you have received it in error, please notify the sender by reply e-mail and immediately delete the e-mail and any attachments without copying or disclosing the contents. Thank you. >> >> -----Original Message----- >> From: Jae Hyun Yoo >> Sent: Thursday, November 4, 2021 11:54 PM >> To: Jammy Huang ; 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: Re: [PATCH] media: aspeed: use reset to replace clk off/on >> >> Hi Jammy, >> >> On 11/2/2021 10:43 PM, Jammy Huang wrote: >>> 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); >> You can find the ECLK configuration in 'clk-aspeed.c' or in 'clk-ast2600.c' that it's coupled with the video engine reset (SCU04[6] for AST2500 / SCU040[6] for AST2600). It means that if we call >> clk_disable() and clk_enable() through aspeed_video_off() and aspeed_video_on(), the video engine reset will be implicitly asserted and de-asserted by the clock driver so the reset mechanism is already in the existing code. >> >> Thanks, >> Jae >> >>> 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"); >>> -- Best Regards Jammy