Skip to contentSkip to conversation

mfd: cpcap: convert documentation to schema and add Mot board support

PATCH Superseded Svyatoslav Ryhel 4 participants 20 messages May 10 – May 20

Subsystems (5)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover mfd: cpcap: convert documentation to schema and add Mot board support

The initial goal was only to add support for the CPCAP used in the Mot Tegra20 board; however, since the documentation was already partially converted, I decided to complete the conversion to schema too.

The CPCAP regulator, leds, rtc, pwrbutton and core files were converted from TXT to YAML while preserving the original structure. Mot board compatibility was added to the regulator and core schema. Since these were one-line patches, they were not separated into dedicated commits; however, the commit message notes this for both cases.

Finally, the CPCAP MFD was slightly refactored to improve support for multiple subcell compositions.

---
Changes in v2:
- fixed code style
- rtc conversion was picked, so patch dropped
- added audio ports description into mfd schema
- splitted schema conversion and compatible addition
- minor style improvements and typo fixes

Changes in v3:
- added regulator node names list into pattern
- filled spi_device_id with driver data
- ADC patches were picked, so changes dropped

Changes in v4:
- dropped regulator patches (applied)

Changes in v5:
- switched to MFD_CELL_* macros
- switched to use determinator of model
- switched to spi_get_device_match_data
---

Svyatoslav Ryhel (6):
dt-bindings: leds: leds-cpcap: convert to DT schema
dt-bindings: input: cpcap-pwrbutton: convert to DT schema
dt-bindings: mfd: motorola-cpcap: convert to DT schema
dt-bindings: mfd: motorola-cpcap: document Mapphone and Mot CPCAP
mfd: motorola-cpcap: diverge configuration per-board
mfd: motorola-cpcap: add support for Mot CPCAP composition

 .../bindings/input/cpcap-pwrbutton.txt        |  20 -
 .../input/motorola,cpcap-pwrbutton.yaml       |  32 ++
 .../devicetree/bindings/leds/leds-cpcap.txt   |  29 --
 .../bindings/leds/motorola,cpcap-leds.yaml    |  42 ++
 .../bindings/mfd/motorola,cpcap.yaml          | 419 ++++++++++++++++++
 .../bindings/mfd/motorola-cpcap.txt           |  78 ----
 drivers/mfd/motorola-cpcap.c                  | 172 ++++---
 include/linux/mfd/motorola-cpcap.h            |   7 +
 8 files changed, 611 insertions(+), 188 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
 create mode 100644 Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-cpcap.txt
 create mode 100644 Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml
 create mode 100644 Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
 delete mode 100644 Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
Signature · 1 line
2.51.0
#1 lore raw

PATCH v5 1/6 dt-bindings: leds: leds-cpcap: convert to DT schema

Convert LEDs devicetree bindings for the Motorola CPCAP MFD from TXT to YAML format. This patch does not change any functionality; the bindings remain the same.

---
 .../devicetree/bindings/leds/leds-cpcap.txt   | 29 -------------
 .../bindings/leds/motorola,cpcap-leds.yaml    | 42 +++++++++++++++++++
 2 files changed, 42 insertions(+), 29 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-cpcap.txt
 create mode 100644 Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml
Documentation/devicetree/bindings/leds/leds-cpcap.txt deleted +0 -29
deleted file mode 100644
index ebf7cdc7f70c..000000000000
@@ -1,29 +0,0 @@
-Motorola CPCAP PMIC LEDs
-------------------------
-
-This module is part of the CPCAP. For more details about the whole
-chip see Documentation/devicetree/bindings/mfd/motorola-cpcap.txt.
-
-Requires node properties:
-- compatible: should be one of
-   * "motorola,cpcap-led-mdl"		(Main Display Lighting)
-   * "motorola,cpcap-led-kl"		(Keyboard Lighting)
-   * "motorola,cpcap-led-adl"		(Aux Display Lighting)
-   * "motorola,cpcap-led-red"		(Red Triode)
-   * "motorola,cpcap-led-green"		(Green Triode)
-   * "motorola,cpcap-led-blue"		(Blue Triode)
-   * "motorola,cpcap-led-cf"		(Camera Flash)
-   * "motorola,cpcap-led-bt"		(Bluetooth)
-   * "motorola,cpcap-led-cp"		(Camera Privacy LED)
-- label: see Documentation/devicetree/bindings/leds/common.txt
-- vdd-supply: A phandle to the regulator powering the LED
-
-Example:
-
-&cpcap {
-	cpcap_led_red: red-led {
-		compatible = "motorola,cpcap-led-red";
-		label = "cpcap:red";
-		vdd-supply = <&sw5>;
-	};
-};
Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v5 1/6] dt-bindings: leds: leds-cpcap: convert to DT schema

Quoted 4 lines · Svyatoslav Ryhel

Convert LEDs devicetree bindings for the Motorola CPCAP MFD from TXT to YAML format. This patch does not change any functionality; the bindings remain the same.

Quoted 9 lines
---
 .../devicetree/bindings/leds/leds-cpcap.txt   | 29 -------------
 .../bindings/leds/motorola,cpcap-leds.yaml    | 42 +++++++++++++++++++
 2 files changed, 42 insertions(+), 29 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/leds/leds-cpcap.txt
 create mode 100644 Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):
Warning: Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml references a file that doesn't exist: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
Warning: Documentation/devicetree/bindings/mfd/motorola-cpcap.txt references a file that doesn't exist: Documentation/devicetree/bindings/leds/leds-cpcap.txt Documentation/devicetree/bindings/leds/motorola,cpcap-leds.yaml: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml Documentation/devicetree/bindings/mfd/motorola-cpcap.txt: Documentation/devicetree/bindings/leds/leds-cpcap.txt

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#3 lore raw

PATCH v5 2/6 dt-bindings: input: cpcap-pwrbutton: convert to DT schema

In reply to Svyatoslav Ryhel

Convert power button devicetree bindings for the Motorola CPCAP MFD from TXT to YAML format. This patch does not change any functionality; the bindings remain the same.

---
 .../bindings/input/cpcap-pwrbutton.txt        | 20 ------------
 .../input/motorola,cpcap-pwrbutton.yaml       | 32 +++++++++++++++++++
 2 files changed, 32 insertions(+), 20 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
 create mode 100644 Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml
Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt deleted +0 -20
deleted file mode 100644
index 0dd0076daf71..000000000000
@@ -1,20 +0,0 @@
-Motorola CPCAP on key
-
-This module is part of the CPCAP. For more details about the whole
-chip see Documentation/devicetree/bindings/mfd/motorola-cpcap.txt.
-
-This module provides a simple power button event via an Interrupt.
-
-Required properties:
-- compatible: should be one of the following
-   - "motorola,cpcap-pwrbutton"
-- interrupts: irq specifier for CPCAP's ON IRQ
-
-Example:
-
-&cpcap {
-	cpcap_pwrbutton: pwrbutton {
-		compatible = "motorola,cpcap-pwrbutton";
-		interrupts = <23 IRQ_TYPE_NONE>;
-	};
-};
Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml new file +32 -0
new file mode 100644
index 000000000000..77a3e5a47d1a
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/motorola,cpcap-pwrbutton.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorola CPCAP PMIC power key
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+description:
+  This module is part of the Motorola CPCAP MFD device. For more details
+  see Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml. The
+  power key is represented as a sub-node of the PMIC node on the device
+  tree.
+
+properties:
+  compatible:
+    const: motorola,cpcap-pwrbutton
+
+  interrupts:
+    items:
+      - description: CPCAP's ON interrupt
+
+required:
+  - compatible
+  - interrupts
+
+additionalProperties: false
+
+...
Signature · 1 line
2.51.0
#4 lore raw

Re: [PATCH v5 2/6] dt-bindings: input: cpcap-pwrbutton: convert to DT schema

Quoted 7 lines · Svyatoslav Ryhel

Convert power button devicetree bindings for the Motorola CPCAP MFD from TXT to YAML format. This patch does not change any functionality; the bindings remain the same.

Quoted 7 lines
---
 .../bindings/input/cpcap-pwrbutton.txt        | 20 ------------
 .../input/motorola,cpcap-pwrbutton.yaml       | 32 +++++++++++++++++++
 2 files changed, 32 insertions(+), 20 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
 create mode 100644 Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):
Warning: Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml references a file that doesn't exist: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
Warning: Documentation/devicetree/bindings/mfd/motorola-cpcap.txt references a file that doesn't exist: Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt Documentation/devicetree/bindings/input/motorola,cpcap-pwrbutton.yaml: Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml Documentation/devicetree/bindings/mfd/motorola-cpcap.txt: Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt

See https://patchwork.kernel.org/project/devicetree/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#5 lore raw

PATCH v5 3/6 dt-bindings: mfd: motorola-cpcap: convert to DT schema

In reply to Svyatoslav Ryhel

Convert devicetree bindings for the Motorola CPCAP MFD from TXT to YAML.

---
 .../bindings/mfd/motorola,cpcap.yaml          | 414 ++++++++++++++++++
 .../bindings/mfd/motorola-cpcap.txt           |  78 ----
 2 files changed, 414 insertions(+), 78 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
 delete mode 100644 Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +414 -0
new file mode 100644
index 000000000000..7f257f3a1a5a
@@ -0,0 +1,414 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/motorola,cpcap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorola CPCAP PMIC MFD
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: motorola,cpcap
+      - const: st,6556002
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  spi-max-frequency:
+    maximum: 9600000
+
+  spi-cs-high: true
+  spi-cpol: true
+  spi-cpha: true
+
+  adc:
+    $ref: /schemas/iio/adc/motorola,cpcap-adc.yaml#
+
+  audio-codec:
+    type: object
+    additionalProperties: false
+
+    properties:
+      interrupts:
+        items:
+          - description: headset detect interrupt
+          - description: microphone bias 2 detect interrupt
+
+      interrupt-names:
+        items:
+          - const: hs
+          - const: mb2
+
+      "#sound-dai-cells":
+        const: 1
+
+      VAUDIO-supply:
+        description:
+          Codec power supply, usually VAUDIO regulator of CPCAP.
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Stereo HiFi DAC
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Voice DAC
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - interrupts
+      - interrupt-names
+      - "#sound-dai-cells"
+
+  battery:
+    $ref: /schemas/power/supply/cpcap-battery.yaml#
+
+  charger:
+    $ref: /schemas/power/supply/cpcap-charger.yaml#
+
+  key-power:
+    $ref: /schemas/input/motorola,cpcap-pwrbutton.yaml#
+
+  phy:
+    $ref: /schemas/phy/motorola,cpcap-usb-phy.yaml#
+
+  regulator:
+    $ref: /schemas/regulator/motorola,cpcap-regulator.yaml#
+
+  rtc:
+    $ref: /schemas/rtc/motorola,cpcap-rtc.yaml#
+
+patternProperties:
+  "^led(-[a-z]+)?$":
+    $ref: /schemas/leds/motorola,cpcap-leds.yaml#
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - "#interrupt-cells"
+  - spi-max-frequency
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/linux-event-codes.h>
+
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        cpcap: pmic@0 {
+            compatible = "motorola,cpcap", "st,6556002";
+            reg = <0>; /* cs0 */
+
+            interrupt-parent = <&gpio1>;
+            interrupts = <7 IRQ_TYPE_EDGE_RISING>;
+
+            interrupt-controller;
+            #interrupt-cells = <2>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            spi-max-frequency = <3000000>;
+            spi-cs-high;
+
+            spi-cpol;
+            spi-cpha;
+
+            cpcap_adc: adc {
+                compatible = "motorola,cpcap-adc";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <8 IRQ_TYPE_NONE>;
+                interrupt-names = "adcdone";
+
+                #io-channel-cells = <1>;
+            };
+
+            cpcap_audio: audio-codec {
+                interrupt-parent = <&cpcap>;
+                interrupts = <9 IRQ_TYPE_NONE>, <10 IRQ_TYPE_NONE>;
+                interrupt-names = "hs", "mb2";
+
+                VAUDIO-supply = <&vdd_audio>;
+
+                #sound-dai-cells = <1>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    /* HiFi */
+                    port@0 {
+                        reg = <0>;
+
+                        cpcap_audio_codec0: endpoint {
+                        };
+                    };
+
+                    /* Voice */
+                    port@1 {
+                        reg = <1>;
+
+                        cpcap_audio_codec1: endpoint {
+                        };
+                    };
+                };
+            };
+
+            cpcap_battery: battery {
+                compatible = "motorola,cpcap-battery";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <6 IRQ_TYPE_NONE>, <5 IRQ_TYPE_NONE>,
+                             <3 IRQ_TYPE_NONE>, <20 IRQ_TYPE_NONE>,
+                             <54 IRQ_TYPE_NONE>, <57 IRQ_TYPE_NONE>;
+                interrupt-names = "eol", "lowbph", "lowbpl",
+                                  "chrgcurr1", "battdetb", "cccal";
+
+                io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>,
+                              <&cpcap_adc 5>, <&cpcap_adc 6>;
+                io-channel-names = "battdetb", "battp",
+                                   "chg_isense", "batti";
+                power-supplies = <&cpcap_charger>;
+            };
+
+            cpcap_charger: charger {
+                compatible = "motorola,mapphone-cpcap-charger";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <13 IRQ_TYPE_NONE>, <12 IRQ_TYPE_NONE>,
+                             <29 IRQ_TYPE_NONE>, <28 IRQ_TYPE_NONE>,
+                             <22 IRQ_TYPE_NONE>, <21 IRQ_TYPE_NONE>,
+                             <20 IRQ_TYPE_NONE>, <19 IRQ_TYPE_NONE>,
+                             <54 IRQ_TYPE_NONE>;
+                interrupt-names = "chrg_det", "rvrs_chrg", "chrg_se1b",
+                                  "se0conn", "rvrs_mode", "chrgcurr2",
+                                  "chrgcurr1", "vbusvld", "battdetb";
+
+                mode-gpios = <&gpio3 29 GPIO_ACTIVE_LOW>,
+                             <&gpio3 23 GPIO_ACTIVE_LOW>;
+
+                io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>,
+                              <&cpcap_adc 2>, <&cpcap_adc 5>,
+                              <&cpcap_adc 6>;
+                io-channel-names = "battdetb", "battp",
+                                   "vbus", "chg_isense",
+                                   "batti";
+            };
+
+            key-power {
+                compatible = "motorola,cpcap-pwrbutton";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <23 IRQ_TYPE_NONE>;
+            };
+
+            led-red {
+                compatible = "motorola,cpcap-led-red";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::red";
+            };
+
+            led-green {
+                compatible = "motorola,cpcap-led-green";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::green";
+            };
+
+            led-blue {
+                compatible = "motorola,cpcap-led-blue";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::blue";
+            };
+
+            cpcap_usb2_phy: phy {
+                compatible = "motorola,cpcap-usb-phy";
+
+                pinctrl-0 = <&usb_gpio_mux_sel1>, <&usb_gpio_mux_sel2>;
+                pinctrl-1 = <&usb_ulpi_pins>;
+                pinctrl-2 = <&usb_utmi_pins>;
+                pinctrl-3 = <&uart3_pins>;
+                pinctrl-names = "default", "ulpi", "utmi", "uart";
+                #phy-cells = <0>;
+
+                interrupts-extended =
+                    <&cpcap 15 IRQ_TYPE_NONE>, <&cpcap 14 IRQ_TYPE_NONE>,
+                    <&cpcap 28 IRQ_TYPE_NONE>, <&cpcap 19 IRQ_TYPE_NONE>,
+                    <&cpcap 18 IRQ_TYPE_NONE>, <&cpcap 17 IRQ_TYPE_NONE>,
+                    <&cpcap 16 IRQ_TYPE_NONE>, <&cpcap 49 IRQ_TYPE_NONE>,
+                    <&cpcap 48 IRQ_TYPE_NONE>;
+                interrupt-names = "id_ground", "id_float", "se0conn",
+                                  "vbusvld", "sessvld", "sessend",
+                                  "se1", "dm", "dp";
+
+                mode-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>,
+                             <&gpio1 0 GPIO_ACTIVE_HIGH>;
+
+                io-channels = <&cpcap_adc 2>, <&cpcap_adc 7>;
+                io-channel-names = "vbus", "id";
+
+                vusb-supply = <&avdd_usb>;
+            };
+
+            regulator {
+                compatible = "motorola,cpcap-regulator";
+
+                regulators {
+                    vdd_cpu: SW1 {
+                        regulator-name = "vdd_cpu";
+                        regulator-min-microvolt = <750000>;
+                        regulator-max-microvolt = <1125000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_core: SW2 {
+                        regulator-name = "vdd_core";
+                        regulator-min-microvolt = <950000>;
+                        regulator-max-microvolt = <1300000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_1v8_vio: SW3 {
+                        regulator-name = "vdd_1v8_vio";
+                        regulator-min-microvolt = <1800000>;
+                        regulator-max-microvolt = <1800000>;
+                        regulator-enable-ramp-delay = <0>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_aon: SW4 {
+                        regulator-name = "vdd_aon";
+                        regulator-min-microvolt = <950000>;
+                        regulator-max-microvolt = <1300000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_led: SW5 {
+                        regulator-name = "vdd_led";
+                        regulator-min-microvolt = <5050000>;
+                        regulator-max-microvolt = <5050000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-boot-on;
+                    };
+
+                    vdd_hvio: VHVIO {
+                        regulator-name = "vdd_hvio";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <2775000>;
+                        regulator-enable-ramp-delay = <1000>;
+                    };
+
+                    vcore_emmc: VSDIO {
+                        regulator-name = "vcore_emmc";
+                        regulator-min-microvolt = <1500000>;
+                        regulator-max-microvolt = <3000000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    avdd_dsi_csi: VCSI {
+                        regulator-name = "avdd_dsi_csi";
+                        regulator-min-microvolt = <1200000>;
+                        regulator-max-microvolt = <1200000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    avdd_3v3_periph: VWLAN2 {
+                        regulator-name = "avdd_3v3_periph";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <3300000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    vddio_usd: VSIMCARD {
+                        regulator-name = "vddio_usd";
+                        regulator-min-microvolt = <1800000>;
+                        regulator-max-microvolt = <2900000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    vdd_haptic: VVIB {
+                        regulator-name = "vdd_haptic";
+                        regulator-min-microvolt = <1300000>;
+                        regulator-max-microvolt = <3000000>;
+                        regulator-enable-ramp-delay = <1000>;
+                    };
+
+                    avdd_usb: VUSB {
+                        regulator-name = "avdd_usb";
+                        regulator-min-microvolt = <3300000>;
+                        regulator-max-microvolt = <3300000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_audio: VAUDIO {
+                        regulator-name = "vdd_audio";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <2775000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+                };
+            };
+
+            cpcap_rtc: rtc {
+                compatible = "motorola,cpcap-rtc";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>;
+            };
+        };
+    };
+
+...
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt deleted +0 -78

78 lines not on this page · raw message

Signature · 1 line
2.51.0
#6 lore raw

Re: [PATCH v5 3/6] dt-bindings: mfd: motorola-cpcap: convert to DT schema

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Medium] The YAML schema enforces a `ports` wrapper node for `audio-codec`, breaking validation for…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] The YAML schema enforces a ports wrapper node for audio-codec, breaking validation for existing device trees.
- [Medium] The power button subnode name key-power conflicts with existing device trees, causing validation failures.
- [Medium] The spi-cs-high property was dropped from the required list during YAML conversion.
- [Low] The schema uses additionalProperties: false alongside a $ref in allOf, which is a dt-schema anti-pattern. --

commit f0e021d94a5e3dc2af4a93b58f8cc3b052099a76
Author: Svyatoslav Ryhel <[email protected]>

dt-bindings: mfd: motorola-cpcap: convert to DT schema

Convert devicetree bindings for the Motorola CPCAP MFD from TXT to YAML.

Quoted 21 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +15 -0
new file mode 100644
index 0000000000000..7f257f3a1a5a2
@@ -0,0 +1,414 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/motorola,cpcap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorola CPCAP PMIC MFD
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:

[ ... ]

Quoted 5 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +5 -0
+  audio-codec:
+    type: object
+    additionalProperties: false
+
+    properties:

[ ... ]

Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml line 80

Quoted 11 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +11 -0
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Stereo HiFi DAC
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Voice DAC

Will this cause validation failures for existing device trees?

The new YAML schema defines additionalProperties: false on the audio-codec node and expects OF graph ports to be nested strictly inside a ports child node. The original TXT binding example and existing device trees place port@0 directly under the audio-codec node without a ports wrapper.

[ ... ]

Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml line 98

Quoted 8 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +8 -0
+  battery:
+    $ref: /schemas/power/supply/cpcap-battery.yaml#
+
+  charger:
+    $ref: /schemas/power/supply/cpcap-charger.yaml#
+
+  key-power:
+    $ref: /schemas/input/motorola,cpcap-pwrbutton.yaml#

Is this node name conflict expected?

The schema strictly defines the power button child node as key-power, but existing upstream device trees name this node button. Since button is not explicitly defined in the YAML properties, will it be rejected by dtbs_check?

[ ... ]

Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml line 121

Quoted 9 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +9 -0
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - "#interrupt-cells"
+  - spi-max-frequency
+  - "#address-cells"
+  - "#size-cells"

Was spi-cs-high intentionally omitted from the required list?

The original TXT binding explicitly listed it under required properties, and the hardware requires an active-high SPI chip select to function correctly.

Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml

Quoted 2 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +2 -0
+
+additionalProperties: false

Should this be unevaluatedProperties: false instead?

In JSON schema, additionalProperties: false ignores properties inherited from $ref inclusions inside allOf. This rejects standard SPI properties unless they are manually duplicated in the local properties block.

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

Re: [PATCH v5 3/6] dt-bindings: mfd: motorola-cpcap: convert to DT schema

In reply to Svyatoslav Ryhel
Quoted 43 lines · Svyatoslav Ryhel

Convert devicetree bindings for the Motorola CPCAP MFD from TXT to YAML.

---
 .../bindings/mfd/motorola,cpcap.yaml          | 414 ++++++++++++++++++
 .../bindings/mfd/motorola-cpcap.txt           |  78 ----
 2 files changed, 414 insertions(+), 78 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
 delete mode 100644 Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +26 -0
new file mode 100644
index 000000000000..7f257f3a1a5a
@@ -0,0 +1,414 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/motorola,cpcap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorola CPCAP PMIC MFD
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: motorola,cpcap
+      - const: st,6556002
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+

Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml line 36

Quoted 10 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +10 -0
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0

There aren't any child nodes with an address. These 2 can be dropped.

Quoted 465 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +378 -0
+
+  spi-max-frequency:
+    maximum: 9600000
+
+  spi-cs-high: true
+  spi-cpol: true
+  spi-cpha: true
+
+  adc:
+    $ref: /schemas/iio/adc/motorola,cpcap-adc.yaml#
+
+  audio-codec:
+    type: object
+    additionalProperties: false
+
+    properties:
+      interrupts:
+        items:
+          - description: headset detect interrupt
+          - description: microphone bias 2 detect interrupt
+
+      interrupt-names:
+        items:
+          - const: hs
+          - const: mb2
+
+      "#sound-dai-cells":
+        const: 1
+
+      VAUDIO-supply:
+        description:
+          Codec power supply, usually VAUDIO regulator of CPCAP.
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Stereo HiFi DAC
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Voice DAC
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - interrupts
+      - interrupt-names
+      - "#sound-dai-cells"
+
+  battery:
+    $ref: /schemas/power/supply/cpcap-battery.yaml#
+
+  charger:
+    $ref: /schemas/power/supply/cpcap-charger.yaml#
+
+  key-power:
+    $ref: /schemas/input/motorola,cpcap-pwrbutton.yaml#
+
+  phy:
+    $ref: /schemas/phy/motorola,cpcap-usb-phy.yaml#
+
+  regulator:
+    $ref: /schemas/regulator/motorola,cpcap-regulator.yaml#
+
+  rtc:
+    $ref: /schemas/rtc/motorola,cpcap-rtc.yaml#
+
+patternProperties:
+  "^led(-[a-z]+)?$":
+    $ref: /schemas/leds/motorola,cpcap-leds.yaml#
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - "#interrupt-cells"
+  - spi-max-frequency
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/linux-event-codes.h>
+
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        cpcap: pmic@0 {
+            compatible = "motorola,cpcap", "st,6556002";
+            reg = <0>; /* cs0 */
+
+            interrupt-parent = <&gpio1>;
+            interrupts = <7 IRQ_TYPE_EDGE_RISING>;
+
+            interrupt-controller;
+            #interrupt-cells = <2>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            spi-max-frequency = <3000000>;
+            spi-cs-high;
+
+            spi-cpol;
+            spi-cpha;
+
+            cpcap_adc: adc {
+                compatible = "motorola,cpcap-adc";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <8 IRQ_TYPE_NONE>;
+                interrupt-names = "adcdone";
+
+                #io-channel-cells = <1>;
+            };
+
+            cpcap_audio: audio-codec {
+                interrupt-parent = <&cpcap>;
+                interrupts = <9 IRQ_TYPE_NONE>, <10 IRQ_TYPE_NONE>;
+                interrupt-names = "hs", "mb2";
+
+                VAUDIO-supply = <&vdd_audio>;
+
+                #sound-dai-cells = <1>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    /* HiFi */
+                    port@0 {
+                        reg = <0>;
+
+                        cpcap_audio_codec0: endpoint {
+                        };
+                    };
+
+                    /* Voice */
+                    port@1 {
+                        reg = <1>;
+
+                        cpcap_audio_codec1: endpoint {
+                        };
+                    };
+                };
+            };
+
+            cpcap_battery: battery {
+                compatible = "motorola,cpcap-battery";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <6 IRQ_TYPE_NONE>, <5 IRQ_TYPE_NONE>,
+                             <3 IRQ_TYPE_NONE>, <20 IRQ_TYPE_NONE>,
+                             <54 IRQ_TYPE_NONE>, <57 IRQ_TYPE_NONE>;
+                interrupt-names = "eol", "lowbph", "lowbpl",
+                                  "chrgcurr1", "battdetb", "cccal";
+
+                io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>,
+                              <&cpcap_adc 5>, <&cpcap_adc 6>;
+                io-channel-names = "battdetb", "battp",
+                                   "chg_isense", "batti";
+                power-supplies = <&cpcap_charger>;
+            };
+
+            cpcap_charger: charger {
+                compatible = "motorola,mapphone-cpcap-charger";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <13 IRQ_TYPE_NONE>, <12 IRQ_TYPE_NONE>,
+                             <29 IRQ_TYPE_NONE>, <28 IRQ_TYPE_NONE>,
+                             <22 IRQ_TYPE_NONE>, <21 IRQ_TYPE_NONE>,
+                             <20 IRQ_TYPE_NONE>, <19 IRQ_TYPE_NONE>,
+                             <54 IRQ_TYPE_NONE>;
+                interrupt-names = "chrg_det", "rvrs_chrg", "chrg_se1b",
+                                  "se0conn", "rvrs_mode", "chrgcurr2",
+                                  "chrgcurr1", "vbusvld", "battdetb";
+
+                mode-gpios = <&gpio3 29 GPIO_ACTIVE_LOW>,
+                             <&gpio3 23 GPIO_ACTIVE_LOW>;
+
+                io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>,
+                              <&cpcap_adc 2>, <&cpcap_adc 5>,
+                              <&cpcap_adc 6>;
+                io-channel-names = "battdetb", "battp",
+                                   "vbus", "chg_isense",
+                                   "batti";
+            };
+
+            key-power {
+                compatible = "motorola,cpcap-pwrbutton";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <23 IRQ_TYPE_NONE>;
+            };
+
+            led-red {
+                compatible = "motorola,cpcap-led-red";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::red";
+            };
+
+            led-green {
+                compatible = "motorola,cpcap-led-green";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::green";
+            };
+
+            led-blue {
+                compatible = "motorola,cpcap-led-blue";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::blue";
+            };
+
+            cpcap_usb2_phy: phy {
+                compatible = "motorola,cpcap-usb-phy";
+
+                pinctrl-0 = <&usb_gpio_mux_sel1>, <&usb_gpio_mux_sel2>;
+                pinctrl-1 = <&usb_ulpi_pins>;
+                pinctrl-2 = <&usb_utmi_pins>;
+                pinctrl-3 = <&uart3_pins>;
+                pinctrl-names = "default", "ulpi", "utmi", "uart";
+                #phy-cells = <0>;
+
+                interrupts-extended =
+                    <&cpcap 15 IRQ_TYPE_NONE>, <&cpcap 14 IRQ_TYPE_NONE>,
+                    <&cpcap 28 IRQ_TYPE_NONE>, <&cpcap 19 IRQ_TYPE_NONE>,
+                    <&cpcap 18 IRQ_TYPE_NONE>, <&cpcap 17 IRQ_TYPE_NONE>,
+                    <&cpcap 16 IRQ_TYPE_NONE>, <&cpcap 49 IRQ_TYPE_NONE>,
+                    <&cpcap 48 IRQ_TYPE_NONE>;
+                interrupt-names = "id_ground", "id_float", "se0conn",
+                                  "vbusvld", "sessvld", "sessend",
+                                  "se1", "dm", "dp";
+
+                mode-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>,
+                             <&gpio1 0 GPIO_ACTIVE_HIGH>;
+
+                io-channels = <&cpcap_adc 2>, <&cpcap_adc 7>;
+                io-channel-names = "vbus", "id";
+
+                vusb-supply = <&avdd_usb>;
+            };
+
+            regulator {
+                compatible = "motorola,cpcap-regulator";
+
+                regulators {
+                    vdd_cpu: SW1 {
+                        regulator-name = "vdd_cpu";
+                        regulator-min-microvolt = <750000>;
+                        regulator-max-microvolt = <1125000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_core: SW2 {
+                        regulator-name = "vdd_core";
+                        regulator-min-microvolt = <950000>;
+                        regulator-max-microvolt = <1300000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_1v8_vio: SW3 {
+                        regulator-name = "vdd_1v8_vio";
+                        regulator-min-microvolt = <1800000>;
+                        regulator-max-microvolt = <1800000>;
+                        regulator-enable-ramp-delay = <0>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_aon: SW4 {
+                        regulator-name = "vdd_aon";
+                        regulator-min-microvolt = <950000>;
+                        regulator-max-microvolt = <1300000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_led: SW5 {
+                        regulator-name = "vdd_led";
+                        regulator-min-microvolt = <5050000>;
+                        regulator-max-microvolt = <5050000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-boot-on;
+                    };
+
+                    vdd_hvio: VHVIO {
+                        regulator-name = "vdd_hvio";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <2775000>;
+                        regulator-enable-ramp-delay = <1000>;
+                    };
+
+                    vcore_emmc: VSDIO {
+                        regulator-name = "vcore_emmc";
+                        regulator-min-microvolt = <1500000>;
+                        regulator-max-microvolt = <3000000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    avdd_dsi_csi: VCSI {
+                        regulator-name = "avdd_dsi_csi";
+                        regulator-min-microvolt = <1200000>;
+                        regulator-max-microvolt = <1200000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    avdd_3v3_periph: VWLAN2 {
+                        regulator-name = "avdd_3v3_periph";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <3300000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    vddio_usd: VSIMCARD {
+                        regulator-name = "vddio_usd";
+                        regulator-min-microvolt = <1800000>;
+                        regulator-max-microvolt = <2900000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    vdd_haptic: VVIB {
+                        regulator-name = "vdd_haptic";
+                        regulator-min-microvolt = <1300000>;
+                        regulator-max-microvolt = <3000000>;
+                        regulator-enable-ramp-delay = <1000>;
+                    };
+
+                    avdd_usb: VUSB {
+                        regulator-name = "avdd_usb";
+                        regulator-min-microvolt = <3300000>;
+                        regulator-max-microvolt = <3300000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_audio: VAUDIO {
+                        regulator-name = "vdd_audio";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <2775000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+                };
+            };
+
+            cpcap_rtc: rtc {
+                compatible = "motorola,cpcap-rtc";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>;
+            };
+        };
+    };
+
+...
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt deleted +0 -78
deleted file mode 100644
index 18c3fc26ca93..000000000000
@@ -1,78 +0,0 @@
-Motorola CPCAP PMIC device tree binding
-
-Required properties:
-- compatible		: One or both of "motorola,cpcap" or "ste,6556002"
-- reg			: SPI chip select
-- interrupts		: The interrupt line the device is connected to
-- interrupt-controller	: Marks the device node as an interrupt controller
-- #interrupt-cells	: The number of cells to describe an IRQ, should be 2
-- #address-cells	: Child device offset number of cells, should be 1
-- #size-cells		: Child device size number of cells, should be 0
-- spi-max-frequency	: Typically set to 3000000
-- spi-cs-high		: SPI chip select direction
-
-Optional subnodes:
-
-The sub-functions of CPCAP get their own node with their own compatible values,
-which are described in the following files:
-
-- Documentation/devicetree/bindings/power/supply/cpcap-battery.yaml
-- Documentation/devicetree/bindings/power/supply/cpcap-charger.yaml
-- Documentation/devicetree/bindings/regulator/cpcap-regulator.txt
-- Documentation/devicetree/bindings/phy/motorola,cpcap-usb-phy.yaml
-- Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
-- Documentation/devicetree/bindings/rtc/cpcap-rtc.txt
-- Documentation/devicetree/bindings/leds/leds-cpcap.txt
-- Documentation/devicetree/bindings/iio/adc/motorola,cpcap-adc.yaml
-
-The only exception is the audio codec. Instead of a compatible value its
-node must be named "audio-codec".
-
-Required properties for the audio-codec subnode:
-
-- #sound-dai-cells = <1>;
-- interrupts		: should contain jack detection interrupts, with headset
-			  detect interrupt matching "hs" and microphone bias 2
-			  detect interrupt matching "mb2" in interrupt-names.
-- interrupt-names	: Contains "hs", "mb2"
-
-The audio-codec provides two DAIs. The first one is connected to the
-Stereo HiFi DAC and the second one is connected to the Voice DAC.
-
-Example:
-
-&mcspi1 {
-	cpcap: pmic@0 {
-		compatible = "motorola,cpcap", "ste,6556002";
-		reg = <0>;	/* cs0 */
-		interrupt-parent = <&gpio1>;
-		interrupts = <7 IRQ_TYPE_EDGE_RISING>;
-		interrupt-controller;
-		#interrupt-cells = <2>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-		spi-max-frequency = <3000000>;
-		spi-cs-high;
-
-		audio-codec {
-			#sound-dai-cells = <1>;
-			interrupts-extended = <&cpcap 9 0>, <&cpcap 10 0>;
-			interrupt-names = "hs", "mb2";
-
-			/* HiFi */
-			port@0 {
-				endpoint {
-					remote-endpoint = <&cpu_dai1>;
-				};
-			};
-
-			/* Voice */
-			port@1 {
-				endpoint {
-					remote-endpoint = <&cpu_dai2>;
-				};
-			};
-		};
-	};
-};
-
Signature · 1 line
2.51.0
#8 lore raw

Re: [PATCH v5 3/6] dt-bindings: mfd: motorola-cpcap: convert to DT schema

вт, 12 трав. 2026 р. о 15:53 Rob Herring <[email protected]> пише:

Quoted 49 lines · Svyatoslav Ryhel
Quoted 47 lines

Convert devicetree bindings for the Motorola CPCAP MFD from TXT to YAML.

---
 .../bindings/mfd/motorola,cpcap.yaml          | 414 ++++++++++++++++++
 .../bindings/mfd/motorola-cpcap.txt           |  78 ----
 2 files changed, 414 insertions(+), 78 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml
 delete mode 100644 Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +30 -0
new file mode 100644
index 000000000000..7f257f3a1a5a
@@ -0,0 +1,414 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/motorola,cpcap.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorola CPCAP PMIC MFD
+
+maintainers:
+  - Svyatoslav Ryhel <[email protected]>
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+properties:
+  compatible:
+    items:
+      - const: motorola,cpcap
+      - const: st,6556002
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  "#interrupt-cells":
+    const: 2
Quoted 9 lines

Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml line 36

Quoted 6 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +6 -0
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0

There aren't any child nodes with an address. These 2 can be dropped.

I will adjust in v6 if there will be need in one.

Quoted 465 lines
Quoted 465 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml new file +378 -0
+
+  spi-max-frequency:
+    maximum: 9600000
+
+  spi-cs-high: true
+  spi-cpol: true
+  spi-cpha: true
+
+  adc:
+    $ref: /schemas/iio/adc/motorola,cpcap-adc.yaml#
+
+  audio-codec:
+    type: object
+    additionalProperties: false
+
+    properties:
+      interrupts:
+        items:
+          - description: headset detect interrupt
+          - description: microphone bias 2 detect interrupt
+
+      interrupt-names:
+        items:
+          - const: hs
+          - const: mb2
+
+      "#sound-dai-cells":
+        const: 1
+
+      VAUDIO-supply:
+        description:
+          Codec power supply, usually VAUDIO regulator of CPCAP.
+
+      ports:
+        $ref: /schemas/graph.yaml#/properties/ports
+
+        properties:
+          port@0:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Stereo HiFi DAC
+
+          port@1:
+            $ref: /schemas/graph.yaml#/properties/port
+            description: port connected to the Voice DAC
+
+        required:
+          - port@0
+          - port@1
+
+    required:
+      - interrupts
+      - interrupt-names
+      - "#sound-dai-cells"
+
+  battery:
+    $ref: /schemas/power/supply/cpcap-battery.yaml#
+
+  charger:
+    $ref: /schemas/power/supply/cpcap-charger.yaml#
+
+  key-power:
+    $ref: /schemas/input/motorola,cpcap-pwrbutton.yaml#
+
+  phy:
+    $ref: /schemas/phy/motorola,cpcap-usb-phy.yaml#
+
+  regulator:
+    $ref: /schemas/regulator/motorola,cpcap-regulator.yaml#
+
+  rtc:
+    $ref: /schemas/rtc/motorola,cpcap-rtc.yaml#
+
+patternProperties:
+  "^led(-[a-z]+)?$":
+    $ref: /schemas/leds/motorola,cpcap-leds.yaml#
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - "#interrupt-cells"
+  - spi-max-frequency
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/input/linux-event-codes.h>
+
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        cpcap: pmic@0 {
+            compatible = "motorola,cpcap", "st,6556002";
+            reg = <0>; /* cs0 */
+
+            interrupt-parent = <&gpio1>;
+            interrupts = <7 IRQ_TYPE_EDGE_RISING>;
+
+            interrupt-controller;
+            #interrupt-cells = <2>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+
+            spi-max-frequency = <3000000>;
+            spi-cs-high;
+
+            spi-cpol;
+            spi-cpha;
+
+            cpcap_adc: adc {
+                compatible = "motorola,cpcap-adc";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <8 IRQ_TYPE_NONE>;
+                interrupt-names = "adcdone";
+
+                #io-channel-cells = <1>;
+            };
+
+            cpcap_audio: audio-codec {
+                interrupt-parent = <&cpcap>;
+                interrupts = <9 IRQ_TYPE_NONE>, <10 IRQ_TYPE_NONE>;
+                interrupt-names = "hs", "mb2";
+
+                VAUDIO-supply = <&vdd_audio>;
+
+                #sound-dai-cells = <1>;
+
+                ports {
+                    #address-cells = <1>;
+                    #size-cells = <0>;
+
+                    /* HiFi */
+                    port@0 {
+                        reg = <0>;
+
+                        cpcap_audio_codec0: endpoint {
+                        };
+                    };
+
+                    /* Voice */
+                    port@1 {
+                        reg = <1>;
+
+                        cpcap_audio_codec1: endpoint {
+                        };
+                    };
+                };
+            };
+
+            cpcap_battery: battery {
+                compatible = "motorola,cpcap-battery";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <6 IRQ_TYPE_NONE>, <5 IRQ_TYPE_NONE>,
+                             <3 IRQ_TYPE_NONE>, <20 IRQ_TYPE_NONE>,
+                             <54 IRQ_TYPE_NONE>, <57 IRQ_TYPE_NONE>;
+                interrupt-names = "eol", "lowbph", "lowbpl",
+                                  "chrgcurr1", "battdetb", "cccal";
+
+                io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>,
+                              <&cpcap_adc 5>, <&cpcap_adc 6>;
+                io-channel-names = "battdetb", "battp",
+                                   "chg_isense", "batti";
+                power-supplies = <&cpcap_charger>;
+            };
+
+            cpcap_charger: charger {
+                compatible = "motorola,mapphone-cpcap-charger";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <13 IRQ_TYPE_NONE>, <12 IRQ_TYPE_NONE>,
+                             <29 IRQ_TYPE_NONE>, <28 IRQ_TYPE_NONE>,
+                             <22 IRQ_TYPE_NONE>, <21 IRQ_TYPE_NONE>,
+                             <20 IRQ_TYPE_NONE>, <19 IRQ_TYPE_NONE>,
+                             <54 IRQ_TYPE_NONE>;
+                interrupt-names = "chrg_det", "rvrs_chrg", "chrg_se1b",
+                                  "se0conn", "rvrs_mode", "chrgcurr2",
+                                  "chrgcurr1", "vbusvld", "battdetb";
+
+                mode-gpios = <&gpio3 29 GPIO_ACTIVE_LOW>,
+                             <&gpio3 23 GPIO_ACTIVE_LOW>;
+
+                io-channels = <&cpcap_adc 0>, <&cpcap_adc 1>,
+                              <&cpcap_adc 2>, <&cpcap_adc 5>,
+                              <&cpcap_adc 6>;
+                io-channel-names = "battdetb", "battp",
+                                   "vbus", "chg_isense",
+                                   "batti";
+            };
+
+            key-power {
+                compatible = "motorola,cpcap-pwrbutton";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <23 IRQ_TYPE_NONE>;
+            };
+
+            led-red {
+                compatible = "motorola,cpcap-led-red";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::red";
+            };
+
+            led-green {
+                compatible = "motorola,cpcap-led-green";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::green";
+            };
+
+            led-blue {
+                compatible = "motorola,cpcap-led-blue";
+                vdd-supply = <&vdd_led>;
+                label = "status-led::blue";
+            };
+
+            cpcap_usb2_phy: phy {
+                compatible = "motorola,cpcap-usb-phy";
+
+                pinctrl-0 = <&usb_gpio_mux_sel1>, <&usb_gpio_mux_sel2>;
+                pinctrl-1 = <&usb_ulpi_pins>;
+                pinctrl-2 = <&usb_utmi_pins>;
+                pinctrl-3 = <&uart3_pins>;
+                pinctrl-names = "default", "ulpi", "utmi", "uart";
+                #phy-cells = <0>;
+
+                interrupts-extended =
+                    <&cpcap 15 IRQ_TYPE_NONE>, <&cpcap 14 IRQ_TYPE_NONE>,
+                    <&cpcap 28 IRQ_TYPE_NONE>, <&cpcap 19 IRQ_TYPE_NONE>,
+                    <&cpcap 18 IRQ_TYPE_NONE>, <&cpcap 17 IRQ_TYPE_NONE>,
+                    <&cpcap 16 IRQ_TYPE_NONE>, <&cpcap 49 IRQ_TYPE_NONE>,
+                    <&cpcap 48 IRQ_TYPE_NONE>;
+                interrupt-names = "id_ground", "id_float", "se0conn",
+                                  "vbusvld", "sessvld", "sessend",
+                                  "se1", "dm", "dp";
+
+                mode-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>,
+                             <&gpio1 0 GPIO_ACTIVE_HIGH>;
+
+                io-channels = <&cpcap_adc 2>, <&cpcap_adc 7>;
+                io-channel-names = "vbus", "id";
+
+                vusb-supply = <&avdd_usb>;
+            };
+
+            regulator {
+                compatible = "motorola,cpcap-regulator";
+
+                regulators {
+                    vdd_cpu: SW1 {
+                        regulator-name = "vdd_cpu";
+                        regulator-min-microvolt = <750000>;
+                        regulator-max-microvolt = <1125000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_core: SW2 {
+                        regulator-name = "vdd_core";
+                        regulator-min-microvolt = <950000>;
+                        regulator-max-microvolt = <1300000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_1v8_vio: SW3 {
+                        regulator-name = "vdd_1v8_vio";
+                        regulator-min-microvolt = <1800000>;
+                        regulator-max-microvolt = <1800000>;
+                        regulator-enable-ramp-delay = <0>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_aon: SW4 {
+                        regulator-name = "vdd_aon";
+                        regulator-min-microvolt = <950000>;
+                        regulator-max-microvolt = <1300000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_led: SW5 {
+                        regulator-name = "vdd_led";
+                        regulator-min-microvolt = <5050000>;
+                        regulator-max-microvolt = <5050000>;
+                        regulator-enable-ramp-delay = <1500>;
+                        regulator-boot-on;
+                    };
+
+                    vdd_hvio: VHVIO {
+                        regulator-name = "vdd_hvio";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <2775000>;
+                        regulator-enable-ramp-delay = <1000>;
+                    };
+
+                    vcore_emmc: VSDIO {
+                        regulator-name = "vcore_emmc";
+                        regulator-min-microvolt = <1500000>;
+                        regulator-max-microvolt = <3000000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    avdd_dsi_csi: VCSI {
+                        regulator-name = "avdd_dsi_csi";
+                        regulator-min-microvolt = <1200000>;
+                        regulator-max-microvolt = <1200000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    avdd_3v3_periph: VWLAN2 {
+                        regulator-name = "avdd_3v3_periph";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <3300000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    vddio_usd: VSIMCARD {
+                        regulator-name = "vddio_usd";
+                        regulator-min-microvolt = <1800000>;
+                        regulator-max-microvolt = <2900000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-boot-on;
+                    };
+
+                    vdd_haptic: VVIB {
+                        regulator-name = "vdd_haptic";
+                        regulator-min-microvolt = <1300000>;
+                        regulator-max-microvolt = <3000000>;
+                        regulator-enable-ramp-delay = <1000>;
+                    };
+
+                    avdd_usb: VUSB {
+                        regulator-name = "avdd_usb";
+                        regulator-min-microvolt = <3300000>;
+                        regulator-max-microvolt = <3300000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+
+                    vdd_audio: VAUDIO {
+                        regulator-name = "vdd_audio";
+                        regulator-min-microvolt = <2775000>;
+                        regulator-max-microvolt = <2775000>;
+                        regulator-enable-ramp-delay = <1000>;
+                        regulator-always-on;
+                        regulator-boot-on;
+                    };
+                };
+            };
+
+            cpcap_rtc: rtc {
+                compatible = "motorola,cpcap-rtc";
+
+                interrupt-parent = <&cpcap>;
+                interrupts = <39 IRQ_TYPE_NONE>, <26 IRQ_TYPE_NONE>;
+            };
+        };
+    };
+
+...
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt deleted +0 -79
deleted file mode 100644
index 18c3fc26ca93..000000000000
@@ -1,78 +0,0 @@
-Motorola CPCAP PMIC device tree binding
-
-Required properties:
-- compatible         : One or both of "motorola,cpcap" or "ste,6556002"
-- reg                        : SPI chip select
-- interrupts         : The interrupt line the device is connected to
-- interrupt-controller       : Marks the device node as an interrupt controller
-- #interrupt-cells   : The number of cells to describe an IRQ, should be 2
-- #address-cells     : Child device offset number of cells, should be 1
-- #size-cells                : Child device size number of cells, should be 0
-- spi-max-frequency  : Typically set to 3000000
-- spi-cs-high                : SPI chip select direction
-
-Optional subnodes:
-
-The sub-functions of CPCAP get their own node with their own compatible values,
-which are described in the following files:
-
-- Documentation/devicetree/bindings/power/supply/cpcap-battery.yaml
-- Documentation/devicetree/bindings/power/supply/cpcap-charger.yaml
-- Documentation/devicetree/bindings/regulator/cpcap-regulator.txt
-- Documentation/devicetree/bindings/phy/motorola,cpcap-usb-phy.yaml
-- Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
-- Documentation/devicetree/bindings/rtc/cpcap-rtc.txt
-- Documentation/devicetree/bindings/leds/leds-cpcap.txt
-- Documentation/devicetree/bindings/iio/adc/motorola,cpcap-adc.yaml
-
-The only exception is the audio codec. Instead of a compatible value its
-node must be named "audio-codec".
-
-Required properties for the audio-codec subnode:
-
-- #sound-dai-cells = <1>;
-- interrupts         : should contain jack detection interrupts, with headset
-                       detect interrupt matching "hs" and microphone bias 2
-                       detect interrupt matching "mb2" in interrupt-names.
-- interrupt-names    : Contains "hs", "mb2"
-
-The audio-codec provides two DAIs. The first one is connected to the
-Stereo HiFi DAC and the second one is connected to the Voice DAC.
-
-Example:
-
-&mcspi1 {
-     cpcap: pmic@0 {
-             compatible = "motorola,cpcap", "ste,6556002";
-             reg = <0>;      /* cs0 */
-             interrupt-parent = <&gpio1>;
-             interrupts = <7 IRQ_TYPE_EDGE_RISING>;
-             interrupt-controller;
-             #interrupt-cells = <2>;
-             #address-cells = <1>;
-             #size-cells = <0>;
-             spi-max-frequency = <3000000>;
-             spi-cs-high;
-
-             audio-codec {
-                     #sound-dai-cells = <1>;
-                     interrupts-extended = <&cpcap 9 0>, <&cpcap 10 0>;
-                     interrupt-names = "hs", "mb2";
-
-                     /* HiFi */
-                     port@0 {
-                             endpoint {
-                                     remote-endpoint = <&cpu_dai1>;
-                             };
-                     };
-
-                     /* Voice */
-                     port@1 {
-                             endpoint {
-                                     remote-endpoint = <&cpu_dai2>;
-                             };
-                     };
-             };
-     };
-};
-
--

2.51.0

#9 lore raw

PATCH v5 4/6 dt-bindings: mfd: motorola-cpcap: document Mapphone and Mot CPCAP

In reply to Svyatoslav Ryhel

Add compatibles for Mapphone and Mot CPCAP subdevice compositions. Both variations cannot use st,6556002 fallback since they may be based on different controllers.

---
 .../devicetree/bindings/mfd/motorola,cpcap.yaml       | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml +8 -3
index 7f257f3a1a5a..542d149d2b39 100644
@@ -14,9 +14,14 @@ allOf:
 
 properties:
   compatible:
-    items:
-      - const: motorola,cpcap
-      - const: st,6556002
+    oneOf:
+      - enum:
+          - motorola,mapphone-cpcap
+          - motorola,mot-cpcap
+
+      - items:
+          - const: motorola,cpcap
+          - const: st,6556002
 
   reg:
     maxItems: 1
Signature · 1 line
2.51.0
#10 lore raw

Re: [PATCH v5 4/6] dt-bindings: mfd: motorola-cpcap: document Mapphone and Mot CPCAP

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The schema prevents the use of the generic `motorola,cpcap` fallback for the new compatible…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The schema prevents the use of the generic motorola,cpcap fallback for the new compatible strings, which will break device probing. --

commit 43b55cbad252ef116a236dfd195512e35a6f5c82
Author: Svyatoslav Ryhel <[email protected]>

dt-bindings: mfd: motorola-cpcap: document Mapphone and Mot CPCAP

Add compatibles for Mapphone and Mot CPCAP subdevice compositions. Both variations cannot use st,6556002 fallback since they may be based on different controllers.

Quoted 5 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml +0 -0
index 7f257f3a1a5a2..542d149d2b39c 100644

Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml allOf: · line 20

Quoted 10 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml +4 -3
@@ -14,9 +14,14 @@ allOf:
 
 properties:
   compatible:
-    items:
-      - const: motorola,cpcap
-      - const: st,6556002
+    oneOf:
+      - enum:
+          - motorola,mapphone-cpcap
+          - motorola,mot-cpcap

Will this prevent the use of motorola,cpcap as a fallback for the new compatible strings? It looks like this branch of the schema requires devices to provide only a single compatible string.

Looking at the OMAP4 board code for Mapphone devices, it explicitly matches against the generic motorola,cpcap string:

arch/arm/mach-omap2/pmic-cpcap.c:cpcap_init() {
    ...
	if (!of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
		return -ENODEV;
    ...
}

By forbidding motorola,cpcap as a fallback in the bindings, will device trees updated to pass schema validation (by using only the new specific compatibles) fail to find the node at runtime in the board code?

If the node is not found, does this prevent the initialization of the CPCAP PMIC voltage regulators on OMAP4 devices, breaking power management and voltage scaling?

Could the schema permit motorola,cpcap as a fallback for the new compatible strings, perhaps by using an items list with the new strings as the first item and motorola,cpcap as the const fallback?

Quoted 7 lines
Documentation/devicetree/bindings/mfd/motorola,cpcap.yaml +4 -0
+
+      - items:
+          - const: motorola,cpcap
+          - const: st,6556002
 
   reg:
     maxItems: 1
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#11 lore raw

PATCH v5 5/6 mfd: motorola-cpcap: diverge configuration per-board

In reply to Svyatoslav Ryhel

MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration.

Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board.

Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition.

---
 drivers/mfd/motorola-cpcap.c       | 142 ++++++++++++++++-------------
 include/linux/mfd/motorola-cpcap.h |   6 ++
 2 files changed, 87 insertions(+), 61 deletions(-)
drivers/mfd/motorola-cpcap.c +81 -61
index d8243b956f87..f5a7fdd89dd5 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/sysfs.h>
 
@@ -30,6 +31,7 @@ struct cpcap_ddata {
 	struct regmap_irq_chip_data *irqdata[CPCAP_NR_IRQ_CHIPS];
 	const struct regmap_config *regmap_conf;
 	struct regmap *regmap;
+	enum cpcap_variant variant;
 };
 
 static int cpcap_sense_irq(struct regmap *regmap, int irq)
@@ -195,20 +197,6 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap)
 	return 0;
 }
 
-static const struct of_device_id cpcap_of_match[] = {
-	{ .compatible = "motorola,cpcap", },
-	{ .compatible = "st,6556002", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, cpcap_of_match);
-
-static const struct spi_device_id cpcap_spi_ids[] = {
-	{ .name = "cpcap", },
-	{ .name = "6556002", },
-	{},
-};
-MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
-
 static const struct regmap_config cpcap_regmap_config = {
 	.reg_bits = 16,
 	.reg_stride = 4,
@@ -241,62 +229,76 @@ static int cpcap_resume(struct device *dev)
 
 static DEFINE_SIMPLE_DEV_PM_OPS(cpcap_pm, cpcap_suspend, cpcap_resume);
 
-static const struct mfd_cell cpcap_mfd_devices[] = {
-	{
-		.name          = "cpcap_adc",
-		.of_compatible = "motorola,mapphone-cpcap-adc",
-	}, {
-		.name          = "cpcap_battery",
-		.of_compatible = "motorola,cpcap-battery",
-	}, {
-		.name          = "cpcap-charger",
-		.of_compatible = "motorola,mapphone-cpcap-charger",
-	}, {
-		.name          = "cpcap-regulator",
-		.of_compatible = "motorola,mapphone-cpcap-regulator",
-	}, {
-		.name          = "cpcap-rtc",
-		.of_compatible = "motorola,cpcap-rtc",
-	}, {
-		.name          = "cpcap-pwrbutton",
-		.of_compatible = "motorola,cpcap-pwrbutton",
-	}, {
-		.name          = "cpcap-usb-phy",
-		.of_compatible = "motorola,mapphone-cpcap-usb-phy",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 0,
-		.of_compatible = "motorola,cpcap-led-red",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 1,
-		.of_compatible = "motorola,cpcap-led-green",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 2,
-		.of_compatible = "motorola,cpcap-led-blue",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 3,
-		.of_compatible = "motorola,cpcap-led-adl",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 4,
-		.of_compatible = "motorola,cpcap-led-cp",
-	}, {
-		.name          = "cpcap-codec",
-	}
+static const struct mfd_cell cpcap_default_mfd_devices[] = {
+	MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
+	MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+		    "motorola,cpcap-battery"),
+	MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+		    "motorola,cpcap-regulator"),
+	MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+	MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+		    "motorola,cpcap-pwrbutton"),
+	MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+		    "motorola,cpcap-usb-phy"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+	MFD_CELL_NAME("cpcap-codec"),
+};
+
+static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
+	MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-adc"),
+	MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+		    "motorola,cpcap-battery"),
+	MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-charger"),
+	MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-regulator"),
+	MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+	MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+		    "motorola,cpcap-pwrbutton"),
+	MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-usb-phy"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+	MFD_CELL_NAME("cpcap-codec"),
 };
 
 static int cpcap_probe(struct spi_device *spi)
 {
 	struct cpcap_ddata *cpcap;
+	const struct mfd_cell *cells;
+	unsigned int num_cells;
 	int ret;
 
 	cpcap = devm_kzalloc(&spi->dev, sizeof(*cpcap), GFP_KERNEL);
 	if (!cpcap)
 		return -ENOMEM;
 
+	cpcap->variant = (enum cpcap_variant)spi_get_device_match_data(spi);
+	if (!cpcap->variant)
+		return -ENODEV;
+
+	switch (cpcap->variant) {
+	case CPCAP_DEFAULT:
+		cells = cpcap_default_mfd_devices;
+		num_cells = ARRAY_SIZE(cpcap_default_mfd_devices);
+		break;
+	case CPCAP_MAPPHONE:
+		cells = cpcap_mapphone_mfd_devices;
+		num_cells = ARRAY_SIZE(cpcap_mapphone_mfd_devices);
+		break;
+	default:
+		return dev_err_probe(&spi->dev, -EINVAL,
+				     "Unknown device %d\n", cpcap->variant);
+	}
+
 	cpcap->spi = spi;
 	spi_set_drvdata(spi, cpcap);
 
@@ -331,10 +333,28 @@ static int cpcap_probe(struct spi_device *spi)
 	spi->dev.coherent_dma_mask = 0;
 	spi->dev.dma_mask = &spi->dev.coherent_dma_mask;
 
-	return devm_mfd_add_devices(&spi->dev, 0, cpcap_mfd_devices,
-				    ARRAY_SIZE(cpcap_mfd_devices), NULL, 0, NULL);
+	return devm_mfd_add_devices(&spi->dev, 0, cells, num_cells, NULL, 0, NULL);
 }
 
+static const struct of_device_id cpcap_of_match[] = {
+	{
+		.compatible = "motorola,cpcap",
+		.data = (void *)CPCAP_DEFAULT
+	}, {
+		.compatible = "motorola,mapphone-cpcap",
+		.data = (void *)CPCAP_MAPPHONE
+	},
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cpcap_of_match);
+
+static const struct spi_device_id cpcap_spi_ids[] = {
+	{ "cpcap", CPCAP_DEFAULT },
+	{ "mapphone-cpcap", CPCAP_MAPPHONE },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
+
 static struct spi_driver cpcap_driver = {
 	.driver = {
 		.name = "cpcap-core",
include/linux/mfd/motorola-cpcap.h +6 -0
index 981e5777deb7..1a85b06272c8 100644
@@ -25,6 +25,12 @@
 #define CPCAP_REVISION_2_0	0x10
 #define CPCAP_REVISION_2_1	0x11
 
+enum cpcap_variant {
+	CPCAP_DEFAULT = 1,
+	CPCAP_MAPPHONE,
+	CPCAP_MAX
+};
+
 /* CPCAP registers */
 #define CPCAP_REG_INT1		0x0000	/* Interrupt 1 */
 #define CPCAP_REG_INT2		0x0004	/* Interrupt 2 */
Signature · 1 line
2.51.0
#12 lore raw

Re: [PATCH v5 5/6] mfd: motorola-cpcap: diverge configuration per-board

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Device Tree ABI breakage for existing Mapphone boards and legacy compatibles - [Low] Compiler…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Device Tree ABI breakage for existing Mapphone boards and legacy compatibles
- [Low] Compiler warning (-Wpointer-to-int-cast) on 64-bit architectures due to direct pointer-to-enum cast --

commit 31f4e82a2615f7d51f1707bf1ca43b9d741b3c90
Author: Svyatoslav Ryhel <[email protected]>

mfd: motorola-cpcap: diverge configuration per-board

This commit separates the CPCAP subdevice configuration to support different board-specific settings. It introduces a default composition and renames the existing one for Mapphone boards.

drivers/mfd/motorola-cpcap.c static int cpcap_init_irq(struct cpcap_ddata *cpcap) · line 202

Quoted 13 lines
drivers/mfd/motorola-cpcap.c +0 -5
index d8243b956f875..f5a7fdd89dd5e 100644
@@ -195,20 +197,6 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap)
 	return 0;
 }
 
-static const struct of_device_id cpcap_of_match[] = {
-	{ .compatible = "motorola,cpcap", },
-	{ .compatible = "st,6556002", },
-	{},
-};

Will existing device trees relying on the st,6556002 compatible string fail to probe since it was removed from the match tables?

[ ... ]

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 284

Quoted 12 lines
drivers/mfd/motorola-cpcap.c +3 -0
 static int cpcap_probe(struct spi_device *spi)
 {
 	struct cpcap_ddata *cpcap;
+	const struct mfd_cell *cells;
+	unsigned int num_cells;
 	int ret;
 
 	cpcap = devm_kzalloc(&spi->dev, sizeof(*cpcap), GFP_KERNEL);
 	if (!cpcap)
 		return -ENOMEM;
 
+	cpcap->variant = (enum cpcap_variant)spi_get_device_match_data(spi);

Could this direct cast from a pointer to an enum cause a compiler warning (-Wpointer-to-int-cast) on 64-bit architectures?

spi_get_device_match_data() returns a const void *, which is 64 bits wide on architectures like arm64, while enum cpcap_variant is typically a 32-bit integer. Casting through a pointer-sized integer first might prevent this.

[ ... ]

drivers/mfd/motorola-cpcap.c static int cpcap_probe(struct spi_device *spi) · line 343

Quoted 5 lines
drivers/mfd/motorola-cpcap.c +5 -0
+static const struct of_device_id cpcap_of_match[] = {
+	{
+		.compatible = "motorola,cpcap",
+		.data = (void *)CPCAP_DEFAULT
+	}, {

Will this mapping break backwards compatibility for existing Mapphone boards?

Existing device trees use compatible = "motorola,cpcap" for the parent MFD node, but define their child nodes with Mapphone-specific compatibles like motorola,mapphone-cpcap-adc.

By mapping motorola,cpcap to CPCAP_DEFAULT, the driver now expects child cells to use motorola,cpcap-adc. This means mfd_add_devices() might fail to bind child platform devices to their DT nodes since of_device_is_compatible() won't match.

If this happens, the child platform devices will be created with pdev->dev.of_node == NULL, completely breaking driver probing for subdevices on existing boards.

Could motorola,cpcap continue to map to the historical CPCAP_MAPPHONE configuration to preserve the ABI?

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

Re: [PATCH v5 5/6] mfd: motorola-cpcap: diverge configuration per-board

In reply to Svyatoslav Ryhel
Quoted 8 lines · Svyatoslav Ryhel

MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration.

Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board.

Quoted 8 lines

Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition.

---
 drivers/mfd/motorola-cpcap.c       | 142 ++++++++++++++++-------------
 include/linux/mfd/motorola-cpcap.h |   6 ++
 2 files changed, 87 insertions(+), 61 deletions(-)

Looking much better, thanks.

Nit: A patch-level changelog really is much more helpful to reviewers.

Quoted 98 lines
drivers/mfd/motorola-cpcap.c +10 -59
index d8243b956f87..f5a7fdd89dd5 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/sysfs.h>
 
@@ -30,6 +31,7 @@ struct cpcap_ddata {
 	struct regmap_irq_chip_data *irqdata[CPCAP_NR_IRQ_CHIPS];
 	const struct regmap_config *regmap_conf;
 	struct regmap *regmap;
+	enum cpcap_variant variant;
 };
 
 static int cpcap_sense_irq(struct regmap *regmap, int irq)
@@ -195,20 +197,6 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap)
 	return 0;
 }
 
-static const struct of_device_id cpcap_of_match[] = {
-	{ .compatible = "motorola,cpcap", },
-	{ .compatible = "st,6556002", },
-	{},
-};
-MODULE_DEVICE_TABLE(of, cpcap_of_match);
-
-static const struct spi_device_id cpcap_spi_ids[] = {
-	{ .name = "cpcap", },
-	{ .name = "6556002", },
-	{},
-};
-MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
-
 static const struct regmap_config cpcap_regmap_config = {
 	.reg_bits = 16,
 	.reg_stride = 4,
@@ -241,62 +229,76 @@ static int cpcap_resume(struct device *dev)
 
 static DEFINE_SIMPLE_DEV_PM_OPS(cpcap_pm, cpcap_suspend, cpcap_resume);
 
-static const struct mfd_cell cpcap_mfd_devices[] = {
-	{
-		.name          = "cpcap_adc",
-		.of_compatible = "motorola,mapphone-cpcap-adc",
-	}, {
-		.name          = "cpcap_battery",
-		.of_compatible = "motorola,cpcap-battery",
-	}, {
-		.name          = "cpcap-charger",
-		.of_compatible = "motorola,mapphone-cpcap-charger",
-	}, {
-		.name          = "cpcap-regulator",
-		.of_compatible = "motorola,mapphone-cpcap-regulator",
-	}, {
-		.name          = "cpcap-rtc",
-		.of_compatible = "motorola,cpcap-rtc",
-	}, {
-		.name          = "cpcap-pwrbutton",
-		.of_compatible = "motorola,cpcap-pwrbutton",
-	}, {
-		.name          = "cpcap-usb-phy",
-		.of_compatible = "motorola,mapphone-cpcap-usb-phy",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 0,
-		.of_compatible = "motorola,cpcap-led-red",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 1,
-		.of_compatible = "motorola,cpcap-led-green",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 2,
-		.of_compatible = "motorola,cpcap-led-blue",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 3,
-		.of_compatible = "motorola,cpcap-led-adl",
-	}, {
-		.name          = "cpcap-led",
-		.id            = 4,
-		.of_compatible = "motorola,cpcap-led-cp",
-	}, {
-		.name          = "cpcap-codec",
-	}
+static const struct mfd_cell cpcap_default_mfd_devices[] = {
+	MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
+	MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+		    "motorola,cpcap-battery"),
+	MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+		    "motorola,cpcap-regulator"),
+	MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+	MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 249

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +10 -0
+		    "motorola,cpcap-pwrbutton"),
+	MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+		    "motorola,cpcap-usb-phy"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+	MFD_CELL_NAME("cpcap-codec"),
+};

Nit: I wouldn't complain if you wanted to have all of these on a single line for neatness.

Quoted 11 lines
drivers/mfd/motorola-cpcap.c +11 -0
+static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
+	MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-adc"),
+	MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+		    "motorola,cpcap-battery"),
+	MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-charger"),
+	MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-regulator"),
+	MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+	MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 271

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +9 -0
+		    "motorola,cpcap-pwrbutton"),
+	MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+		    "motorola,mapphone-cpcap-usb-phy"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+	MFD_CELL_NAME("cpcap-codec"),
 };

A lot of these are duplicated, right?

I would have a comment set, then the differences in separate containers.

Quoted 4 lines
drivers/mfd/motorola-cpcap.c +1 -0
 static int cpcap_probe(struct spi_device *spi)
 {
 	struct cpcap_ddata *cpcap;
+	const struct mfd_cell *cells;

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 286

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +4 -0
+	unsigned int num_cells;
 	int ret;
 
 	cpcap = devm_kzalloc(&spi->dev, sizeof(*cpcap), GFP_KERNEL);
 	if (!cpcap)
 		return -ENOMEM;
 
+	cpcap->variant = (enum cpcap_variant)spi_get_device_match_data(spi);
+	if (!cpcap->variant)
+		return -ENODEV;

Isn't this covered in the 'default' below?

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 299

Quoted 12 lines
drivers/mfd/motorola-cpcap.c +12 -0
+	switch (cpcap->variant) {
+	case CPCAP_DEFAULT:
+		cells = cpcap_default_mfd_devices;
+		num_cells = ARRAY_SIZE(cpcap_default_mfd_devices);
+		break;
+	case CPCAP_MAPPHONE:
+		cells = cpcap_mapphone_mfd_devices;
+		num_cells = ARRAY_SIZE(cpcap_mapphone_mfd_devices);
+		break;
+	default:
+		return dev_err_probe(&spi->dev, -EINVAL,
+				     "Unknown device %d\n", cpcap->variant);

This should be -ENODEV.

Quoted 8 lines
drivers/mfd/motorola-cpcap.c +2 -0
+	}
+
 	cpcap->spi = spi;
 	spi_set_drvdata(spi, cpcap);
 
@@ -331,10 +333,28 @@ static int cpcap_probe(struct spi_device *spi)
 	spi->dev.coherent_dma_mask = 0;
 	spi->dev.dma_mask = &spi->dev.coherent_dma_mask;

drivers/mfd/motorola-cpcap.c static int cpcap_probe(struct spi_device *spi) · line 342

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +5 -2
 
-	return devm_mfd_add_devices(&spi->dev, 0, cpcap_mfd_devices,
-				    ARRAY_SIZE(cpcap_mfd_devices), NULL, 0, NULL);
+	return devm_mfd_add_devices(&spi->dev, 0, cells, num_cells, NULL, 0, NULL);
 }
 
+static const struct of_device_id cpcap_of_match[] = {
+	{
+		.compatible = "motorola,cpcap",
+		.data = (void *)CPCAP_DEFAULT

Single line should be fine.

Quoted 38 lines
drivers/mfd/motorola-cpcap.c +15 -0
+	}, {
+		.compatible = "motorola,mapphone-cpcap",
+		.data = (void *)CPCAP_MAPPHONE
+	},
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cpcap_of_match);
+
+static const struct spi_device_id cpcap_spi_ids[] = {
+	{ "cpcap", CPCAP_DEFAULT },
+	{ "mapphone-cpcap", CPCAP_MAPPHONE },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
+
 static struct spi_driver cpcap_driver = {
 	.driver = {
 		.name = "cpcap-core",
include/linux/mfd/motorola-cpcap.h +6 -0
index 981e5777deb7..1a85b06272c8 100644
@@ -25,6 +25,12 @@
 #define CPCAP_REVISION_2_0	0x10
 #define CPCAP_REVISION_2_1	0x11
 
+enum cpcap_variant {
+	CPCAP_DEFAULT = 1,
+	CPCAP_MAPPHONE,
+	CPCAP_MAX
+};
+
 /* CPCAP registers */
 #define CPCAP_REG_INT1		0x0000	/* Interrupt 1 */
 #define CPCAP_REG_INT2		0x0004	/* Interrupt 2 */
Signature · 1 line
2.51.0
Signature · 1 line
Lee Jones
#14 lore raw

Re: [PATCH v5 5/6] mfd: motorola-cpcap: diverge configuration per-board

ср, 20 трав. 2026 р. о 18:08 Lee Jones <[email protected]> пише:

Quoted 20 lines · Svyatoslav Ryhel
Quoted 9 lines

MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration.

Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board.

Quoted 8 lines

Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition.

---
 drivers/mfd/motorola-cpcap.c       | 142 ++++++++++++++++-------------
 include/linux/mfd/motorola-cpcap.h |   6 ++
 2 files changed, 87 insertions(+), 61 deletions(-)
Quoted 4 lines

Looking much better, thanks.

Nit: A patch-level changelog really is much more helpful to reviewers.

Noted, but I will not guarantee that I will do patch-level changelogs, sorry.

Quoted 103 lines
Quoted 103 lines
drivers/mfd/motorola-cpcap.c +15 -59
index d8243b956f87..f5a7fdd89dd5 100644
@@ -12,6 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/sysfs.h>
 
@@ -30,6 +31,7 @@ struct cpcap_ddata {
      struct regmap_irq_chip_data *irqdata[CPCAP_NR_IRQ_CHIPS];
      const struct regmap_config *regmap_conf;
      struct regmap *regmap;
+     enum cpcap_variant variant;
 };
 
 static int cpcap_sense_irq(struct regmap *regmap, int irq)
@@ -195,20 +197,6 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap)
      return 0;
 }
 
-static const struct of_device_id cpcap_of_match[] = {
-     { .compatible = "motorola,cpcap", },
-     { .compatible = "st,6556002", },
-     {},
-};
-MODULE_DEVICE_TABLE(of, cpcap_of_match);
-
-static const struct spi_device_id cpcap_spi_ids[] = {
-     { .name = "cpcap", },
-     { .name = "6556002", },
-     {},
-};
-MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
-
 static const struct regmap_config cpcap_regmap_config = {
      .reg_bits = 16,
      .reg_stride = 4,
@@ -241,62 +229,76 @@ static int cpcap_resume(struct device *dev)
 
 static DEFINE_SIMPLE_DEV_PM_OPS(cpcap_pm, cpcap_suspend, cpcap_resume);
 
-static const struct mfd_cell cpcap_mfd_devices[] = {
-     {
-             .name          = "cpcap_adc",
-             .of_compatible = "motorola,mapphone-cpcap-adc",
-     }, {
-             .name          = "cpcap_battery",
-             .of_compatible = "motorola,cpcap-battery",
-     }, {
-             .name          = "cpcap-charger",
-             .of_compatible = "motorola,mapphone-cpcap-charger",
-     }, {
-             .name          = "cpcap-regulator",
-             .of_compatible = "motorola,mapphone-cpcap-regulator",
-     }, {
-             .name          = "cpcap-rtc",
-             .of_compatible = "motorola,cpcap-rtc",
-     }, {
-             .name          = "cpcap-pwrbutton",
-             .of_compatible = "motorola,cpcap-pwrbutton",
-     }, {
-             .name          = "cpcap-usb-phy",
-             .of_compatible = "motorola,mapphone-cpcap-usb-phy",
-     }, {
-             .name          = "cpcap-led",
-             .id            = 0,
-             .of_compatible = "motorola,cpcap-led-red",
-     }, {
-             .name          = "cpcap-led",
-             .id            = 1,
-             .of_compatible = "motorola,cpcap-led-green",
-     }, {
-             .name          = "cpcap-led",
-             .id            = 2,
-             .of_compatible = "motorola,cpcap-led-blue",
-     }, {
-             .name          = "cpcap-led",
-             .id            = 3,
-             .of_compatible = "motorola,cpcap-led-adl",
-     }, {
-             .name          = "cpcap-led",
-             .id            = 4,
-             .of_compatible = "motorola,cpcap-led-cp",
-     }, {
-             .name          = "cpcap-codec",
-     }
+static const struct mfd_cell cpcap_default_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
Quoted 9 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 249

Quoted 5 lines
drivers/mfd/motorola-cpcap.c +5 -0
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
+};

Nit: I wouldn't complain if you wanted to have all of these on a single line for neatness.

Noted

Quoted 22 lines
Quoted 11 lines
drivers/mfd/motorola-cpcap.c +11 -0
+static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-charger"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 271

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +9 -0
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
 };
Quoted 3 lines

A lot of these are duplicated, right?

I would have a comment set, then the differences in separate containers.

It may be impossible to predict a generic setup since some devices may require unique compatibles, other may not have LEDs, third may be partially incompatible with existing cells. In other mfd cases creating a generic bundle might be good, but in this case I would suggest better to keep these separate entirely per-device. They will not take much space, nor add confusion with these macros.

Quoted 12 lines
Quoted 12 lines
drivers/mfd/motorola-cpcap.c +2 -0
 static int cpcap_probe(struct spi_device *spi)
 {
      struct cpcap_ddata *cpcap;
+     const struct mfd_cell *cells;
+     unsigned int num_cells;
      int ret;
 
      cpcap = devm_kzalloc(&spi->dev, sizeof(*cpcap), GFP_KERNEL);
      if (!cpcap)
              return -ENOMEM;
 
Quoted 6 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 286

Quoted 3 lines
drivers/mfd/motorola-cpcap.c +3 -0
+     cpcap->variant = (enum cpcap_variant)spi_get_device_match_data(spi);
+     if (!cpcap->variant)
+             return -ENODEV;

Isn't this covered in the 'default' below?

This is for case cpcap->variant = 0, it should never happen, but check will not cause harm

Quoted 14 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 299

Quoted 13 lines
drivers/mfd/motorola-cpcap.c +12 -0
+     switch (cpcap->variant) {
+     case CPCAP_DEFAULT:
+             cells = cpcap_default_mfd_devices;
+             num_cells = ARRAY_SIZE(cpcap_default_mfd_devices);
+             break;
+     case CPCAP_MAPPHONE:
+             cells = cpcap_mapphone_mfd_devices;
+             num_cells = ARRAY_SIZE(cpcap_mapphone_mfd_devices);
+             break;
+     default:
+             return dev_err_probe(&spi->dev, -EINVAL,
+                                  "Unknown device %d\n", cpcap->variant);
Quoted 2 lines

This should be -ENODEV.

hm, match is ENODEV cause it looks for device, here driver checks id/variant, so shouldn't it be EINVAL? I assume error message should be "Unknown device version" or "Unknown device ID"

Quoted 14 lines
Quoted 14 lines
drivers/mfd/motorola-cpcap.c +3 -2
+     }
+
      cpcap->spi = spi;
      spi_set_drvdata(spi, cpcap);
 
@@ -331,10 +333,28 @@ static int cpcap_probe(struct spi_device *spi)
      spi->dev.coherent_dma_mask = 0;
      spi->dev.dma_mask = &spi->dev.coherent_dma_mask;
 
-     return devm_mfd_add_devices(&spi->dev, 0, cpcap_mfd_devices,
-                                 ARRAY_SIZE(cpcap_mfd_devices), NULL, 0, NULL);
+     return devm_mfd_add_devices(&spi->dev, 0, cells, num_cells, NULL, 0, NULL);
 }
 
Quoted 7 lines

drivers/mfd/motorola-cpcap.c static int cpcap_probe(struct spi_device *spi) · line 342

Quoted 4 lines
drivers/mfd/motorola-cpcap.c +4 -0
+static const struct of_device_id cpcap_of_match[] = {
+     {
+             .compatible = "motorola,cpcap",
+             .data = (void *)CPCAP_DEFAULT

Single line should be fine.

Noted

Quoted 41 lines
Quoted 36 lines
drivers/mfd/motorola-cpcap.c +15 -0
+     }, {
+             .compatible = "motorola,mapphone-cpcap",
+             .data = (void *)CPCAP_MAPPHONE
+     },
+     { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cpcap_of_match);
+
+static const struct spi_device_id cpcap_spi_ids[] = {
+     { "cpcap", CPCAP_DEFAULT },
+     { "mapphone-cpcap", CPCAP_MAPPHONE },
+     { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
+
 static struct spi_driver cpcap_driver = {
      .driver = {
              .name = "cpcap-core",
include/linux/mfd/motorola-cpcap.h +6 -1
index 981e5777deb7..1a85b06272c8 100644
@@ -25,6 +25,12 @@
 #define CPCAP_REVISION_2_0   0x10
 #define CPCAP_REVISION_2_1   0x11
 
+enum cpcap_variant {
+     CPCAP_DEFAULT = 1,
+     CPCAP_MAPPHONE,
+     CPCAP_MAX
+};
+
 /* CPCAP registers */
 #define CPCAP_REG_INT1               0x0000  /* Interrupt 1 */
 #define CPCAP_REG_INT2               0x0004  /* Interrupt 2 */
--
Quoted 2 lines

2.51.0

--
Lee Jones

maintainer
#15 lore raw

Re: [PATCH v5 5/6] mfd: motorola-cpcap: diverge configuration per-board

Quoted 21 lines · Svyatoslav Ryhel

ср, 20 трав. 2026 р. о 18:08 Lee Jones <[email protected]> пише:

Quoted 20 lines · Svyatoslav Ryhel
Quoted 17 lines

MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration.

Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board.

Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition.

---
 drivers/mfd/motorola-cpcap.c       | 142 ++++++++++++++++-------------
 include/linux/mfd/motorola-cpcap.h |   6 ++
 2 files changed, 87 insertions(+), 61 deletions(-)
Quoted 6 lines
Quoted 4 lines

Looking much better, thanks.

Nit: A patch-level changelog really is much more helpful to reviewers.

Noted, but I will not guarantee that I will do patch-level changelogs, sorry.

That's fine. All I can do is ask.

Note that, helping out reviewers usually ends up helping you too.

[...]

Quoted 49 lines
Quoted 13 lines
Quoted 13 lines
drivers/mfd/motorola-cpcap.c +13 -0
+static const struct mfd_cell cpcap_default_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
Quoted 9 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 249

Quoted 5 lines
drivers/mfd/motorola-cpcap.c +5 -0
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
+};

Nit: I wouldn't complain if you wanted to have all of these on a single line for neatness.

Noted

Quoted 24 lines
Quoted 11 lines
drivers/mfd/motorola-cpcap.c +11 -0
+static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-charger"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 271

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +9 -0
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
 };

A lot of these are duplicated, right?

Quoted 8 lines
Quoted 1 line

I would have a comment set, then the differences in separate containers.

It may be impossible to predict a generic setup since some devices may require unique compatibles, other may not have LEDs, third may be partially incompatible with existing cells. In other mfd cases creating a generic bundle might be good, but in this case I would suggest better to keep these separate entirely per-device. They will not take much space, nor add confusion with these macros.

I'm not sure we're understanding each other. Let me give you an example:

static const struct mfd_cell cpcap_common_devices[] = {
     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0, "motorola,cpcap-battery"),
     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0, "motorola,cpcap-pwrbutton"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
     MFD_CELL_NAME("cpcap-codec"),
};
static const struct mfd_cell cpcap_default_devices[] = {
     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,cpcap-regulator"),
     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,cpcap-usb-phy"),
};

static const struct mfd_cell cpcap_mapphone_devices[] = {
MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-adc"), MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-charger"), MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-regulator"), MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-usb-phy"),
};

This way, it's super easy to read / maintain the common and unique devices.

The only potential drawback would be 2 calls to mfd_add_devices() but that's common practice.

Also notice that I droped the "_mfd" parts, which you should too.

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines

static int cpcap_probe(struct spi_device *spi)

 {
      struct cpcap_ddata *cpcap;
drivers/mfd/motorola-cpcap.c +5 -0
+     const struct mfd_cell *cells;
+     unsigned int num_cells;
      int ret;
 
      cpcap = devm_kzalloc(&spi->dev, sizeof(*cpcap), GFP_KERNEL);
      if (!cpcap)
              return -ENOMEM;
 
+     cpcap->variant = (enum cpcap_variant)spi_get_device_match_data(spi);
+     if (!cpcap->variant)
+             return -ENODEV;
Quoted 5 lines
Quoted 2 lines

Isn't this covered in the 'default' below?

This is for case cpcap->variant = 0, it should never happen, but check will not cause harm

The 'default' branch in the switch below will pick that up too. This check is superfluous.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/mfd/motorola-cpcap.c +12 -0
+     switch (cpcap->variant) {
+     case CPCAP_DEFAULT:
+             cells = cpcap_default_mfd_devices;
+             num_cells = ARRAY_SIZE(cpcap_default_mfd_devices);
+             break;
+     case CPCAP_MAPPHONE:
+             cells = cpcap_mapphone_mfd_devices;
+             num_cells = ARRAY_SIZE(cpcap_mapphone_mfd_devices);
+             break;
+     default:
+             return dev_err_probe(&spi->dev, -EINVAL,
+                                  "Unknown device %d\n", cpcap->variant);
Quoted 6 lines
Quoted 2 lines

This should be -ENODEV.

hm, match is ENODEV cause it looks for device, here driver checks id/variant, so shouldn't it be EINVAL? I assume error message should be "Unknown device version" or "Unknown device ID"

All of your supported devices are represented in this switch statement. Any other request, regardless of the reason should results in "Unsupported device" and a -ENODEV - same as your check for !cpcap->variant above.

Signature · 1 line
Lee Jones
#16 lore raw

Re: [PATCH v5 5/6] mfd: motorola-cpcap: diverge configuration per-board

ср, 20 трав. 2026 р. о 19:05 Lee Jones <[email protected]> пише:

Quoted 122 lines · Svyatoslav Ryhel
Quoted 22 lines

ср, 20 трав. 2026 р. о 18:08 Lee Jones <[email protected]> пише:

Quoted 20 lines · Svyatoslav Ryhel
Quoted 17 lines

MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration.

Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board.

Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition.

---
 drivers/mfd/motorola-cpcap.c       | 142 ++++++++++++++++-------------
 include/linux/mfd/motorola-cpcap.h |   6 ++
 2 files changed, 87 insertions(+), 61 deletions(-)
Quoted 6 lines
Quoted 4 lines

Looking much better, thanks.

Nit: A patch-level changelog really is much more helpful to reviewers.

Noted, but I will not guarantee that I will do patch-level changelogs, sorry.

That's fine. All I can do is ask.

Note that, helping out reviewers usually ends up helping you too.

[...]

Quoted 49 lines
Quoted 13 lines
Quoted 13 lines
drivers/mfd/motorola-cpcap.c +13 -0
+static const struct mfd_cell cpcap_default_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
Quoted 9 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 249

Quoted 5 lines
drivers/mfd/motorola-cpcap.c +5 -0
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
+};

Nit: I wouldn't complain if you wanted to have all of these on a single line for neatness.

Noted

Quoted 24 lines
Quoted 11 lines
drivers/mfd/motorola-cpcap.c +11 -0
+static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-charger"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 271

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +9 -0
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
 };

A lot of these are duplicated, right?

Quoted 8 lines
Quoted 1 line

I would have a comment set, then the differences in separate containers.

It may be impossible to predict a generic setup since some devices may require unique compatibles, other may not have LEDs, third may be partially incompatible with existing cells. In other mfd cases creating a generic bundle might be good, but in this case I would suggest better to keep these separate entirely per-device. They will not take much space, nor add confusion with these macros.

I'm not sure we're understanding each other. Let me give you an example:

static const struct mfd_cell cpcap_common_devices[] = {
     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0, "motorola,cpcap-battery"),
     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0, "motorola,cpcap-pwrbutton"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
     MFD_CELL_NAME("cpcap-codec"),
};
static const struct mfd_cell cpcap_default_devices[] = {
     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,cpcap-regulator"),
     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,cpcap-usb-phy"),
};

static const struct mfd_cell cpcap_mapphone_devices[] = {
MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-adc"), MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-charger"), MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-regulator"), MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-usb-phy"),
};

Quoted 7 lines

This way, it's super easy to read / maintain the common and unique devices.

The only potential drawback would be 2 calls to mfd_add_devices() but that's common practice.

Also notice that I droped the "_mfd" parts, which you should too.

What if next added device does not have cpcap-battery, cpcap-led-adl, cpcap-pwrbutton, uses external codec and would require cpcap-watchdog which is not yet present. This will cause issues. Even Mot introduces in the last patch of this patchset has slightly different composition.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines

static int cpcap_probe(struct spi_device *spi)

 {
      struct cpcap_ddata *cpcap;
drivers/mfd/motorola-cpcap.c +5 -0
+     const struct mfd_cell *cells;
+     unsigned int num_cells;
      int ret;
 
      cpcap = devm_kzalloc(&spi->dev, sizeof(*cpcap), GFP_KERNEL);
      if (!cpcap)
              return -ENOMEM;
 
+     cpcap->variant = (enum cpcap_variant)spi_get_device_match_data(spi);
+     if (!cpcap->variant)
+             return -ENODEV;
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

Isn't this covered in the 'default' below?

This is for case cpcap->variant = 0, it should never happen, but check will not cause harm

The 'default' branch in the switch below will pick that up too. This check is superfluous.

Noted

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 299

Quoted 12 lines
drivers/mfd/motorola-cpcap.c +12 -0
+     switch (cpcap->variant) {
+     case CPCAP_DEFAULT:
+             cells = cpcap_default_mfd_devices;
+             num_cells = ARRAY_SIZE(cpcap_default_mfd_devices);
+             break;
+     case CPCAP_MAPPHONE:
+             cells = cpcap_mapphone_mfd_devices;
+             num_cells = ARRAY_SIZE(cpcap_mapphone_mfd_devices);
+             break;
+     default:
+             return dev_err_probe(&spi->dev, -EINVAL,
+                                  "Unknown device %d\n", cpcap->variant);

This should be -ENODEV.

Quoted 9 lines
Quoted 3 lines

hm, match is ENODEV cause it looks for device, here driver checks id/variant, so shouldn't it be EINVAL? I assume error message should be "Unknown device version" or "Unknown device ID"

All of your supported devices are represented in this switch statement. Any other request, regardless of the reason should results in "Unsupported device" and a -ENODEV - same as your check for !cpcap->variant above.

Noted

Quoted 2 lines

--
Lee Jones

maintainer
#17 lore raw

Re: [PATCH v5 5/6] mfd: motorola-cpcap: diverge configuration per-board

Quoted 128 lines · Svyatoslav Ryhel

ср, 20 трав. 2026 р. о 19:05 Lee Jones <[email protected]> пише:

Quoted 127 lines · Svyatoslav Ryhel
Quoted 22 lines

ср, 20 трав. 2026 р. о 18:08 Lee Jones <[email protected]> пише:

Quoted 20 lines · Svyatoslav Ryhel
Quoted 17 lines

MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration.

Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board.

Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition.

---
 drivers/mfd/motorola-cpcap.c       | 142 ++++++++++++++++-------------
 include/linux/mfd/motorola-cpcap.h |   6 ++
 2 files changed, 87 insertions(+), 61 deletions(-)
Quoted 6 lines
Quoted 4 lines

Looking much better, thanks.

Nit: A patch-level changelog really is much more helpful to reviewers.

Noted, but I will not guarantee that I will do patch-level changelogs, sorry.

That's fine. All I can do is ask.

Note that, helping out reviewers usually ends up helping you too.

[...]

Quoted 49 lines
Quoted 13 lines
Quoted 13 lines
drivers/mfd/motorola-cpcap.c +13 -0
+static const struct mfd_cell cpcap_default_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
Quoted 9 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 249

Quoted 5 lines
drivers/mfd/motorola-cpcap.c +5 -0
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
+};

Nit: I wouldn't complain if you wanted to have all of these on a single line for neatness.

Noted

Quoted 24 lines
Quoted 11 lines
drivers/mfd/motorola-cpcap.c +11 -0
+static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-charger"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 271

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +9 -0
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
 };

A lot of these are duplicated, right?

Quoted 8 lines
Quoted 1 line

I would have a comment set, then the differences in separate containers.

It may be impossible to predict a generic setup since some devices may require unique compatibles, other may not have LEDs, third may be partially incompatible with existing cells. In other mfd cases creating a generic bundle might be good, but in this case I would suggest better to keep these separate entirely per-device. They will not take much space, nor add confusion with these macros.

I'm not sure we're understanding each other. Let me give you an example:

static const struct mfd_cell cpcap_common_devices[] = {
     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0, "motorola,cpcap-battery"),
     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0, "motorola,cpcap-pwrbutton"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
     MFD_CELL_NAME("cpcap-codec"),
};
static const struct mfd_cell cpcap_default_devices[] = {
     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,cpcap-regulator"),
     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,cpcap-usb-phy"),
};

static const struct mfd_cell cpcap_mapphone_devices[] = {
MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-adc"), MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-charger"), MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-regulator"), MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-usb-phy"),
};

This way, it's super easy to read / maintain the common and unique devices.

The only potential drawback would be 2 calls to mfd_add_devices() but that's common practice.

Quoted 7 lines
Quoted 2 lines

Also notice that I droped the "_mfd" parts, which you should too.

What if next added device does not have cpcap-battery, cpcap-led-adl, cpcap-pwrbutton, uses external codec and would require cpcap-watchdog which is not yet present. This will cause issues. Even Mot introduces in the last patch of this patchset has slightly different composition.

We usually just code-up what we have _today_.

If new devices come in with different requirements, it takes 5 mins to rejig.

Signature · 1 line
Lee Jones
#18 lore raw

Re: [PATCH v5 5/6] mfd: motorola-cpcap: diverge configuration per-board

ср, 20 трав. 2026 р. о 20:02 Lee Jones <[email protected]> пише:

Quoted 134 lines · Svyatoslav Ryhel
Quoted 132 lines

ср, 20 трав. 2026 р. о 19:05 Lee Jones <[email protected]> пише:

Quoted 129 lines · Svyatoslav Ryhel
Quoted 22 lines

ср, 20 трав. 2026 р. о 18:08 Lee Jones <[email protected]> пише:

Quoted 20 lines · Svyatoslav Ryhel
Quoted 17 lines

MFD have rigid subdevice structure which does not allow flexible dynamic subdevice linking. Address this by diverging CPCAP subdevice composition to take into account board specific configuration.

Create a common default subdevice composition, rename existing subdevice composition into cpcap_mapphone_mfd_devices since it targets mainly Mapphone board.

Removed st,6556002 as it is no longer applicable to all cases and duplicates motorola,cpcap, which is used as the default composition.

---
 drivers/mfd/motorola-cpcap.c       | 142 ++++++++++++++++-------------
 include/linux/mfd/motorola-cpcap.h |   6 ++
 2 files changed, 87 insertions(+), 61 deletions(-)
Quoted 6 lines
Quoted 4 lines

Looking much better, thanks.

Nit: A patch-level changelog really is much more helpful to reviewers.

Noted, but I will not guarantee that I will do patch-level changelogs, sorry.

That's fine. All I can do is ask.

Note that, helping out reviewers usually ends up helping you too.

[...]

Quoted 49 lines
Quoted 13 lines
Quoted 13 lines
drivers/mfd/motorola-cpcap.c +13 -0
+static const struct mfd_cell cpcap_default_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
Quoted 9 lines

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 249

Quoted 5 lines
drivers/mfd/motorola-cpcap.c +5 -0
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
+};

Nit: I wouldn't complain if you wanted to have all of these on a single line for neatness.

Noted

Quoted 24 lines
Quoted 11 lines
drivers/mfd/motorola-cpcap.c +11 -0
+static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
+     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-adc"),
+     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+                 "motorola,cpcap-battery"),
+     MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-charger"),
+     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-regulator"),
+     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,

drivers/mfd/motorola-cpcap.c static int cpcap_resume(struct device *dev) · line 271

Quoted 10 lines
drivers/mfd/motorola-cpcap.c +9 -0
+                 "motorola,cpcap-pwrbutton"),
+     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0,
+                 "motorola,mapphone-cpcap-usb-phy"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
+     MFD_CELL_NAME("cpcap-codec"),
 };

A lot of these are duplicated, right?

Quoted 8 lines
Quoted 1 line

I would have a comment set, then the differences in separate containers.

It may be impossible to predict a generic setup since some devices may require unique compatibles, other may not have LEDs, third may be partially incompatible with existing cells. In other mfd cases creating a generic bundle might be good, but in this case I would suggest better to keep these separate entirely per-device. They will not take much space, nor add confusion with these macros.

I'm not sure we're understanding each other. Let me give you an example:

static const struct mfd_cell cpcap_common_devices[] = {
     MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0, "motorola,cpcap-battery"),
     MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
     MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0, "motorola,cpcap-pwrbutton"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
     MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 4, "motorola,cpcap-led-cp"),
     MFD_CELL_NAME("cpcap-codec"),
};
static const struct mfd_cell cpcap_default_devices[] = {
     MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,cpcap-adc"),
     MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,cpcap-regulator"),
     MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,cpcap-usb-phy"),
};

static const struct mfd_cell cpcap_mapphone_devices[] = {
MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-adc"), MFD_CELL_OF("cpcap-charger", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-charger"), MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-regulator"), MFD_CELL_OF("cpcap-usb-phy", NULL, NULL, 0, 0, "motorola,mapphone-cpcap-usb-phy"),
};

This way, it's super easy to read / maintain the common and unique devices.

The only potential drawback would be 2 calls to mfd_add_devices() but that's common practice.

Also notice that I droped the "_mfd" parts, which you should too.

Quoted 9 lines
Quoted 4 lines

What if next added device does not have cpcap-battery, cpcap-led-adl, cpcap-pwrbutton, uses external codec and would require cpcap-watchdog which is not yet present. This will cause issues. Even Mot introduces in the last patch of this patchset has slightly different composition.

We usually just code-up what we have _today_.

If new devices come in with different requirements, it takes 5 mins to rejig.

Ok, but I will take into account Mot commit when factoring out common.

Quoted 2 lines

--
Lee Jones

#19 lore raw

PATCH v5 6/6 mfd: motorola-cpcap: add support for Mot CPCAP composition

In reply to Svyatoslav Ryhel

Add a MFD subdevice composition used in Tegra20 based Mot board (Motorola Atrix 4G and Droid X2).

---
 drivers/mfd/motorola-cpcap.c       | 30 ++++++++++++++++++++++++++++++
 include/linux/mfd/motorola-cpcap.h |  1 +
 2 files changed, 31 insertions(+)
drivers/mfd/motorola-cpcap.c +30 -0
index f5a7fdd89dd5..bd9fb0d61ba6 100644
@@ -270,6 +270,28 @@ static const struct mfd_cell cpcap_mapphone_mfd_devices[] = {
 	MFD_CELL_NAME("cpcap-codec"),
 };
 
+/*
+ * The Mot board features a USB-PHY and charger similar to the ones in
+ * Mapphone; however, because Mot is based on Tegra20, it is incompatible
+ * with the existing implementation, which is tightly interconnected with
+ * the OMAP USB PHY.
+ */
+static const struct mfd_cell cpcap_mot_mfd_devices[] = {
+	MFD_CELL_OF("cpcap_adc", NULL, NULL, 0, 0, "motorola,mot-cpcap-adc"),
+	MFD_CELL_OF("cpcap_battery", NULL, NULL, 0, 0,
+		    "motorola,cpcap-battery"),
+	MFD_CELL_OF("cpcap-regulator", NULL, NULL, 0, 0,
+		    "motorola,mot-cpcap-regulator"),
+	MFD_CELL_OF("cpcap-rtc", NULL, NULL, 0, 0, "motorola,cpcap-rtc"),
+	MFD_CELL_OF("cpcap-pwrbutton", NULL, NULL, 0, 0,
+		    "motorola,cpcap-pwrbutton"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 0, "motorola,cpcap-led-red"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 1, "motorola,cpcap-led-green"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 2, "motorola,cpcap-led-blue"),
+	MFD_CELL_OF("cpcap-led", NULL, NULL, 0, 3, "motorola,cpcap-led-adl"),
+	MFD_CELL_NAME("cpcap-codec"),
+};
+
 static int cpcap_probe(struct spi_device *spi)
 {
 	struct cpcap_ddata *cpcap;
@@ -294,6 +316,10 @@ static int cpcap_probe(struct spi_device *spi)
 		cells = cpcap_mapphone_mfd_devices;
 		num_cells = ARRAY_SIZE(cpcap_mapphone_mfd_devices);
 		break;
+	case CPCAP_MOT:
+		cells = cpcap_mot_mfd_devices;
+		num_cells = ARRAY_SIZE(cpcap_mot_mfd_devices);
+		break;
 	default:
 		return dev_err_probe(&spi->dev, -EINVAL,
 				     "Unknown device %d\n", cpcap->variant);
@@ -343,6 +369,9 @@ static const struct of_device_id cpcap_of_match[] = {
 	}, {
 		.compatible = "motorola,mapphone-cpcap",
 		.data = (void *)CPCAP_MAPPHONE
+	}, {
+		.compatible = "motorola,mot-cpcap",
+		.data = (void *)CPCAP_MOT
 	},
 	{ /* sentinel */ }
 };
@@ -351,6 +380,7 @@ MODULE_DEVICE_TABLE(of, cpcap_of_match);
 static const struct spi_device_id cpcap_spi_ids[] = {
 	{ "cpcap", CPCAP_DEFAULT },
 	{ "mapphone-cpcap", CPCAP_MAPPHONE },
+	{ "mot-cpcap", CPCAP_MOT },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(spi, cpcap_spi_ids);
include/linux/mfd/motorola-cpcap.h +1 -0
index 1a85b06272c8..bb23363eeccd 100644
@@ -28,6 +28,7 @@
 enum cpcap_variant {
 	CPCAP_DEFAULT = 1,
 	CPCAP_MAPPHONE,
+	CPCAP_MOT,
 	CPCAP_MAX
 };
 
Signature · 1 line
2.51.0