Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ladislav Michl and committed by
Boris Brezillon
bdaca934 f5229331

+22 -32
+22 -32
drivers/mtd/onenand/omap2.c
··· 152 152 } 153 153 154 154 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) { 166 162 int retry_cnt = 0; 167 163 retry: 168 164 if (!wait_for_completion_io_timeout(&c->irq_done, ··· 446 450 447 451 static int omap2_onenand_probe(struct platform_device *pdev) 448 452 { 453 + dma_cap_mask_t mask; 449 454 struct omap_onenand_platform_data *pdata; 450 455 struct omap2_onenand *c; 451 456 struct onenand_chip *this; ··· 510 513 dev_err(&pdev->dev, "Failed to request GPIO%d for " 511 514 "OneNAND\n", c->gpio_irq); 512 515 goto err_iounmap; 516 + } 517 + gpio_direction_input(c->gpio_irq); 518 + 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 + 524 + this->wait = omap2_onenand_wait; 513 525 } 514 - gpio_direction_input(c->gpio_irq); 515 526 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; 520 - } 527 + dma_cap_zero(mask); 528 + dma_cap_set(DMA_MEMCPY, mask); 521 529 522 - if (pdata->dma_channel >= 0) { 523 - dma_cap_mask_t mask; 524 - 525 - dma_cap_zero(mask); 526 - dma_cap_set(DMA_MEMCPY, mask); 527 - 528 - c->dma_chan = dma_request_channel(mask, NULL, NULL); 529 - if (!c->dma_chan) 530 - dev_info(&pdev->dev, 531 - "failed to allocate DMA for OneNAND, " 532 - "using PIO instead\n"); 533 - } 530 + c->dma_chan = dma_request_channel(mask, NULL, NULL); 534 531 535 532 dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual " 536 - "base %p, freq %d MHz\n", c->gpmc_cs, c->phys_base, 537 - c->onenand.base, c->freq); 533 + "base %p, freq %d MHz, %s mode\n", c->gpmc_cs, c->phys_base, 534 + c->onenand.base, c->freq, c->dma_chan ? "DMA" : "PIO"); 538 535 539 536 c->pdev = pdev; 540 537 c->mtd.priv = &c->onenand; ··· 538 547 539 548 this = &c->onenand; 540 549 if (c->dma_chan) { 541 - this->wait = omap2_onenand_wait; 542 550 this->read_bufferram = omap2_onenand_read_bufferram; 543 551 this->write_bufferram = omap2_onenand_write_bufferram; 544 552 }