Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dts: arm: npcx: add I2C port helper macro #83629

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -484,7 +485,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 @@ -493,7 +494,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 @@ -502,7 +503,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 @@ -511,7 +512,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 @@ -520,7 +521,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 @@ -529,7 +530,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 @@ -538,7 +539,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 @@ -547,7 +548,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 @@ -556,7 +557,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 @@ -565,7 +566,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 @@ -522,7 +522,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 @@ -531,7 +531,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_ */
Loading