mfd: axp20x: Allow AXP 806 chips without interrupt lines

Currently the AXP chip requires to have its IRQ line connected to some
interrupt controller, and will fail probing when this is not the case.

On a new Allwinner SoC (H616) there is no NMI pin anymore, and at
least one board does not connect the AXP's IRQ pin to anything else,
so the interrupt functionality of the AXP chip is simply not available.

Check whether the interrupt line number returned by the platform code is
valid, before trying to register the irqchip. If not, we skip this
registration, to avoid the driver to bail out completely.
Also we need to skip the power key functionality, as this relies on
a valid IRQ as well.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Andre Przywara 2021-05-19 11:41:37 +01:00 committed by Lee Jones
parent 3b0850440a
commit 3efc465f91
1 changed files with 17 additions and 7 deletions

View File

@ -884,8 +884,13 @@ int axp20x_match_device(struct axp20x_dev *axp20x)
axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;
break;
case AXP806_ID:
/*
* Don't register the power key part if in slave mode or
* if there is no interrupt line.
*/
if (of_property_read_bool(axp20x->dev->of_node,
"x-powers,self-working-mode")) {
"x-powers,self-working-mode") &&
axp20x->irq > 0) {
axp20x->nr_cells = ARRAY_SIZE(axp806_self_working_cells);
axp20x->cells = axp806_self_working_cells;
} else {
@ -959,12 +964,17 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE);
}
ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq,
IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags,
-1, axp20x->regmap_irq_chip, &axp20x->regmap_irqc);
if (ret) {
dev_err(axp20x->dev, "failed to add irq chip: %d\n", ret);
return ret;
/* Only if there is an interrupt line connected towards the CPU. */
if (axp20x->irq > 0) {
ret = regmap_add_irq_chip(axp20x->regmap, axp20x->irq,
IRQF_ONESHOT | IRQF_SHARED | axp20x->irq_flags,
-1, axp20x->regmap_irq_chip,
&axp20x->regmap_irqc);
if (ret) {
dev_err(axp20x->dev, "failed to add irq chip: %d\n",
ret);
return ret;
}
}
ret = mfd_add_devices(axp20x->dev, -1, axp20x->cells,