From patchwork Mon Sep 5 10:29:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Wu X-Patchwork-Id: 1124792 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p85AUo3l016949 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 5 Sep 2011 10:31:11 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1R0WRT-0000VS-Dv; Mon, 05 Sep 2011 10:30:15 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1R0WRT-00020p-35; Mon, 05 Sep 2011 10:30:15 +0000 Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1R0WRO-00020X-4j for linux-arm-kernel@lists.infradead.org; Mon, 05 Sep 2011 10:30:12 +0000 Received: from penbh01.corp.atmel.com ([10.168.5.31]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id p85AQZLb004591; Mon, 5 Sep 2011 03:26:36 -0700 (PDT) Received: from penmb01.corp.atmel.com ([10.168.5.33]) by penbh01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 5 Sep 2011 18:29:55 +0800 Received: from localhost.localdomain ([10.217.2.52]) by penmb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 5 Sep 2011 18:29:54 +0800 From: Josh Wu To: g.liakhovetski@gmx.de, linux-media@vger.kernel.org, plagnioj@jcrosoft.com Subject: [PATCH] [media] at91: add code to initialize and manage the ISI_MCK for Atmel ISI driver. Date: Mon, 5 Sep 2011 18:29:53 +0800 Message-Id: <1315218593-10822-1-git-send-email-josh.wu@atmel.com> X-Mailer: git-send-email 1.6.3.3 X-OriginalArrivalTime: 05 Sep 2011 10:29:54.0592 (UTC) FILETIME=[C0921200:01CC6BB6] X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110905_063010_377705_16303E28 X-CRM114-Status: GOOD ( 14.97 ) X-Spam-Score: -0.5 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Josh Wu , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 05 Sep 2011 10:31:11 +0000 (UTC) This patch enable the configuration for ISI_MCK, which is provided by programmable clock. Signed-off-by: Josh Wu --- drivers/media/video/atmel-isi.c | 56 ++++++++++++++++++++++++++++++++++++++- include/media/atmel-isi.h | 4 +++ 2 files changed, 59 insertions(+), 1 deletions(-) diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c index 7b89f00..8bb59a8 100644 --- a/drivers/media/video/atmel-isi.c +++ b/drivers/media/video/atmel-isi.c @@ -90,7 +90,10 @@ struct atmel_isi { struct isi_dma_desc dma_desc[MAX_BUFFER_NUM]; struct completion complete; + /* ISI peripherial clock */ struct clk *pclk; + /* ISI_MCK, provided by PCK */ + struct clk *mck; unsigned int irq; struct isi_platform_data *pdata; @@ -763,6 +766,10 @@ static int isi_camera_add_device(struct soc_camera_device *icd) if (ret) return ret; + ret = clk_enable(isi->mck); + if (ret) + return ret; + isi->icd = icd; dev_dbg(icd->parent, "Atmel ISI Camera driver attached to camera %d\n", icd->devnum); @@ -776,6 +783,7 @@ static void isi_camera_remove_device(struct soc_camera_device *icd) BUG_ON(icd != isi->icd); + clk_disable(isi->mck); clk_disable(isi->pclk); isi->icd = NULL; @@ -882,6 +890,46 @@ static struct soc_camera_host_ops isi_soc_camera_host_ops = { }; /* -----------------------------------------------------------------------*/ +static int initialize_mck(struct atmel_isi *isi, + struct isi_platform_data *pdata) +{ + int ret; + struct clk *pck_parent; + + if (!strlen(pdata->pck_name) || !strlen(pdata->pck_parent_name)) + return -EINVAL; + + /* ISI_MCK is provided by PCK clock */ + isi->mck = clk_get(NULL, pdata->pck_name); + if (IS_ERR(isi->mck)) { + printk(KERN_ERR "Failed to get PCK: %s\n", pdata->pck_name); + return PTR_ERR(isi->mck); + } + + pck_parent = clk_get(NULL, pdata->pck_parent_name); + if (IS_ERR(pck_parent)) { + ret = PTR_ERR(pck_parent); + printk(KERN_ERR "Failed to get PCK parent: %s\n", + pdata->pck_parent_name); + goto err_init_mck; + } + + ret = clk_set_parent(isi->mck, pck_parent); + clk_put(pck_parent); + if (ret) + goto err_init_mck; + + ret = clk_set_rate(isi->mck, pdata->isi_mck_hz); + if (ret < 0) + goto err_init_mck; + + return 0; + +err_init_mck: + clk_put(isi->mck); + return ret; +} + static int __devexit atmel_isi_remove(struct platform_device *pdev) { struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev); @@ -897,6 +945,7 @@ static int __devexit atmel_isi_remove(struct platform_device *pdev) isi->fb_descriptors_phys); iounmap(isi->regs); + clk_put(isi->mck); clk_put(isi->pclk); kfree(isi); @@ -915,7 +964,8 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev) struct isi_platform_data *pdata; pdata = dev->platform_data; - if (!pdata || !pdata->data_width_flags) { + if (!pdata || !pdata->data_width_flags || !pdata->isi_mck_hz + || !pdata->pck_name || !pdata->pck_parent_name) { dev_err(&pdev->dev, "No config available for Atmel ISI\n"); return -EINVAL; @@ -944,6 +994,10 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev) INIT_LIST_HEAD(&isi->video_buffer_list); INIT_LIST_HEAD(&isi->dma_desc_head); + ret = initialize_mck(isi, pdata); + if (ret) + goto err_alloc_descriptors; + isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev, sizeof(struct fbd) * MAX_BUFFER_NUM, &isi->fb_descriptors_phys, diff --git a/include/media/atmel-isi.h b/include/media/atmel-isi.h index 26cece5..dcbb822 100644 --- a/include/media/atmel-isi.h +++ b/include/media/atmel-isi.h @@ -114,6 +114,10 @@ struct isi_platform_data { u32 data_width_flags; /* Using for ISI_CFG1 */ u32 frate; + /* Using for ISI_MCK, provided by PCK */ + u32 isi_mck_hz; + const char *pck_name; + const char *pck_parent_name; }; #endif /* __ATMEL_ISI_H__ */