diff options
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/mxs-dma.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index 083e7f1a94f0..530267068061 100644 --- a/drivers/dma/mxs-dma.c +++ b/drivers/dma/mxs-dma.c | |||
@@ -60,6 +60,7 @@ | |||
60 | (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70) | 60 | (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x080 : 0x140) + (n) * 0x70) |
61 | #define HW_APBHX_CHn_BAR(d, n) \ | 61 | #define HW_APBHX_CHn_BAR(d, n) \ |
62 | (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x070 : 0x130) + (n) * 0x70) | 62 | (((dma_is_apbh(d) && apbh_is_old(d)) ? 0x070 : 0x130) + (n) * 0x70) |
63 | #define HW_APBX_CHn_DEBUG1(d, n) (0x150 + (n) * 0x70) | ||
63 | 64 | ||
64 | /* | 65 | /* |
65 | * ccw bits definitions | 66 | * ccw bits definitions |
@@ -204,12 +205,36 @@ static void mxs_dma_reset_chan(struct mxs_dma_chan *mxs_chan) | |||
204 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; | 205 | struct mxs_dma_engine *mxs_dma = mxs_chan->mxs_dma; |
205 | int chan_id = mxs_chan->chan.chan_id; | 206 | int chan_id = mxs_chan->chan.chan_id; |
206 | 207 | ||
207 | if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) | 208 | if (dma_is_apbh(mxs_dma) && apbh_is_old(mxs_dma)) { |
208 | writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL), | 209 | writel(1 << (chan_id + BP_APBH_CTRL0_RESET_CHANNEL), |
209 | mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); | 210 | mxs_dma->base + HW_APBHX_CTRL0 + STMP_OFFSET_REG_SET); |
210 | else | 211 | } else { |
212 | unsigned long elapsed = 0; | ||
213 | const unsigned long max_wait = 50000; /* 50ms */ | ||
214 | void __iomem *reg_dbg1 = mxs_dma->base + | ||
215 | HW_APBX_CHn_DEBUG1(mxs_dma, chan_id); | ||
216 | |||
217 | /* | ||
218 | * On i.MX28 APBX, the DMA channel can stop working if we reset | ||
219 | * the channel while it is in READ_FLUSH (0x08) state. | ||
220 | * We wait here until we leave the state. Then we trigger the | ||
221 | * reset. Waiting a maximum of 50ms, the kernel shouldn't crash | ||
222 | * because of this. | ||
223 | */ | ||
224 | while ((readl(reg_dbg1) & 0xf) == 0x8 && elapsed < max_wait) { | ||
225 | udelay(100); | ||
226 | elapsed += 100; | ||
227 | } | ||
228 | |||
229 | if (elapsed >= max_wait) | ||
230 | dev_err(&mxs_chan->mxs_dma->pdev->dev, | ||
231 | "Failed waiting for the DMA channel %d to leave state READ_FLUSH, trying to reset channel in READ_FLUSH state now\n", | ||
232 | chan_id); | ||
233 | |||
234 | |||
211 | writel(1 << (chan_id + BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL), | 235 | writel(1 << (chan_id + BP_APBHX_CHANNEL_CTRL_RESET_CHANNEL), |
212 | mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET); | 236 | mxs_dma->base + HW_APBHX_CHANNEL_CTRL + STMP_OFFSET_REG_SET); |
237 | } | ||
213 | } | 238 | } |
214 | 239 | ||
215 | static void mxs_dma_enable_chan(struct mxs_dma_chan *mxs_chan) | 240 | static void mxs_dma_enable_chan(struct mxs_dma_chan *mxs_chan) |