summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/i2c_controller.c6
-rw-r--r--include/virtual_battery.h3
-rw-r--r--zephyr/Kconfig.battery11
-rw-r--r--zephyr/boards/arm/trogdor/trogdor.dts4
-rw-r--r--zephyr/boards/riscv/asurada/asurada.dts5
-rw-r--r--zephyr/boards/riscv/corsola/corsola.dts5
-rw-r--r--zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml2
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/i2c.dts4
-rw-r--r--zephyr/shim/include/config_chip.h2
9 files changed, 32 insertions, 10 deletions
diff --git a/common/i2c_controller.c b/common/i2c_controller.c
index 62beb38e5a..90d8a8da80 100644
--- a/common/i2c_controller.c
+++ b/common/i2c_controller.c
@@ -1250,7 +1250,7 @@ static int check_i2c_params(const struct host_cmd_handler_args *args)
return EC_RES_SUCCESS;
}
-#ifdef I2C_PORT_VIRTUAL_BATTERY
+#ifdef CONFIG_I2C_VIRTUAL_BATTERY
static inline int is_i2c_port_virtual_battery(int port)
{
#ifdef CONFIG_ZEPHYR
@@ -1263,7 +1263,7 @@ static inline int is_i2c_port_virtual_battery(int port)
return (port == I2C_PORT_VIRTUAL_BATTERY);
#endif
}
-#endif /* I2C_PORT_VIRTUAL_BATTERY */
+#endif /* CONFIG_I2C_VIRTUAL_BATTERY */
static enum ec_status i2c_command_passthru(struct host_cmd_handler_args *args)
{
@@ -1338,7 +1338,7 @@ static enum ec_status i2c_command_passthru(struct host_cmd_handler_args *args)
if (resp->num_msgs == params->num_msgs - 1)
xferflags |= I2C_XFER_STOP;
-#if defined(VIRTUAL_BATTERY_ADDR_FLAGS) && defined(I2C_PORT_VIRTUAL_BATTERY)
+#ifdef CONFIG_I2C_VIRTUAL_BATTERY
if (is_i2c_port_virtual_battery(params->port) &&
addr_flags == VIRTUAL_BATTERY_ADDR_FLAGS) {
if (virtual_battery_handler(resp, in_len, &rv,
diff --git a/include/virtual_battery.h b/include/virtual_battery.h
index 4e7ca31d05..a5cac1140c 100644
--- a/include/virtual_battery.h
+++ b/include/virtual_battery.h
@@ -6,7 +6,8 @@
#ifndef __CROS_EC_VIRTUAL_BATTERY_H
#define __CROS_EC_VIRTUAL_BATTERY_H
-#if defined(CONFIG_I2C_VIRTUAL_BATTERY) && defined(CONFIG_BATTERY_SMART)
+#if defined(CONFIG_I2C_VIRTUAL_BATTERY) && defined(CONFIG_BATTERY_SMART) \
+ && !defined(VIRTUAL_BATTERY_ADDR_FLAGS)
#define VIRTUAL_BATTERY_ADDR_FLAGS BATTERY_ADDR_FLAGS
#endif
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
index 02cc19a3f3..77f2086d98 100644
--- a/zephyr/Kconfig.battery
+++ b/zephyr/Kconfig.battery
@@ -98,6 +98,17 @@ config PLATFORM_EC_I2C_VIRTUAL_BATTERY
return desired data to host instead of issuing I2C transaction every
time.
+config PLATFORM_EC_I2C_VIRTUAL_BATTERY_ADDR
+ hex "I2C virtual battery address"
+ default 0x0B if PLATFORM_EC_BATTERY_SMART
+ range 0x00 0x7f
+ depends on PLATFORM_EC_I2C_VIRTUAL_BATTERY
+ help
+ This config sets i2c address that will be intercepted by virtual
+ battery feature. All communication to this port will be cached
+ to decrease i2c communication traffic.
+ This should be equal to the address of real battery.
+
menuconfig PLATFORM_EC_CHARGER
bool "Charging support"
default y
diff --git a/zephyr/boards/arm/trogdor/trogdor.dts b/zephyr/boards/arm/trogdor/trogdor.dts
index 4bc7f7efc1..24fb584ae1 100644
--- a/zephyr/boards/arm/trogdor/trogdor.dts
+++ b/zephyr/boards/arm/trogdor/trogdor.dts
@@ -71,9 +71,9 @@
enum-name = "I2C_PORT_BATTERY";
label = "BATTERY";
};
- virtual {
+ virtual-battery {
i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_VIRTUAL";
+ enum-name = "I2C_PORT_VIRTUAL_BATTERY";
label = "VIRTUAL";
};
charger {
diff --git a/zephyr/boards/riscv/asurada/asurada.dts b/zephyr/boards/riscv/asurada/asurada.dts
index 9624360d42..8dc3c2abb7 100644
--- a/zephyr/boards/riscv/asurada/asurada.dts
+++ b/zephyr/boards/riscv/asurada/asurada.dts
@@ -97,6 +97,11 @@
enum-name = "I2C_PORT_BATTERY";
label = "BATTERY";
};
+ virtual-battery {
+ i2c-port = <&i2c0>;
+ enum-name = "I2C_PORT_VIRTUAL_BATTERY";
+ label = "VIRTUAL_BATTERY";
+ };
eeprom {
i2c-port = <&i2c0>;
enum-name = "I2C_PORT_EEPROM";
diff --git a/zephyr/boards/riscv/corsola/corsola.dts b/zephyr/boards/riscv/corsola/corsola.dts
index 9fe934604e..8a03035550 100644
--- a/zephyr/boards/riscv/corsola/corsola.dts
+++ b/zephyr/boards/riscv/corsola/corsola.dts
@@ -97,6 +97,11 @@
enum-name = "I2C_PORT_BATTERY";
label = "BATTERY";
};
+ virtual-battery {
+ i2c-port = <&i2c0>;
+ enum-name = "I2C_PORT_VIRTUAL_BATTERY";
+ label = "VIRTUAL_BATTERY";
+ };
eeprom {
i2c-port = <&i2c0>;
enum-name = "I2C_PORT_EEPROM";
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 ba2cc7b172..2161c8c037 100644
--- a/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
+++ b/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
@@ -46,7 +46,7 @@ properties:
- I2C_PORT_USB_C1_TCPC
- I2C_PORT_USB_MUX0
- I2C_PORT_USB_MUX1
- - I2C_PORT_VIRTUAL
+ - I2C_PORT_VIRTUAL_BATTERY
- I2C_PORT_WLC
label:
required: true
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/i2c.dts b/zephyr/projects/herobrine/herobrine_npcx9/i2c.dts
index 0821f8b806..93de10c100 100644
--- a/zephyr/projects/herobrine/herobrine_npcx9/i2c.dts
+++ b/zephyr/projects/herobrine/herobrine_npcx9/i2c.dts
@@ -28,9 +28,9 @@
enum-name = "I2C_PORT_BATTERY";
label = "BATTERY";
};
- virtual {
+ virtual-battery {
i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_VIRTUAL";
+ enum-name = "I2C_PORT_VIRTUAL_BATTERY";
label = "VIRTUAL";
};
charger {
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 74ab74335d..0548b3ba5d 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -161,7 +161,7 @@
#undef I2C_PORT_VIRTUAL_BATTERY
#ifdef CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY
#define CONFIG_I2C_VIRTUAL_BATTERY
-#define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY
+#define VIRTUAL_BATTERY_ADDR_FLAGS CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY_ADDR
#endif
#undef CONFIG_I2C_PASSTHRU_RESTRICTED