From patchwork Thu Jul 26 11:20:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 1241971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 66667DFFBF for ; Thu, 26 Jul 2012 11:55:34 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SuMYn-000116-Bd; Thu, 26 Jul 2012 11:48:53 +0000 Received: from mail-wi0-f171.google.com ([209.85.212.171]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SuM81-0003Oo-6h for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2012 11:21:16 +0000 Received: by wibhq4 with SMTP id hq4so4668161wib.0 for ; Thu, 26 Jul 2012 04:20:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=DgzrGOLnqWyPLkVomp/Tsbtp/Jp5NlIQcLlIbPFbv+E=; b=W3jgG5jhfu4qeeK0kjMDsVv2RQ4/3/D4zutx+jvRI7m79XnMVhZOcS44ayeccqSq9X /uSTp7sVWSByCEnLLaBppj/LVPQVYxHaMjOETCuycBmvURH1XtVtTp7OU6Jg/hxVmed1 LUK6pv1R3JMqBFA+37guSshRk4tbqz5fKJQEHAlPb3emPQWUbBttrG0H7JUfavTbFrfg 10/NbrtbIRWk47sl/qlgvMWT0AQBqgtwdD5Wo6lKgG84glmFzVwW+Yj5dGBDwQoSF0Le u0n+kWK2jtB0JGm7Z67DJ2RfO8AsBPJyrt3WX3aASininlm1mogI5R1KBcslKMTabbKt ZzHA== Received: by 10.180.78.4 with SMTP id x4mr12618309wiw.19.1343301655905; Thu, 26 Jul 2012 04:20:55 -0700 (PDT) Received: from piscis.vsilicon.net (96.252.106.212.dynamic.jazztel.es. [212.106.252.96]) by mx.google.com with ESMTPS id o2sm11826677wiz.11.2012.07.26.04.20.53 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jul 2012 04:20:55 -0700 (PDT) From: Javier Martin To: linux-media@vger.kernel.org Subject: [PATCH 4/4] media: mx2_camera: Fix clock handling for i.MX27. Date: Thu, 26 Jul 2012 13:20:37 +0200 Message-Id: <1343301637-19676-5-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1343301637-19676-1-git-send-email-javier.martin@vista-silicon.com> References: <1343301637-19676-1-git-send-email-javier.martin@vista-silicon.com> X-Gm-Message-State: ALoCoQlG7OHh/4BTZg30wUxHw8Nnq4LNEP8Yl9+ON8WZ+29elxKzOasd8errmCogNmDg2WzqgcuB X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.171 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: fabio.estevam@freescale.com, sakari.ailus@maxwell.research.nokia.com, kernel@pengutronix.de, mchehab@infradead.org, kyungmin.park@samsung.com, laurent.pinchart@ideasonboard.com, s.nawrocki@samsung.com, linux@arm.linux.org.uk, g.liakhovetski@gmx.de, linux-arm-kernel@lists.infradead.org, Javier Martin X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This driver wasn't converted to the new clock framework (e038ed50a4a767add205094c035b6943e7b30140). Signed-off-by: Javier Martin --- drivers/media/video/mx2_camera.c | 67 ++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 3c38b5f..88dcae6 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -273,7 +273,7 @@ struct mx2_camera_dev { struct device *dev; struct soc_camera_host soc_host; struct soc_camera_device *icd; - struct clk *clk_csi, *clk_emma; + struct clk *clk_csi, *clk_emma_ahb, *clk_emma_ipg; unsigned int irq_csi, irq_emma; void __iomem *base_csi, *base_emma; @@ -436,7 +436,8 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev) { unsigned long flags; - clk_disable(pcdev->clk_csi); + if (cpu_is_mx27()) + clk_disable_unprepare(pcdev->clk_csi); writel(0, pcdev->base_csi + CSICR1); if (cpu_is_mx27()) { writel(0, pcdev->base_emma + PRP_CNTL); @@ -464,9 +465,11 @@ static int mx2_camera_add_device(struct soc_camera_device *icd) if (pcdev->icd) return -EBUSY; - ret = clk_enable(pcdev->clk_csi); - if (ret < 0) - return ret; + if (cpu_is_mx27()) { + ret = clk_prepare_enable(pcdev->clk_csi); + if (ret < 0) + return ret; + } csicr1 = CSICR1_MCLKEN; @@ -1675,23 +1678,12 @@ static int __devinit mx27_camera_emma_init(struct mx2_camera_dev *pcdev) goto exit_iounmap; } - pcdev->clk_emma = clk_get(NULL, "emma"); - if (IS_ERR(pcdev->clk_emma)) { - err = PTR_ERR(pcdev->clk_emma); - goto exit_free_irq; - } - - clk_enable(pcdev->clk_emma); - err = mx27_camera_emma_prp_reset(pcdev); if (err) - goto exit_clk_emma_put; + goto exit_free_irq; return err; -exit_clk_emma_put: - clk_disable(pcdev->clk_emma); - clk_put(pcdev->clk_emma); exit_free_irq: free_irq(pcdev->irq_emma, pcdev); exit_iounmap: @@ -1714,6 +1706,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) res_csi = platform_get_resource(pdev, IORESOURCE_MEM, 0); irq_csi = platform_get_irq(pdev, 0); + if (res_csi == NULL || irq_csi < 0) { dev_err(&pdev->dev, "Missing platform resources data\n"); err = -ENODEV; @@ -1727,11 +1720,26 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) goto exit; } - pcdev->clk_csi = clk_get(&pdev->dev, NULL); - if (IS_ERR(pcdev->clk_csi)) { - dev_err(&pdev->dev, "Could not get csi clock\n"); - err = PTR_ERR(pcdev->clk_csi); - goto exit_kfree; + if (cpu_is_mx27()) { + pcdev->clk_csi = devm_clk_get(&pdev->dev, "ahb"); + if (IS_ERR(pcdev->clk_csi)) { + dev_err(&pdev->dev, "Could not get csi clock\n"); + err = PTR_ERR(pcdev->clk_csi); + goto exit_kfree; + } + pcdev->clk_emma_ipg = devm_clk_get(&pdev->dev, "emma-ipg"); + if (IS_ERR(pcdev->clk_emma_ipg)) { + err = PTR_ERR(pcdev->clk_emma_ipg); + goto exit_kfree; + } + pcdev->clk_emma_ahb = devm_clk_get(&pdev->dev, "emma-ahb"); + if (IS_ERR(pcdev->clk_emma_ahb)) { + err = PTR_ERR(pcdev->clk_emma_ahb); + goto exit_kfree; + } + clk_prepare_enable(pcdev->clk_csi); + clk_prepare_enable(pcdev->clk_emma_ipg); + clk_prepare_enable(pcdev->clk_emma_ahb); } pcdev->res_csi = res_csi; @@ -1827,8 +1835,8 @@ exit_free_emma: eallocctx: if (cpu_is_mx27()) { free_irq(pcdev->irq_emma, pcdev); - clk_disable(pcdev->clk_emma); - clk_put(pcdev->clk_emma); + clk_disable_unprepare(pcdev->clk_emma_ipg); + clk_disable_unprepare(pcdev->clk_emma_ahb); iounmap(pcdev->base_emma); release_mem_region(pcdev->res_emma->start, resource_size(pcdev->res_emma)); } @@ -1840,7 +1848,11 @@ exit_iounmap: exit_release: release_mem_region(res_csi->start, resource_size(res_csi)); exit_dma_free: - clk_put(pcdev->clk_csi); + if (cpu_is_mx27()) { + clk_disable_unprepare(pcdev->clk_emma_ipg); + clk_disable_unprepare(pcdev->clk_emma_ahb); + clk_disable_unprepare(pcdev->clk_csi); + } exit_kfree: kfree(pcdev); exit: @@ -1854,7 +1866,6 @@ static int __devexit mx2_camera_remove(struct platform_device *pdev) struct mx2_camera_dev, soc_host); struct resource *res; - clk_put(pcdev->clk_csi); if (cpu_is_mx25()) free_irq(pcdev->irq_csi, pcdev); if (cpu_is_mx27()) @@ -1867,8 +1878,8 @@ static int __devexit mx2_camera_remove(struct platform_device *pdev) iounmap(pcdev->base_csi); if (cpu_is_mx27()) { - clk_disable(pcdev->clk_emma); - clk_put(pcdev->clk_emma); + clk_disable_unprepare(pcdev->clk_emma_ipg); + clk_disable_unprepare(pcdev->clk_emma_ahb); iounmap(pcdev->base_emma); res = pcdev->res_emma; release_mem_region(res->start, resource_size(res));