Skip to content

Commit f5619f3

Browse files
ffainellimiquelraynal
authored andcommitted
mtd: rawnand: brcmnand: Allow working without interrupts
The BCMA devices include the brcmnand controller but they do not wire up any interrupt line, allow the main interrupt to be optional and update the completion path to also check for the lack of an interrupt line. Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 75ac944 commit f5619f3

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

drivers/mtd/nand/raw/brcmnand/brcmnand.c

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ struct brcmnand_controller {
216216
void __iomem *nand_base;
217217
void __iomem *nand_fc; /* flash cache */
218218
void __iomem *flash_dma_base;
219-
unsigned int irq;
219+
int irq;
220220
unsigned int dma_irq;
221221
int nand_version;
222222

@@ -1610,7 +1610,7 @@ static bool brcmstb_nand_wait_for_completion(struct nand_chip *chip)
16101610
bool err = false;
16111611
int sts;
16121612

1613-
if (mtd->oops_panic_write) {
1613+
if (mtd->oops_panic_write || ctrl->irq < 0) {
16141614
/* switch to interrupt polling and PIO mode */
16151615
disable_ctrl_irqs(ctrl);
16161616
sts = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY,
@@ -3144,33 +3144,29 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)
31443144
}
31453145

31463146
/* IRQ */
3147-
ctrl->irq = platform_get_irq(pdev, 0);
3148-
if ((int)ctrl->irq < 0) {
3149-
dev_err(dev, "no IRQ defined\n");
3150-
ret = -ENODEV;
3151-
goto err;
3152-
}
3153-
3154-
/*
3155-
* Some SoCs integrate this controller (e.g., its interrupt bits) in
3156-
* interesting ways
3157-
*/
3158-
if (soc) {
3159-
ret = devm_request_irq(dev, ctrl->irq, brcmnand_irq, 0,
3160-
DRV_NAME, ctrl);
3147+
ctrl->irq = platform_get_irq_optional(pdev, 0);
3148+
if (ctrl->irq > 0) {
3149+
/*
3150+
* Some SoCs integrate this controller (e.g., its interrupt bits) in
3151+
* interesting ways
3152+
*/
3153+
if (soc) {
3154+
ret = devm_request_irq(dev, ctrl->irq, brcmnand_irq, 0,
3155+
DRV_NAME, ctrl);
31613156

3162-
/* Enable interrupt */
3163-
ctrl->soc->ctlrdy_ack(ctrl->soc);
3164-
ctrl->soc->ctlrdy_set_enabled(ctrl->soc, true);
3165-
} else {
3166-
/* Use standard interrupt infrastructure */
3167-
ret = devm_request_irq(dev, ctrl->irq, brcmnand_ctlrdy_irq, 0,
3168-
DRV_NAME, ctrl);
3169-
}
3170-
if (ret < 0) {
3171-
dev_err(dev, "can't allocate IRQ %d: error %d\n",
3172-
ctrl->irq, ret);
3173-
goto err;
3157+
/* Enable interrupt */
3158+
ctrl->soc->ctlrdy_ack(ctrl->soc);
3159+
ctrl->soc->ctlrdy_set_enabled(ctrl->soc, true);
3160+
} else {
3161+
/* Use standard interrupt infrastructure */
3162+
ret = devm_request_irq(dev, ctrl->irq, brcmnand_ctlrdy_irq, 0,
3163+
DRV_NAME, ctrl);
3164+
}
3165+
if (ret < 0) {
3166+
dev_err(dev, "can't allocate IRQ %d: error %d\n",
3167+
ctrl->irq, ret);
3168+
goto err;
3169+
}
31743170
}
31753171

31763172
for_each_available_child_of_node(dn, child) {

0 commit comments

Comments
 (0)