diff options
Diffstat (limited to 'zephyr/shim')
-rw-r--r-- | zephyr/shim/include/charger/chg_bq25710.h | 19 | ||||
-rw-r--r-- | zephyr/shim/include/charger/chg_isl923x.h | 16 | ||||
-rw-r--r-- | zephyr/shim/include/charger/chg_isl9241.h | 16 | ||||
-rw-r--r-- | zephyr/shim/include/charger/chg_rt9490.h | 16 | ||||
-rw-r--r-- | zephyr/shim/include/charger/chg_sm5803.h | 16 | ||||
-rw-r--r-- | zephyr/shim/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/shim/src/charger.c | 49 |
7 files changed, 133 insertions, 0 deletions
diff --git a/zephyr/shim/include/charger/chg_bq25710.h b/zephyr/shim/include/charger/chg_bq25710.h new file mode 100644 index 0000000000..ed6771014b --- /dev/null +++ b/zephyr/shim/include/charger/chg_bq25710.h @@ -0,0 +1,19 @@ +/* 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 <devicetree.h> +#if defined(CONFIG_PLATFORM_EC_CHARGER_BQ25720) || \ + defined(CONFIG_PLATFORM_EC_CHARGER_BQ25710) +#include "driver/charger/bq25710.h" + +#define BQ25710_CHG_COMPAT ti_bq25710 + +#define CHG_CONFIG_BQ25710(id) \ + { \ + .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \ + .i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS, \ + .drv = &bq25710_drv, \ + }, +#endif diff --git a/zephyr/shim/include/charger/chg_isl923x.h b/zephyr/shim/include/charger/chg_isl923x.h new file mode 100644 index 0000000000..0bf65b4f38 --- /dev/null +++ b/zephyr/shim/include/charger/chg_isl923x.h @@ -0,0 +1,16 @@ +/* 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 <devicetree.h> +#include "driver/charger/isl923x_public.h" + +#define ISL923X_CHG_COMPAT intersil_isl923x + +#define CHG_CONFIG_ISL923X(id) \ + { \ + .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \ + .i2c_addr_flags = ISL923X_ADDR_FLAGS, \ + .drv = &isl923x_drv, \ + }, diff --git a/zephyr/shim/include/charger/chg_isl9241.h b/zephyr/shim/include/charger/chg_isl9241.h new file mode 100644 index 0000000000..7eba9f3bc9 --- /dev/null +++ b/zephyr/shim/include/charger/chg_isl9241.h @@ -0,0 +1,16 @@ +/* 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 <devicetree.h> +#include "driver/charger/isl9241_public.h" + +#define ISL9241_CHG_COMPAT intersil_isl9241 + +#define CHG_CONFIG_ISL9241(id) \ + { \ + .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \ + .i2c_addr_flags = ISL9241_ADDR_FLAGS, \ + .drv = &isl9241_drv, \ + }, diff --git a/zephyr/shim/include/charger/chg_rt9490.h b/zephyr/shim/include/charger/chg_rt9490.h new file mode 100644 index 0000000000..a51d056e12 --- /dev/null +++ b/zephyr/shim/include/charger/chg_rt9490.h @@ -0,0 +1,16 @@ +/* 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 <devicetree.h> +#include "driver/charger/rt9490.h" + +#define RT9490_CHG_COMPAT richtek_rt9490 + +#define CHG_CONFIG_RT9490(id) \ + { \ + .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \ + .i2c_addr_flags = RT9490_ADDR_FLAGS, \ + .drv = &rt9490_drv, \ + }, diff --git a/zephyr/shim/include/charger/chg_sm5803.h b/zephyr/shim/include/charger/chg_sm5803.h new file mode 100644 index 0000000000..5b2f947b8e --- /dev/null +++ b/zephyr/shim/include/charger/chg_sm5803.h @@ -0,0 +1,16 @@ +/* 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 <devicetree.h> +#include "driver/charger/sm5803.h" + +#define SM5803_CHG_COMPAT siliconmitus_sm5803 + +#define CHG_CONFIG_SM5803(id) \ + { \ + .i2c_port = I2C_PORT(DT_PHANDLE(id, port)), \ + .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS, \ + .drv = &sm5803_drv, \ + }, diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt index 23aacc177f..514e6ef385 100644 --- a/zephyr/shim/src/CMakeLists.txt +++ b/zephyr/shim/src/CMakeLists.txt @@ -26,6 +26,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY battery.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_RT9490 bc12_rt9490.c) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER charger.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI espi.c) zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN fan.c) diff --git a/zephyr/shim/src/charger.c b/zephyr/shim/src/charger.c new file mode 100644 index 0000000000..7196e57b88 --- /dev/null +++ b/zephyr/shim/src/charger.c @@ -0,0 +1,49 @@ +/* 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 "charger.h" +#include <devicetree.h> +#include "charger/chg_bq25710.h" +#include "charger/chg_isl923x.h" +#include "charger/chg_isl9241.h" +#include "charger/chg_rt9490.h" +#include "charger/chg_sm5803.h" + +#if DT_HAS_COMPAT_STATUS_OKAY(ISL923X_CHG_COMPAT) || \ + DT_HAS_COMPAT_STATUS_OKAY(ISL9241_CHG_COMPAT) || \ + DT_HAS_COMPAT_STATUS_OKAY(RT9490_CHG_COMPAT) || \ + DT_HAS_COMPAT_STATUS_OKAY(SM5803_CHG_COMPAT) + +#define CHG_CHIP(id, fn) [DT_REG_ADDR(DT_PARENT(id))] = fn(id) + +/* Charger chips */ +#ifndef CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG +const struct charger_config_t chg_chips[] = { +#else +struct charger_config_t chg_chips[] = { +#endif + DT_FOREACH_STATUS_OKAY_VARGS(BQ25710_CHG_COMPAT, CHG_CHIP, + CHG_CONFIG_BQ25710) + DT_FOREACH_STATUS_OKAY_VARGS(ISL923X_CHG_COMPAT, CHG_CHIP, + CHG_CONFIG_ISL923X) + DT_FOREACH_STATUS_OKAY_VARGS(ISL9241_CHG_COMPAT, CHG_CHIP, + CHG_CONFIG_ISL9241) + DT_FOREACH_STATUS_OKAY_VARGS(RT9490_CHG_COMPAT, CHG_CHIP, + CHG_CONFIG_RT9490) + DT_FOREACH_STATUS_OKAY_VARGS(SM5803_CHG_COMPAT, CHG_CHIP, + CHG_CONFIG_SM5803) +}; + +#ifdef CONFIG_PLATFORM_EC_CHARGER_SINGLE_CHIP +BUILD_ASSERT(ARRAY_SIZE(chg_chips) == 1, + "For the CHARGER_SINGLE_CHIP config, the number of defined charger " + "chips must equal 1."); +#else +BUILD_ASSERT(ARRAY_SIZE(chg_chips) == CONFIG_USB_PD_PORT_MAX_COUNT, + "For the OCPC config, the number of defined charger chips must equal " + "the number of USB-C ports."); +#endif + +#endif /* #if DT_HAS_COMPAT_STATUS_OKAY */ |