linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [media] V4L: atmel-isi: add code to enable/disable ISI_MCK clock
@ 2011-11-28 13:34 Nicolas Ferre
  2011-11-28 13:50 ` Guennadi Liakhovetski
  2011-11-28 16:00 ` Russell King - ARM Linux
  0 siblings, 2 replies; 4+ messages in thread
From: Nicolas Ferre @ 2011-11-28 13:34 UTC (permalink / raw)
  To: linux-arm-kernel, g.liakhovetski; +Cc: linux-kernel, josh.wu, linux-media

From: Josh Wu <josh.wu@atmel.com>

This patch
- add ISI_MCK clock enable/disable code.
- change field name in isi_platform_data structure

Signed-off-by: Josh Wu <josh.wu@atmel.com>
[g.liakhovetski@gmx.de: fix label names]
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
Guennadi,

Here is the pach form Josh and yourself about the Atmel ISI driver
modifications. I have rebased it on top of 3.2-rc3 (and tested it on
linux-next also).
I plan to submit the board/device related patches (2-3/3 of this series) to
the arm-soc tree real soon. Do you whant me to include this one or can you
schedulle an inclusion in mainline for 3.3?

Best regards,

 drivers/media/video/atmel-isi.c |   31 +++++++++++++++++++++++++++++--
 include/media/atmel-isi.h       |    4 +++-
 2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c
index 8c775c5..5a7ab84 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, feed to camera sensor to generate pixel clock */
+	struct clk			*mck;
 	unsigned int			irq;
 
 	struct isi_platform_data	*pdata;
@@ -766,6 +769,12 @@ static int isi_camera_add_device(struct soc_camera_device *icd)
 	if (ret)
 		return ret;
 
+	ret = clk_enable(isi->mck);
+	if (ret) {
+		clk_disable(isi->pclk);
+		return ret;
+	}
+
 	isi->icd = icd;
 	dev_dbg(icd->parent, "Atmel ISI Camera driver attached to camera %d\n",
 		 icd->devnum);
@@ -779,6 +788,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;
 
@@ -874,7 +884,7 @@ static int isi_camera_set_bus_param(struct soc_camera_device *icd, u32 pixfmt)
 
 	if (isi->pdata->has_emb_sync)
 		cfg1 |= ISI_CFG1_EMB_SYNC;
-	if (isi->pdata->isi_full_mode)
+	if (isi->pdata->full_mode)
 		cfg1 |= ISI_CFG1_FULL_MODE;
 
 	isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
@@ -912,6 +922,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);
 
@@ -930,7 +941,7 @@ 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->mck_hz) {
 		dev_err(&pdev->dev,
 			"No config available for Atmel ISI\n");
 		return -EINVAL;
@@ -959,6 +970,19 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev)
 	INIT_LIST_HEAD(&isi->video_buffer_list);
 	INIT_LIST_HEAD(&isi->dma_desc_head);
 
+	/* Get ISI_MCK, provided by programmable clock or external clock */
+	isi->mck = clk_get(dev, "isi_mck");
+	if (IS_ERR_OR_NULL(isi->mck)) {
+		dev_err(dev, "Failed to get isi_mck\n");
+		ret = isi->mck ? PTR_ERR(isi->mck) : -EINVAL;
+		goto err_clk_get;
+	}
+
+	/* Set ISI_MCK's frequency, it should be faster than pixel clock */
+	ret = clk_set_rate(isi->mck, pdata->mck_hz);
+	if (ret < 0)
+		goto err_set_mck_rate;
+
 	isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev,
 				sizeof(struct fbd) * MAX_BUFFER_NUM,
 				&isi->fb_descriptors_phys,
@@ -1034,6 +1058,9 @@ err_alloc_ctx:
 			isi->p_fb_descriptors,
 			isi->fb_descriptors_phys);
 err_alloc_descriptors:
+err_set_mck_rate:
+	clk_put(isi->mck);
+err_clk_get:
 	kfree(isi);
 err_alloc_isi:
 	clk_put(isi->pclk);
diff --git a/include/media/atmel-isi.h b/include/media/atmel-isi.h
index 26cece5..6568230 100644
--- a/include/media/atmel-isi.h
+++ b/include/media/atmel-isi.h
@@ -110,10 +110,12 @@ struct isi_platform_data {
 	u8 hsync_act_low;
 	u8 vsync_act_low;
 	u8 pclk_act_falling;
-	u8 isi_full_mode;
+	u8 full_mode;
 	u32 data_width_flags;
 	/* Using for ISI_CFG1 */
 	u32 frate;
+	/* Using for ISI_MCK */
+	u32 mck_hz;
 };
 
 #endif /* __ATMEL_ISI_H__ */
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] [media] V4L: atmel-isi: add code to enable/disable ISI_MCK clock
  2011-11-28 13:34 [PATCH] [media] V4L: atmel-isi: add code to enable/disable ISI_MCK clock Nicolas Ferre
@ 2011-11-28 13:50 ` Guennadi Liakhovetski
  2011-11-28 15:01   ` Nicolas Ferre
  2011-11-28 16:00 ` Russell King - ARM Linux
  1 sibling, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2011-11-28 13:50 UTC (permalink / raw)
  To: Nicolas Ferre; +Cc: linux-arm-kernel, linux-kernel, josh.wu, linux-media

Hi Nicolas

On Mon, 28 Nov 2011, Nicolas Ferre wrote:

> From: Josh Wu <josh.wu@atmel.com>
> 
> This patch
> - add ISI_MCK clock enable/disable code.
> - change field name in isi_platform_data structure
> 
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> [g.liakhovetski@gmx.de: fix label names]
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

Thanks for the ack. All patches, affecting drivers/media & include/media 
should go via the media tree, I'll push this one along with others for 3.3 
as appropriate.

Thanks
Guennadi

> ---
> Guennadi,
> 
> Here is the pach form Josh and yourself about the Atmel ISI driver
> modifications. I have rebased it on top of 3.2-rc3 (and tested it on
> linux-next also).
> I plan to submit the board/device related patches (2-3/3 of this series) to
> the arm-soc tree real soon. Do you whant me to include this one or can you
> schedulle an inclusion in mainline for 3.3?
> 
> Best regards,
> 
>  drivers/media/video/atmel-isi.c |   31 +++++++++++++++++++++++++++++--
>  include/media/atmel-isi.h       |    4 +++-
>  2 files changed, 32 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c
> index 8c775c5..5a7ab84 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, feed to camera sensor to generate pixel clock */
> +	struct clk			*mck;
>  	unsigned int			irq;
>  
>  	struct isi_platform_data	*pdata;
> @@ -766,6 +769,12 @@ static int isi_camera_add_device(struct soc_camera_device *icd)
>  	if (ret)
>  		return ret;
>  
> +	ret = clk_enable(isi->mck);
> +	if (ret) {
> +		clk_disable(isi->pclk);
> +		return ret;
> +	}
> +
>  	isi->icd = icd;
>  	dev_dbg(icd->parent, "Atmel ISI Camera driver attached to camera %d\n",
>  		 icd->devnum);
> @@ -779,6 +788,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;
>  
> @@ -874,7 +884,7 @@ static int isi_camera_set_bus_param(struct soc_camera_device *icd, u32 pixfmt)
>  
>  	if (isi->pdata->has_emb_sync)
>  		cfg1 |= ISI_CFG1_EMB_SYNC;
> -	if (isi->pdata->isi_full_mode)
> +	if (isi->pdata->full_mode)
>  		cfg1 |= ISI_CFG1_FULL_MODE;
>  
>  	isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
> @@ -912,6 +922,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);
>  
> @@ -930,7 +941,7 @@ 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->mck_hz) {
>  		dev_err(&pdev->dev,
>  			"No config available for Atmel ISI\n");
>  		return -EINVAL;
> @@ -959,6 +970,19 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev)
>  	INIT_LIST_HEAD(&isi->video_buffer_list);
>  	INIT_LIST_HEAD(&isi->dma_desc_head);
>  
> +	/* Get ISI_MCK, provided by programmable clock or external clock */
> +	isi->mck = clk_get(dev, "isi_mck");
> +	if (IS_ERR_OR_NULL(isi->mck)) {
> +		dev_err(dev, "Failed to get isi_mck\n");
> +		ret = isi->mck ? PTR_ERR(isi->mck) : -EINVAL;
> +		goto err_clk_get;
> +	}
> +
> +	/* Set ISI_MCK's frequency, it should be faster than pixel clock */
> +	ret = clk_set_rate(isi->mck, pdata->mck_hz);
> +	if (ret < 0)
> +		goto err_set_mck_rate;
> +
>  	isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev,
>  				sizeof(struct fbd) * MAX_BUFFER_NUM,
>  				&isi->fb_descriptors_phys,
> @@ -1034,6 +1058,9 @@ err_alloc_ctx:
>  			isi->p_fb_descriptors,
>  			isi->fb_descriptors_phys);
>  err_alloc_descriptors:
> +err_set_mck_rate:
> +	clk_put(isi->mck);
> +err_clk_get:
>  	kfree(isi);
>  err_alloc_isi:
>  	clk_put(isi->pclk);
> diff --git a/include/media/atmel-isi.h b/include/media/atmel-isi.h
> index 26cece5..6568230 100644
> --- a/include/media/atmel-isi.h
> +++ b/include/media/atmel-isi.h
> @@ -110,10 +110,12 @@ struct isi_platform_data {
>  	u8 hsync_act_low;
>  	u8 vsync_act_low;
>  	u8 pclk_act_falling;
> -	u8 isi_full_mode;
> +	u8 full_mode;
>  	u32 data_width_flags;
>  	/* Using for ISI_CFG1 */
>  	u32 frate;
> +	/* Using for ISI_MCK */
> +	u32 mck_hz;
>  };
>  
>  #endif /* __ATMEL_ISI_H__ */
> -- 
> 1.7.5.4
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [media] V4L: atmel-isi: add code to enable/disable ISI_MCK clock
  2011-11-28 13:50 ` Guennadi Liakhovetski
@ 2011-11-28 15:01   ` Nicolas Ferre
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Ferre @ 2011-11-28 15:01 UTC (permalink / raw)
  To: Guennadi Liakhovetski, josh.wu
  Cc: linux-arm-kernel, linux-kernel, linux-media

On 11/28/2011 02:50 PM, Guennadi Liakhovetski :
> Hi Nicolas
> 
> On Mon, 28 Nov 2011, Nicolas Ferre wrote:
> 
>> From: Josh Wu <josh.wu@atmel.com>
>>
>> This patch
>> - add ISI_MCK clock enable/disable code.
>> - change field name in isi_platform_data structure
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> [g.liakhovetski@gmx.de: fix label names]
>> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> 
> Thanks for the ack. All patches, affecting drivers/media & include/media 
> should go via the media tree, I'll push this one along with others for 3.3 
> as appropriate.

That is just great!
On my side, I will take care of the device/board code through
at91/arm-soc trees...

Thanks, best regards,

>> ---
>> Guennadi,
>>
>> Here is the pach form Josh and yourself about the Atmel ISI driver
>> modifications. I have rebased it on top of 3.2-rc3 (and tested it on
>> linux-next also).
>> I plan to submit the board/device related patches (2-3/3 of this series) to
>> the arm-soc tree real soon. Do you whant me to include this one or can you
>> schedulle an inclusion in mainline for 3.3?
>>
>> Best regards,
>>
>>  drivers/media/video/atmel-isi.c |   31 +++++++++++++++++++++++++++++--
>>  include/media/atmel-isi.h       |    4 +++-
>>  2 files changed, 32 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c
>> index 8c775c5..5a7ab84 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, feed to camera sensor to generate pixel clock */
>> +	struct clk			*mck;
>>  	unsigned int			irq;
>>  
>>  	struct isi_platform_data	*pdata;
>> @@ -766,6 +769,12 @@ static int isi_camera_add_device(struct soc_camera_device *icd)
>>  	if (ret)
>>  		return ret;
>>  
>> +	ret = clk_enable(isi->mck);
>> +	if (ret) {
>> +		clk_disable(isi->pclk);
>> +		return ret;
>> +	}
>> +
>>  	isi->icd = icd;
>>  	dev_dbg(icd->parent, "Atmel ISI Camera driver attached to camera %d\n",
>>  		 icd->devnum);
>> @@ -779,6 +788,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;
>>  
>> @@ -874,7 +884,7 @@ static int isi_camera_set_bus_param(struct soc_camera_device *icd, u32 pixfmt)
>>  
>>  	if (isi->pdata->has_emb_sync)
>>  		cfg1 |= ISI_CFG1_EMB_SYNC;
>> -	if (isi->pdata->isi_full_mode)
>> +	if (isi->pdata->full_mode)
>>  		cfg1 |= ISI_CFG1_FULL_MODE;
>>  
>>  	isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
>> @@ -912,6 +922,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);
>>  
>> @@ -930,7 +941,7 @@ 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->mck_hz) {
>>  		dev_err(&pdev->dev,
>>  			"No config available for Atmel ISI\n");
>>  		return -EINVAL;
>> @@ -959,6 +970,19 @@ static int __devinit atmel_isi_probe(struct platform_device *pdev)
>>  	INIT_LIST_HEAD(&isi->video_buffer_list);
>>  	INIT_LIST_HEAD(&isi->dma_desc_head);
>>  
>> +	/* Get ISI_MCK, provided by programmable clock or external clock */
>> +	isi->mck = clk_get(dev, "isi_mck");
>> +	if (IS_ERR_OR_NULL(isi->mck)) {
>> +		dev_err(dev, "Failed to get isi_mck\n");
>> +		ret = isi->mck ? PTR_ERR(isi->mck) : -EINVAL;
>> +		goto err_clk_get;
>> +	}
>> +
>> +	/* Set ISI_MCK's frequency, it should be faster than pixel clock */
>> +	ret = clk_set_rate(isi->mck, pdata->mck_hz);
>> +	if (ret < 0)
>> +		goto err_set_mck_rate;
>> +
>>  	isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev,
>>  				sizeof(struct fbd) * MAX_BUFFER_NUM,
>>  				&isi->fb_descriptors_phys,
>> @@ -1034,6 +1058,9 @@ err_alloc_ctx:
>>  			isi->p_fb_descriptors,
>>  			isi->fb_descriptors_phys);
>>  err_alloc_descriptors:
>> +err_set_mck_rate:
>> +	clk_put(isi->mck);
>> +err_clk_get:
>>  	kfree(isi);
>>  err_alloc_isi:
>>  	clk_put(isi->pclk);
>> diff --git a/include/media/atmel-isi.h b/include/media/atmel-isi.h
>> index 26cece5..6568230 100644
>> --- a/include/media/atmel-isi.h
>> +++ b/include/media/atmel-isi.h
>> @@ -110,10 +110,12 @@ struct isi_platform_data {
>>  	u8 hsync_act_low;
>>  	u8 vsync_act_low;
>>  	u8 pclk_act_falling;
>> -	u8 isi_full_mode;
>> +	u8 full_mode;
>>  	u32 data_width_flags;
>>  	/* Using for ISI_CFG1 */
>>  	u32 frate;
>> +	/* Using for ISI_MCK */
>> +	u32 mck_hz;
>>  };
>>  
>>  #endif /* __ATMEL_ISI_H__ */
>> -- 
>> 1.7.5.4
>>
> 
> ---
> Guennadi Liakhovetski, Ph.D.
> Freelance Open-Source Software Developer
> http://www.open-technology.de/
> 


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [media] V4L: atmel-isi: add code to enable/disable ISI_MCK clock
  2011-11-28 13:34 [PATCH] [media] V4L: atmel-isi: add code to enable/disable ISI_MCK clock Nicolas Ferre
  2011-11-28 13:50 ` Guennadi Liakhovetski
@ 2011-11-28 16:00 ` Russell King - ARM Linux
  1 sibling, 0 replies; 4+ messages in thread
From: Russell King - ARM Linux @ 2011-11-28 16:00 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: linux-arm-kernel, g.liakhovetski, josh.wu, linux-kernel, linux-media

On Mon, Nov 28, 2011 at 02:34:44PM +0100, Nicolas Ferre wrote:
> From: Josh Wu <josh.wu@atmel.com>
> 
> This patch
> - add ISI_MCK clock enable/disable code.
> - change field name in isi_platform_data structure
> 
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> [g.liakhovetski@gmx.de: fix label names]
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> ---
> Guennadi,
> 
> Here is the pach form Josh and yourself about the Atmel ISI driver
> modifications. I have rebased it on top of 3.2-rc3 (and tested it on
> linux-next also).
> I plan to submit the board/device related patches (2-3/3 of this series) to
> the arm-soc tree real soon. Do you whant me to include this one or can you
> schedulle an inclusion in mainline for 3.3?

While you're doing this, why not also prepare for the common clk API by
adding support for clk_prepare()/clk_unprepare() to these drivers?

We are actually now at the point where we should be saying a firm no to
any new introductions of clk_enable()/clk_disable() without there being
corresponding clk_prepare()/clk_unprepare() calls for that clk.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-28 16:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-28 13:34 [PATCH] [media] V4L: atmel-isi: add code to enable/disable ISI_MCK clock Nicolas Ferre
2011-11-28 13:50 ` Guennadi Liakhovetski
2011-11-28 15:01   ` Nicolas Ferre
2011-11-28 16:00 ` Russell King - ARM Linux

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).