Skip to contentSkip to conversation

mfd: add X-Powers AC200 support

PATCH Superseded James Hilliard 3 participants 8 messages Sep 6 – Sep 7

Subsystems (3)

v10 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v10 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 and initializes the paged regmap. Before creating the regmap, retain the 40 ms wait used by the BSP resume path after enabling the input clock. No minimum delay is documented.

Deassert the common reset without first asserting it, and leave it deasserted during removal and shutdown. This avoids a provider-initiated chip-wide reset of unrelated function registers. Supplier unbind still tears down linked consumers and releases the provider's clock references; it does not guarantee uninterrupted operation or wake-state retention.

Describe and instantiate the audio codec and TV encoder as MFD children, and provide a shared regmap interrupt controller for boards with INTB connected. Only enabled, DT-described function devices are instantiated; PHY-only systems therefore acquire no unused platform devices.

The INTB connection and TV encoder cable-detection interrupt are optional. Enabled codec and TV encoder nodes are valid without INTB connected, and cable detection status remains readable over I2C. A declared TV encoder interrupt requires a complete parent interrupt domain and upstream path. 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, retaining their sign-off chain:

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, W=1 x86_64 object builds, strict checkpatch checks and a clean diff check. A 38-case host-side harness checked the actual IRQ initialization and cleanup functions with stubbed regmap and IRQ APIs, covering trigger selection, firmware register states and failure unwinding under ASan and UBSan. A 30-case DT validation matrix covered wired and unwired configurations, enabled and disabled functions, both interrupt-specifier forms and incomplete IRQ paths.

In earlier AC200 hardware checks, a writable common-register marker survived supplier unbind and rebind. The provider and PHY completed 100 deliberately overlapping bind cycles while both device links remained valid and the 100 Mbps full-duplex link recovered.

With temporary codec and TV encoder DT child nodes, a second 100-cycle run verified that both automatically numbered platform devices were removed and recreated on every supplier rebind while the PHY continued to recover. After restoring the production DT, no child devices were instantiated. One hundred pings in each direction completed without loss and 8 MiB transfers in both directions compared correctly.

The latest revision was also booted with both MFD children enabled and no IRQ connection. Twenty supplier rebinds completed without DMA-mask warnings. All 42 child probes verified DMA-mask inheritance, read the parent common control register as 0x1 and obtained the expected absent optional IRQ. The PHY recovered at 100 Mbps full duplex; 20 pings in each direction had no loss and an 8 MiB upload/download round trip compared correctly. These child runtime checks cover enumeration, removal/recreation and shared resource access.

Assisted-by Codex:gpt-6-astra

---
Changes v9 -> v10:
- combine the parent and function bindings into one complete binding patch (requested by Conor Dooley)
- introduce the complete MFD provider, IRQ controller and function cells in one driver patch, reducing the series from four patches to two
- retain the existing sign-off chains for the adapted binding and MFD work
- allow enabled codec and TV encoder nodes when INTB is not connected; require the parent IRQ path only when a TV encoder interrupt is declared
or the parent advertises an interrupt controller
- add an unwired TV encoder example
- move the existing 40 ms wait before constructing and publishing the
regmap, and clarify its origin in the BSP resume path
- use automatic platform-device IDs so MFD children from multiple AC200 instances cannot collide
- initialize the parent's DMA mask for its non-DMA children, avoiding
"DMA mask not set" warnings during child enumeration
- explicitly request level-low when no upstream IRQ trigger is configured
- keep INTB disabled until source masking and handler setup are complete,
and disable it before releasing the IRQ chip on failure or removal
- narrow reset-preservation claims to avoiding a provider-initiated global reset; supplier unbind still tears down consumers and releases clocks
- Link to v9: https://patch.msgid.link/[email protected]

Changes v8 -> v9:
- deassert common reset without first resetting the entire chip
- leave common reset deasserted during removal and shutdown, avoiding a provider-initiated chip-wide reset
(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

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

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

Best regards,

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

PATCH v10 1/2 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 together with the audio codec and TV encoder child nodes. 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 used by the TV encoder. 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.

Keep the INTB connection and TV encoder interrupt optional, including when the TV encoder is enabled. Cable detection status is readable over I2C without an interrupt. If a TV encoder interrupt is described, require the parent interrupt domain and its upstream connection. Include examples with and without INTB connected.

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    | 231 +++++++++++++++++++++
 MAINTAINERS                                        |   8 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 252 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml new file +231 -0
new file mode 100644
index 000000000000..0f2e6922fc4f
@@ -0,0 +1,231 @@
+# 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.
+
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts. Omit when INTB is not connected.
+
+  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 routed through the AC200 interrupt
+          controller. Omit when INTB is not connected. Cable detection status
+          can also be read over I2C without an 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
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+allOf:
+  - if:
+      properties:
+        tv-encoder:
+          anyOf:
+            - required: [ interrupts ]
+            - required: [ interrupts-extended ]
+      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>;
+
+        mixed-signal@10 {
+            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>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        mixed-signal@10 {
+            compatible = "x-powers,ac200";
+            reg = <0x10>;
+            clocks = <&pwm 5>;
+            /* INTB is not connected. */
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+...
MAINTAINERS +8 -0
index 3a19da74d00c..1b1dd57cc419 100644
@@ -29504,6 +29504,14 @@ 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
+F:	include/dt-bindings/mfd/x-powers,ac200.h
+
 X-POWERS AXP288 PMIC DRIVERS
 M:	Hans de Goede <[email protected]>
 S:	Maintained
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
#2 lore raw

Re: [PATCH v10 1/2] dt-bindings: mfd: x-powers: Add AC200

Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 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 together with the audio codec and TV encoder child nodes. 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 used by the TV encoder. 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.

Keep the INTB connection and TV encoder interrupt optional, including when the TV encoder is enabled. Cable detection status is readable over I2C without an interrupt. If a TV encoder interrupt is described, require the parent interrupt domain and its upstream connection. Include examples with and without INTB connected.

Quoted 6 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

Re: [PATCH v10 1/2] dt-bindings: mfd: x-powers: Add AC200

In reply to James Hilliard
Quoted 19 lines · James Hilliard

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 together with the audio codec and TV encoder child nodes. 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 used by the TV encoder. 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.

Keep the INTB connection and TV encoder interrupt optional, including when the TV encoder is enabled. Cable detection status is readable over I2C without an interrupt. If a TV encoder interrupt is described, require the parent interrupt domain and its upstream connection. Include examples with and without INTB connected.

Quoted 4 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.

This should have been dropped when you merged the patches. Not sure why you sent v10 without waiting for a reply from me on the v9.

Thanks,
Conor.

Quoted 287 lines
---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 231 +++++++++++++++++++++
 MAINTAINERS                                        |   8 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 252 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml new file +231 -0
new file mode 100644
index 000000000000..0f2e6922fc4f
@@ -0,0 +1,231 @@
+# 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.
+
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts. Omit when INTB is not connected.
+
+  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 routed through the AC200 interrupt
+          controller. Omit when INTB is not connected. Cable detection status
+          can also be read over I2C without an 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
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+allOf:
+  - if:
+      properties:
+        tv-encoder:
+          anyOf:
+            - required: [ interrupts ]
+            - required: [ interrupts-extended ]
+      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>;
+
+        mixed-signal@10 {
+            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>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        mixed-signal@10 {
+            compatible = "x-powers,ac200";
+            reg = <0x10>;
+            clocks = <&pwm 5>;
+            /* INTB is not connected. */
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+...
MAINTAINERS +8 -0
index 3a19da74d00c..1b1dd57cc419 100644
@@ -29504,6 +29504,14 @@ 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
+F:	include/dt-bindings/mfd/x-powers,ac200.h
+
 X-POWERS AXP288 PMIC DRIVERS
 M:	Hans de Goede <[email protected]>
 S:	Maintained
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
#4 lore raw

Re: [PATCH v10 1/2] dt-bindings: mfd: x-powers: Add AC200

Quoted 21 lines · Conor Dooley
Quoted 19 lines · James Hilliard

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 together with the audio codec and TV encoder child nodes. 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 used by the TV encoder. 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.

Keep the INTB connection and TV encoder interrupt optional, including when the TV encoder is enabled. Cable detection status is readable over I2C without an interrupt. If a TV encoder interrupt is described, require the parent interrupt domain and its upstream connection. Include examples with and without INTB connected.

Quoted 6 lines
Quoted 4 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.

This should have been dropped when you merged the patches.

Oh, forgot to do that.

Quoted 1 line

Not sure why you sent v10 without waiting for a reply from me on the v9.

I had figured I had enough pending fixes(i.e. sashiko reported issues and combining the patches) that it made sense to spin an updated series.

Quoted 291 lines

Thanks,
Conor.

Quoted 287 lines
---
 .../devicetree/bindings/mfd/x-powers,ac200.yaml    | 231 +++++++++++++++++++++
 MAINTAINERS                                        |   8 +
 include/dt-bindings/mfd/x-powers,ac200.h           |  13 ++
 3 files changed, 252 insertions(+)
Documentation/devicetree/bindings/mfd/x-powers,ac200.yaml new file +231 -0
new file mode 100644
index 000000000000..0f2e6922fc4f
@@ -0,0 +1,231 @@
+# 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.
+
+  interrupts:
+    maxItems: 1
+    description:
+      The shared open-drain INTB output for the TV encoder, Ethernet PHY and
+      RTC interrupts. Omit when INTB is not connected.
+
+  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 routed through the AC200 interrupt
+          controller. Omit when INTB is not connected. Cable detection status
+          can also be read over I2C without an 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
+      - tv-vcc-supply
+      - ports
+
+    dependencies:
+      nvmem-cells: [ nvmem-cell-names ]
+      nvmem-cell-names: [ nvmem-cells ]
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+allOf:
+  - if:
+      properties:
+        tv-encoder:
+          anyOf:
+            - required: [ interrupts ]
+            - required: [ interrupts-extended ]
+      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>;
+
+        mixed-signal@10 {
+            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>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        mixed-signal@10 {
+            compatible = "x-powers,ac200";
+            reg = <0x10>;
+            clocks = <&pwm 5>;
+            /* INTB is not connected. */
+
+            tv-encoder {
+                compatible = "x-powers,ac200-tve";
+                tv-vcc-supply = <&reg_aldo2>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    port@0 {
+                        reg = <0>;
+
+                        endpoint {
+                            remote-endpoint = <&tcon_out_tve>;
+                        };
+                    };
+
+                    port@1 {
+                        reg = <1>;
+
+                        endpoint {
+                            remote-endpoint = <&composite_in>;
+                        };
+                    };
+                };
+            };
+        };
+    };
+...
MAINTAINERS +8 -0
index 3a19da74d00c..1b1dd57cc419 100644
@@ -29504,6 +29504,14 @@ 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
+F:   include/dt-bindings/mfd/x-powers,ac200.h
+
 X-POWERS AXP288 PMIC DRIVERS
 M:   Hans de Goede <[email protected]>
 S:   Maintained
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

#5 lore raw

Re: [PATCH v10 1/2] dt-bindings: mfd: x-powers: Add AC200

Quoted 27 lines · James Hilliard
Quoted 26 lines · Conor Dooley
Quoted 23 lines · James Hilliard

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 together with the audio codec and TV encoder child nodes. 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 used by the TV encoder. 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.

Keep the INTB connection and TV encoder interrupt optional, including when the TV encoder is enabled. Cable detection status is readable over I2C without an interrupt. If a TV encoder interrupt is described, require the parent interrupt domain and its upstream connection. Include examples with and without INTB connected.

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.

Quoted 8 lines
Quoted 1 line

This should have been dropped when you merged the patches.

Oh, forgot to do that.

Quoted 1 line

Not sure why you sent v10 without waiting for a reply from me on the v9.

I had figured I had enough pending fixes(i.e. sashiko reported issues and combining the patches) that it made sense to spin an updated series.

Please don't, it leads to fragmented discussions and missed comments.

Thanks,
Conor.

#6 lore raw

PATCH v10 2/2 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, retain the BSP resume path's 40 ms wait before creating the regmap and accessing registers, and deassert the common reset. No minimum delay is documented. Set only the deassert bit instead of forcing a reset cycle, avoiding a chip-wide reset of unrelated function registers. Leave the common reset deasserted during driver removal and system shutdown; function drivers own their block resets. Supplier unbind still tears down linked consumers and releases the provider's clock references.

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

Register the audio codec and TV encoder as MFD cells when their enabled child nodes are present. Filtering the cell list avoids unused platform devices and warnings about missing firmware nodes on PHY-only boards. Use automatically assigned platform device IDs to support multiple AC200 instances. Initialize the parent's DMA mask for its non-DMA children so their OF configuration does not warn about a missing mask.

Add a regmap IRQ controller for the shared level-triggered INTB output so the TV encoder can consume its cable-detection interrupt. Default to level-low when the upstream interrupt has no trigger type configured. Keep INTB disabled until regmap has masked the sources and installed the handler, and disable it before releasing the IRQ chip. The source function remains responsible for clearing its interrupt condition.

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.

---
 MAINTAINERS          |   1 +
 drivers/mfd/Kconfig  |  15 +++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/ac200.c  | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 272 insertions(+)
MAINTAINERS +1 -0
index 1b1dd57cc419..8a48f6a1e593 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
 F:	include/dt-bindings/mfd/x-powers,ac200.h
 
 X-POWERS AXP288 PMIC DRIVERS
drivers/mfd/Kconfig +15 -0
index 857ca3bb0d5b..5193c6f71bd8 100644
@@ -205,6 +205,21 @@ 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 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 and instantiates the individual function
+	  devices.
+
 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 +255 -0

255 lines not on this page · raw message

Signature · 1 line
2.53.0
#7 lore raw

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

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Creating a local stack copy of the mfd_cell array for dynamic amendments violates MFD subsystem…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Creating a local stack copy of the mfd_cell array for dynamic amendments violates MFD subsystem guidelines. --

commit 89b84971b8215b5790b042d0288d352785ec348e
Author: James Hilliard <[email protected]>

mfd: ac200: Add X-Powers AC200 support

This patch adds support for the X-Powers AC200 mixed-signal companion IC. It provides shared regmap access, an IRQ controller for the INTB output, and instantiates the individual function devices like the audio codec and TV encoder.

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

[ ... ]

Quoted 15 lines
drivers/mfd/ac200.c new file +15 -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;
+
+	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;

drivers/mfd/ac200.c line 177

Quoted 10 lines
drivers/mfd/ac200.c new file +10 -0
+		if (of_device_is_available(child))
+			cells[num_cells++] = *cell;
+		of_node_put(child);
+	}
+
+	if (!num_cells)
+		return 0;
+
+	ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cells, num_cells,
+				   NULL, 0, NULL);

[Severity: Medium]
Does this pass a dynamically amended local stack copy of the mfd_cell array to the MFD core?

The MFD subsystem guidelines advise against creating local copies of mfd_cell arrays for dynamic amendments, as standard practice requires static const references for these arrays.

Could this be updated so the static array is passed directly, leaving the node availability checks to either the MFD core or the individual child drivers during their own probe sequences?

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