Skip to contentSkip to conversation

mfd: add X-Powers AC200 support

PATCH Superseded James Hilliard 3 participants 13 messages Sep 3 – Sep 7

Subsystems (3)

v9 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v9 cover mfd: add X-Powers AC200 support

The X-Powers AC200 is an I2C-controlled mixed-signal companion IC with a paged register map shared by its audio, video, RTC and Fast Ethernet PHY functions.

Add the parent binding and an I2C provider which enables and rate-locks the shared input clock, initializes the paged regmap and deasserts the common reset without resetting state left by firmware. The common reset remains deasserted during removal and shutdown, so unbinding the provider does not disrupt independently enumerated functions or discard wake state.

Describe and instantiate the audio codec and TV encoder as MFD children, and provide the shared regmap interrupt controller needed by the TV encoder. Only enabled, DT-described function devices are instantiated; PHY-only systems therefore acquire no unused platform devices. The ASoC codec and DRM bridge drivers are separate subsystem work and are not part of this MFD-only series.

The current regmap consumer is the separately submitted AC200/AC300 Ethernet PHY series:

https://patch.msgid.link/[email protected]

The PHY remains enumerated on MDIO, its primary management bus. Its AC200 package node follows the x-powers,ac200 phandle for ancillary I2C register access, adds a managed device link and obtains the regmap with dev_get_regmap(). This series and the PHY series can be merged in either order; AC200 Ethernet support requires both.

The child descriptions and MFD implementation are adapted from earlier work by Jernej Skrabec and Andre Przywara, with their authorship and sign-off chain retained:

https://github.com/jernejsk/linux-1/commits/opi3-eth/

Public AC200 documentation is linked from:

https://linux-sunxi.org/AC200

Validation included dt_binding_check with dtschema 2026.6, a W=1 x86_64 object build and strict checkpatch checks. On AC200 hardware, a writable common-register marker survived supplier unbind and rebind. The provider and PHY then completed 100 overlapping bind cycles; both MFD cells were removed and recreated during every cycle while both device links remained valid and the 100 Mbps full-duplex link recovered. Afterward, 100 pings in each direction completed without loss and 8 MiB transfers in both directions compared correctly.

The available board does not expose the codec, TV encoder or INTB pin, so the functional audio, video and interrupt paths were not runtime-tested. Temporary child nodes nevertheless instantiated both MFD devices, and a temporary probe driver bound to each and read the parent common-control register as 0x1.

Assisted-by Codex:gpt-5.6-sol

---
Changes v8 -> v9:
- deassert common reset without first resetting the entire chip
- leave common reset deasserted during removal and shutdown, preventing supplier unbind from disrupting the PHY or discarding RTC/WoL state (reported by Sashiko and queried by Lee Jones)
- stop storing the regmap as unused driver data after dropping teardown callbacks
- describe the audio codec and TV encoder MFD children
- add the AC200 interrupt definitions and shared regmap IRQ controller
- register only enabled, DT-described codec and TV encoder function devices
- retain Jernej Skrabec and Andre Przywara's authorship and sign-off chain for the adapted child and MFD work
- make the base provider depend on COMMON_CLK before child support is added
- require an upstream interrupt when the parent is an interrupt controller
- credit Jernej Skrabec in the module metadata
- exercise child enumeration and parent-regmap access with temporary probes
- rebase on the current MFD for-mfd-next branch
- verify register-state preservation across supplier unbind and rebind
- Link to v8: https://patch.msgid.link/[email protected]

Changes v7 -> v8:
- identify the PHY series as the current regmap consumer
- describe future MFD children and the MDIO/I2C split
- store the regmap directly as driver data (suggested by Lee Jones)
- reset the chip from the remove callback (suggested by Lee Jones)
- drop the revision log and inherited-driver attribution (suggested by Lee Jones)
- add Krzysztof's Reviewed-by tag to the binding
- rebase on the current MFD for-mfd-next branch
- Link to v7: https://patch.msgid.link/[email protected]

Changes v6 -> v7:
- drop the managed external-syscon helper and AC200 syscon registration
- leave the regmap attached to the I2C provider for direct device lookup
- reduce the MFD series from three patches to two
- Link to v6: https://patch.msgid.link/[email protected]

Changes v5 -> v6:
- split the MFD work from the independently mergeable networking series
- put the merge routing and shared DT design at the start of the cover letter
- rebase on the MFD for-mfd-next branch
- Link to v5: https://patch.msgid.link/[email protected]

To: Jernej Skrabec <[email protected]>
To: James Hilliard <[email protected]>
To: Lee Jones <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
James Hilliard (2):
dt-bindings: mfd: x-powers: Add AC200
mfd: ac200: Add X-Powers AC200 support

Jernej Skrabec (2):
dt-bindings: mfd: x-powers: Describe AC200 functions
mfd: ac200: Add codec and TV encoder cells

 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 186 +++++++++++++++++
 MAINTAINERS                                        |   9 +
 drivers/mfd/Kconfig                                |  15 ++
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/ac200.c                                | 230 +++++++++++++++++++++
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 6 files changed, 454 insertions(+)

---
base-commit: b07adc1a304c7ca9ac25a01051561538757363c9
change-id: 20260811-submit-ac200-mfd-8bad6d09e285

Best regards,

Signature · 1 line
James Hilliard <[email protected]>
#1 lore raw

PATCH v9 1/4 dt-bindings: mfd: x-powers: Add AC200

The AC200 is an I2C-controlled mixed-signal companion IC containing audio, video, RTC and Fast Ethernet PHY functions.

Describe the parent device and its shared input clock. The Ethernet PHY is represented by a PHY package on its MDIO bus, with a phandle back to this device for access to the package control registers, so it does not require an MFD child node. Function-specific supplies belong to their consumer bindings rather than the shared parent.

The input clock must run at 24 or 27 MHz when the Ethernet PHY is used, matching the rates encoded by its documented clock selector.

---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 50 ++++++++++++++++++++++
 MAINTAINERS                                        |  7 +++
 2 files changed, 57 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml new file +50 -0
new file mode 100644
index 000000000000..ca7a910b2c73
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/x-powers,ac200.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: X-Powers AC200 mixed-signal IC
+
+maintainers:
+  - James Hilliard <[email protected]>
+  - Jernej Skrabec <[email protected]>
+
+description:
+  The AC200 is a mixed-signal companion IC containing audio, video, RTC and
+  Fast Ethernet PHY functions. Its control registers are accessed over I2C.
+
+properties:
+  compatible:
+    const: x-powers,ac200
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+    description:
+      AC200 input clock. When using the Ethernet PHY, its configured rate must
+      be 24 or 27 MHz, matching the rates encoded by the documented EPHY clock
+      selector.
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        mixed-signal@10 {
+            compatible = "x-powers,ac200";
+            reg = <0x10>;
+            clocks = <&pwm 5>;
+        };
+    };
+...
MAINTAINERS +7 -0
index 3a19da74d00c..419340093c9b 100644
@@ -29504,6 +29504,13 @@ F:	drivers/net/wwan/
 F:	include/linux/wwan.h
 F:	include/uapi/linux/wwan.h
 
+X-POWERS AC200 DRIVERS
+M:	Jernej Skrabec <[email protected]>
+M:	James Hilliard <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml
+
 X-POWERS AXP288 PMIC DRIVERS
 M:	Hans de Goede <[email protected]>
 S:	Maintained
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v9 1/4] dt-bindings: mfd: x-powers: Add AC200

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines

The AC200 is an I2C-controlled mixed-signal companion IC containing audio, video, RTC and Fast Ethernet PHY functions.

Describe the parent device and its shared input clock. The Ethernet PHY is represented by a PHY package on its MDIO bus, with a phandle back to this device for access to the package control registers, so it does not require an MFD child node. Function-specific supplies belong to their consumer bindings rather than the shared parent.

Quoted 5 lines

The input clock must run at 24 or 27 MHz when the Ethernet PHY is used, matching the rates encoded by its documented clock selector.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

PATCH v9 2/4 mfd: ac200: Add X-Powers AC200 support

In reply to James Hilliard

The X-Powers AC200 is a mixed-signal companion IC with a paged register map accessed over I2C.

Enable and rate-lock the shared input clock, wait 40 ms before the first register access, initialize the paged regmap and deassert the common reset. Set only the deassert bit instead of forcing a reset cycle, so state established by firmware or independently powered functions remains intact. Leave the common reset deasserted during driver removal and system shutdown; function drivers own their block resets.

The Ethernet PHY is enumerated on its MDIO bus rather than as an MFD child. It follows the x-powers,ac200 phandle and uses this regmap for ancillary package-control access. The audio codec and TV encoder are added as MFD children by subsequent patches.

Cache only the common page selector. Individual functions can reset independently and invalidate their other registers, so leave all functional registers volatile.

---
 MAINTAINERS          |   1 +
 drivers/mfd/Kconfig  |  12 ++++++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/ac200.c  | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 127 insertions(+)
MAINTAINERS +1 -0
index 419340093c9b..1d03b0060bda 100644
@@ -29510,6 +29510,7 @@ M:	James Hilliard <[email protected]>
 L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml
+F:	drivers/mfd/ac200.c
 
 X-POWERS AXP288 PMIC DRIVERS
 M:	Hans de Goede <[email protected]>
drivers/mfd/Kconfig +12 -0
index 857ca3bb0d5b..6dea35c8c18e 100644
@@ -205,6 +205,18 @@ config MFD_AC100
 	  This driver include only the core APIs. You have to select individual
 	  components like codecs or RTC under the corresponding menus.
 
+config MFD_AC200
+	tristate "X-Powers AC200"
+	depends on COMMON_CLK
+	depends on I2C
+	depends on OF
+	select REGMAP_I2C
+	help
+	  Support for the X-Powers AC200 mixed-signal companion IC. The AC200
+	  contains audio, video, RTC and Fast Ethernet PHY functions and is
+	  co-packaged with some Allwinner H6 and H616 SoCs. This driver provides
+	  the shared register access used by the individual function drivers.
+
 config MFD_AXP20X
 	tristate
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index 72d3944b0ad8..f8101d2a9ce9 100644
@@ -150,6 +150,7 @@ obj-$(CONFIG_MFD_DA9052_SPI)	+= da9052-spi.o
 obj-$(CONFIG_MFD_DA9052_I2C)	+= da9052-i2c.o
 
 obj-$(CONFIG_MFD_AC100)		+= ac100.o
+obj-$(CONFIG_MFD_AC200)		+= ac200.o
 obj-$(CONFIG_MFD_AXP20X)	+= axp20x.o
 obj-$(CONFIG_MFD_AXP20X_I2C)	+= axp20x-i2c.o
 obj-$(CONFIG_MFD_AXP20X_RSB)	+= axp20x-rsb.o
drivers/mfd/ac200.c new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH v9 2/4] mfd: ac200: Add X-Powers AC200 support

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Regmap exposed to userspace and consumers before hardware initialization delay completes. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Regmap exposed to userspace and consumers before hardware initialization delay completes. --

commit 35526ae046a1822af569d5228aa956640657303c
Author: James Hilliard <[email protected]>

mfd: ac200: Add X-Powers AC200 support

This commit adds MFD core driver support for the X-Powers AC200 mixed-signal companion IC. It configures the shared regmap over I2C, handles clock enabling, and manages the common reset state for the device.

Quoted 5 lines
drivers/mfd/ac200.c new file +0 -0
new file mode 100644
index 0000000000000..94aa13deb0f8c

[ ... ]

Quoted 16 lines
drivers/mfd/ac200.c new file +16 -0
+static int ac200_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct regmap *regmap;
+	struct clk *clk;
+	int ret;
+
+	clk = devm_clk_get_enabled(dev, NULL);
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk),
+				     "failed to enable input clock\n");
+
+	ret = devm_clk_rate_exclusive_get(dev, clk);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to lock clock rate\n");
+

drivers/mfd/ac200.c line 79

Quoted 10 lines
drivers/mfd/ac200.c new file +10 -0
+	regmap = devm_regmap_init_i2c(client, &ac200_regmap_config);
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap),
+				     "failed to initialize regmap\n");
+
+	/*
+	 * No minimum delay is documented. Match the vendor driver's 40 ms delay
+	 * before its first AC200 register access after enabling the input clock.
+	 */
+	msleep(40);

[Severity: Medium]
Could exposing the regmap before the 40 ms initialization delay completes lead to I2C bus lockups or device malfunctions?

The devm_regmap_init_i2c() call exposes the regmap to userspace via debugfs and to other consumers, such as an asynchronously probing Ethernet PHY. During this 40 ms window, these concurrent access paths might attempt to access the hardware before the stabilization delay is met.

Would it be safer to move the msleep(40) above the regmap initialization to prevent this race condition?

Quoted 8 lines
drivers/mfd/ac200.c new file +8 -0
+
+	ret = regmap_set_bits(regmap, AC200_SYS_CONTROL_REG,
+			      AC200_SYS_CONTROL_CHIP_RESET_DEASSERT);
+	if (ret)
+		return ret;
+
+	return 0;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#5 lore raw

PATCH v9 3/4 dt-bindings: mfd: x-powers: Describe AC200 functions

In reply to James Hilliard

From: Jernej Skrabec <[email protected]>

Describe the AC200 audio codec and TV encoder as child nodes of the shared I2C register provider. Keep their analog supplies on the function consumers and describe the TV encoder display graph and optional bandgap calibration cell.

Add the shared interrupt-controller properties and interrupt numbers needed by the TV encoder. The Ethernet PHY remains represented on its primary MDIO bus and is therefore not an MFD child.

---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 136 +++++++++++++++++++++
 MAINTAINERS                                        |   1 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 150 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +136 -0
index ca7a910b2c73..935dc07138cb 100644
@@ -28,15 +28,114 @@ properties:
       be 24 or 27 MHz, matching the rates encoded by the documented EPHY clock
       selector.
 
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts.
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+    description:
+      The interrupt number, as defined in
+      include/dt-bindings/mfd/x-powers,ac200.h.
+
+  codec:
+    type: object
+    $ref: /schemas/sound/dai-common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-codec
+
+      '#sound-dai-cells':
+        const: 0
+
+      ac-ldoin-supply:
+        description: The 3.3 V supply for the audio codec LDO input.
+
+    required:
+      - compatible
+      - '#sound-dai-cells'
+      - ac-ldoin-supply
+
+  tv-encoder:
+    type: object
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-tve
+
+      interrupts:
+        maxItems: 1
+        description: Cable detection interrupt.
+
+      tv-vcc-supply:
+        description: The 3.3 V supply for the composite-video DAC.
+
+      nvmem-cells:
+        maxItems: 1
+
+      nvmem-cell-names:
+        items:
+          - const: bandgap
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Input from the display pipeline, carrying CCIR656.
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Output to the composite-video connector.
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - compatible
+      - interrupts
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
 required:
   - compatible
   - reg
   - clocks
 
+allOf:
+  - if:
+      required:
+        - tv-encoder
+    then:
+      required:
+        - interrupts
+        - interrupt-controller
+        - '#interrupt-cells'
+
+dependencies:
+  interrupt-controller: [ '#interrupt-cells', interrupts ]
+  '#interrupt-cells': [ interrupt-controller ]
+
 additionalProperties: false
 
 examples:
   - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/mfd/x-powers,ac200.h>
+
     i2c {
         #address-cells = <1>;
         #size-cells = <0>;
@@ -45,6 +144,43 @@ examples:
             compatible = "x-powers,ac200";
             reg = <0x10>;
             clocks = <&pwm 5>;
+            interrupt-parent = <&pio>;
+            interrupts = <1 20 IRQ_TYPE_LEVEL_LOW>;
+            interrupt-controller;
+            #interrupt-cells = <1>;
+
+            codec {
+                compatible = "x-powers,ac200-codec";
+                #sound-dai-cells = <0>;
+                ac-ldoin-supply = <&reg_aldo2>;
+            };
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                interrupts = <AC200_IRQ_TVE>;
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        tve_in: endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        tve_out: endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
         };
     };
 ...
MAINTAINERS +1 -0
index 1d03b0060bda..8a48f6a1e593 100644
@@ -29511,6 +29511,7 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml
 F:	drivers/mfd/ac200.c
+F:	include/dt-bindings/mfd/x-powers,ac200.h
 
 X-POWERS AXP288 PMIC DRIVERS
 M:	Hans de Goede <[email protected]>
include/dt-bindings/mfd/x-powers,ac200.h new file +13 -0
new file mode 100644
index 000000000000..cc59e2ab4912
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Interrupt numbers of the X-Powers AC200 interrupt controller.
+ */
+
+#ifndef _DT_BINDINGS_MFD_X_POWERS_AC200_H
+#define _DT_BINDINGS_MFD_X_POWERS_AC200_H
+
+#define AC200_IRQ_TVE			0
+#define AC200_IRQ_EPHY			1
+#define AC200_IRQ_RTC			2
+
+#endif /* _DT_BINDINGS_MFD_X_POWERS_AC200_H */
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH v9 3/4] dt-bindings: mfd: x-powers: Describe AC200 functions

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines

From: Jernej Skrabec <[email protected]>

Describe the AC200 audio codec and TV encoder as child nodes of the shared I2C register provider. Keep their analog supplies on the function consumers and describe the TV encoder display graph and optional bandgap calibration cell.

Quoted 6 lines

Add the shared interrupt-controller properties and interrupt numbers needed by the TV encoder. The Ethernet PHY remains represented on its primary MDIO bus and is therefore not an MFD child.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#7 lore raw

Re: [PATCH v9 3/4] dt-bindings: mfd: x-powers: Describe AC200 functions

In reply to James Hilliard
Quoted 62 lines · James Hilliard

From: Jernej Skrabec <[email protected]>

Describe the AC200 audio codec and TV encoder as child nodes of the shared I2C register provider. Keep their analog supplies on the function consumers and describe the TV encoder display graph and optional bandgap calibration cell.

Add the shared interrupt-controller properties and interrupt numbers needed by the TV encoder. The Ethernet PHY remains represented on its primary MDIO bus and is therefore not an MFD child.

---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 136 +++++++++++++++++++++
 MAINTAINERS                                        |   1 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 150 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +35 -0
index ca7a910b2c73..935dc07138cb 100644
@@ -28,15 +28,114 @@ properties:
       be 24 or 27 MHz, matching the rates encoded by the documented EPHY clock
       selector.
 
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts.
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+    description:
+      The interrupt number, as defined in
+      include/dt-bindings/mfd/x-powers,ac200.h.
+
+  codec:
+    type: object
+    $ref: /schemas/sound/dai-common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-codec
+
+      '#sound-dai-cells':
+        const: 0
+
+      ac-ldoin-supply:
+        description: The 3.3 V supply for the audio codec LDO input.
+
+    required:
+      - compatible
+      - '#sound-dai-cells'
+      - ac-ldoin-supply
+
+  tv-encoder:

Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml properties: · line 75

Quoted 10 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +10 -0
+    type: object
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-tve
+
+      interrupts:
+        maxItems: 1
+        description: Cable detection interrupt.

Given the example, this looks like a hack.
Is this mfd actually an interrupt controller, or is that just part of this hack too?

Quite frankly, I am not really sure why either the tv-encoder or codec have dedicated child nodes, they don't appear to have conflicting properties.

Additionally, why is this not part of patch 1? Add the binding in a complete state from the get-go. On that basis, at least,
pw-bot: changes-requested

Cheers,
Conor.

Quoted 145 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +91 -0
+
+      tv-vcc-supply:
+        description: The 3.3 V supply for the composite-video DAC.
+
+      nvmem-cells:
+        maxItems: 1
+
+      nvmem-cell-names:
+        items:
+          - const: bandgap
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Input from the display pipeline, carrying CCIR656.
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Output to the composite-video connector.
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - compatible
+      - interrupts
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
 required:
   - compatible
   - reg
   - clocks
 
+allOf:
+  - if:
+      required:
+        - tv-encoder
+    then:
+      required:
+        - interrupts
+        - interrupt-controller
+        - '#interrupt-cells'
+
+dependencies:
+  interrupt-controller: [ '#interrupt-cells', interrupts ]
+  '#interrupt-cells': [ interrupt-controller ]
+
 additionalProperties: false
 
 examples:
   - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/mfd/x-powers,ac200.h>
+
     i2c {
         #address-cells = <1>;
         #size-cells = <0>;
@@ -45,6 +144,43 @@ examples:
             compatible = "x-powers,ac200";
             reg = <0x10>;
             clocks = <&pwm 5>;
+            interrupt-parent = <&pio>;
+            interrupts = <1 20 IRQ_TYPE_LEVEL_LOW>;
+            interrupt-controller;
+            #interrupt-cells = <1>;
+
+            codec {
+                compatible = "x-powers,ac200-codec";
+                #sound-dai-cells = <0>;
+                ac-ldoin-supply = <&reg_aldo2>;
+            };
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                interrupts = <AC200_IRQ_TVE>;
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        tve_in: endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        tve_out: endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
         };
     };
...
MAINTAINERS +1 -0
index 1d03b0060bda..8a48f6a1e593 100644
@@ -29511,6 +29511,7 @@ L:	[email protected]
 S:	Maintained
 F:	Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml
 F:	drivers/mfd/ac200.c
+F:	include/dt-bindings/mfd/x-powers,ac200.h
 
 X-POWERS AXP288 PMIC DRIVERS
 M:	Hans de Goede <[email protected]>
include/dt-bindings/mfd/x-powers,ac200.h new file +13 -0
new file mode 100644
index 000000000000..cc59e2ab4912
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Interrupt numbers of the X-Powers AC200 interrupt controller.
+ */
+
+#ifndef _DT_BINDINGS_MFD_X_POWERS_AC200_H
+#define _DT_BINDINGS_MFD_X_POWERS_AC200_H
+
+#define AC200_IRQ_TVE			0
+#define AC200_IRQ_EPHY			1
+#define AC200_IRQ_RTC			2
+
+#endif /* _DT_BINDINGS_MFD_X_POWERS_AC200_H */
Signature · 2 lines
-- 
2.53.0
#8 lore raw

Re: [PATCH v9 3/4] dt-bindings: mfd: x-powers: Describe AC200 functions

Quoted 70 lines · Conor Dooley
Quoted 68 lines · James Hilliard

From: Jernej Skrabec <[email protected]>

Describe the AC200 audio codec and TV encoder as child nodes of the shared I2C register provider. Keep their analog supplies on the function consumers and describe the TV encoder display graph and optional bandgap calibration cell.

Add the shared interrupt-controller properties and interrupt numbers needed by the TV encoder. The Ethernet PHY remains represented on its primary MDIO bus and is therefore not an MFD child.

---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 136 +++++++++++++++++++++
 MAINTAINERS                                        |   1 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 150 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +41 -0
index ca7a910b2c73..935dc07138cb 100644
@@ -28,15 +28,114 @@ properties:
       be 24 or 27 MHz, matching the rates encoded by the documented EPHY clock
       selector.
 
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts.
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+    description:
+      The interrupt number, as defined in
+      include/dt-bindings/mfd/x-powers,ac200.h.
+
+  codec:
+    type: object
+    $ref: /schemas/sound/dai-common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-codec
+
+      '#sound-dai-cells':
+        const: 0
+
+      ac-ldoin-supply:
+        description: The 3.3 V supply for the audio codec LDO input.
+
+    required:
+      - compatible
+      - '#sound-dai-cells'
+      - ac-ldoin-supply
+
+  tv-encoder:
+    type: object
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-tve
Quoted 8 lines

Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml properties: · line 75

Quoted 4 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +4 -0
+
+      interrupts:
+        maxItems: 1
+        description: Cable detection interrupt.

Given the example, this looks like a hack.
Is this mfd actually an interrupt controller, or is that just part of this hack too?

The AC200 has separate TV encoder, Ethernet PHY and RTC status and enable bits which are multiplexed onto its shared INTB output, so the intent was to represent that demultiplexer as an interrupt controller.

I notice that the example's tv-encoder interrupts property inherits interrupt-parent = <&pio> rather than explicitly referencing the AC200 interrupt domain. Is that incorrect interrupt relationship what looks like a hack here, or do you also object to representing the AC200 interrupt demultiplexer as an interrupt controller?

Quoted 3 lines

Quite frankly, I am not really sure why either the tv-encoder or codec have dedicated child nodes, they don't appear to have conflicting properties.

Do you mean that the DT properties for both functions should be folded into the AC200 parent node, while the MFD driver still creates separate codec and TV encoder platform devices?

Lee requested at least two MFD children in this series, so I want to distinguish the Linux MFD cells from whether those cells need dedicated firmware child nodes.

Quoted 3 lines

Additionally, why is this not part of patch 1? Add the binding in a complete state from the get-go. On that basis, at least,
pw-bot: changes-requested

Do you want patches 1 and 3 combined into one complete binding patch, while retaining separate implementation commits for the base provider and the MFD cells?

Quoted 148 lines

Cheers,
Conor.

Quoted 145 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +91 -0
+
+      tv-vcc-supply:
+        description: The 3.3 V supply for the composite-video DAC.
+
+      nvmem-cells:
+        maxItems: 1
+
+      nvmem-cell-names:
+        items:
+          - const: bandgap
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Input from the display pipeline, carrying CCIR656.
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Output to the composite-video connector.
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - compatible
+      - interrupts
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
 required:
   - compatible
   - reg
   - clocks
 
+allOf:
+  - if:
+      required:
+        - tv-encoder
+    then:
+      required:
+        - interrupts
+        - interrupt-controller
+        - '#interrupt-cells'
+
+dependencies:
+  interrupt-controller: [ '#interrupt-cells', interrupts ]
+  '#interrupt-cells': [ interrupt-controller ]
+
 additionalProperties: false
 
 examples:
   - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/mfd/x-powers,ac200.h>
+
     i2c {
         #address-cells = <1>;
         #size-cells = <0>;
@@ -45,6 +144,43 @@ examples:
             compatible = "x-powers,ac200";
             reg = <0x10>;
             clocks = <&pwm 5>;
+            interrupt-parent = <&pio>;
+            interrupts = <1 20 IRQ_TYPE_LEVEL_LOW>;
+            interrupt-controller;
+            #interrupt-cells = <1>;
+
+            codec {
+                compatible = "x-powers,ac200-codec";
+                #sound-dai-cells = <0>;
+                ac-ldoin-supply = <&reg_aldo2>;
+            };
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                interrupts = <AC200_IRQ_TVE>;
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        tve_in: endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        tve_out: endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
         };
     };
...
MAINTAINERS +1 -0
index 1d03b0060bda..8a48f6a1e593 100644
@@ -29511,6 +29511,7 @@ L:    [email protected]
 S:   Maintained
 F:   Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml
 F:   drivers/mfd/ac200.c
+F:   include/dt-bindings/mfd/x-powers,ac200.h
 
 X-POWERS AXP288 PMIC DRIVERS
 M:   Hans de Goede <[email protected]>
include/dt-bindings/mfd/x-powers,ac200.h new file +13 -1
new file mode 100644
index 000000000000..cc59e2ab4912
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Interrupt numbers of the X-Powers AC200 interrupt controller.
+ */
+
+#ifndef _DT_BINDINGS_MFD_X_POWERS_AC200_H
+#define _DT_BINDINGS_MFD_X_POWERS_AC200_H
+
+#define AC200_IRQ_TVE                        0
+#define AC200_IRQ_EPHY                       1
+#define AC200_IRQ_RTC                        2
+
+#endif /* _DT_BINDINGS_MFD_X_POWERS_AC200_H */
 
--

2.53.0

#9 lore raw

Re: [PATCH v9 3/4] dt-bindings: mfd: x-powers: Describe AC200 functions

Quoted 80 lines · James Hilliard
Quoted 70 lines · Conor Dooley
Quoted 68 lines · James Hilliard

From: Jernej Skrabec <[email protected]>

Describe the AC200 audio codec and TV encoder as child nodes of the shared I2C register provider. Keep their analog supplies on the function consumers and describe the TV encoder display graph and optional bandgap calibration cell.

Add the shared interrupt-controller properties and interrupt numbers needed by the TV encoder. The Ethernet PHY remains represented on its primary MDIO bus and is therefore not an MFD child.

---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 136 +++++++++++++++++++++
 MAINTAINERS                                        |   1 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 150 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +41 -0
index ca7a910b2c73..935dc07138cb 100644
@@ -28,15 +28,114 @@ properties:
       be 24 or 27 MHz, matching the rates encoded by the documented EPHY clock
       selector.
 
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts.
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+    description:
+      The interrupt number, as defined in
+      include/dt-bindings/mfd/x-powers,ac200.h.
+
+  codec:
+    type: object
+    $ref: /schemas/sound/dai-common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-codec
+
+      '#sound-dai-cells':
+        const: 0
+
+      ac-ldoin-supply:
+        description: The 3.3 V supply for the audio codec LDO input.
+
+    required:
+      - compatible
+      - '#sound-dai-cells'
+      - ac-ldoin-supply
+
+  tv-encoder:
+    type: object
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-tve
Quoted 8 lines

Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml properties: · line 75

Quoted 4 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +4 -0
+
+      interrupts:
+        maxItems: 1
+        description: Cable detection interrupt.

Given the example, this looks like a hack.
Is this mfd actually an interrupt controller, or is that just part of this hack too?

Quoted 8 lines

The AC200 has separate TV encoder, Ethernet PHY and RTC status and enable bits which are multiplexed onto its shared INTB output, so the intent was to represent that demultiplexer as an interrupt controller.

I notice that the example's tv-encoder interrupts property inherits interrupt-parent = <&pio> rather than explicitly referencing the AC200 interrupt domain. Is that incorrect interrupt relationship what looks like a hack here, or do you also object to representing the AC200

No, I noticed the lack of an explicit parent but attributed it to a mistake. The define used in the child node, and the interrupt properties in the parent are why I considered it a hack - the device looked like it was pointing to itself as it's own interrupt parent. How would this work for the rtc, since that is implemented without a child node?

Personally I would just implement these devices using IRQF_SHARED.

Quoted 6 lines

interrupt demultiplexer as an interrupt controller?

Quoted 3 lines

Quite frankly, I am not really sure why either the tv-encoder or codec have dedicated child nodes, they don't appear to have conflicting properties.

Quoted 7 lines

Do you mean that the DT properties for both functions should be folded into the AC200 parent node, while the MFD driver still creates separate codec and TV encoder platform devices?

Lee requested at least two MFD children in this series, so I want to distinguish the Linux MFD cells from whether those cells need dedicated firmware child nodes.

I don't see Lee requesting that they be in the devicetree though, just that there are two mfd children. mfd_cell would (IMO) qualify for that.

I don't see anything here that'd be problematic in terms of folding the codec and encodering into the parent mfd device and using mfd_cell, given the phy is not represented here.

Quoted 8 lines
Quoted 4 lines

Additionally, why is this not part of patch 1? Add the binding in a complete state from the get-go. On that basis, at least,
pw-bot: changes-requested

Do you want patches 1 and 3 combined into one complete binding patch, while retaining separate implementation commits for the base provider and the MFD cells?

Correct.

Quoted 3 lines
Quoted 3 lines

Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml properties: · line 78

Quoted 3 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +3 -0
+
+      tv-vcc-supply:
+        description: The 3.3 V supply for the composite-video DAC.

Are these genuinely different 3.3 V supplies btw? Or are you just representing them as two different ones because of different device nodes using them?

Cheers,
Conor.

Quoted 142 lines
Quoted 142 lines
Quoted 142 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +88 -0
+
+      nvmem-cells:
+        maxItems: 1
+
+      nvmem-cell-names:
+        items:
+          - const: bandgap
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Input from the display pipeline, carrying CCIR656.
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Output to the composite-video connector.
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - compatible
+      - interrupts
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
 required:
   - compatible
   - reg
   - clocks
 
+allOf:
+  - if:
+      required:
+        - tv-encoder
+    then:
+      required:
+        - interrupts
+        - interrupt-controller
+        - '#interrupt-cells'
+
+dependencies:
+  interrupt-controller: [ '#interrupt-cells', interrupts ]
+  '#interrupt-cells': [ interrupt-controller ]
+
 additionalProperties: false
 
 examples:
   - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/mfd/x-powers,ac200.h>
+
     i2c {
         #address-cells = <1>;
         #size-cells = <0>;
@@ -45,6 +144,43 @@ examples:
             compatible = "x-powers,ac200";
             reg = <0x10>;
             clocks = <&pwm 5>;
+            interrupt-parent = <&pio>;
+            interrupts = <1 20 IRQ_TYPE_LEVEL_LOW>;
+            interrupt-controller;
+            #interrupt-cells = <1>;
+
+            codec {
+                compatible = "x-powers,ac200-codec";
+                #sound-dai-cells = <0>;
+                ac-ldoin-supply = <&reg_aldo2>;
+            };
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                interrupts = <AC200_IRQ_TVE>;
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        tve_in: endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        tve_out: endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
         };
     };
...
MAINTAINERS +1 -0
index 1d03b0060bda..8a48f6a1e593 100644
@@ -29511,6 +29511,7 @@ L:    [email protected]
 S:   Maintained
 F:   Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml
 F:   drivers/mfd/ac200.c
+F:   include/dt-bindings/mfd/x-powers,ac200.h
 
 X-POWERS AXP288 PMIC DRIVERS
 M:   Hans de Goede <[email protected]>
include/dt-bindings/mfd/x-powers,ac200.h new file +13 -1
new file mode 100644
index 000000000000..cc59e2ab4912
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Interrupt numbers of the X-Powers AC200 interrupt controller.
+ */
+
+#ifndef _DT_BINDINGS_MFD_X_POWERS_AC200_H
+#define _DT_BINDINGS_MFD_X_POWERS_AC200_H
+
+#define AC200_IRQ_TVE                        0
+#define AC200_IRQ_EPHY                       1
+#define AC200_IRQ_RTC                        2
+
+#endif /* _DT_BINDINGS_MFD_X_POWERS_AC200_H */
 
--

2.53.0

#10 lore raw

Re: [PATCH v9 3/4] dt-bindings: mfd: x-powers: Describe AC200 functions

Quoted 91 lines · Conor Dooley
Quoted 80 lines · James Hilliard
Quoted 70 lines · Conor Dooley
Quoted 68 lines · James Hilliard

From: Jernej Skrabec <[email protected]>

Describe the AC200 audio codec and TV encoder as child nodes of the shared I2C register provider. Keep their analog supplies on the function consumers and describe the TV encoder display graph and optional bandgap calibration cell.

Add the shared interrupt-controller properties and interrupt numbers needed by the TV encoder. The Ethernet PHY remains represented on its primary MDIO bus and is therefore not an MFD child.

---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 136 +++++++++++++++++++++
 MAINTAINERS                                        |   1 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 150 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +41 -0
index ca7a910b2c73..935dc07138cb 100644
@@ -28,15 +28,114 @@ properties:
       be 24 or 27 MHz, matching the rates encoded by the documented EPHY clock
       selector.
 
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts.
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+    description:
+      The interrupt number, as defined in
+      include/dt-bindings/mfd/x-powers,ac200.h.
+
+  codec:
+    type: object
+    $ref: /schemas/sound/dai-common.yaml#
+    unevaluatedProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-codec
+
+      '#sound-dai-cells':
+        const: 0
+
+      ac-ldoin-supply:
+        description: The 3.3 V supply for the audio codec LDO input.
+
+    required:
+      - compatible
+      - '#sound-dai-cells'
+      - ac-ldoin-supply
+
+  tv-encoder:
+    type: object
+    additionalProperties: false
+
+    properties:
+      compatible:
+        const: x-powers,ac200-tve
Quoted 8 lines

Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml properties: · line 75

Quoted 4 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +4 -0
+
+      interrupts:
+        maxItems: 1
+        description: Cable detection interrupt.

Given the example, this looks like a hack.
Is this mfd actually an interrupt controller, or is that just part of this hack too?

Quoted 8 lines

The AC200 has separate TV encoder, Ethernet PHY and RTC status and enable bits which are multiplexed onto its shared INTB output, so the intent was to represent that demultiplexer as an interrupt controller.

I notice that the example's tv-encoder interrupts property inherits interrupt-parent = <&pio> rather than explicitly referencing the AC200 interrupt domain. Is that incorrect interrupt relationship what looks like a hack here, or do you also object to representing the AC200

Quoted 5 lines

No, I noticed the lack of an explicit parent but attributed it to a mistake. The define used in the child node, and the interrupt properties in the parent are why I considered it a hack - the device looked like it was pointing to itself as it's own interrupt parent. How would this work for the rtc, since that is implemented without a child node?

There isn't an RTC driver in this series; only its interrupt source was described. A future RTC MFD cell could receive the shared parent IRQ without requiring a separate DT node.

Quoted 1 line

Personally I would just implement these devices using IRQF_SHARED.

I've implemented that approach in my local v11 tree. The binding now describes the optional INTB connection without interrupt-controller properties or internal interrupt numbers.

The MFD driver passes the physical IRQ to the TV encoder cell when connected. Without INTB connected, the cell has no IRQ resource.

Function drivers remain separate work. They will need to request IRQF_SHARED | IRQF_ONESHOT handlers before enabling their own source, check and clear their own status in the threaded handler, and mask their source before freeing the IRQ. The parent initially masks all sources before enabling INTB.

Quoted 14 lines
Quoted 6 lines

interrupt demultiplexer as an interrupt controller?

Quoted 3 lines

Quite frankly, I am not really sure why either the tv-encoder or codec have dedicated child nodes, they don't appear to have conflicting properties.

Quoted 7 lines

Do you mean that the DT properties for both functions should be folded into the AC200 parent node, while the MFD driver still creates separate codec and TV encoder platform devices?

Lee requested at least two MFD children in this series, so I want to distinguish the Linux MFD cells from whether those cells need dedicated firmware child nodes.

Quoted 6 lines

I don't see Lee requesting that they be in the devicetree though, just that there are two mfd children. mfd_cell would (IMO) qualify for that.

I don't see anything here that'd be problematic in terms of folding the codec and encodering into the parent mfd device and using mfd_cell, given the phy is not represented here.

I've moved the audio DAI properties, supplies, bandgap calibration cell and display ports into the AC200 parent node. The codec and TV encoder remain separate Linux devices described by static MFD cells, without separate DT nodes. Their supply lookups use MFD parent-supply aliases. The PHY remains on MDIO.

Quoted 11 lines
Quoted 8 lines
Quoted 4 lines

Additionally, why is this not part of patch 1? Add the binding in a complete state from the get-go. On that basis, at least,
pw-bot: changes-requested

Do you want patches 1 and 3 combined into one complete binding patch, while retaining separate implementation commits for the base provider and the MFD cells?

Correct.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml properties: · line 78

Quoted 3 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +3 -0
+
+      tv-vcc-supply:
+        description: The 3.3 V supply for the composite-video DAC.

Are these genuinely different 3.3 V supplies btw? Or are you just representing them as two different ones because of different device nodes using them?

They correspond to distinct physical supply inputs: TV_VCC is pin 1 and AC_LDOIN is pin 2, both nominally 3.3 V. The AC200 datasheet lists these separately:

https://linux-sunxi.org/images/0/0f/AC200_Datasheet_V1.1.pdf

They do not require separate external regulators; the example connects both to reg_aldo2. The revised parent-node descriptions now explicitly state that these inputs may share a regulator.

Quoted 145 lines

Cheers,
Conor.

Quoted 142 lines
Quoted 142 lines
Quoted 142 lines
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml +88 -0
+
+      nvmem-cells:
+        maxItems: 1
+
+      nvmem-cell-names:
+        items:
+          - const: bandgap
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Input from the display pipeline, carrying CCIR656.
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: Output to the composite-video connector.
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - compatible
+      - interrupts
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
 required:
   - compatible
   - reg
   - clocks
 
+allOf:
+  - if:
+      required:
+        - tv-encoder
+    then:
+      required:
+        - interrupts
+        - interrupt-controller
+        - '#interrupt-cells'
+
+dependencies:
+  interrupt-controller: [ '#interrupt-cells', interrupts ]
+  '#interrupt-cells': [ interrupt-controller ]
+
 additionalProperties: false
 
 examples:
   - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/mfd/x-powers,ac200.h>
+
     i2c {
         #address-cells = <1>;
         #size-cells = <0>;
@@ -45,6 +144,43 @@ examples:
             compatible = "x-powers,ac200";
             reg = <0x10>;
             clocks = <&pwm 5>;
+            interrupt-parent = <&pio>;
+            interrupts = <1 20 IRQ_TYPE_LEVEL_LOW>;
+            interrupt-controller;
+            #interrupt-cells = <1>;
+
+            codec {
+                compatible = "x-powers,ac200-codec";
+                #sound-dai-cells = <0>;
+                ac-ldoin-supply = <&reg_aldo2>;
+            };
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                interrupts = <AC200_IRQ_TVE>;
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        tve_in: endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        tve_out: endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
         };
     };
...
MAINTAINERS +1 -0
index 1d03b0060bda..8a48f6a1e593 100644
@@ -29511,6 +29511,7 @@ L:    [email protected]
 S:   Maintained
 F:   Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml
 F:   drivers/mfd/ac200.c
+F:   include/dt-bindings/mfd/x-powers,ac200.h
 
 X-POWERS AXP288 PMIC DRIVERS
 M:   Hans de Goede <[email protected]>
include/dt-bindings/mfd/x-powers,ac200.h new file +13 -1
new file mode 100644
index 000000000000..cc59e2ab4912
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Interrupt numbers of the X-Powers AC200 interrupt controller.
+ */
+
+#ifndef _DT_BINDINGS_MFD_X_POWERS_AC200_H
+#define _DT_BINDINGS_MFD_X_POWERS_AC200_H
+
+#define AC200_IRQ_TVE                        0
+#define AC200_IRQ_EPHY                       1
+#define AC200_IRQ_RTC                        2
+
+#endif /* _DT_BINDINGS_MFD_X_POWERS_AC200_H */
 
--

2.53.0

#11 lore raw

PATCH v9 4/4 mfd: ac200: Add codec and TV encoder cells

In reply to James Hilliard

From: Jernej Skrabec <[email protected]>

Register the AC200 audio codec and TV encoder as MFD cells when their enabled child nodes are present. Filtering the cell list avoids creating unused platform devices, or warnings about missing firmware nodes, on boards which use only the separately enumerated MDIO PHY.

Add a regmap IRQ controller for the shared level-triggered INTB output so the TV encoder can consume its cable-detection interrupt. The source function remains responsible for clearing its interrupt condition.

---
 drivers/mfd/Kconfig |   5 ++-
 drivers/mfd/ac200.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 122 insertions(+), 2 deletions(-)
drivers/mfd/Kconfig +4 -1
index 6dea35c8c18e..5193c6f71bd8 100644
@@ -210,12 +210,15 @@ config MFD_AC200
 	depends on COMMON_CLK
 	depends on I2C
 	depends on OF
+	select MFD_CORE
 	select REGMAP_I2C
+	select REGMAP_IRQ
 	help
 	  Support for the X-Powers AC200 mixed-signal companion IC. The AC200
 	  contains audio, video, RTC and Fast Ethernet PHY functions and is
 	  co-packaged with some Allwinner H6 and H616 SoCs. This driver provides
-	  the shared register access used by the individual function drivers.
+	  the shared register access and instantiates the individual function
+	  devices.
 
 config MFD_AXP20X
 	tristate
drivers/mfd/ac200.c +118 -1

148 lines not on this page · raw message

Signature · 1 line
2.53.0
#12 lore raw

Re: [PATCH v9 4/4] mfd: ac200: Add codec and TV encoder cells

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Using PLATFORM_DEVID_NONE instead of PLATFORM_DEVID_AUTO causes sysfs device naming collisions.…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Using PLATFORM_DEVID_NONE instead of PLATFORM_DEVID_AUTO causes sysfs device naming collisions.
- [Low] Dynamic creation of a local stack copy of the mfd_cell array for filtering violates MFD architectural rules. --

commit 5b7692c955e218224dd53b696f2b08c851828b93
Author: Jernej Skrabec <[email protected]>

mfd: ac200: Add codec and TV encoder cells

Register the AC200 audio codec and TV encoder as MFD cells when their enabled child nodes are present. Filtering the cell list avoids creating unused platform devices.

Quoted 4 lines
drivers/mfd/ac200.c +0 -0
index 94aa13deb0f8c..f7d818141d9cb 100644

[ ... ]

Quoted 7 lines
drivers/mfd/ac200.c +7 -0
+static int ac200_add_devices(struct device *dev)
+{
+	struct mfd_cell cells[ARRAY_SIZE(ac200_cells)];
+	unsigned int num_cells = 0;
+	unsigned int i;
+	int ret;
+

drivers/mfd/ac200.c static const struct regmap_config ac200_regmap_config = { · line 148

Quoted 10 lines
drivers/mfd/ac200.c +10 -0
+	for (i = 0; i < ARRAY_SIZE(ac200_cells); i++) {
+		const struct mfd_cell *cell = &ac200_cells[i];
+		struct device_node *child;
+
+		child = of_get_compatible_child(dev->of_node,
+						cell->of_compatible);
+		if (!child)
+			continue;
+		if (of_device_is_available(child))
+			cells[num_cells++] = *cell;

[Severity: Low]
Does creating a dynamic local stack copy of the mfd_cell array here violate the MFD architectural guidelines?

The MFD subsystem rules typically require cell arrays to remain static const. Dynamically amending and explicitly copying into a local array during probe in ac200_add_devices() bypasses the standard static definition approach.

Could this instead use static references or a switch statement if variants or filtering are needed?

drivers/mfd/ac200.c static const struct regmap_config ac200_regmap_config = { · line 156

Quoted 8 lines
drivers/mfd/ac200.c +8 -0
+		of_node_put(child);
+	}
+
+	if (!num_cells)
+		return 0;
+
+	ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, cells, num_cells,
+				   NULL, 0, NULL);

[Severity: Medium]
Can passing PLATFORM_DEVID_NONE here cause sysfs device naming collisions?

If a system developer instantiates multiple AC200 chips in the device tree, the second instance might fail during devm_mfd_add_devices() because both instances will attempt to register child platform devices with identical hard-coded names (like 'ac200-codec').

Would it be safer to use PLATFORM_DEVID_AUTO to allow automatic cell indexing and properly support multi-instance configurations?

Quoted 6 lines
drivers/mfd/ac200.c +6 -0
+	if (ret)
+		return dev_err_probe(dev, ret,
+				     "failed to add function devices\n");
+
+	return 0;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4