# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright 2025-2026 NXP
%YAML 1.2
---
$id: http://devicetree.org/schemas/i3c/nxp,p3h2840.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: NXP P3H2X4X I3C HUB

maintainers:
  - Aman Kumar Pandey <aman.kumarpandey@nxp.com>
  - Vikash Bansal <vikash.bansal@nxp.com>
  - Lakshay Piplani <lakshay.piplani@nxp.com>

description: |
  P3H2x4x (P3H2440/P3H2441/P3H2840/P3H2841) is a family of multiport I3C
  hub devices that connect to:-
  1. A host CPU via I3C/I2C/SMBus bus on upstream side and connect to multiple
     peripheral devices on the downstream  side.
  2. Have two Controller Ports which can support either
     I2C/SMBus or I3C buses and connect to a CPU, BMC or SOC.
  3. P3H2840/ P3H2841 are 8 port I3C hub with eight Target Ports.
  4. P3H2440/ P3H2441 are 4 port I3C hub with four Target Ports.
     Target ports can be configured as SMBus or I3C and connect to
     peripherals.

  All variants share the same register interface and programmable
  functionality. The x0 and x1 variants differ only in power-up defaults.

properties:
  compatible:
    oneOf:
      - const: nxp,p3h2840
      - items:
          - enum:
              - nxp,p3h2440
              - nxp,p3h2441
              - nxp,p3h2841
          - const: nxp,p3h2840

  reg:
    maxItems: 1

  '#address-cells':
    const: 1

  '#size-cells':
    const: 0

  assigned-address:
    maximum: 0x7f

  nxp,tp0145-pullup-ohms:
    description:
      Selects the pull up resistance for target Port 0/1/4/5, in ohms.
    enum: [250, 500, 1000, 2000]
    default: 500

  nxp,tp2367-pullup-ohms:
    description:
      Selects the pull up resistance for target Port 2/3/6/7, in ohms.
    enum: [250, 500, 1000, 2000]
    default: 500

  nxp,cp0-io-strength-ohms:
    description:
      Selects the IO drive strength for controller Port 0, in ohms.
    enum: [20, 30, 40, 50]
    default: 20

  nxp,cp1-io-strength-ohms:
    description:
      Selects the IO drive strength for controller Port 1, in ohms.
    enum: [20, 30, 40, 50]
    default: 20

  nxp,tp0145-io-strength-ohms:
    description:
      Selects the IO drive strength for target port 0/1/4/5, in ohms.
    enum: [20, 30, 40, 50]
    default: 20

  nxp,tp2367-io-strength-ohms:
    description:
      Selects the IO drive strength for target port 2/3/6/7, in ohms.
    enum: [20, 30, 40, 50]
    default: 20

  vcc1-supply:
    description: Controller port 0 power supply.

  vcc2-supply:
    description: Controller port 1 power supply.

  vcc3-supply:
    description: Target port 0/1/4/5 power supply.

  vcc4-supply:
    description: Target port 2/3/6/7 power supply.

  regulators:
    type: object
    additionalProperties: false

    properties:
      ldo-cp0:
        type: object
        $ref: /schemas/regulator/regulator.yaml#
        unevaluatedProperties: false

      ldo-cp1:
        type: object
        $ref: /schemas/regulator/regulator.yaml#
        unevaluatedProperties: false

      ldo-tpg0:
        type: object
        $ref: /schemas/regulator/regulator.yaml#
        unevaluatedProperties: false

      ldo-tpg1:
        type: object
        $ref: /schemas/regulator/regulator.yaml#
        unevaluatedProperties: false

required:
  - reg
  - '#address-cells'
  - '#size-cells'

patternProperties:
  "^i3c@[0-7]$":
    type: object
    $ref: /schemas/i3c/i3c.yaml#
    unevaluatedProperties: false

    properties:
      reg:
        description:
          The I3C HUB Target Port number.
        items:
          - minimum: 0
            maximum: 7

      nxp,pullup-enable:
        type: boolean
        description:
          Enables the on-die pull-up for Target Port.

    required:
      - reg

  "^smbus@[0-7]$":
    type: object
    $ref: /schemas/i2c/i2c-controller.yaml#
    unevaluatedProperties: false

    properties:
      reg:
        description:
          The I3C HUB Target Port number.
        items:
          - minimum: 0
            maximum: 7

      nxp,pullup-enable:
        type: boolean
        description:
          Enables the on-die pull-up for Target Port.

    required:
      - reg

allOf:
  - if:
      properties:
        compatible:
          contains:
            enum:
              - nxp,p3h2440
              - nxp,p3h2441
    then:
      patternProperties:
        "^i3c@[0-3]$":
          properties:
            reg:
              items:
                - maximum: 3
        "^smbus@[0-3]$":
          properties:
            reg:
              items:
                - maximum: 3
        "^i3c@[4-7]$": false
        "^smbus@[4-7]$": false

unevaluatedProperties: false

examples:
  - |
    i3c {
        #address-cells = <3>;
        #size-cells = <0>;

        hub@70,236153000c2 {
            reg = <0x70 0x236 0x153000c2>;
            compatible = "nxp,p3h2441", "nxp,p3h2840";
            #address-cells = <1>;
            #size-cells = <0>;
            assigned-address = <0x50>;

            nxp,tp0145-pullup-ohms = <1000>;
            nxp,tp2367-pullup-ohms = <1000>;
            nxp,cp0-io-strength-ohms = <50>;
            nxp,cp1-io-strength-ohms = <50>;
            nxp,tp0145-io-strength-ohms = <50>;
            nxp,tp2367-io-strength-ohms = <50>;
            vcc3-supply = <&reg_tpg0>;
            vcc4-supply = <&reg_tpg1>;

            regulators {
                reg_cp0: ldo-cp0 {
                    regulator-name = "ldo-cp0";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };

                reg_cp1: ldo-cp1 {
                    regulator-name = "ldo-cp1";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };

                reg_tpg0: ldo-tpg0 {
                    regulator-name = "ldo-tpg0";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };

                reg_tpg1: ldo-tpg1 {
                    regulator-name = "ldo-tpg1";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };
            };

            smbus@0 {
                reg = <0x0>;
                #address-cells = <1>;
                #size-cells = <0>;
                nxp,pullup-enable;
            };

            smbus@1 {
                reg = <0x1>;
                #address-cells = <1>;
                #size-cells = <0>;
                nxp,pullup-enable;
            };

            i3c@2 {
                reg = <0x2>;
                #address-cells = <3>;
                #size-cells = <0>;
                nxp,pullup-enable;
            };
        };
    };

  - |
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        hub@70 {
            reg = <0x70>;
            compatible = "nxp,p3h2840";
            #address-cells = <1>;
            #size-cells = <0>;

            nxp,tp0145-pullup-ohms = <1000>;
            nxp,tp2367-pullup-ohms = <1000>;
            nxp,cp0-io-strength-ohms = <50>;
            nxp,cp1-io-strength-ohms = <50>;
            nxp,tp0145-io-strength-ohms = <50>;
            nxp,tp2367-io-strength-ohms = <50>;
            vcc3-supply = <&reg_tpg0_i2c>;
            vcc4-supply = <&reg_tpg1_i2c>;

            regulators {
                reg_cp0_i2c: ldo-cp0 {
                    regulator-name = "ldo-cp0";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };

                reg_cp1_i2c: ldo-cp1 {
                    regulator-name = "ldo-cp1";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };

                reg_tpg0_i2c: ldo-tpg0 {
                    regulator-name = "ldo-tpg0";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };

                reg_tpg1_i2c: ldo-tpg1 {
                    regulator-name = "ldo-tpg1";
                    regulator-min-microvolt = <1800000>;
                    regulator-max-microvolt = <1800000>;
                };
            };

            smbus@0 {
                reg = <0x0>;
                #address-cells = <1>;
                #size-cells = <0>;
                nxp,pullup-enable;
            };

            smbus@1 {
                reg = <0x1>;
                #address-cells = <1>;
                #size-cells = <0>;
                nxp,pullup-enable;
            };
        };
    };