From: Robby Cai Date: Mon, 10 Dec 2012 09:13:45 +0000 (+0800) Subject: ENGR00236722 mx6sl: csi: Ensure dma reflash operation done when dma is disabled X-Git-Tag: v3.0.35-fsl~190 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a43ace46136c8ab135db4c6bbea41e567e846383;p=karo-tx-linux.git ENGR00236722 mx6sl: csi: Ensure dma reflash operation done when dma is disabled If do dma reflash operation when dma is enabled, the system will hang and we can not connect to the core through jtag. The reason is the reflash signal (DMA_REFLASH_RFF) will initialize the AHB bus signals and it indeed seems to modify the AHB address on the clock as soon as the programmable register value is changed, the bus may not respond. This patch revised it according to the RM: "Reflash DMA Controller for RxFIFO. This bit reflash the embedded DMA controller for RxFIFO. It should be reflashed before the embedded DMA controller starts to work." Signed-off-by: Robby Cai --- diff --git a/drivers/media/video/mxc/capture/csi_v4l2_capture.c b/drivers/media/video/mxc/capture/csi_v4l2_capture.c index 74266b0367a8..53f35d487b21 100644 --- a/drivers/media/video/mxc/capture/csi_v4l2_capture.c +++ b/drivers/media/video/mxc/capture/csi_v4l2_capture.c @@ -547,6 +547,7 @@ static int csi_streamon(cam_data *cam) cam->capture_on = true; csi_cap_image(cam); csi_enable_int(1); + csi_dmareq_rff_enable(); return 0; } @@ -567,6 +568,7 @@ static int csi_streamoff(cam_data *cam) if (cam->capture_on == false) return 0; + csi_dmareq_rff_disable(); csi_disable_int(); cam->capture_on = false; diff --git a/drivers/media/video/mxc/capture/fsl_csi.c b/drivers/media/video/mxc/capture/fsl_csi.c index cd59b8e3cb1b..ede69b814b1b 100644 --- a/drivers/media/video/mxc/capture/fsl_csi.c +++ b/drivers/media/video/mxc/capture/fsl_csi.c @@ -56,6 +56,9 @@ static irqreturn_t csi_irq_handler(int irq, void *data) __raw_writel(cr3 | BIT_DMA_REFLASH_RFF, CSI_CSICR3); } + if (status & BIT_HRESP_ERR_INT) + pr_warning("Hresponse error is detected.\n"); + if (status & BIT_DMA_TSF_DONE_FB1) { if (cam->capture_on) { spin_lock(&cam->queue_int_lock); @@ -264,6 +267,24 @@ void csi_mclk_disable(void) clk_disable(&csi_mclk); } +void csi_dmareq_rff_enable(void) +{ + unsigned long cr3 = __raw_readl(CSI_CSICR3); + + cr3 |= BIT_DMA_REQ_EN_RFF; + cr3 |= BIT_HRESP_ERR_EN; + __raw_writel(cr3, CSI_CSICR3); +} + +void csi_dmareq_rff_disable(void) +{ + unsigned long cr3 = __raw_readl(CSI_CSICR3); + + cr3 &= ~BIT_DMA_REQ_EN_RFF; + cr3 &= ~BIT_HRESP_ERR_EN; + __raw_writel(cr3, CSI_CSICR3); +} + static int __devinit csi_probe(struct platform_device *pdev) { int ret = 0; @@ -293,6 +314,7 @@ static int __devinit csi_probe(struct platform_device *pdev) csihw_reset(); csi_init_interface(); + csi_dmareq_rff_disable(); per_clk = clk_get(NULL, "csi_clk"); if (IS_ERR(per_clk)) diff --git a/drivers/media/video/mxc/capture/fsl_csi.h b/drivers/media/video/mxc/capture/fsl_csi.h index 8dfce286fe53..d8096cc3b16d 100644 --- a/drivers/media/video/mxc/capture/fsl_csi.h +++ b/drivers/media/video/mxc/capture/fsl_csi.h @@ -195,3 +195,5 @@ void csi_enable_int(int arg); void csi_disable_int(void); void csi_mclk_enable(void); void csi_mclk_disable(void); +void csi_dmareq_rff_enable(void); +void csi_dmareq_rff_disable(void);