All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: i3c: Add NXP P3H2x4x i3c-hub support
@ 2025-02-12 13:22 ` Aman Kumar Pandey
  0 siblings, 0 replies; 27+ messages in thread
From: Aman Kumar Pandey @ 2025-02-12 13:22 UTC (permalink / raw)
  To: linux-kernel, linux-i3c, alexandre.belloni, krzk+dt, robh,
	conor+dt, devicetree
  Cc: vikash.bansal, priyanka.jain, shashank.rebbapragada, Frank.Li,
	Aman Kumar Pandey

P3H2x4x (P3H2440/P3H2441/P3H2840/P3H2841) is multiport I3C hub
device which connects to a host CPU via I3C/I2C/SMBus bus on one
side and to multiple peripheral devices on the other side.

Signed-off-by: Aman Kumar Pandey <aman.kumarpandey@nxp.com>
Signed-off-by: Vikash Bansal <vikash.bansal@nxp.com>
---
 .../bindings/i3c/p3h2x4x_i3c_hub.yaml         | 404 ++++++++++++++++++
 MAINTAINERS                                   |   7 +
 2 files changed, 411 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i3c/p3h2x4x_i3c_hub.yaml

diff --git a/Documentation/devicetree/bindings/i3c/p3h2x4x_i3c_hub.yaml b/Documentation/devicetree/bindings/i3c/p3h2x4x_i3c_hub.yaml
new file mode 100644
index 000000000000..33ea524e5432
--- /dev/null
+++ b/Documentation/devicetree/bindings/i3c/p3h2x4x_i3c_hub.yaml
@@ -0,0 +1,404 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2024-2025 NXP
+
+%YAML 1.2
+
+$id: http://devicetree.org/schemas/i3c/p3h2x4x_i3c_hub.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: P3H2X4X I3C HUB
+
+maintainers:
+  - Vikash Bansal <vikash.bansal@nxp.com>
+  - Aman Kumar Pandey <aman.kumarpandey@nxp.com>
+
+description: |
+	P3H2x4x (P3H2440/P3H2441/P3H2840/P3H2841) are multiport I3C hub devices
+  that connect to:-
+  1. A host CPU via I3C/I2C/SMBus bus on one side and connect to multiple
+     peripheral devices on the other 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 devices with eight I3C/I2C Target Port.
+  4. P3H2440/ P3H2441 are 4 port I3C hub devices with four I3C/I2C Target Port.
+     Target ports can be configured as I2C/SMBus, I3C or GPIO and connect to
+     peripherals.
+
+  Device tree node can be used for following configurations:-
+  1. Controller Port can be configured via dt entry to support
+  2. I2C/SMBus mode or I3C buses.
+  3. Enabling voltage compatibility across I3C Controller and
+     Target devices.
+  4. Up to eight target devices and their modes(I3C/I2C/SMbus modes).
+  5. To support MCTP device
+  6. To support In-band interrupts
+
+  Controller Port can be configured via dt entry to support I2C/SMBus mode or
+  I3C buses.
+
+  For I2C devices, use below format:
+      DT node: hub@static_address
+      reg: encodes the static I2C address.
+
+  For I3C devices, use below format:
+      DT node: hub@static_address,PID
+      reg: encodes the static I2C address (0 if the device does not have one), and the
+      Provisioned ID (PID) used to uniquely identify a device on a bus.
+      This PID contains information about the vendor, the part, and an instance ID so
+      that several devices of the same type can be connected on the same bus.
+      assigned-address: represents the dynamic address to be assigned to this device.
+
+allOf:
+  - $ref: i3c.yaml#
+
+properties:
+
+  cp0-ldo-en:
+    enum:
+      - disabled
+      - enabled
+    description: |
+      I3C HUB Controller Port 0 LDO setting for turning on and off. If enabled, the dedicated
+      pin will provide the voltage generated by the on-die LDO. It is an optional property,
+      the configuration remains default if it is not supplied.
+
+  cp1-ldo-en:
+    enum:
+      - disabled
+      - enabled
+
+    description: |
+      I3C HUB Controller Port 0 LDO setting for turning on and off. If enabled, the dedicated
+      pin will provide the voltage generated by the on-die LDO. It is an optional property,
+      the configuration remains default if it is not supplied.
+
+  tp0145-ldo-en:
+    enum:
+      - disabled
+      - enabled
+
+    description: |
+      I3C HUB Target Ports 0/1/4/5 LDO setting for turning on and off. If enabled, the dedicated
+      pin will provide the voltage generated by the on-die LDO. It is an optional property,
+      the configuration remains default if it is not supplied.
+
+  tp2367-ldo-en:
+    enum:
+      - disabled
+      - enabled
+
+    description: |
+      I3C HUB Target Ports 2/3/6/7 LDO setting for turning on and off. If enabled, the dedicated
+      pin will provide the voltage generated by the on-die LDO. It is an optional property,
+      the configuration remains default if it is not supplied.
+
+  cp0-ldo-volt:
+    enum:
+      - 1.0V
+      - 1.1V
+      - 1.2V
+      - 1.8V
+
+    description: |
+      Controller Port 0 voltage level is controlled by the I3C HUB Controller Port 0
+      LDO setting.
+      Since this parameter is optional, the configuration remains default if it is not supplied.
+
+  cp1-ldo-volt:
+    enum:
+      - 1.0V
+      - 1.1V
+      - 1.2V
+      - 1.8V
+
+    description: |
+    Controller Port 1 voltage level is controlled by the I3C HUB Controller Port 1
+    LDO setting.
+    Since this parameter is optional, the configuration remains default if it is not supplied.
+
+  tp0145-ldo-volt:
+    enum:
+      - 1.0V
+      - 1.1V
+      - 1.2V
+      - 1.8V
+
+    description: |
+      Target Port 0/1/4/5 voltage level is controlled by the I3C HUB Target Port 0/1/4/5
+      LDO setting.
+      Since this parameter is optional, the configuration remains default if it is not supplied.
+
+  tp2367-ldo-volt:
+    enum:
+      - 1.0V
+      - 1.1V
+      - 1.2V
+      - 1.8V
+
+    description: |
+      Target Port 2/3/6/7 voltage level is controlled by the I3C HUB Target Port 2/3/6/7
+      LDO setting.
+      Since this parameter is optional, the configuration remains default if it is not supplied.
+
+  tp0145-pullup:
+    enum:
+      - 250R
+      - 500R
+      - 1000R
+      - 2000R
+
+    description: |
+      Target Port 0/1/4/5 pull up setting is controlled by the I3C HUB Target Port 0/1/4/5
+      pull up resistance level.
+      Since this parameter is optional, the configuration remains default if it is not supplied.
+
+  tp2367-pullup:
+    enum:
+      - 250R
+      - 500R
+      - 1000R
+      - 2000R
+
+    description: |
+      Target Port 2/3/6/7 pull up setting is controlled by the I3C HUB Target Port 2/3/6/7
+      pull up resistance level.
+      Since this parameter is optional, the configuration remains default if it is not supplied.
+
+  cp0-io-strength:
+    enum:
+      - 20Ohms
+      - 30Ohms
+      - 40Ohms
+      - 50Ohms
+
+    description: |
+      To regulate the output driver strength at Controller Port 0, use the I3C HUB Controller
+      Port 0 IO strength setting.
+      It is an optional property, the configuration remains default if it is not supplied.
+
+  cp1-io-strength:
+    enum:
+      - 20Ohms
+      - 30Ohms
+      - 40Ohms
+      - 50Ohms
+    description: |
+      To regulate the output driver strength at Controller Port 1, use the I3C HUB Controller
+      Port 1 IO strength setting.
+      It is an optional property, the configuration remains default if it is not supplied.
+
+  tp0145-io-strength:
+    enum:
+      - 20Ohms
+      - 30Ohms
+      - 40Ohms
+      - 50Ohms
+
+    description: |
+      To regulate the output driver strength at Target port 0/1/4/5, use the I3C HUB Target
+      port 0/1/4/5 IO strength setting.
+      It is an optional property, the configuration remains default if it is not supplied.
+
+  tp2367-io-strength:
+    enum:
+      - 20Ohms
+      - 30Ohms
+      - 40Ohms
+      - 50Ohms
+
+    description: |
+      To regulate the output driver strength at Target port 2/3/6/7, use the I3C HUB Target
+      port 2/3/6/7 IO strength setting.
+      It is an optional property, the configuration remains default if it is not supplied.
+
+patternProperties:
+  "@[0-7]$":
+    type: object
+    description: |
+      I3C HUB Target Port child, should be named: target-port@<target-port-id>
+
+    properties:
+      mode:
+        enum:
+          - i3c
+          - smbus
+          - i2c
+          - gpio
+
+        description: |
+          I3C HUB Target Port mode setting to control Target Port functionality.
+          As per now it is oly supporting SMBus, i2c and i3c( i2c mode will work
+          with hub network).
+
+      pullup:
+        enum:
+          - disabled
+          - enabled
+        description: |
+          I3C HUB Target Port pull-up setting to disable/enable Target Port pull-up.
+          It is an optional property, the configuration remains default if it is not supplied.
+
+      ibi_en:
+        enum:
+          - disabled
+          - enabled
+        description: |
+          I3C HUB Target Port IBI setting to disable/enable IBI for Target Port.
+          This property is optional. If not provided, Target Port IBI will disabled.
+
+      local_dev:
+        description: |
+          SMBus Target Agent can discard transactions of downstream device and not generate an IBI to upstream I3C Hub
+          Controller Port. Up to 8 device (addresses) can be configured as local Devices.
+
+          This property is optional. If not provided, local device list will empty.
+
+      always-enable:
+        description: |
+          Add this field to enable hub network(Controller port -> target port).
+
+          This property is optional. If not provided, by default hub network will disabled for respective port.
+
+    patternProperties:
+      "@slave-address,pid$":
+        type: object
+        description: |
+          Adding this node to install the downstream devices.
+
+        properties:
+          compatible:
+            description:
+              Compatible of the I2C/SMBus downstream device.
+
+          reg:
+            description:
+              Downstream device addresses which are connected to target port.
+
+          I3c HUB driver supports standerd i2c/i3c DT entry as it passes DT node to respective driver for
+          downstream device.
+
+additionalProperties: true
+
+examples:
+  - |
+      i3c_hub: hub@70,236153000c2{
+          reg = <0x70 0x236 0x3000c2>;
+          assigned-address = <0x50>;
+          dcr = <0xC2>;
+
+          cp0-ldo-en = "disabled";
+          cp1-ldo-en = "disabled";
+          cp0-ldo-volt = "1.8V";
+          cp1-ldo-volt = "1.8V";
+          tp0145-ldo-en = "disabled";
+          tp2367-ldo-en = "disabled";
+          tp0145-ldo-volt = "1.8V";
+          tp2367-ldo-volt = "1.8V";
+          tp0145-pullup= "1000R";
+          tp2367-pullup = "1000R";
+          tp0145-io-strength = "20Ohms";
+          tp2367-io-strength = "20Ohms";
+          cp0-io-strength = "20Ohms";
+          cp1-io-strength = "20Ohms";
+          target-port@0 {
+            #address-cells = <1>;
+                #size-cells = <0>;
+            mode = "smbus";
+            pullup_en = "enabled";
+            ibi_en = "enabled";
+            local_dev = <0x30>, <0x40>, <0x50>;
+            backend@4c{
+              compatible = "i3c-hub";
+              reg = <0x4c>;
+            };
+            rtc@68 {
+              compatible = "dallas,ds3232";
+              reg = <0x68>;
+              interrupt-parent = <&gpio2>;
+              interrupts = <20 0>;
+              trickle-resistor-ohms = <250>;
+            };
+
+            eeprom@57 {
+              compatible = "atmel,24c32";
+              reg = <0x57>;
+              pagesize = <32>;
+              wp-gpios = <&gpio2 2 0>;
+              num-addresses = <8>;
+            };
+          };
+          target-port@1 {
+            #address-cells = <1>;
+                #size-cells = <0>;
+            mode = "smbus";
+            pullup_en = "enabled";
+            ibi_en = "enabled";
+              local_dev = <0x35>, <0x45>, <0x55>;
+          };
+          target-port@2 {
+            #address-cells = <1>;
+                #size-cells = <0>;
+            mode = "i3c";
+            pullup_en = "enabled";
+            hub-test@4c,25400000000{
+              reg = <0x4c 0x254 0x0000>;
+              assigned-address = <0x50>;
+            };
+          };
+          target-port@3 {
+            #address-cells = <1>;
+                #size-cells = <0>;
+            mode = "i3c";
+            pullup_en = "enabled";
+            always-enable;
+          };
+      };
+
+      i3c_hub: hub@70 {
+          compatible = "nxp,p3h2x4x";
+          reg = <0x70>;
+
+          cp0-ldo-en = "disabled";
+          cp1-ldo-en = "disabled";
+          cp0-ldo-volt = "1.8V";
+          cp1-ldo-volt = "1.8V";
+          tp0145-ldo-en = "disabled";
+          tp2367-ldo-en = "disabled";
+          tp0145-ldo-volt = "1.8V";
+          tp2367-ldo-volt = "1.8V";
+          tp0145-pullup= "1000R";
+          tp2367-pullup = "1000R";
+          tp0145-io-strength = "20Ohms";
+          tp2367-io-strength = "20Ohms";
+          cp0-io-strength = "20Ohms";
+          cp1-io-strength = "20Ohms";
+          target-port@0 {
+            #address-cells = <1>;
+                #size-cells = <0>;
+            mode = "smbus";
+            pullup_en = "enabled";
+            ibi_en = "enabled";
+            local_dev = <0x30>, <0x40>, <0x50>;
+
+            backend@4c{
+              compatible = "test-dvr";
+              reg = <0x4c>;
+            };
+            rtc@68 {
+              compatible = "dallas,ds3232";
+              reg = <0x68>;
+              interrupt-parent = <&gpio2>;
+              interrupts = <20 0>;
+              trickle-resistor-ohms = <250>;
+            };
+
+            eeprom@57 {
+              compatible = "atmel,24c32";
+              reg = <0x57>;
+              pagesize = <32>;
+              wp-gpios = <&gpio2 2 0>;
+              num-addresses = <8>;
+            };
+          };
+	    };
+-  |
diff --git a/MAINTAINERS b/MAINTAINERS
index af686e0bb6d7..20aa3e987ac5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17167,6 +17167,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/sound/nxp,tfa989x.yaml
 F:	sound/soc/codecs/tfa989x.c
 
+NXP P3H2X4X I3C-HUB DRIVER
+M:	Vikash Bansal <vikash.bansal@nxp.com>
+M:	Aman Kumar Pandey <aman.kumarpandey@nxp.com>
+L:	linux-kernel@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/i3c/p3h2x4x_i3c_hub.yaml
+
 NZXT-KRAKEN2 HARDWARE MONITORING DRIVER
 M:	Jonas Malaco <jonas@protocubo.io>
 L:	linux-hwmon@vger.kernel.org
-- 
2.25.1


-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply related	[flat|nested] 27+ messages in thread
* Re: [PATCH 2/2] drivers: i3c: Add driver for NXP P3H2x4x i3c-hub device
@ 2025-02-15  1:02 kernel test robot
  0 siblings, 0 replies; 27+ messages in thread
From: kernel test robot @ 2025-02-15  1:02 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250212132227.1348374-2-aman.kumarpandey@nxp.com>
References: <20250212132227.1348374-2-aman.kumarpandey@nxp.com>
TO: Aman Kumar Pandey <aman.kumarpandey@nxp.com>
TO: linux-kernel@vger.kernel.org
TO: linux-i3c@lists.infradead.org
TO: alexandre.belloni@bootlin.com
TO: krzk+dt@kernel.org
TO: robh@kernel.org
TO: conor+dt@kernel.org
TO: devicetree@vger.kernel.org
CC: vikash.bansal@nxp.com
CC: priyanka.jain@nxp.com
CC: shashank.rebbapragada@nxp.com
CC: Frank.Li@nxp.com
CC: Aman Kumar Pandey <aman.kumarpandey@nxp.com>

Hi Aman,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.14-rc2 next-20250214]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aman-Kumar-Pandey/drivers-i3c-Add-driver-for-NXP-P3H2x4x-i3c-hub-device/20250212-213659
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20250212132227.1348374-2-aman.kumarpandey%40nxp.com
patch subject: [PATCH 2/2] drivers: i3c: Add driver for NXP P3H2x4x i3c-hub device
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: i386-randconfig-r073-20250215 (https://download.01.org/0day-ci/archive/20250215/202502150815.xfIJk1kS-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202502150815.xfIJk1kS-lkp@intel.com/

smatch warnings:
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c:370 p3h2x4x_of_get_tp_dt_conf() warn: potential spectre issue 'priv->tp_bus' [w] (local cap)
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c:410 p3h2x4x_read_backend_from_p3h2x4x_dts() warn: potential spectre issue 'priv->tp_bus' [w] (local cap)
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c:412 p3h2x4x_read_backend_from_p3h2x4x_dts() error: buffer overflow 'priv->settings.tp' 8 <= 8 user_rl='0-8'
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c:510 p3h2x4x_get_tp_of_get_setting() warn: potential spectre issue 'tp_setting' [w] (local cap)
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c:572 p3h2x4x_of_get_p3h2x4x_conf() warn: inconsistent indenting
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c:771 p3h2x4x_device_remove_i3c() error: dereferencing freed memory 'backend' (line 775)
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c:902 p3h2x4x_device_remove_i2c() error: dereferencing freed memory 'backend' (line 904)
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_smbus.c:80 p3h2x4x_read_smbus_agent_rx_buf() error: uninitialized symbol 'flag_clear'.
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_smbus.c:460 p3h2x4x_tp_smbus_xfer_msg() error: uninitialized symbol 'write_length'.
drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_smbus.c:461 p3h2x4x_tp_smbus_xfer_msg() error: uninitialized symbol 'read_length'.

vim +370 drivers/i3c/p3h2x4x/p3h2x4x_i3c_hub_common.c

5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  356  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  357  static void p3h2x4x_of_get_tp_dt_conf(struct device *dev,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  358  					const struct device_node *node)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  359  {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  360  	struct p3h2x4x *priv = dev_get_drvdata(dev);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  361  	struct device_node *dev_node;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  362  	int tp_port;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  363  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  364  	for_each_available_child_of_node(node, dev_node) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  365  		if (!dev_node->full_name ||
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  366  			(sscanf(dev_node->full_name, "target-port@%d", &tp_port) != 1))
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  367  			continue;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  368  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  369  		if (tp_port < P3H2x4x_TP_MAX_COUNT) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12 @370  			priv->tp_bus[tp_port].dt_available = true;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  371  			priv->tp_bus[tp_port].of_node = dev_node;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  372  			priv->tp_bus[tp_port].tp_mask = BIT(tp_port);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  373  			priv->tp_bus[tp_port].priv = priv;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  374  			priv->tp_bus[tp_port].tp_port = tp_port;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  375  		}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  376  	}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  377  }
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  378  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  379  /* return true when backend node exist */
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  380  static bool p3h2x4x_is_backend_node_exist(int port, struct p3h2x4x *priv, u32 addr)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  381  {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  382  	struct smbus_device *backend = NULL;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  383  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  384  	list_for_each_entry(backend,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  385  			&priv->tp_bus[port].tp_device_entry, list) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  386  		if (backend->addr == addr)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  387  			return true;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  388  	}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  389  	return false;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  390  }
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  391  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  392  static int p3h2x4x_read_backend_from_p3h2x4x_dts(struct device_node *i3c_node_target,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  393  					struct p3h2x4x *priv)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  394  {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  395  	struct device_node *i3c_node_tp;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  396  	const char *compatible;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  397  	int tp_port, ret;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  398  	u32 addr_dts;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  399  	struct smbus_device *backend;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  400  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  401  	if (sscanf(i3c_node_target->full_name, "target-port@%d", &tp_port) == 0)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  402  		return -EINVAL;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  403  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  404  	if (tp_port > P3H2x4x_TP_MAX_COUNT)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  405  		return -ERANGE;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  406  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  407  	if (tp_port < 0)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  408  		return -EINVAL;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  409  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12 @410  	INIT_LIST_HEAD(&priv->tp_bus[tp_port].tp_device_entry);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  411  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12 @412  	if (priv->settings.tp[tp_port].mode == P3H2x4x_TP_MODE_I3C)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  413  		return 0;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  414  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  415  	for_each_available_child_of_node(i3c_node_target, i3c_node_tp) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  416  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  417  		ret = of_property_read_u32(i3c_node_tp, "reg", &addr_dts);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  418  		if (ret)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  419  			return ret;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  420  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  421  		if (p3h2x4x_is_backend_node_exist(tp_port, priv, addr_dts))
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  422  			continue;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  423  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  424  		ret = of_property_read_string(i3c_node_tp, "compatible", &compatible);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  425  		if (ret)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  426  			return ret;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  427  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  428  		backend = kzalloc(sizeof(*backend), GFP_KERNEL);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  429  		if (!backend)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  430  			return -ENOMEM;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  431  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  432  		backend->addr = addr_dts;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  433  		backend->compatible = compatible;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  434  		backend->tp_device_dt_node = i3c_node_tp;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  435  		backend->client = NULL;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  436  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  437  		list_add(&backend->list,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  438  			&priv->tp_bus[tp_port].tp_device_entry);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  439  	}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  440  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  441  	return 0;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  442  }
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  443  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  444  static void p3h2x4x_parse_dt_tp(struct device *dev,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  445  				const struct device_node *i3c_node_hub,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  446  				struct p3h2x4x *priv)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  447  {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  448  	struct device_node *i3c_node_target;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  449  	int ret;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  450  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  451  	for_each_available_child_of_node(i3c_node_hub, i3c_node_target) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  452  		if (!strcmp(i3c_node_target->name, "target-port")) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  453  			ret = p3h2x4x_read_backend_from_p3h2x4x_dts(i3c_node_target, priv);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  454  			if (ret)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  455  				dev_err(dev, "DTS entry invalid - error %d", ret);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  456  		}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  457  	}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  458  }
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  459  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  460  static int p3h2x4x_get_tp_local_device_dt_setting(struct device *dev,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  461  					const struct device_node *node, u32 id)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  462  {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  463  	u8 i;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  464  	u32 local_dev_count, local_dev;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  465  	struct p3h2x4x *priv = dev_get_drvdata(dev);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  466  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  467  	if (!of_get_property(node, "local_dev", &local_dev_count))
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  468  		return -EINVAL;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  469  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  470  	local_dev_count = local_dev_count / (sizeof(u32));
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  471  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  472  	if (local_dev_count > P3H2x4x_TP_LOCAL_DEV)
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  473  		return -ERANGE;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  474  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  475  	for (i = 0; i < local_dev_count; i++) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  476  		if (of_property_read_u32_index(node, "local_dev", i, &local_dev)) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  477  			priv->tp_bus[id].local_dev_count = 0;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  478  			return -EINVAL;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  479  		}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  480  		priv->tp_bus[id].local_dev_list[i] = (u8)(local_dev*2);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  481  	}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  482  	priv->tp_bus[id].local_dev_count = local_dev_count;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  483  	return 0;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  484  }
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  485  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  486  static void p3h2x4x_get_tp_of_get_setting(struct device *dev,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  487  					const struct device_node *node,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  488  					struct tp_setting tp_setting[])
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  489  {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  490  	struct device_node *tp_node;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  491  	u32 id;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  492  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  493  	for_each_available_child_of_node(node, tp_node) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  494  		if (!tp_node->name || of_node_cmp(tp_node->name, "target-port"))
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  495  			continue;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  496  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  497  		if (!tp_node->full_name ||
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  498  			(sscanf(tp_node->full_name, "target-port@%u", &id) != 1)) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  499  			dev_warn(dev, "Invalid target port node found in DT: %s\n",
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  500  				tp_node->full_name);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  501  			continue;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  502  		}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  503  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  504  		if (id >= P3H2x4x_TP_MAX_COUNT) {
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  505  			dev_warn(dev, "Invalid target port index found in DT: %i\n", id);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  506  			continue;
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  507  		}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  508  		p3h2x4x_of_get_dt_setting(dev, tp_node, "mode", tp_mode_settings,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  509  					ARRAY_SIZE(tp_mode_settings),
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12 @510  					&tp_setting[id].mode);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  511  		p3h2x4x_of_get_dt_setting(dev, tp_node, "pullup_en", tp_pullup_settings,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  512  					ARRAY_SIZE(tp_pullup_settings),
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  513  					&tp_setting[id].pullup_en);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  514  		p3h2x4x_of_get_dt_setting(dev, tp_node, "ibi_en", ibi_en_settings,
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  515  					ARRAY_SIZE(ibi_en_settings),
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  516  					&tp_setting[id].ibi_en);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  517  		tp_setting[id].always_enable =
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  518  					of_property_read_bool(tp_node, "always-enable");
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  519  
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  520  		p3h2x4x_get_tp_local_device_dt_setting(dev, tp_node, id);
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  521  	}
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  522  }
5185c1dfec77e7 Aman Kumar Pandey 2025-02-12  523  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2025-02-19  4:52 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 13:22 [PATCH 1/2] dt-bindings: i3c: Add NXP P3H2x4x i3c-hub support Aman Kumar Pandey
2025-02-12 13:22 ` Aman Kumar Pandey
2025-02-12 13:22 ` [PATCH 2/2] drivers: i3c: Add driver for NXP P3H2x4x i3c-hub device Aman Kumar Pandey
2025-02-12 13:22   ` Aman Kumar Pandey
2025-02-12 16:42   ` Frank Li
2025-02-12 16:42     ` Frank Li
2025-02-12 16:53   ` Krzysztof Kozlowski
2025-02-12 16:53     ` Krzysztof Kozlowski
2025-02-12 18:20   ` Alexandre Belloni
2025-02-12 18:20     ` Alexandre Belloni
2025-02-13 11:49   ` kernel test robot
2025-02-13 11:49     ` kernel test robot
2025-02-13 17:46   ` kernel test robot
2025-02-13 17:46     ` kernel test robot
2025-02-14  4:21   ` kernel test robot
2025-02-14  4:21     ` kernel test robot
2025-02-16 15:17   ` Dan Carpenter
2025-02-16 15:17     ` Dan Carpenter
2025-02-19  4:52   ` kernel test robot
2025-02-19  4:52     ` kernel test robot
2025-02-12 15:25 ` [PATCH 1/2] dt-bindings: i3c: Add NXP P3H2x4x i3c-hub support Rob Herring (Arm)
2025-02-12 15:25   ` Rob Herring (Arm)
2025-02-12 16:23 ` Frank Li
2025-02-12 16:23   ` Frank Li
2025-02-12 16:49 ` Krzysztof Kozlowski
2025-02-12 16:49   ` Krzysztof Kozlowski
  -- strict thread matches above, loose matches on Subject: below --
2025-02-15  1:02 [PATCH 2/2] drivers: i3c: Add driver for NXP P3H2x4x i3c-hub device kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.