From patchwork Fri Sep 1 03:09:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou.Yang@microchip.com X-Patchwork-Id: 9933401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA5056016C for ; Fri, 1 Sep 2017 03:33:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0EC023B3C for ; Fri, 1 Sep 2017 03:33:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B51EE28396; Fri, 1 Sep 2017 03:33:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4194F23B3C for ; Fri, 1 Sep 2017 03:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xNcpEJ/n53xRJ0UxWlSDVEv8ej3yOpEFpadC5Dmh1I4=; b=n9x/lrYXVONwec UwPY9kN4MeKwLTdy9jISMXfvDqd0tnRPTKXavgt8kDLis329UR3U7I10HvTy/5Sc76hfQ3su0OCZ0 7SpLKodPLFVcoYynhFFnQFJk9WocBJbO+amYsrIombIPqpUg9lQkdKpgpQWaio2VFraqzMkJOOlvs OFpXOSRZG/wIfJm6y+UitCluXng9Nt9B5VS/BMHyoiafLLOMuvSNrJn977XTY5+hs6TgYc8q8bmry kgZB+V0JK63glOABWVg9Ujvu8+7c3D7ex8LPLzO9qS/efutJGeXKrCAkrxuirVxIT1IVguf2rd5zE uN8QOKTbN5951cISfy9A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dnchu-0002TV-Ev; Fri, 01 Sep 2017 03:33:22 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dnchs-0002L1-8e for linux-arm-kernel@bombadil.infradead.org; Fri, 01 Sep 2017 03:33:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=URRQ4LnKpLlwwlqIFLpTdY7ZeOjkvgu4VbqHwEt6To0=; b=l4FW2guJPSJGe+5PY0k5pvCtU 2XTAf7ZwLL7MOhap6C3o+3mYDESbwUtBfIRY85bhLvCCLUnaBnQCGsOrhwf8TXGOKfT6eTHgA48nL J4JW7GklfAzHJjytI6MBOriOeryhHX5Qv6R1AyT5roFsvPMaadnILMSBJXIRl77kRrQxhkaBogvQF hCN9omwQVNwOdtvfdI2e4+hVG/7pGUo83+vD5KdWSbH/DLgRhaeyLN42TyXO1T3INIlVGLrGIeGMQ DwHWmNrY7xS0vFe/QJs4gZ+zusjIdnckvsNAbhp8zB+gyORx1qZb2a+K/+nck4Z+CX/v0QhCN+oTT L5ZYfSJUw==; Received: from eusmtp01.atmel.com ([212.144.249.242]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dncQI-000390-Jx for linux-arm-kernel@lists.infradead.org; Fri, 01 Sep 2017 03:15:12 +0000 Received: from apsmtp01.atmel.com (10.168.254.31) by eusmtp01.atmel.com (10.145.145.30) with Microsoft SMTP Server id 14.3.235.1; Fri, 1 Sep 2017 05:14:11 +0200 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.atmel.com (10.168.254.31) with Microsoft SMTP Server id 14.3.235.1; Fri, 1 Sep 2017 11:18:27 +0800 From: Wenyou Yang To: Mauro Carvalho Chehab Subject: [PATCH 3/4] media: atmel-isc: Enable the clocks during probe Date: Fri, 1 Sep 2017 11:09:34 +0800 Message-ID: <20170901030935.29717-4-wenyou.yang@microchip.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170901030935.29717-1-wenyou.yang@microchip.com> References: <20170901030935.29717-1-wenyou.yang@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170901_041510_708677_DFA38449 X-CRM114-Status: GOOD ( 13.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wenyou Yang , Jonathan Corbet , linux-kernel@vger.kernel.org, Hans Verkuil , Sakari Ailus , linux-arm-kernel@lists.infradead.org, Linux Media Mailing List Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To meet the relationship, enable the HCLOCK and ispck during the device probe, "isc_pck frequency is less than or equal to isc_ispck, and isc_ispck is greater than or equal to HCLOCK." Meanwhile, call the pm_runtime_enable() in the right place. Signed-off-by: Wenyou Yang --- drivers/media/platform/atmel/atmel-isc.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/atmel/atmel-isc.c b/drivers/media/platform/atmel/atmel-isc.c index 80968f7d79f2..bc3098982d12 100644 --- a/drivers/media/platform/atmel/atmel-isc.c +++ b/drivers/media/platform/atmel/atmel-isc.c @@ -1595,6 +1595,7 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) struct isc_subdev_entity *sd_entity; struct video_device *vdev = &isc->video_dev; struct vb2_queue *q = &isc->vb2_vidq; + struct device *dev = isc->dev; int ret; ret = v4l2_device_register_subdev_nodes(&isc->v4l2_dev); @@ -1678,6 +1679,10 @@ static int isc_async_complete(struct v4l2_async_notifier *notifier) return ret; } + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + pm_request_idle(dev); + return 0; } @@ -1857,25 +1862,37 @@ static int atmel_isc_probe(struct platform_device *pdev) return ret; } + ret = clk_prepare_enable(isc->hclock); + if (ret) { + dev_err(dev, "failed to enable hclock: %d\n", ret); + return ret; + } + ret = isc_clk_init(isc); if (ret) { dev_err(dev, "failed to init isc clock: %d\n", ret); - goto clean_isc_clk; + goto unprepare_hclk; } isc->ispck = isc->isc_clks[ISC_ISPCK].clk; + ret = clk_prepare_enable(isc->ispck); + if (ret) { + dev_err(dev, "failed to enable ispck: %d\n", ret); + goto unprepare_hclk; + } + /* ispck should be greater or equal to hclock */ ret = clk_set_rate(isc->ispck, clk_get_rate(isc->hclock)); if (ret) { dev_err(dev, "failed to set ispck rate: %d\n", ret); - goto clean_isc_clk; + goto unprepare_clk; } ret = v4l2_device_register(dev, &isc->v4l2_dev); if (ret) { dev_err(dev, "unable to register v4l2 device.\n"); - goto clean_isc_clk; + goto unprepare_clk; } ret = isc_parse_dt(dev, isc); @@ -1908,8 +1925,6 @@ static int atmel_isc_probe(struct platform_device *pdev) break; } - pm_runtime_enable(dev); - return 0; cleanup_subdev: @@ -1918,7 +1933,11 @@ static int atmel_isc_probe(struct platform_device *pdev) unregister_v4l2_device: v4l2_device_unregister(&isc->v4l2_dev); -clean_isc_clk: +unprepare_clk: + clk_disable_unprepare(isc->ispck); +unprepare_hclk: + clk_disable_unprepare(isc->hclock); + isc_clk_cleanup(isc); return ret;