summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2021-07-06 17:52:16 +0800
committerCommit Bot <commit-bot@chromium.org>2021-07-29 16:53:01 +0000
commit5e07ac82ecf51aff07a8def8a4bae1330c426b22 (patch)
tree58eb76f1407c91b28f37ec9949383b72282ec59b
parent128ffb9526c7275f158d588243d03a4f4e2ac0af (diff)
downloadchrome-ec-5e07ac82ecf51aff07a8def8a4bae1330c426b22.tar.gz
zephyr: npcx_evb: Enable I2C
This CL enables I2C for npcx7/9_evb. Currently, zephyr-OS ec doesn't use the GPIO for i2c unwedge functionality. Remove the GPIO setting for i2c in gpio.dts. BUG=none BRANCH=none TEST=Get sensor value by `i2c` shell command ``` uart:~$ i2c scan I2C_2_PORT_0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- 1 devices found on I2C_2_PORT_0 uart:~$ i2c read I2C_2_PORT_0 0x48 0x00 2 00000000: 1f 80 ``` Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: If5029c41b7ba5400ee1492b408f7ab6975218c5b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3060348 Reviewed-by: Yuval Peress <peress@chromium.org> Commit-Queue: Yuval Peress <peress@chromium.org>
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig3
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig3
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx_evb.dtsi55
-rw-r--r--zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml3
-rw-r--r--zephyr/projects/npcx_evb/npcx7/gpio.dts40
-rw-r--r--zephyr/projects/npcx_evb/npcx7/prj.conf1
-rw-r--r--zephyr/projects/npcx_evb/npcx9/gpio.dts40
-rw-r--r--zephyr/projects/npcx_evb/npcx9/prj.conf1
8 files changed, 64 insertions, 82 deletions
diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
index 7491ae09df..cacc3fe709 100644
--- a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
+++ b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
@@ -32,3 +32,6 @@ CONFIG_CLOCK_CONTROL=y
# WATCHDOG configuration
CONFIG_WATCHDOG=y
+
+# I2C
+CONFIG_I2C=y
diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
index cfb3a263e8..3dc981e555 100644
--- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
+++ b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
@@ -31,3 +31,6 @@ CONFIG_CLOCK_CONTROL=y
# WATCHDOG configuration
CONFIG_WATCHDOG=y
+
+# I2C
+CONFIG_I2C=y
diff --git a/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi b/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi
index 65c1ab7e68..3c1bb67f94 100644
--- a/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi
+++ b/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi
@@ -14,4 +14,59 @@
zephyr,shell-uart = &uart1;
zephyr,flash = &flash0;
};
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_evb_0_0 {
+ i2c-port = <&i2c0_0>;
+ enum-name = "I2C_PORT_EVB_0";
+ label = "I2C0_0";
+ };
+ i2c_evb_1_0 {
+ i2c-port = <&i2c1_0>;
+ enum-name = "I2C_PORT_EVB_1";
+ label = "I2C1_0";
+ };
+ i2c_evb_2_0 {
+ i2c-port = <&i2c2_0>;
+ enum-name = "I2C_PORT_EVB_2";
+ label = "I2C2_0";
+ };
+ i2c_evb_3_0 {
+ i2c-port = <&i2c3_0>;
+ enum-name = "I2C_PORT_EVB_3";
+ label = "I2C3_0";
+ };
+ i2c_evb_7_0 {
+ i2c-port = <&i2c7_0>;
+ enum-name = "I2C_PORT_EVB_7";
+ label = "I2C7_0";
+ };
+ };
+};
+
+&i2c0_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&i2c1_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&i2c2_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&i2c3_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&i2c7_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
};
diff --git a/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml b/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
index a7d5232599..b1b7916f85 100644
--- a/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
+++ b/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
@@ -23,8 +23,11 @@ properties:
- I2C_PORT_BATTERY
- I2C_PORT_CHARGER
- I2C_PORT_EEPROM
+ - I2C_PORT_EVB_0
- I2C_PORT_EVB_1
- I2C_PORT_EVB_2
+ - I2C_PORT_EVB_3
+ - I2C_PORT_EVB_7
- I2C_PORT_OPT_4
- I2C_PORT_POWER
- I2C_PORT_PPC0
diff --git a/zephyr/projects/npcx_evb/npcx7/gpio.dts b/zephyr/projects/npcx_evb/npcx7/gpio.dts
index 3f10215613..15f2c28a5d 100644
--- a/zephyr/projects/npcx_evb/npcx7/gpio.dts
+++ b/zephyr/projects/npcx_evb/npcx7/gpio.dts
@@ -48,46 +48,6 @@
gpios = <&gpioa 5 GPIO_OUT_HIGH>;
label = "SPI_CS_L";
};
- i2c0_scl0 {
- gpios = <&gpiob 5 GPIO_ODR_HIGH>;
- label = "I2C0_SCL0";
- };
- i2c0_sda0 {
- gpios = <&gpiob 4 GPIO_ODR_HIGH>;
- label = "I2C0_SDA0";
- };
- i2c1_scl0 {
- gpios = <&gpio9 0 GPIO_ODR_HIGH>;
- label = "I2C1_SCL0";
- };
- i2c1_sda0 {
- gpios = <&gpio8 7 GPIO_ODR_HIGH>;
- label = "I2C1_SDA0";
- };
- i2c2_scl0 {
- gpios = <&gpio9 2 GPIO_ODR_HIGH>;
- label = "I2C2_SCL0";
- };
- i2c2_sda0 {
- gpios = <&gpio9 1 GPIO_ODR_HIGH>;
- label = "I2C2_SDA0";
- };
- i2c3_scl0 {
- gpios = <&gpiod 1 GPIO_ODR_HIGH>;
- label = "I2C3_SCL0";
- };
- i2c3_sda0 {
- gpios = <&gpiod 0 GPIO_ODR_HIGH>;
- label = "I2C3_SDA0";
- };
- i2c7_sda0 {
- gpios = <&gpiob 2 GPIO_ODR_HIGH>;
- label = "I2C7_SDA0";
- };
- i2c7_scl0 {
- gpios = <&gpiob 3 GPIO_ODR_HIGH>;
- label = "I2C7_SCL0";
- };
board_version1 {
gpios = <&gpio6 4 GPIO_INPUT>;
enum-name = "GPIO_BOARD_VERSION1";
diff --git a/zephyr/projects/npcx_evb/npcx7/prj.conf b/zephyr/projects/npcx_evb/npcx7/prj.conf
index 5bc2922e47..9941bc4c83 100644
--- a/zephyr/projects/npcx_evb/npcx7/prj.conf
+++ b/zephyr/projects/npcx_evb/npcx7/prj.conf
@@ -14,7 +14,6 @@ CONFIG_CROS_KB_RAW_NPCX=n
CONFIG_PLATFORM_EC_ADC=n
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_I2C=n
CONFIG_PLATFORM_EC_KEYBOARD=n
CONFIG_PLATFORM_EC_SWITCH=n
CONFIG_PLATFORM_EC_VBOOT=n
diff --git a/zephyr/projects/npcx_evb/npcx9/gpio.dts b/zephyr/projects/npcx_evb/npcx9/gpio.dts
index 3f10215613..15f2c28a5d 100644
--- a/zephyr/projects/npcx_evb/npcx9/gpio.dts
+++ b/zephyr/projects/npcx_evb/npcx9/gpio.dts
@@ -48,46 +48,6 @@
gpios = <&gpioa 5 GPIO_OUT_HIGH>;
label = "SPI_CS_L";
};
- i2c0_scl0 {
- gpios = <&gpiob 5 GPIO_ODR_HIGH>;
- label = "I2C0_SCL0";
- };
- i2c0_sda0 {
- gpios = <&gpiob 4 GPIO_ODR_HIGH>;
- label = "I2C0_SDA0";
- };
- i2c1_scl0 {
- gpios = <&gpio9 0 GPIO_ODR_HIGH>;
- label = "I2C1_SCL0";
- };
- i2c1_sda0 {
- gpios = <&gpio8 7 GPIO_ODR_HIGH>;
- label = "I2C1_SDA0";
- };
- i2c2_scl0 {
- gpios = <&gpio9 2 GPIO_ODR_HIGH>;
- label = "I2C2_SCL0";
- };
- i2c2_sda0 {
- gpios = <&gpio9 1 GPIO_ODR_HIGH>;
- label = "I2C2_SDA0";
- };
- i2c3_scl0 {
- gpios = <&gpiod 1 GPIO_ODR_HIGH>;
- label = "I2C3_SCL0";
- };
- i2c3_sda0 {
- gpios = <&gpiod 0 GPIO_ODR_HIGH>;
- label = "I2C3_SDA0";
- };
- i2c7_sda0 {
- gpios = <&gpiob 2 GPIO_ODR_HIGH>;
- label = "I2C7_SDA0";
- };
- i2c7_scl0 {
- gpios = <&gpiob 3 GPIO_ODR_HIGH>;
- label = "I2C7_SCL0";
- };
board_version1 {
gpios = <&gpio6 4 GPIO_INPUT>;
enum-name = "GPIO_BOARD_VERSION1";
diff --git a/zephyr/projects/npcx_evb/npcx9/prj.conf b/zephyr/projects/npcx_evb/npcx9/prj.conf
index a901b00adc..b36ae34768 100644
--- a/zephyr/projects/npcx_evb/npcx9/prj.conf
+++ b/zephyr/projects/npcx_evb/npcx9/prj.conf
@@ -14,7 +14,6 @@ CONFIG_CROS_KB_RAW_NPCX=n
CONFIG_PLATFORM_EC_ADC=n
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_I2C=n
CONFIG_PLATFORM_EC_KEYBOARD=n
CONFIG_PLATFORM_EC_SWITCH=n
CONFIG_PLATFORM_EC_VBOOT=n