Skip to content

Commit bdaca93

Browse files
3x380VBoris Brezillon
authored andcommitted
mtd: onenand: omap2: Decouple DMA enabling from INT pin availability
INT pin (gpio_irq) is not really needed for DMA but only for notification when a command that needs wait has completed. DMA memcpy can be still used even without gpio_irq available, so enable it unconditionally. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Tested-by: Tony Lindgren <tony@atomide.com> Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi> Acked-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
1 parent f522933 commit bdaca93

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

drivers/mtd/onenand/omap2.c

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,13 @@ static int omap2_onenand_wait(struct mtd_info *mtd, int state)
152152
}
153153

154154
reinit_completion(&c->irq_done);
155-
if (c->gpio_irq) {
156-
result = gpio_get_value(c->gpio_irq);
157-
if (result == -1) {
158-
ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
159-
intr = read_reg(c, ONENAND_REG_INTERRUPT);
160-
wait_err("gpio error", state, ctrl, intr);
161-
return -EIO;
162-
}
163-
} else
164-
result = 0;
165-
if (result == 0) {
155+
result = gpio_get_value(c->gpio_irq);
156+
if (result < 0) {
157+
ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS);
158+
intr = read_reg(c, ONENAND_REG_INTERRUPT);
159+
wait_err("gpio error", state, ctrl, intr);
160+
return -EIO;
161+
} else if (result == 0) {
166162
int retry_cnt = 0;
167163
retry:
168164
if (!wait_for_completion_io_timeout(&c->irq_done,
@@ -450,6 +446,7 @@ static void omap2_onenand_shutdown(struct platform_device *pdev)
450446

451447
static int omap2_onenand_probe(struct platform_device *pdev)
452448
{
449+
dma_cap_mask_t mask;
453450
struct omap_onenand_platform_data *pdata;
454451
struct omap2_onenand *c;
455452
struct onenand_chip *this;
@@ -513,31 +510,25 @@ static int omap2_onenand_probe(struct platform_device *pdev)
513510
dev_err(&pdev->dev, "Failed to request GPIO%d for "
514511
"OneNAND\n", c->gpio_irq);
515512
goto err_iounmap;
516-
}
517-
gpio_direction_input(c->gpio_irq);
513+
}
514+
gpio_direction_input(c->gpio_irq);
518515

519-
if ((r = request_irq(gpio_to_irq(c->gpio_irq),
520-
omap2_onenand_interrupt, IRQF_TRIGGER_RISING,
521-
pdev->dev.driver->name, c)) < 0)
522-
goto err_release_gpio;
523-
}
516+
if ((r = request_irq(gpio_to_irq(c->gpio_irq),
517+
omap2_onenand_interrupt, IRQF_TRIGGER_RISING,
518+
pdev->dev.driver->name, c)) < 0)
519+
goto err_release_gpio;
524520

525-
if (pdata->dma_channel >= 0) {
526-
dma_cap_mask_t mask;
521+
this->wait = omap2_onenand_wait;
522+
}
527523

528-
dma_cap_zero(mask);
529-
dma_cap_set(DMA_MEMCPY, mask);
524+
dma_cap_zero(mask);
525+
dma_cap_set(DMA_MEMCPY, mask);
530526

531-
c->dma_chan = dma_request_channel(mask, NULL, NULL);
532-
if (!c->dma_chan)
533-
dev_info(&pdev->dev,
534-
"failed to allocate DMA for OneNAND, "
535-
"using PIO instead\n");
536-
}
527+
c->dma_chan = dma_request_channel(mask, NULL, NULL);
537528

538529
dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual "
539-
"base %p, freq %d MHz\n", c->gpmc_cs, c->phys_base,
540-
c->onenand.base, c->freq);
530+
"base %p, freq %d MHz, %s mode\n", c->gpmc_cs, c->phys_base,
531+
c->onenand.base, c->freq, c->dma_chan ? "DMA" : "PIO");
541532

542533
c->pdev = pdev;
543534
c->mtd.priv = &c->onenand;
@@ -547,7 +538,6 @@ static int omap2_onenand_probe(struct platform_device *pdev)
547538

548539
this = &c->onenand;
549540
if (c->dma_chan) {
550-
this->wait = omap2_onenand_wait;
551541
this->read_bufferram = omap2_onenand_read_bufferram;
552542
this->write_bufferram = omap2_onenand_write_bufferram;
553543
}

0 commit comments

Comments
 (0)