Skip to content

Commit

Permalink
dts: arm: npcx: add I2C port helper macro
Browse files Browse the repository at this point in the history
As title.

Signed-off-by: Alvis Sun <[email protected]>
  • Loading branch information
alvsun committed Jan 7, 2025
1 parent 892e5e1 commit 3190a11
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
21 changes: 11 additions & 10 deletions dts/arm/nuvoton/npcx/npcx.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <zephyr/dt-bindings/flash_controller/npcx_fiu_qspi.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/i2c/i2c.h>
#include <zephyr/dt-bindings/i2c/npcx-i2c.h>
#include <zephyr/dt-bindings/pinctrl/npcx-pinctrl.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/sensor/npcx_tach.h>
Expand Down Expand Up @@ -549,7 +550,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x00>;
port = <NPCX_I2C_CTRL_PORT(0, 0)>;
controller = <&i2c_ctrl0>;
status = "disabled";
};
Expand All @@ -558,7 +559,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x10>;
port = <NPCX_I2C_CTRL_PORT(1, 0)>;
controller = <&i2c_ctrl1>;
status = "disabled";
};
Expand All @@ -567,7 +568,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x20>;
port = <NPCX_I2C_CTRL_PORT(2, 0)>;
controller = <&i2c_ctrl2>;
status = "disabled";
};
Expand All @@ -576,7 +577,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x30>;
port = <NPCX_I2C_CTRL_PORT(3, 0)>;
controller = <&i2c_ctrl3>;
status = "disabled";
};
Expand All @@ -585,7 +586,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x41>;
port = <NPCX_I2C_CTRL_PORT(4, 1)>;
controller = <&i2c_ctrl4>;
status = "disabled";
};
Expand All @@ -594,7 +595,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x50>;
port = <NPCX_I2C_CTRL_PORT(5, 0)>;
controller = <&i2c_ctrl5>;
status = "disabled";
};
Expand All @@ -603,7 +604,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x51>;
port = <NPCX_I2C_CTRL_PORT(5, 1)>;
controller = <&i2c_ctrl5>;
status = "disabled";
};
Expand All @@ -612,7 +613,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x60>;
port = <NPCX_I2C_CTRL_PORT(6, 0)>;
controller = <&i2c_ctrl6>;
status = "disabled";
};
Expand All @@ -621,7 +622,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x61>;
port = <NPCX_I2C_CTRL_PORT(6, 1)>;
controller = <&i2c_ctrl6>;
status = "disabled";
};
Expand All @@ -630,7 +631,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x70>;
port = <NPCX_I2C_CTRL_PORT(7, 0)>;
controller = <&i2c_ctrl7>;
status = "disabled";
};
Expand Down
4 changes: 2 additions & 2 deletions dts/arm/nuvoton/npcx/npcx4.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x40>;
port = <NPCX_I2C_CTRL_PORT(4, 0)>;
controller = <&i2c_ctrl4>;
status = "disabled";
};
Expand All @@ -458,7 +458,7 @@
compatible = "nuvoton,npcx-i2c-port";
#address-cells = <1>;
#size-cells = <0>;
port = <0x71>;
port = <NPCX_I2C_CTRL_PORT(7, 1)>;
controller = <&i2c_ctrl7>;
status = "disabled";
};
Expand Down
8 changes: 7 additions & 1 deletion dts/bindings/i2c/nuvoton,npcx-i2c-port.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ properties:
port:
type: int
required: true
description: index of i2c port
description: |
Index of i2c port
This property is used to differentiate between multiple I2C ports controlled by the same
or different I2C controllers.
Bit[7:4] module id (controller).
Bit[3:0] port id.
Use the macro NPCX_I2C_CTRL_PORT(ctrl, port) to set this property.
controller:
type: phandle
Expand Down
12 changes: 12 additions & 0 deletions include/zephyr/dt-bindings/i2c/npcx-i2c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2024 Nuvoton Technology Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_I2C_NPCX_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_I2C_NPCX_H_


#define NPCX_I2C_CTRL_PORT(ctrl, port) (((ctrl & 0xf) << 4) | (port & 0xf))

#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_I2C_NPCX_H_ */

0 comments on commit 3190a11

Please sign in to comment.