From patchwork Fri Jul 6 10:56:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 169412 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9E8C32C0083 for ; Fri, 6 Jul 2012 21:02:07 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sn6DQ-0003Pj-1F; Fri, 06 Jul 2012 10:56:48 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sn6Cw-0003PU-Mb for linux-arm-kernel@lists.infradead.org; Fri, 06 Jul 2012 10:56:21 +0000 Received: by wibhm2 with SMTP id hm2so491399wib.0 for ; Fri, 06 Jul 2012 03:56:11 -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:x-gm-message-state; bh=HbMlywheHbDQyhslOi6NY/x900AmhJU7ujN7LN487yg=; b=CMjxHYQLg5KvYo8YCzX74S9wzDkcnvtwChPaWdF4dZ/QjUMKRmRphsZKVdNuJwe7bX URF4x9dHtZQHIUSHxZT7PAHKAvsCrW26xNYLXEUtknxc4KK95tTf0AEbbTZTrgxvHKgk 5mJ+ku+v+J9GEPaPtsuqiFRYqc00XFr5yCebJnOzv59smjhsWcfM7leTSLyD6w7RZ+YU 83SQgyhpJ5gZgBQqJDAXKNPuOH8WFKkH/dVytadheN75vIN33wJYg0sN173Eos1MpdGs kJ98tUIgP6YKzGkQCG6cZLneflFsQTKFfu+FGGqNVXFudNIfxkvolEt1Wo/+ABLy54y2 bedQ== Received: by 10.216.138.73 with SMTP id z51mr9981475wei.39.1341572171174; Fri, 06 Jul 2012 03:56:11 -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 bc2sm7974892wib.0.2012.07.06.03.56.09 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 06 Jul 2012 03:56:10 -0700 (PDT) From: Javier Martin To: linux-media@vger.kernel.org Subject: [PATCH] [v3] i.MX27: Fix emma-prp clocks in mx2_camera.c Date: Fri, 6 Jul 2012 12:56:02 +0200 Message-Id: <1341572162-29126-1-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQkxIKXtdcnZTKIw++2OBKSnAlYOFj65tHR2N+AnOxxL1G8PoHMhWd0QIKjTx7fW+Nh+PHsX 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.169 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, mchehab@infradead.org, laurent.pinchart@ideasonboard.com, kernel@pengutronix.de, 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-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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org This driver wasn't converted to the new clock changes (clk_prepare_enable/clk_disable_unprepare). Also naming of emma-prp related clocks for the i.MX27 was not correct. --- Enable clocks only for i.MX27. --- arch/arm/mach-imx/clk-imx27.c | 8 +++-- drivers/media/video/mx2_camera.c | 67 ++++++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c index 295cbd7..373c8fd 100644 --- a/arch/arm/mach-imx/clk-imx27.c +++ b/arch/arm/mach-imx/clk-imx27.c @@ -223,7 +223,7 @@ int __init mx27_clocks_init(unsigned long fref) clk_register_clkdev(clk[per3_gate], "per", "imx-fb.0"); clk_register_clkdev(clk[lcdc_ipg_gate], "ipg", "imx-fb.0"); clk_register_clkdev(clk[lcdc_ahb_gate], "ahb", "imx-fb.0"); - clk_register_clkdev(clk[csi_ahb_gate], NULL, "mx2-camera.0"); + clk_register_clkdev(clk[csi_ahb_gate], "ahb", "mx2-camera.0"); clk_register_clkdev(clk[usb_div], "per", "fsl-usb2-udc"); clk_register_clkdev(clk[usb_ipg_gate], "ipg", "fsl-usb2-udc"); clk_register_clkdev(clk[usb_ahb_gate], "ahb", "fsl-usb2-udc"); @@ -250,8 +250,10 @@ int __init mx27_clocks_init(unsigned long fref) clk_register_clkdev(clk[i2c2_ipg_gate], NULL, "imx-i2c.1"); clk_register_clkdev(clk[owire_ipg_gate], NULL, "mxc_w1.0"); clk_register_clkdev(clk[kpp_ipg_gate], NULL, "imx-keypad"); - clk_register_clkdev(clk[emma_ahb_gate], "ahb", "imx-emma"); - clk_register_clkdev(clk[emma_ipg_gate], "ipg", "imx-emma"); + clk_register_clkdev(clk[emma_ahb_gate], "emma-ahb", "mx2-camera.0"); + clk_register_clkdev(clk[emma_ipg_gate], "emma-ipg", "mx2-camera.0"); + clk_register_clkdev(clk[emma_ahb_gate], "ahb", "m2m-emmaprp.0"); + clk_register_clkdev(clk[emma_ipg_gate], "ipg", "m2m-emmaprp.0"); clk_register_clkdev(clk[iim_ipg_gate], "iim", NULL); clk_register_clkdev(clk[gpio_ipg_gate], "gpio", NULL); clk_register_clkdev(clk[brom_ahb_gate], "brom", NULL); diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 41f9a25..11a9353 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c @@ -270,7 +270,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; @@ -389,7 +389,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); @@ -417,9 +418,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; @@ -1616,23 +1619,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: @@ -1655,6 +1647,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; @@ -1668,11 +1661,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; @@ -1768,8 +1776,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)); } @@ -1781,7 +1789,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: @@ -1795,7 +1807,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()) @@ -1808,8 +1819,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));