diff options
author | wen zhang <zhangwen6@huaqin.corp-partner.google.com> | 2022-01-07 10:34:11 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-26 12:54:08 +0000 |
commit | 149419982d3a98625705eefbab223db361c649fc (patch) | |
tree | 4d25b62062aff63dfa65776aac5d07ed8aaf114d | |
parent | 9f3e637336fc8beacdbd5f44e476f7b3d38b7acb (diff) | |
download | chrome-ec-149419982d3a98625705eefbab223db361c649fc.tar.gz |
zephyr: kingler: enable virtual battery
Enable virtual battery function for Kingler
BUG=b:203739613
TEST=1.the battery icon shows in the CrOS
2.the node sbs-10-000b exist in /sys/class/power_supply/
3.power_supply_info can get the battery data
BRANCH=none
Change-Id: I8ed4db0c50197f147d84638a9ffdac246c92cd19
Signed-off-by: wen zhang <zhangwen6@huaqin.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3372122
Reviewed-by: Eric Yilun Lin <yllin@google.com>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r-- | zephyr/projects/corsola/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/projects/corsola/i2c_kingler.dts | 5 | ||||
-rw-r--r-- | zephyr/projects/corsola/prj_kingler.conf | 2 | ||||
-rw-r--r-- | zephyr/projects/corsola/src/kingler/i2c.c | 17 |
4 files changed, 25 insertions, 0 deletions
diff --git a/zephyr/projects/corsola/CMakeLists.txt b/zephyr/projects/corsola/CMakeLists.txt index 1f905a7445..20e4010a1d 100644 --- a/zephyr/projects/corsola/CMakeLists.txt +++ b/zephyr/projects/corsola/CMakeLists.txt @@ -31,6 +31,7 @@ if(DEFINED CONFIG_BOARD_KRABBY) "src/krabby/usbc_config.c") elseif(DEFINED CONFIG_BOARD_KINGLER) project(kingler) + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/kingler/usb_pd_policy.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC diff --git a/zephyr/projects/corsola/i2c_kingler.dts b/zephyr/projects/corsola/i2c_kingler.dts index 3737f56f4e..565ca76794 100644 --- a/zephyr/projects/corsola/i2c_kingler.dts +++ b/zephyr/projects/corsola/i2c_kingler.dts @@ -37,8 +37,13 @@ }; battery { i2c-port = <&i2c5_0>; + remote-port = <5>; enum-name = "I2C_PORT_BATTERY"; }; + virtual-battery { + i2c-port = <&i2c5_0>; + enum-name = "I2C_PORT_VIRTUAL_BATTERY"; + }; }; }; diff --git a/zephyr/projects/corsola/prj_kingler.conf b/zephyr/projects/corsola/prj_kingler.conf index b9ff8cd904..7da63fb9c0 100644 --- a/zephyr/projects/corsola/prj_kingler.conf +++ b/zephyr/projects/corsola/prj_kingler.conf @@ -36,6 +36,8 @@ CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y CONFIG_PLATFORM_EC_BATTERY_SMART=y CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y +CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y # CBI CONFIG_PLATFORM_EC_CBI_EEPROM=y diff --git a/zephyr/projects/corsola/src/kingler/i2c.c b/zephyr/projects/corsola/src/kingler/i2c.c new file mode 100644 index 0000000000..dc18b937c3 --- /dev/null +++ b/zephyr/projects/corsola/src/kingler/i2c.c @@ -0,0 +1,17 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "i2c/i2c.h" +#include "i2c.h" + +/* Kingler board specific i2c implementation */ + +#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED +int board_allow_i2c_passthru(int port) +{ + return (i2c_get_device_for_port(port) == + i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY)); +} +#endif |