From db63b8678627cf690f07792dfdbe703cf288b1c6 Mon Sep 17 00:00:00 2001 From: Yuval Peress Date: Thu, 13 May 2021 22:52:47 -0600 Subject: zephyr: i2c: remove scl and sda references The SDA and SCL components of the struct i2c_port_t are only used in and for the i2c_wedge.c logic. This isn't needed in Zephyr. Remove the values and functions that use them from the Zephyr build. BRANCH=none BUG=b:188179405 TEST=build volteer and trogdor Signed-off-by: Yuval Peress Change-Id: I71a26fbd9bc51def744ef1f16a540728482c5a2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2896235 Reviewed-by: Fabio Baltieri --- common/i2c_controller.c | 2 + include/i2c.h | 2 +- zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml | 6 --- .../asurada/boards/riscv/asurada/asurada.dts | 32 --------------- .../trogdor/boards/arm/trogdor/trogdor.dts | 8 ---- .../volteer/boards/arm/volteer/volteer.dts | 48 ---------------------- zephyr/shim/include/i2c/i2c.h | 2 +- zephyr/shim/src/i2c.c | 15 +++---- 8 files changed, 9 insertions(+), 106 deletions(-) diff --git a/common/i2c_controller.c b/common/i2c_controller.c index 5b04e079fb..035cf8d8ca 100644 --- a/common/i2c_controller.c +++ b/common/i2c_controller.c @@ -860,6 +860,7 @@ int i2c_write_block(const int port, return rv; } +#ifndef CONFIG_ZEPHYR int get_sda_from_i2c_port(int port, enum gpio_signal *sda) { const struct i2c_port_t *i2c_port = get_i2c_port(port); @@ -1068,6 +1069,7 @@ unwedge_done: return ret; } +#endif /* !CONFIG_ZEPHYR */ int i2c_set_freq(int port, enum i2c_freq freq) { diff --git a/include/i2c.h b/include/i2c.h index 709da7d451..231561caea 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -110,9 +110,9 @@ struct i2c_port_t { int port; /* Port */ #ifndef CONFIG_ZEPHYR int kbps; /* Speed in kbps */ -#endif /* CONFIG_ZEPHYR */ enum gpio_signal scl; /* Port SCL GPIO line */ enum gpio_signal sda; /* Port SDA GPIO line */ +#endif /* CONFIG_ZEPHYR */ /* When bus is protected, returns true if passthru allowed for address. * If the function is not defined, the default value is true. */ int (*passthru_allowed)(const struct i2c_port_t *port, 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 ee61a837b3..49d9ee53c4 100644 --- a/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml +++ b/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml @@ -32,9 +32,3 @@ properties: description: Human readable string describing the device (used as device_get_binding() argument). - -child-binding: - description: Optional configuration bindings - child-binding: - description: SCL and SDA configurations - include: gpio-enum-name.yaml diff --git a/zephyr/projects/asurada/boards/riscv/asurada/asurada.dts b/zephyr/projects/asurada/boards/riscv/asurada/asurada.dts index f34a887892..e1858b1bd5 100644 --- a/zephyr/projects/asurada/boards/riscv/asurada/asurada.dts +++ b/zephyr/projects/asurada/boards/riscv/asurada/asurada.dts @@ -26,14 +26,6 @@ i2c-port = <&i2c0>; enum-name = "I2C_PORT_POWER"; label = "POWER"; - config { - scl { - enum-name = "GPIO_I2C_B_SCL"; - }; - sda { - enum-name = "GPIO_I2C_B_SDA"; - }; - }; }; battery { i2c-port = <&i2c0>; @@ -54,14 +46,6 @@ i2c-port = <&i2c1>; enum-name = "I2C_PORT_SENSOR"; label = "SENSOR"; - config { - scl { - enum-name = "GPIO_I2C_C_SCL"; - }; - sda { - enum-name = "GPIO_I2C_C_SDA"; - }; - }; }; i2c-accel { i2c-port = <&i2c1>; @@ -72,27 +56,11 @@ i2c-port = <&i2c2>; enum-name = "I2C_PORT_USB_C0"; label = "USB_C0"; - config { - scl { - enum-name = "GPIO_I2C_F_SCL"; - }; - sda { - enum-name = "GPIO_I2C_F_SDA"; - }; - }; }; usb-c1 { i2c-port = <&i2c4>; enum-name = "I2C_PORT_USB_C1"; label = "USB_C1"; - config { - scl { - enum-name = "GPIO_I2C_E_SCL"; - }; - sda { - enum-name = "GPIO_I2C_E_SDA"; - }; - }; }; }; }; diff --git a/zephyr/projects/trogdor/boards/arm/trogdor/trogdor.dts b/zephyr/projects/trogdor/boards/arm/trogdor/trogdor.dts index d361e56d5e..8eb41e67d9 100644 --- a/zephyr/projects/trogdor/boards/arm/trogdor/trogdor.dts +++ b/zephyr/projects/trogdor/boards/arm/trogdor/trogdor.dts @@ -77,14 +77,6 @@ i2c-port = <&i2c7_0>; enum-name = "I2C_PORT_SENSOR"; label = "SENSOR"; - config { - scl { - enum-name = "GPIO_EC_I2C_SENSOR_SCL"; - }; - sda { - enum-name = "GPIO_EC_I2C_SENSOR_SDA"; - }; - }; }; accel { i2c-port = <&i2c7_0>; diff --git a/zephyr/projects/volteer/boards/arm/volteer/volteer.dts b/zephyr/projects/volteer/boards/arm/volteer/volteer.dts index 8a9b467c26..d17428209b 100644 --- a/zephyr/projects/volteer/boards/arm/volteer/volteer.dts +++ b/zephyr/projects/volteer/boards/arm/volteer/volteer.dts @@ -53,14 +53,6 @@ i2c-port = <&i2c0_0>; enum-name = "I2C_PORT_SENSOR"; label = "SENSOR"; - config { - scl { - enum-name = "GPIO_EC_I2C0_SENSOR_SCL"; - }; - sda { - enum-name = "GPIO_EC_I2C0_SENSOR_SDA"; - }; - }; }; i2c-accel { i2c-port = <&i2c0_0>; @@ -71,53 +63,21 @@ i2c-port = <&i2c1_0>; enum-name = "I2C_PORT_USB_C0"; label = "USB_C0"; - config { - scl { - enum-name = "GPIO_EC_I2C1_USB_C0_SCL"; - }; - sda { - enum-name = "GPIO_EC_I2C1_USB_C0_SDA"; - }; - }; }; usb-c1 { i2c-port = <&i2c2_0>; enum-name = "I2C_PORT_USB_C1"; label = "USB_C1"; - config { - scl { - enum-name = "GPIO_EC_I2C2_USB_C1_SCL"; - }; - sda { - enum-name = "GPIO_EC_I2C2_USB_C1_SDA"; - }; - }; }; usb1-mix { i2c-port = <&i2c3_0>; enum-name = "I2C_PORT_USB_1_MIX"; label = "USB_1_MIX"; - config { - scl { - enum-name = "GPIO_EC_I2C3_USB_1_MIX_SCL"; - }; - sda { - enum-name = "GPIO_EC_I2C3_USB_1_MIX_SDA"; - }; - }; }; power { i2c-port = <&i2c5_0>; enum-name = "I2C_PORT_POWER"; label = "POWER"; - config { - scl { - enum-name = "GPIO_EC_I2C5_BATTERY_SCL"; - }; - sda { - enum-name = "GPIO_EC_I2C5_BATTERY_SDA"; - }; - }; }; battery { i2c-port = <&i2c5_0>; @@ -128,14 +88,6 @@ i2c-port = <&i2c7_0>; enum-name = "I2C_PORT_EEPROM"; label = "EEPROM"; - config { - scl { - enum-name = "GPIO_EC_I2C7_EEPROM_PWR_SCL_R"; - }; - sda { - enum-name = "GPIO_EC_I2C7_EEPROM_PWR_SDA_R"; - }; - }; }; charger { i2c-port = <&i2c7_0>; diff --git a/zephyr/shim/include/i2c/i2c.h b/zephyr/shim/include/i2c/i2c.h index 4d3186b4d5..930a6447a1 100644 --- a/zephyr/shim/include/i2c/i2c.h +++ b/zephyr/shim/include/i2c/i2c.h @@ -17,7 +17,7 @@ enum i2c_ports { DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), I2C_PORT_WITH_COMMA) - I2C_PORT_COUNT + I2C_PORT_COUNT }; #define NAMED_I2C(name) I2C_PORT(DT_PATH(named_i2c_ports, name)) #endif /* named_i2c_ports */ diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c index 9a1b19b61f..b3b2117b98 100644 --- a/zephyr/shim/src/i2c.c +++ b/zephyr/shim/src/i2c.c @@ -19,16 +19,11 @@ #define I2C_CONFIG_GPIO(id, type) \ DT_ENUM_UPPER_TOKEN(DT_CHILD(DT_CHILD(id, config), type), enum_name) -#define I2C_PORT_INIT(id) \ - COND_CODE_1(DT_NODE_EXISTS(DT_CHILD(id, config)), \ - ( \ - { \ - .name = DT_LABEL(id), \ - .port = I2C_PORT(id), \ - .scl = I2C_CONFIG_GPIO(id, scl), \ - .sda = I2C_CONFIG_GPIO(id, sda), \ - }, ), \ - ()) +#define I2C_PORT_INIT(id) \ + { \ + .name = DT_LABEL(id), \ + .port = I2C_PORT(id), \ + }, /* * Long term we will not need these, for now they're needed to get things to * build since these extern symbols are usually defined in -- cgit v1.2.1