|
18 | 18 | */
|
19 | 19 |
|
20 | 20 | #include <linux/init.h>
|
| 21 | +#include <linux/iopoll.h> |
21 | 22 | #include <linux/module.h>
|
22 | 23 | #include <linux/types.h>
|
23 | 24 | #include <linux/bitops.h>
|
@@ -571,28 +572,20 @@ static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
|
571 | 572 | static int sdma_run_channel0(struct sdma_engine *sdma)
|
572 | 573 | {
|
573 | 574 | int ret;
|
574 |
| - unsigned long timeout = 500; |
| 575 | + u32 reg; |
575 | 576 |
|
576 | 577 | sdma_enable_channel(sdma, 0);
|
577 | 578 |
|
578 |
| - while (!(ret = readl_relaxed(sdma->regs + SDMA_H_INTR) & 1)) { |
579 |
| - if (timeout-- <= 0) |
580 |
| - break; |
581 |
| - udelay(1); |
582 |
| - } |
583 |
| - |
584 |
| - if (ret) { |
585 |
| - /* Clear the interrupt status */ |
586 |
| - writel_relaxed(ret, sdma->regs + SDMA_H_INTR); |
587 |
| - } else { |
| 579 | + ret = readl_relaxed_poll_timeout_atomic(sdma->regs + SDMA_H_STATSTOP, |
| 580 | + reg, !(reg & 1), 1, 500); |
| 581 | + if (ret) |
588 | 582 | dev_err(sdma->dev, "Timeout waiting for CH0 ready\n");
|
589 |
| - } |
590 | 583 |
|
591 | 584 | /* Set bits of CONFIG register with dynamic context switching */
|
592 | 585 | if (readl(sdma->regs + SDMA_H_CONFIG) == 0)
|
593 | 586 | writel_relaxed(SDMA_H_CONFIG_CSM, sdma->regs + SDMA_H_CONFIG);
|
594 | 587 |
|
595 |
| - return ret ? 0 : -ETIMEDOUT; |
| 588 | + return ret; |
596 | 589 | }
|
597 | 590 |
|
598 | 591 | static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size,
|
@@ -727,9 +720,9 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
|
727 | 720 | unsigned long stat;
|
728 | 721 |
|
729 | 722 | stat = readl_relaxed(sdma->regs + SDMA_H_INTR);
|
730 |
| - /* not interested in channel 0 interrupts */ |
731 |
| - stat &= ~1; |
732 | 723 | writel_relaxed(stat, sdma->regs + SDMA_H_INTR);
|
| 724 | + /* channel 0 is special and not handled here, see run_channel0() */ |
| 725 | + stat &= ~1; |
733 | 726 |
|
734 | 727 | while (stat) {
|
735 | 728 | int channel = fls(stat) - 1;
|
|
0 commit comments