mfd: axp20x: improve support without interrupts
Subsystems (4)
v3 cover mfd: axp20x: improve support without interrupts
This is a more of a re-send, rebased on top of v6.6-rc2, with the tags added, and adding back the binding patch, since this seems to have fallen through the cracks somehow.
Changelog below.
------------------------------
Every AXP PMIC we support sports an IRQ pin, that signals certain events to the SoC. For some of the chip's functionality an interrupt is crucial for operation (for instance a power key event), but for the basic regulator features for instance the interrupt does not add much.
Recently we started seeing boards with smaller PMICs, that don't bother to connect the IRQ line to anything. So far we handled this as a special case for the AXP305, but there are more examples now that justify a more general solution.
Patch 1/2 adds more PMICs to the list of chips for which the interrupts DT property is optional: this is needed to correctly describe some newer boards without the IRQ pin connected.
Ideally we would make this optional for every PMIC, but it is unclear whether this is a good idea: many older the "bigger" PMICs have multiple MFD devices that require an interrupt, so not having interrupt functionality might not be feasible for their operation. Also so far all boards with those PMICs connect the IRQ pin, so there is no immediate need for such a relaxation.
Patch 2/2 then generalises the "no interrupt specified" case in the MFD driver, as this was special cased for two PMIC models so far. This allows boards with an AXP313a to not specify an IRQ line: there are actually multiple boards relying on this out there.
Cheers,
Andre
Changelog v3 ... v2:
- rebased on top of v6.6-rc2
- add back binding patch
- tags added
Changelog v2 ... v1:
- drop reordering approach, use separate cell lists instead
Andre Przywara (2):
dt-bindings: mfd: x-powers,axp152: make interrupt optional for more
chips
mfd: axp20x: Generalise handling without interrupt
.../bindings/mfd/x-powers,axp152.yaml | 5 ++- drivers/mfd/axp20x.c | 44 ++++++++++--------- 2 files changed, 28 insertions(+), 21 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/2 dt-bindings: mfd: x-powers,axp152: make interrupt optional for more chips
All X-Powers PMICs described by this binding have an IRQ pin, and so far (almost) all boards connected this to some NMI pin or GPIO on the SoC they are connected to.
However we start to see boards that omit this connection, and technically the IRQ pin is not essential to the basic PMIC operation.
The existing Linux driver allows skipping the IRQ pin setup for two chips already, so update the binding to also make the DT property optional for the missing chip. And while we are at it, add the AXP313a to that list, as they are actually boards out there not connecting the IRQ pin.
This allows to have DTs correctly describing those boards not wiring up the interrupt.
--- Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml +4 -1
@@ -67,7 +67,10 @@ allOf: properties: compatible: contains: - const: x-powers,axp305 + enum: + - x-powers,axp15060 + - x-powers,axp305 + - x-powers,axp313a then: required:
Signature · 1 line
2.25.1
Jernej Škrabec
maintainerRe: [PATCH v3 1/2] dt-bindings: mfd: x-powers,axp152: make interrupt optional for more chips
Dne torek, 19. september 2023 ob 12:39:12 CEST je Andre Przywara napisal(a):
Quoted 11 lines
All X-Powers PMICs described by this binding have an IRQ pin, and so far (almost) all boards connected this to some NMI pin or GPIO on the SoC they are connected to.
However we start to see boards that omit this connection, and technically the IRQ pin is not essential to the basic PMIC operation.The existing Linux driver allows skipping the IRQ pin setup for two chips already, so update the binding to also make the DT property optional for the missing chip. And while we are at it, add the AXP313a to that list, as they are actually boards out there not connecting the IRQ pin.
Quoted 5 lines
This allows to have DTs correctly describing those boards not wiring up the interrupt.
Signed-off-by Andre Przywara <[email protected]>Acked-by Conor Dooley <[email protected]>
Should I pick this patch through sunxi tree?
Best regards,
Jernej
Quoted 21 lines
--- Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml +4
-1@@ -67,7 +67,10 @@ allOf: properties: compatible: contains: - const: x-powers,axp305 + enum: + - x-powers,axp15060 + - x-powers,axp305 + - x-powers,axp313a then: required:
Lee Jones
maintainerRe: [PATCH v3 1/2] dt-bindings: mfd: x-powers,axp152: make interrupt optional for more chips
Quoted 12 lines · Jernej Škrabec
Dne torek, 19. september 2023 ob 12:39:12 CEST je Andre Przywara napisal(a):
Quoted 11 lines
All X-Powers PMICs described by this binding have an IRQ pin, and so far (almost) all boards connected this to some NMI pin or GPIO on the SoC they are connected to.
However we start to see boards that omit this connection, and technically the IRQ pin is not essential to the basic PMIC operation.The existing Linux driver allows skipping the IRQ pin setup for two chips already, so update the binding to also make the DT property optional for the missing chip. And while we are at it, add the AXP313a to that list, as they are actually boards out there not connecting the IRQ pin.
Quoted 7 lines
Quoted 5 lines
This allows to have DTs correctly describing those boards not wiring up the interrupt.
Signed-off-by Andre Przywara <[email protected]>Acked-by Conor Dooley <[email protected]>Should I pick this patch through sunxi tree?
No thank you.
Signature · 1 line
Lee Jones [李琼斯]
Re: (subset) [PATCH v3 1/2] dt-bindings: mfd: x-powers,axp152: make interrupt optional for more chips
In reply to Andre PrzywaraQuoted 6 lines · Andre Przywara
All X-Powers PMICs described by this binding have an IRQ pin, and so far (almost) all boards connected this to some NMI pin or GPIO on the SoC they are connected to.
However we start to see boards that omit this connection, and technically the IRQ pin is not essential to the basic PMIC operation.
Quoted 6 lines
The existing Linux driver allows skipping the IRQ pin setup for two chips already, so update the binding to also make the DT property optional for the missing chip. And while we are at it, add the AXP313a to that list, as they are actually boards out there not connecting the IRQ pin.
[...]
Applied, thanks!
[1/2] dt-bindings: mfd: x-powers,axp152: make interrupt optional for more chips
commit: cf71329eb3a37f90c8ddec0651dc7b3fa76036c1
--
Lee Jones [李琼斯]
PATCH v3 2/2 mfd: axp20x: Generalise handling without interrupt
In reply to Andre PrzywaraAt the moment we allow the AXP15060 and the AXP806 PMICs to omit the interrupt line to the SoC, and we skip registering the PEK (power key) driver in this case, since that crashes when no IRQ is described in the DT node.
The IRQ pin potentially not being connected to anything does affect more PMICs, though, and the PEK driver is not the only one requiring an
interrupt: at least the AC power supply driver crashes in a similar fashion.
Generalise the handling of AXP MFD devices when the platform tables describe no interrupt, by allowing each device to specify an alternative MFD list for this case. If no specific alternative is specified, we go with the safe default of "just the regulators", which matches the current situation.
This enables new devices using the AXP313a PMIC, but not connecting the IRQ pin.
--- drivers/mfd/axp20x.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-)
drivers/mfd/axp20x.c +24 -20
@@ -1133,6 +1133,8 @@ int axp20x_match_device(struct axp20x_dev *axp20x)struct device *dev = axp20x->dev;const struct acpi_device_id *acpi_id;const struct of_device_id *of_id; +const struct mfd_cell *cells_no_irq =NULL ; +int nr_cells_no_irq =0 ;if (dev->of_node) { of_id =of_match_device (dev->driver->of_match_table, dev);
@@ -1207,14 +1209,15 @@ int axp20x_match_device(struct axp20x_dev *axp20x)* if there is no interrupt line. */ if (of_property_read_bool (axp20x->dev->of_node, -"x-powers,self-working-mode" ) && - axp20x->irq >0 ) { +"x-powers,self-working-mode" )) { axp20x->nr_cells =ARRAY_SIZE (axp806_self_working_cells); axp20x->cells = axp806_self_working_cells; }else { axp20x->nr_cells =ARRAY_SIZE (axp806_cells); axp20x->cells = axp806_cells; } + nr_cells_no_irq =ARRAY_SIZE (axp806_cells); + cells_no_irq = axp806_cells; axp20x->regmap_cfg = &axp806_regmap_config; axp20x->regmap_irq_chip = &axp806_regmap_irq_chip;break ;
@@ -1238,24 +1241,8 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_irq_chip = &axp803_regmap_irq_chip;break ;case AXP15060_ID : -/* -* Don't register the power key part if there is no interrupt -* line. -* -* Since most use cases of AXP PMICs are Allwinner SOCs, board -* designers follow Allwinner's reference design and connects -* IRQ line to SOC, there's no need for those variants to deal -* with cases that IRQ isn't connected. However, AXP15660 is -* used by some other vendors' SOCs that didn't connect IRQ -* line, we need to deal with this case. -*/ -if (axp20x->irq >0 ) { - axp20x->nr_cells =ARRAY_SIZE (axp15060_cells); - axp20x->cells = axp15060_cells; - }else { - axp20x->nr_cells =ARRAY_SIZE (axp_regulator_only_cells); - axp20x->cells = axp_regulator_only_cells; - } + axp20x->nr_cells =ARRAY_SIZE (axp15060_cells); + axp20x->cells = axp15060_cells; axp20x->regmap_cfg = &axp15060_regmap_config; axp20x->regmap_irq_chip = &axp15060_regmap_irq_chip;break ;
@@ -1263,6 +1250,23 @@ int axp20x_match_device(struct axp20x_dev *axp20x)dev_err (dev,"unsupported AXP20X ID %lu\n" , axp20x->variant);return -EINVAL ; } + +/* +* Use an alternative cell array when no interrupt line is connected, +* since IRQs are required by some drivers. +* The default is the safe "regulator-only", as this works fine without +* an interrupt specified. +*/ +if (axp20x->irq <=0 ) { +if (cells_no_irq) { + axp20x->nr_cells = nr_cells_no_irq; + axp20x->cells = cells_no_irq; + }else { + axp20x->nr_cells =ARRAY_SIZE (axp_regulator_only_cells); + axp20x->cells = axp_regulator_only_cells; + } + } +dev_info (dev,"AXP20x variant %s found\n" , axp20x_model_names[axp20x->variant]);
Signature · 1 line
2.25.1