From de3efe99941070122e3cd1f115d8dbf0bf0eea32 Mon Sep 17 00:00:00 2001 From: Alvis Sun Date: Mon, 30 Dec 2024 16:44:36 +0800 Subject: [PATCH] dts: arm: npcx: add I2C port helper macro As title. Signed-off-by: Alvis Sun --- dts/arm/nuvoton/npcx/npcx.dtsi | 21 +++++++++++---------- dts/arm/nuvoton/npcx/npcx4.dtsi | 4 ++-- dts/bindings/i2c/nuvoton,npcx-i2c-port.yaml | 8 +++++++- include/zephyr/dt-bindings/i2c/npcx-i2c.h | 12 ++++++++++++ 4 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 include/zephyr/dt-bindings/i2c/npcx-i2c.h diff --git a/dts/arm/nuvoton/npcx/npcx.dtsi b/dts/arm/nuvoton/npcx/npcx.dtsi index 15e17cf9eecc..aaaca78d0267 100644 --- a/dts/arm/nuvoton/npcx/npcx.dtsi +++ b/dts/arm/nuvoton/npcx/npcx.dtsi @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -484,7 +485,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x00>; + port = ; controller = <&i2c_ctrl0>; status = "disabled"; }; @@ -493,7 +494,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x10>; + port = ; controller = <&i2c_ctrl1>; status = "disabled"; }; @@ -502,7 +503,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x20>; + port = ; controller = <&i2c_ctrl2>; status = "disabled"; }; @@ -511,7 +512,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x30>; + port = ; controller = <&i2c_ctrl3>; status = "disabled"; }; @@ -520,7 +521,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x41>; + port = ; controller = <&i2c_ctrl4>; status = "disabled"; }; @@ -529,7 +530,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x50>; + port = ; controller = <&i2c_ctrl5>; status = "disabled"; }; @@ -538,7 +539,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x51>; + port = ; controller = <&i2c_ctrl5>; status = "disabled"; }; @@ -547,7 +548,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x60>; + port = ; controller = <&i2c_ctrl6>; status = "disabled"; }; @@ -556,7 +557,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x61>; + port = ; controller = <&i2c_ctrl6>; status = "disabled"; }; @@ -565,7 +566,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x70>; + port = ; controller = <&i2c_ctrl7>; status = "disabled"; }; diff --git a/dts/arm/nuvoton/npcx/npcx4.dtsi b/dts/arm/nuvoton/npcx/npcx4.dtsi index 285fcbdd340b..ab83adda7927 100644 --- a/dts/arm/nuvoton/npcx/npcx4.dtsi +++ b/dts/arm/nuvoton/npcx/npcx4.dtsi @@ -522,7 +522,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x40>; + port = ; controller = <&i2c_ctrl4>; status = "disabled"; }; @@ -531,7 +531,7 @@ compatible = "nuvoton,npcx-i2c-port"; #address-cells = <1>; #size-cells = <0>; - port = <0x71>; + port = ; controller = <&i2c_ctrl7>; status = "disabled"; }; diff --git a/dts/bindings/i2c/nuvoton,npcx-i2c-port.yaml b/dts/bindings/i2c/nuvoton,npcx-i2c-port.yaml index 8f5f288705e8..76304f57374b 100644 --- a/dts/bindings/i2c/nuvoton,npcx-i2c-port.yaml +++ b/dts/bindings/i2c/nuvoton,npcx-i2c-port.yaml @@ -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 diff --git a/include/zephyr/dt-bindings/i2c/npcx-i2c.h b/include/zephyr/dt-bindings/i2c/npcx-i2c.h new file mode 100644 index 000000000000..fc46fbf55fd0 --- /dev/null +++ b/include/zephyr/dt-bindings/i2c/npcx-i2c.h @@ -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_ */